1. Go to this page and download the library: Download nekofar/omnipay-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/ */
nekofar / omnipay-zarinpal example snippets
use Omnipay\Omnipay;
$gateway = Omnipay::create('ZarinPal');
$gateway->setMerchantId('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx');
$gateway->setReturnUrl('https://www.example.com/return');
// Send purchase request
$response = $gateway->purchase([
'amount' => 100,
'description' => 'Some description'
])->send();
// Process response
if ($response->isRedirect()) {
// Redirect to offsite payment gateway
$response->redirect();
} else {
// Payment failed: display message to customer
echo $response->getMessage();
}
// Send purchase complete request
$response = $gateway->completePurchase([
'amount' => 100,
'authority' => $_REQUEST['Authority'],
)->send();
// Process response
if ($response->isSuccessful()) {
// Payment was successful
print_r($response);
} else {
// Payment failed: display message to customer
echo $response->getMessage();
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.