dpsoft / parsian-payment
Parsian bank payment
Installs: 1 855
Dependents: 1
Suggesters: 0
Security: 0
Stars: 4
Watchers: 3
Forks: 1
Open Issues: 1
Requires
- php: ^7.4 || ^8.0
- ext-soap: *
Requires (Dev)
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2024-12-07 07:51:18 UTC
README
Easily integrate PHP application with parsian bank payment.
Installation
$ composer require dpsoft/parsian-payment
Implementation
Attention: The Parsian Bank webservice just available with IP that allowed with Parsian Bank.
استفاده از درگاه بانک پارسیان در زبان Php
Request payment
<?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(); }
Verify transaction or maybe reverse transaction in conditions
Customer redirect to callback url with all transaction data and you must verify or rollback transaction.
verify:
<?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(); }
Reverse transaction
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(); }
License
Copyright (c) 2018 dpsoft.ir