asokawotulo/jokul-php

PHP client for Jokul API

2.0.0 2021-11-22 06:29 UTC

This package is auto-updated.

Last update: 2025-06-22 14:52:26 UTC


README

This library is an abstraction of Jokul's API for applications written with PHP.

Table of Contents

Links

Installation

composer require asokawotulo/jokul-php

Usage

Initialization

Get the Client ID and Secret Key from Business Account > Service

use Jokul\Jokul;

Jokul::setClientId('MCH-xxxx-xxxxxxxxxxxxx');
Jokul::setSecretKey('SK-xxxxxxxxxxxxxxxxxxxx');
Jokul::setEnv(Jokul::PRODUCTION); // or Jokul::SANDBOX

Generate Signature

use Jokul\Jokul;
use Jokul\Utils;

$requestTarget = '/api/target';
$secretKey = Jokul::getSecretKey();
$clientId = Jokul::getClientId();
$requestId = Utils::generateRequestId();
$requestTimestamp = Utils::generateRequestTimestamp();

$signature = Utils::generateSignature(
	$secretKey,
	$clientId,
	$requestId,
	$requestTimestamp,
	$requestTarget,
);

Jokul Checkout

$checkoutData = [
	'order' => [
		'amount' => 20000,
		'invoice_number' => 'INV-123',
	],
	'payment' => [
		'payment_due_date' => 60
	]
];

$response = \Jokul\Checkout::create($checkoutData);

echo $response['payment']['url'];