1. Go to this page and download the library: Download nimah79/f3-zarinpal 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/ */
nimah79 / f3-zarinpal example snippets
$zarinpal = new Zarinpal();
$zarinpal->setAmount(5500);
$zarinpal->setDescription('Purchasing test product');
$zarinpal->setCallbackURL('http://example.com/pay/verify');
$result = $zarinpal->request();
if ($result->ok) {
$zarinpal->redirect();
} else {
echo 'Error: ' . $result->message;
}
$zarinpal = new Zarinpal();
$zarinpal->setAmount(5500);
$result = $zarinpal->verify();
if ($result->ok) {
echo 'Successful transaction!';
}
// 4500 Tomans from the main transaction is sent
// to ZP.125732 with this Description: Testing profit
$zarinpal->addSharedPay('ZP.125732', 4500, 'Testing profit');
$zarinpal->addSharedPay('ZP.125732', 4500, 'Testing profit');
$zarinpal->addSharedPay('ZP.133476.2', 1200, 'More testing profit');
$zarinpal->addSharedPay('ZP.197825.1', 6700, 'More than more testing profit');
// Will expire after 7200 seconds (2 hours)
$zarinpal->expireIn(7200);
$zarinpal->getRedirectURL();
$result = $zarinpal->request();
if ($result->ok) {
// It will return something like:
// https://www.zarinpal.com/pg/StartPay/xxxxx/
$zarinpal->getRedirectURL();
}
$result = $zarinpal->request();
if ($result->ok) {
$zarinpal->getAuthority();
}
// This will refresh your authority (xxxxxxxxxx) for 3600 seconds (1 hour)
$zarinpal->refreshAuthority("xxxxxxxxxx", 3600);
$result = $zarinpal->getUnverified();
if ($result->ok) {
// Contains an array of arrays
print_r($result->body->Authorities);
} else {
echo $result->message;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.