swport / exp-php-sdk
PHP集成库的一个简单库
1.0.2
2020-09-28 10:27 UTC
Requires
- php: ^7.0
- expresspaygh/exp-refine: ^1.0
- guzzlehttp/guzzle: ~6.0
Requires (Dev)
- fzaninotto/faker: ^1.9
- phpunit/phpunit: ^7.5
This package is auto-updated.
Last update: 2024-09-14 12:29:20 UTC
README
Expresspay PHP SDK
PHP集成库的一个简单库
安装
- 为您的环境安装composer - (Composer)[https://getcomposer.org.cn/download/]
- 使用以下命令通过composer导入包
composer require expresspaygh/exp-php-sdk
演示 / 测试
- 浏览器演示:[https://github.com/expresspaygh/exp-demos/tree/master/exp-php-sdk-demo]
- 单元测试:
make phpunit
或composer run test
如何使用
允许的环境
- 沙盒 - "sandbox"
- 生产 - "production"
提交请求
此请求创建一个新发票以处理支付,下面您将找到一个示例请求和响应。
require_once('./vendor/autoload.php'); use Expay\SDK\MerchantApi as ExpressPayMerchantApi; /** * $this->merchant_id = Your expressPay merchant id * $this->merchant_key = Your expressPay merchant api key * $this->environment = Your preferred environment, allowed params ('sandbox' or 'production') */ $merchantApi = new ExpressPayMerchantApi($this->merchant_id, $this->merchant_key, $this->environment); /** * submit * * string $currency * float $amount * string $order_id * string $order_desc * string $redirect_url * string $account_number * string | null $order_img_url * string | null $first_name * string | null $last_name * string | null $phone_number * string | null $email */ $response = $merchantApi->submit( "GHS", 20.00, "0925469924813", "Test create invoice", "https://expresspaygh.com", "1234567890", "https://expresspaygh.com/images/logo.png", "Jeffery", "Osei", "233545512042", "jefferyosei@expresspaygh.com" ); // print var_dump($response);
array(13) {
["status"]=> int(1)
["order-id"]=> string(13) "0925469924813"
["guest-checkout"]=> string(4) "TRUE"
["merchantservice-name"]=> string(3) "TEST"
["merchantservice-srvrtid"]=> string(12) "089908783876"
["message"]=> string(7) "Success"
["token"]=> string(64) "43165f2bcf90eef856.514313495f2bcf90eef8b1.85035432516432mjhyte"
["redirect-url"]=> string(24) "https://expresspaygh.com"
["user-key"]=> NULL
["merchant-name"]=> string(3) "TEST"
["merchant-mcc"]=> string(4) "1234"
["merchant-city"]=> string(5) "Accra"
["merchant-countrycode"]=> string(2) "GH"
}
结账请求
此请求为expressPay上的客户创建一个支付结账URL,下面您将找到一个示例请求和响应。
require_once('./vendor/autoload.php'); use Expay\SDK\MerchantApi as ExpressPayMerchantApi; /** * $this->merchant_id = Your expressPay merchant id * $this->merchant_key = Your expressPay merchant api key * $this->environment = Your preferred environment, allowed params ('sandbox' or 'production') */ $merchantApi = new ExpressPayMerchantApi($this->merchant_id, $this->merchant_key, $this->environment); /* * Token returned from your "Submit" request */ $token = "43165f2bcf90eef856.514313495f2bcf90eef8b1.85035432516432mjhyte"; /** * checkout * * string $token */ $response = $merchantApi->checkout($token); // print var_dump($response);
<!-- The checkout url is based on your selected environment -->
string(120) "https://sandbox.expresspaygh.com/api/checkout.php?token=43165f2bcf90eef856.514313495f2bcf90eef8b1.85035432516432mjhyte"
查询请求 - 在支付前
此请求检查expressPay上发票的支付状态,下面您将找到一个未支付发票的示例请求和响应。
require_once('./vendor/autoload.php'); use Expay\SDK\MerchantApi as ExpressPayMerchantApi; /** * $this->merchant_id = Your expressPay merchant id * $this->merchant_key = Your expressPay merchant api key * $this->environment = Your preferred environment, allowed params ('sandbox' or 'production') */ $merchantApi = new ExpressPayMerchantApi($this->merchant_id, $this->merchant_key, $this->environment); /* * Token returned from your "Submit" request */ $token = "43165f2bcf90eef856.514313495f2bcf90eef8b1.85035432516432mjhyte"; /** * checkout * * string $token */ $response = $merchantApi->query($token); // print var_dump($response);
array(6) {
["result"]=> int(3)
["result-text"]=> string(29) "No transaction data available"
["order-id"]=> string(13) "0925469924813"
["token"]=> string(64) "43165f2bcf90eef856.514313495f2bcf90eef8b1.85035432516432mjhyte"
["currency"]=> string(3) "GHS"
["amount"]=> string(2) "20"
}
查询请求 - 在支付后
此请求检查expressPay上发票的支付状态,下面您将找到一个已支付发票的示例请求和响应。
require_once('./vendor/autoload.php'); use Expay\SDK\MerchantApi as ExpressPayMerchantApi; /** * $this->merchant_id = Your expressPay merchant id * $this->merchant_key = Your expressPay merchant api key * $this->environment = Your preferred environment, allowed params ('sandbox' or 'production') */ $merchantApi = new ExpressPayMerchantApi($this->merchant_id, $this->merchant_key, $this->environment); /* * Token returned from your "Submit" request */ $token = "43165f2bcf90eef856.514313495f2bcf90eef8b1.85035432516432mjhyte"; /** * checkout * * string $token */ $response = $merchantApi->query($token); // print var_dump($response);
array(15) {
["result"]=> int(1)
["result-text"]=> string(7) "Success"
["order-id"]=> string(13) "0925469924813"
["token"]=> string(64) "43165f2bcf90eef856.514313495f2bcf90eef8b1.85035432516432mjhyte"
["currency"]=> string(3) "GHS"
["amount"]=> string(2) "20"
["auth-code"]=> string(6) "831000"
["transaction-id"]=> string(13) "030556c7x8c56"
["date-processed"]=> string(19) "2020-08-06 11:36:16"
["paid_from"]=> string(16) "411111******1111"
["payment_type"]=> string(7) "XPAY_GW"
["payment_reference"]=> string(6) "831000"
["payment_option"]=> string(4) "VISA"
["payment_option_type"]=> string(7) "CARDNET"
["payment_option_type_name"]=> string(34) "Visa, Mastercard, Amex or Discover"
}
版权 2020,版权所有。Expresspay Ghana Limited [https://expresspaygh.com]