brikmas/jazzcash-client-php

PHP的Jazzcash支付网关客户端

v1.0.0 2022-09-10 19:57 UTC

This package is auto-updated.

Last update: 2024-09-11 00:20:32 UTC


README

Jazzcash

PHP的Jazzcash支付网关客户端

此客户端库提供了对Jazzcash支付网关Web服务接口的访问。

需求

  • PHP 5.4或更高版本
  • CURL, JSON
  • Jazzcash获取凭据

安装

建议通过Composer进行安装。运行以下命令安装软件包并将其添加到您的项目的composer.json中

composer require brikmas/jazzcash-client-php

初始化客户端

在生产环境中,将sandbox替换为payments并添加凭据。

$client = new JazzClient([
    'apiBaseUrl' => 'https://sandbox.jazzcash.com.pk/',
    'merchantId' => 'xxxxxx',
    'password' => 'xxxxxx',
    'salt' => 'xxxxxx',
]);

凭证/OTC请求

请确保CallbackUrl与Jazzcash门户中给出的相同。

$txn_ref_no = time();

$request = new VoucherReq();
$request->setAmount(10);
$request->setBillRefNumber($txn_ref_no);
$request->setDescription('Unit test case');
$request->setTxnRefNumber($txn_ref_no);
$request->setVersion('1.1');
$request->setTxnType('OTC');
$request->setCallbackUrl('https:///gateway/jazzcash/callback');
$request->setCustomProperty('03331234567');

$response = $client->callVoucherService($request);
if ($response->pp_ResponseCode == 0) {
    // Handle success response
} 
else {
    // Handle fail response
}

测试

检查ClientTest类,添加您的凭据并运行测试以查看密钥是否正常工作。请确保使用生产密钥,不幸的是Jazzcash沙盒密钥无法按预期工作。

./vendor/bin/phpunit tests

错误

如果您发现了错误,请通过问题跟踪器自由地提交一个工单。

致谢

许可

MIT许可(MIT)。请参阅许可文件以获取更多信息。