Jokul PHP Library

Overview

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:

$arr["customerName"], 'amount' => $arr["amount"], 'invoiceNumber' => random_strings(20), 'expiryTime' => $arr["expiredTime"], 'info1' => $arr["info1"], 'info2' => $arr["info2"], 'info3' => $arr["info3"], 'reusableStatus' => $arr["reusableStatus"] );">
// 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 [email protected].

You might also like...
A PHP library to play with the Raspberry PI's GPIO pins
A PHP library to play with the Raspberry PI's GPIO pins

php-gpio php-gpio is a simple PHP library to play with the Raspberry PI's GPIO pins. It provides simple tools such as reading & writing to pins. [UPDA

PHP library for dealing with European VAT

ibericode/vat This is a simple PHP library to help you deal with Europe's VAT rules. Fetch VAT rates for any EU member state using ibericode/vat-rates

iOS passbook library for PHP 5.4+

PHP PASSBOOK LIBRARY What is Passbook? Passbook is an application in iOS that allows users to store coupons, boarding passes, event tickets, store car

Sslurp is a simple library which aims to make properly dealing with SSL in PHP suck less.

Sslurp v1.0 by Evan Coury Introduction Dealing with SSL properly in PHP is a pain in the ass and completely insecure by default. Sslurp aims to make i

A framework agnostic PHP library to build chat bots
A framework agnostic PHP library to build chat bots

BotMan If you want to learn how to create reusable PHP packages yourself, take a look at my upcoming PHP Package Development video course. About BotMa

Lock library to provide serialized execution of PHP code.

Requirements | Installation | Usage | License and authors | Donations php-lock/lock This library helps executing critical code in concurrent situation

PHP Machine Learning library
PHP Machine Learning library

PHP-ML - Machine Learning library for PHP Fresh approach to Machine Learning in PHP. Algorithms, Cross Validation, Neural Network, Preprocessing, Feat

A framework agnostic, multi-gateway payment processing library for PHP 5.6+

Omnipay An easy to use, consistent payment processing library for PHP Omnipay is a payment processing library for PHP. It has been designed based on i

PHP library providing retry functionality with multiple backoff strategies and jitter support

PHP Backoff Easily wrap your code with retry functionality. This library provides: 4 backoff strategies (plus the ability to use your own) Optional ji

Comments
  • What the meaning of this error???

    What the meaning of this error???

    { "error":{ "code":"request_time_out_of_range", "message":"Header Request-Timestamp is not in +- 60 second of now", "type":"invalid_request_error" } }

    opened by abdullahhafizh 0
  • requestid should be more random

    requestid should be more random

    If you look at this line: https://github.com/PTNUSASATUINTIARTHA-DOKU/jokul-php-library/blob/e6ba1c1570d076baf6c5aefea058ee1eb2515b4c/src/DOKU/Common/PaycodeGenerator.php#L45

    The randomization is very prone to colission on site with huge order per minute. generate uuidv4 instead.

    opened by erikdemarco 0
  • Update Generate Signature Function to Support GET Method

    Update Generate Signature Function to Support GET Method

    To use Generate Signature function for GET method, set the Request Body as null like this:

    $signature = \DOKU\Common\Utils::generateSignature($headers, $targetPath, null, $secretKey);
    
    opened by ariefrizkyr 0
Owner
PT Nusa Satu Inti Artha (DOKU)
Official repository from DOKU
PT Nusa Satu Inti Artha (DOKU)
Easy to use utility functions for everyday PHP projects. This is a port of the Lodash JS library to PHP

Lodash-PHP Lodash-PHP is a port of the Lodash JS library to PHP. It is a set of easy to use utility functions for everyday PHP projects. Lodash-PHP tr

Lodash PHP 474 Dec 31, 2022
PHP Text Analysis is a library for performing Information Retrieval (IR) and Natural Language Processing (NLP) tasks using the PHP language

php-text-analysis PHP Text Analysis is a library for performing Information Retrieval (IR) and Natural Language Processing (NLP) tasks using the PHP l

null 464 Dec 28, 2022
php-echarts is a php library for the echarts 5.0.

php-echarts 一款支持Apache EChart5.0+图表的php开发库 优先ThinkPHP5/6的开发及测试。 Apache EChart5.0已经最新发布,在视觉效果、动画效果和大数据展示方面已经远超之前的版本; 故不考虑EChart5.0之前版本的兼容问题;建议直接尝试5.0+

youyiio 5 Aug 15, 2022
Minimalist PHP frame for Core-Library, for Developing PHP application that gives you the full control of your application.

LazyPHP lightweight Pre-Made Frame for Core-library Install Run the below command in your terminal $ composer create-project ryzen/lazyphp my-first-pr

Ry-Zen 7 Aug 21, 2022
Gettext is a PHP (^7.2) library to import/export/edit gettext from PO, MO, PHP, JS files, etc.

Gettext Note: this is the documentation of the new 5.x version. Go to 4.x branch if you're looking for the old 4.x version Created by Oscar Otero http

Gettext 651 Dec 29, 2022
Columnar analytics for PHP - a pure PHP library to read and write simple columnar files in a performant way.

Columnar Analytics (in pure PHP) On GitHub: https://github.com/envoymediagroup/columna About the project What does it do? This library allows you to w

Envoy Media Group 2 Sep 26, 2022
:date: The VObject library for PHP allows you to easily parse and manipulate iCalendar and vCard objects

sabre/vobject The VObject library allows you to easily parse and manipulate iCalendar and vCard objects using PHP. The goal of the VObject library is

sabre.io 532 Dec 25, 2022
Small convention based CQRS library for PHP

LiteCQRS for PHP Small naming-convention based CQRS library for PHP (loosely based on LiteCQRS for C#) that relies on the MessageBus, Command, EventSo

Benjamin Eberlei 560 Nov 20, 2022
Experimental library for forking PHP

Spork: PHP on a Fork <?php $manager = new Spork\ProcessManager(); $manager->fork(function() { // do something in another process! return 'Hel

Kris Wallsmith 588 Nov 20, 2022
Collection pipeline library for PHP

Knapsack Collection pipeline library for PHP Knapsack is a collection library for PHP >= 5.6 that implements most of the sequence operations proposed

Dušan Kasan 540 Dec 17, 2022