adamstipak/webpay-php
最新稳定版本:1.5.1
Composer 安装命令:
composer require adamstipak/webpay-php
包简介
GP Webpay API Wrapper
README 文档
README
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
统计信息
- 总下载量: 160.25k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 45
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2013-08-01