1. Go to this page and download the library: Download dpsoft/pay.ir 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/ */
dpsoft / pay.ir example snippets
try {
$pay = new \Dpsoft\Pay\Pay($apiKey);
$result = $pay->request($callbackUrl,$amount);
//save amount and invoice id to forther use
$_SESSION['amount']=$amount;
$_SESSION['invoice_id']=$result['invoice_id'];
$pay->redirectToBank();
exit();
}catch (Throwable $exception){
echo $exception->getMessage();
}
try {
$pay = new \Dpsoft\Pay\Pay();
$result = $pay->verify($_SESSION['amount'],$_SESSION['invoice_id']);
//save result. The keys are: card_number,transaction_id and token for example $result['token']
echo "Successfull transaction.";
}catch (Throwable $exception){
echo "Error in transaction: ";
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.