Easily integrate PHP application with parsian bank payment.
$ composer require dpsoft/parsian-payment
Attention: The Parsian Bank webservice just available with IP that allowed with Parsian Bank.
استفاده از درگاه بانک پارسیان در زبان Php
<?php
use Dpsoft\Parsian\Parsian;
try{
/**
* @param int $pin (required) The Parsian gateway pin code
*/
$parsian = new Parsian($pin);
/**
* @param int $amount (required) The amount that customer must pay
* @param string $callbackUrl (required) The url that customer redirect to after payment
* @param int $orderId (optional) The unique order id, generate by package if value passed null
* @param int $additionalData (optional) addition data
*
* @method payRequest Return array contain transaction `token` and `orderId` and you cat save.
* $token = $response['token'];
* $orderId = $response['orderId'];
*
*/
$response = $parsian->request($amount, $callbackUrl, $orderId, $additionalData);
/**
* Redirect user to payment gateway
*/
echo $parsian->redirect();
/**
* If you need to get payment url for application or another reason you can use this method
*
* $paymentUrl = $parsian->getPaymentUrl();
*
*/
}catch (\Throwable $exception){
echo $exception->getMessage();
}
Customer redirect to callback url with all transaction data and you must verify or rollback transaction.
<?php
use Dpsoft\Parsian\Parsian;
try{
/**
* @param int $pin (required) The Parsian gateway pin code
*/
$parsian = new Parsian($pin);
/**
*
* @method $verify return array of transaction data.
* $token = $response['token'];
* $orderId = $response['order_id'];
* $RRN = $response['RRN'];
* $hashCardNumber = $response['hash_card_number'];
*/
$response = $parsian->verify();
echo "Successful payment ...";
}catch (\Throwable $exception){
echo $exception->getMessage();
}
If you don't verify transaction you can reverse it.
<?php
use Dpsoft\Parsian\Parsian;
try{
/**
* @param int $pin (required) The Parsian gateway pin code
*/
$parsian = new Parsian($pin);
/**
* @param int $pin (required) The Parsian gateway pin code
*/
$parsian->reverse($token);
echo "Transaction reverse successful ...";
}catch (\Throwable $exception){
echo $exception->getMessage();
}
Copyright (c) 2018 dpsoft.ir