1. Go to this page and download the library: Download hamid-a/saderat-pg 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/ */
hamid-a / saderat-pg example snippets
use SaderatPaymentGateway\SaderatPG;
$tid = 'terminal-id';
$mid = 'merchant-id';
$public_key = __DIR__.'/saderat-public-key.pub'; // path to public key file
$private_key = __DIR__.'/saderat-private-key.key'; // path to private key file
$callback_url = 'callback-url'; // we can set calback url in initializing or getToken section
$gateway = new SaderatPG($tid, $mid, $public_key, $private_key, $callback_url);
$amount = 1000; // in int format
$crn = 'customer receipt number'; // must be unique in each transaction
$callback_url = 'callback-url'; // we can set calback url in initializing or getToken section
token = '';
try {
$token = $gateway->getToken($amount, $crn, $callback_url);
} catch (\Exception $e){
echo 'Error code:'.$e->getCode().' Error message:'.$e->getMessage();
}
if($token != '') {
// redirect user to: https://mabna.shaparak.ir/?ID=$token
}