vitexus / webpay-php5
GP Webpay API 包装器
dev-php56
2018-04-21 22:17 UTC
Requires
- php: 5.*
- ext-openssl: *
Requires (Dev)
- phpunit/phpunit: 6.4.*
This package is auto-updated.
Last update: 2024-09-22 10:04:09 UTC
README
为GP Webpay 支付提供完整功能的PHP SDK。
安装
安装 GP Webpay PHP SDK 的最佳方式是使用 Composer
$ composer require vitexus/webpay-php5 dev-php56 ## Setup ```php $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. );
创建支付
创建支付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.
验证支付响应
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. }
##开发
GP Webpay PHP SDK 通过 Docker 容器使用 docker-compose 命令进行开发。
示例
$ docker-compose run --rm default install # install deps via composer $ docker-compose run --rm default # runs tests in container
连接到容器
$ docker-compose run --rm default bash # runs bash in container and attach tty