Official PHP Library for Jokul. Visit https://jokul.doku.com for more information about the product and https://jokul.doku.com/docs for the technical documentation.
Virtual Account
- BCA VA
- Bank Mandiri VA
- Bank Syariah Indonesia VA
- DOKU VA
- PHP 7.2 or above
If you are using Composer, you can install via composer CLI:
composer require doku/jokul-php-library
or
add this require line to your composer.json
file:
example
{
"require": {
"doku/jokul-php-library": "2.1.0"
}
}
and run composer install
on your terminal.
Get your Client ID and Shared Key from Jokul Back Office. Sandbox Jokul Back Office (for testing purpose) / Production Jokul Back Office (for real payments)
Setup your configuration:
// 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);
If you want to hit to Sandbox, change to $DOKUClient->isProduction(false);
.
First prepare your payment request data:
// 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"]
);
For further details of each parameter, please refer to our Jokul Docs.
After preparing the payment request above, call this function to generate BCA VA:
// Call this function to generate BCA VA
$DOKUClient->generateBcaVa($params);
After preparing the payment request above, call this function to generate Bank Mandiri VA:
// Call this function to generate Bank Mandiri VA
$DOKUClient->generateMandiriVa($params);
After preparing the payment request above, call this function to generate Bank Syariah Indonesia VA:
// Call this function to generate Bank Syariah Indonesia VA
$DOKUClient->generateBsiVa($params);
After preparing the payment request above, call this function to generate DOKU VA:
// Call this function to generate DOKU VA
$DOKUClient->generateDokuVa($params);
For async payment from these channels:
- Virtual Account
We will send the HTTP Notification after the payment made from your customers. Therefore, you will need to handle the notification to update the transaction status on your end. Here is the steps:
- Create notification URL (endpoint) on your server to receieve HTTP POST notification from Jokul. The notification will be sent to you whenever the transaction status is updated on Jokul side. The sample code available in Jokul Java Example.
- Setup the notification URL that you made to the Payment Configuration on Jokul Back Office. Sandbox Jokul Back Office (for testing purpose) / Production Jokul Back Office (for real payments)
- Test the payment with our Payment Simulator (for testing purpose)
Here is the sample of the notification endpoint that you need to setup:
// 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
}
For further reference, please refer to our Jokul Docs.
Please refer to this repo for the example project: Jokul PHP Example.
Got any issues? Found a bug? Have a feature requests? You can open new issue.
For further information, you can contact us on [email protected].