Code Monkey home page Code Monkey logo

gp-webpay-php-sdk's Introduction

GP Webpay PHP SDK

Build Status

Full featured PHP SDK for GP Webpay payments.

Installation

The best way to install GP Webpay PHP SDK is using Composer:

$ composer require adamstipak/webpay-php dev-master

Setup

$signer = new \AdamStipak\Webpay\Signer(
  $privateKeyFilepath,    // Path of private key.
  $privateKeyPassword,    // Password for private key.
  $publicKeyFilepath      // Path of public key.
);
    
$api = new \AdamStipak\Webpay\Api(
  $merchantNumber,    // Merchant number.
  $webpayUrl,         // URL of webpay.
  $signer             // instance of \AdamStipak\Webpay\Signer.
);

Create payment

Create payment url

use \AdamStipak\Webpay\PaymentRequest;

$request = new PaymentRequest(...);

$url = $api->createPaymentRequestUrl($request); // $api instance of \AdamStipak\Webpay\Api

// use $url as you want. In most cases for redirecting to GP Webpay.

ADDINFO parameter

// for minimal setup you can use
use \AdamStipak\Webpay\PaymentRequest;
use AdamStipak\Webpay\PaymentRequest\AddInfo;
 
$schema = file_get_contents("Path to XSD schema (GPwebpayAdditionalInfoRequest_v.4.xsd) from portal https://portal.gpwebpay.com/");
// use minimal valid values for XSD schema
$addInfo = new AddInfo($schema, AddInfo::createMinimalValues());
// or you can use valid values against XSD schema (start here AddInfo::createMinimalValues())
$request = new AddInfo($schema, [...]);

$request = new PaymentRequest(..., $addInfo);

Verify payment response

use \AdamStipak\Webpay\PaymentResponse;
use \AdamStipak\Webpay\Exception;
 
$response = new PaymentResponse(...); // fill response with response parameters (from request).
 
try {
  $api->verifyPaymentResponse($response);
} 
catch (PaymentResponseException $e) {
  // PaymentResponseException has $prCode, $srCode for properties for logging GP Webpay response error codes.
}
catch (Exception $e) {
  // Digest is not correct.
}

Development

GP Webpay PHP SDK is developed in Docker container via docker-compose command.

Example:

$ docker-compose run --rm default install  # install deps via composer
$ docker-compose run --rm default  # runs tests in container

Attach to container:

$ docker-compose run --rm default bash # runs bash in container and attach tty

gp-webpay-php-sdk's People

Contributors

deveidem avatar dg avatar martinvondrak avatar newpope avatar pavol-tuka avatar rudolfbruder avatar sajfi avatar sebik avatar siwa-pparzer avatar vitexus avatar wernerdweight avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.