viras34/tpay-api-client

tPay API 客户端。

dev-master 2021-12-06 14:26 UTC

This package is auto-updated.

Last update: 2024-09-06 20:19:36 UTC


README

通过 composer

composer require viras34/tpay-api-client

创建新的 tPay 交易

use \Viras\Tpay\Client;

$client = new Client([
    'apiKey'=>'75f86137a6635df826e3efe2e66f7c9a946fdde1', 
    'apiPass'=>'p@$$w0rd#@!'
]);

$transaction = $client->transaction->create([
    'merchantId'=>'1010',
    'merchantSecret'=>'demo',
    'amount' => 999.99,
    'description' => 'Transaction description',
    'crc' => '3214',
    'result_url' => 'http://example.pl/transaction_confirmation',
    'result_email' => 'shop@example.com',
    'return_url' => 'http://example.pl/',
    'email' => 'customer@example.com',
    'name' => 'John Doe',
    'language' => 'en',
    'group' => 150,
    'accept_tos' => 1,
]);

print_r($transaction);

/*
stdClass Object
(
[result] => 1
[title] => TR-BRA-1D7Z9TX
[amount] => 999.99
[online] => 1
[url] => https://secure.tpay.com/?gtitle=TR-BRA-1D7Z9TX
)
*/

该方法返回其他 API 方法所需的交易标题以及客户的重定向链接。

发送 Blik 代码

$result = $client->transaction->blik([
    'title'=>$response->title,
    'code'=>'123456',
    'amount' => 999.99,
]);

print_r($result);

/*
stdClass Object
(
    [result] => 1
)
*/

方法返回参数‘result’等于1,表示支付弹出窗口已成功在客户移动应用程序中显示。