2.0.0 2020-11-13 04:01 UTC

This package is not auto-updated.

Last update: 2024-09-25 10:26:05 UTC


README

官方Jokul PHP库。访问https://jokul.doku.com获取更多产品信息,访问https://jokul.doku.com/docs获取技术文档。

目录

支持的支付通道

虚拟账户

  • BCA VA
  • Mandiri VA
  • Bank Syariah Indonesia VA
  • DOKU VA

要求

  • PHP 7.2 或更高版本

安装

如果您使用Composer,可以通过命令行安装

composer require doku/jokul-php-library

或者

将此依赖行添加到您的composer.json文件中

示例

{
    "require": {
        "doku/jokul-php-library": "2.1.0"
    }
}

然后在您的终端上运行composer install

使用

设置配置

从Jokul后台办公室获取您的客户端ID和共享密钥。沙盒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

在准备上述支付请求后,调用此函数以生成BCA VA

// Call this function to generate BCA VA
$DOKUClient->generateBcaVa($params);

Mandiri VA

在准备上述支付请求后,调用此函数以生成Bank Mandiri VA

// Call this function to generate Bank Mandiri VA
$DOKUClient->generateMandiriVa($params);

Bank Syariah Indonesia VA

在准备上述支付请求后,调用此函数以生成Bank Syariah Indonesia VA

// Call this function to generate Bank Syariah Indonesia VA
$DOKUClient->generateBsiVa($params);

DOKU VA

在准备上述支付请求后,调用此函数以生成DOKU VA

// Call this function to generate DOKU VA
$DOKUClient->generateDokuVa($params);

处理HTTP通知

对于这些渠道的异步支付

  • 虚拟账户

在您的客户完成支付后,我们将发送HTTP通知。因此,您需要处理通知以在您的端更新交易状态。以下是步骤

  1. 在您的服务器上创建通知URL(端点)以接收来自Jokul的HTTP POST通知。每当Jokul侧的交易状态更新时,都会向您发送通知。有关示例代码,请参阅Jokul Java 示例
  2. 将您创建的通知URL设置到Jokul后台办公室的支付配置中。沙盒Jokul后台办公室(用于测试目的) / 生产Jokul后台办公室(用于真实支付)
  3. 使用我们的支付模拟器测试支付(用于测试目的)

以下是您需要设置的通知端点示例

// 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 文档

示例项目

请参阅此存储库以获取示例项目:Jokul PHP 示例

帮助和支持

遇到任何问题吗?发现了一个bug?有功能请求吗?您可以通过新建问题来报告。

如需更多信息,您可以通过care@doku.com联系我们。