kevujin / comgate-client
包含所有可用开发请求/响应的Comgate客户端包装器
1.3.1
2024-07-28 11:56 UTC
Requires
- php: 7.4 - 8.3
- ext-mbstring: *
- guzzlehttp/guzzle: 6.5 - 7.7
Requires (Dev)
- phpunit/phpunit: >=6.5.0
README
Comgate API客户端
Comgate API客户端包装器,包含所有可用开发请求/响应
从tomasz-kusy/comgate-client分支而来,并包含renat-magadiev/comgate-client(原始开发者)的更新
要求
- PHP 7.4或更高版本
- guzzlehttp/guzzle
安装
$ composer require kevujin/comgate-client
基本用法 - 创建客户端
use Comgate\Client; $client = new Client( 'merchant', // your merchant ID you got from Comgate true, // if testing environment -> false = production 'secret' // secret passphrase/token you got from Comgate );
创建支付
use Comgate\Request\CreatePayment; $createPayment = new CreatePayment( 1000, // the price in cents 10.00 => 1000 'orderId', // your ID 'test@test.cz', // email of customer or some email for Comgate to communicate with if payment problems 'Product name' // payment label ); $createPaymentResponse = $client->send($createPayment); $redirectUrl = $createPaymentResponse->getRedirectUrl();
CreatePayment
类具有与Comgate文档中描述相同的属性
获取支付状态
use Comgate\Request\PaymentStatus; $paymentStatus = new PaymentStatus( 'transId' // Comgate ID you received from create payment process ); $paymentStatusResponse = $client->send($paymentStatus);
PaymentStatus
响应类具有与Comgate文档中描述相同的属性
取消支付
use Comgate\Request\CancelPayment; $cancelPayment = new CancelPayment( 'transId' // Comgate ID you received from create payment process ); $cancelPaymentResponse = $client->send($cancelPayment);
CancelPayment
响应和请求类具有与Comgate文档中描述相同的属性
获取支付方式
use Comgate\Request\GetMethods; $getMethods = new GetMethods( 'currency', // currency to filter methods for, could be null to match all available 'country' // country to filter methods available in, could be null to match all available ); $getMethodsResponse = $client->send($getMethods); var_dump($getMethodsResponse->methods); var_dump($getMethodsResponse->getMethod('BANK_ALL')); // exact one method
GetMethods
响应和请求类在Comgate文档中描述
列出转账
获取指定日期的资金转账列表。一天中可能有多个转账,也可能没有。转账通常在15:00 GMT处理。
use Comgate\Request\ListTransfers; $listTransfers = new ListTransfers( date('Y-m-d') // let's look for today ); $listTransfersResponse = $client->send($listTransfers); var_dump($listTransfersResponse->transfers); // collection of Response\Item\Transfer
ListTransfers
响应和请求类在Comgate文档中描述
对于每个转账,还有一个API调用来获取其详细信息(确切支付),这些支付包含在转账中
foreach ($listTransfersResponse->transfers as $transfer) { // transfer is object Response\Item\Transfer $getTransferRequest = $transfer->createRequest(); // Request\GetTransfer $getTransferResponse = $client->send($getTransferRequest); var_dump($getTransferResponse->transferItems); // collection of Response\Item\TransferItem }
GetTransfer
响应和请求类在Comgate文档中描述