Skip to content

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.

Notifications You must be signed in to change notification settings

PTNUSASATUINTIARTHA-DOKU/jokul-php-library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 

Repository files navigation

Jokul PHP Library

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.

Table of Contents

Payment Channels Supported

Virtual Account

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

Requirements

  • PHP 7.2 or above

Installation

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.

Usage

Setup Configuration

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);.

Virtual Account

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.

BCA VA

After preparing the payment request above, call this function to generate BCA VA:

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

Bank Mandiri VA

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);

Bank Syariah Indonesia VA

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);

DOKU VA

After preparing the payment request above, call this function to generate DOKU VA:

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

Handling HTTP Notification

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:

  1. 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.
  2. 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)
  3. 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.

Sample Project

Please refer to this repo for the example project: Jokul PHP Example.

Help and Support

Got any issues? Found a bug? Have a feature requests? You can open new issue.

For further information, you can contact us on care@doku.com.

About

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.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages