kevujin/comgate-client

包含所有可用开发请求/响应的Comgate客户端包装器

1.3.1 2024-07-28 11:56 UTC

This package is auto-updated.

Last update: 2024-09-28 12:19:18 UTC


README

Build Status Coverage Status

Comgate API客户端

Comgate API客户端包装器,包含所有可用开发请求/响应

从tomasz-kusy/comgate-client分支而来,并包含renat-magadiev/comgate-client(原始开发者)的更新

要求

安装

$ 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文档中描述