PHP code example of asokawotulo / jokul-php

1. Go to this page and download the library: Download asokawotulo/jokul-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

asokawotulo / jokul-php example snippets


use Jokul\Jokul;

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

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

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

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

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