ohansyah / jokul-php-library
Jokul PHP 库
v0.1.0
2022-10-18 14:09 UTC
Requires
- php: >=7.2
This package is auto-updated.
Last update: 2024-09-18 18:42:45 UTC
README
这是 Jokul PHP Library 的分支
目录
支持的支付渠道
虚拟账户 => 通道名称
- BCA =
bca-virtual-account
- Mandiri =
mandiri-virtual-account
- Bank Syariah Indonesia (BSI)=
bsm-virtual-account
- DOKU =
doku-virtual-account
- BRI =
bri-virtual-account
- CIMB =
cimb-virtual-account
- Permata =
permata-virtual-account
- BNI =
bni-virtual-account
- Danamon =
danamon-virtual-account
要求
- PHP 7.2 或更高版本
安装
如果您使用 Composer,可以通过 composer CLI 安装
composer require doku/jokul-php-library
或
将此 require 行添加到您的 composer.json
文件中
示例
{ "require": { "doku/jokul-php-library": "2.1.0" } }
然后在您的终端上运行 composer install
。
使用
设置配置
从 Jokul 后台办公室获取您的客户端 ID 和共享密钥。 Sandbox Jokul 后台办公室(用于测试目的) / 生产 Jokul 后台办公室(用于真实支付)
设置您的配置
// Instantiate class $DOKUClient = new DOKU\Client; // Set your Client ID $DOKUClient->setClientID('[YOUR_CLIENT_ID]'); // Set your Shared Key $DOKUClient->setSharedKey('[YOUR_SHARED_KEY]'); // Call this function for production use $DOKUClient->isProduction(true);
如果您想访问沙盒,将 $DOKUClient->isProduction(false);
改为。
虚拟账户
首先准备您的支付请求数据
// Setup VA payment request data $params = array( 'customerEmail' => $arr["email"], 'customerName' => $arr["customerName"], 'amount' => $arr["amount"], 'invoiceNumber' => random_strings(20), 'expiryTime' => $arr["expiredTime"], 'info1' => $arr["info1"], 'info2' => $arr["info2"], 'info3' => $arr["info3"], 'reusableStatus' => $arr["reusableStatus"] );
有关每个参数的详细信息,请参阅我们的 Jokul 文档。
虚拟账户
准备好上述支付请求后,调用此函数以生成 BCA VA
// Set channel Virtual Account $DOKUClient->setChannelVA("bca-virtual-account"); // Call this function to generate Virtual Account $DOKUClient->generateVA($params);
处理 HTTP 通知
对于这些渠道的异步支付
- 虚拟账户
我们将在您的客户完成支付后发送 HTTP 通知。因此,您需要处理通知以在您的端更新交易状态。以下是步骤
- 在您的服务器上创建通知 URL(端点)以接收 Jokul 发送的 HTTP POST 通知。每当在 Jokul 端更新交易状态时,都会向您发送通知。在 Jokul Java 示例 中可以找到可用示例代码。
- 将您创建的通知 URL 设置到 Jokul 后台办公室的支付配置中。 Sandbox Jokul 后台办公室(用于测试目的) / 生产 Jokul 后台办公室(用于真实支付)
- 使用我们的 支付模拟器 测试支付(用于测试目的)
以下是您需要设置的示例通知端点
// Mapping the notification received from Jokul $notifyHeaders = getallheaders(); $notifyBody = json_decode(file_get_contents('php://input'), true); // You can use to parse the value from the notification body $targetPath = '/payments/notifications'; // Put this value with your payment notification path $secretKey = 'SK-xxxxxxx'; // Put this value with your Secret Key // Prepare Signature to verify the notification authenticity $signature = \DOKU\Common\Utils::generateSignature($notifyHeaders, $targetPath, file_get_contents('php://input'), $secretKey); // Verify the notification authenticity if ($signature == $notifyHeaders['Signature']) { http_response_code(200); // Return 200 Success to Jokul if the Signature is match // TODO update transaction status on your end to 'SUCCESS' } else { http_response_code(401); // Return 401 Unauthorized to Jokul if the Signature is not match // TODO Do Not update transaction status on your end yet }
有关进一步参考,请参阅我们的 Jokul 文档。
帮助和支持
有任何问题?找到错误?有功能请求?您可以 打开新问题。
有关更多信息,您可以通过 care@doku.com 联系我们。