PHP code example of abdal / abdal-zarinpal-pg
1. Go to this page and download the library: Download abdal/abdal-zarinpal-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/ */
abdal / abdal-zarinpal-pg example snippets bash
'providers' => [
// ...
Abdal\AbdalZarinpalPg\ZarinpalServiceProvider::class,
];
bash
'aliases' => [
// ...
'Zarinpal' => Abdal\AbdalZarinpalPg\Facades\Zarinpal::class,
];
bash
use Abdal\AbdalZarinpalPg\Zarinpal;
public function requestPayment(Request $request)
{
$response = Zarinpal::merchantId('00000000-0000-0000-0000-000000000000')
->amount(13660000)
->currency('IRT')
->callbackUrl(route('payment.verify'))
->description('خرید تست')
->email('[email protected] ')
->mobile('09022223301')
->request();
if (!$response->success()) {
return response()->json(['error' => $response->message()], 400);
}
$authority = $response->getAuthority(); // Save Authority in Database
return $response->redirect();
}
bash
use Abdal\AbdalZarinpalPg\Zarinpal;
public function verifyPayment(Request $request)
{
$response = Zarinpal::merchantId('00000000-0000-0000-0000-000000000000')
->amount(13660000)
->currency('IRT')
->authority($request->query('Authority'))
->verify();
if (!$response->success()) {
return response()->json(['error' => $response->message()], 400);
}
return $response->referenceId();
}
bash
use Abdal\AbdalZarinpalPg\Zarinpal;
public function requestPayment(Request $request)
{
$response = (new Zarinpal())
->amount(13660000)
->callbackUrl(route('payment.verify'))
->description('خرید تست')
->email('[email protected] ')
->mobile('09022223301')
->request();
if (!$response->success()) {
return response()->json(['error' => $response->message()], 400);
}
$authority = $response->getAuthority(); // Save Authority in Database
return $response->redirect();
}
bash
use Abdal\AbdalZarinpalPg\Zarinpal;
public function verifyPayment(Request $request)
{
$response = (new Zarinpal())
->amount(13660000)
->authority($request->query('Authority'))
->verify();
if (!$response->success()) {
return response()->json(['error' => $response->message()], 400);
}
return $response->referenceId();
}