dpsoft / parsian-payment
帕尔斯银行支付
v3.0
2024-08-07 07:10 UTC
Requires
- php: ^7.4 || ^8.0
- ext-soap: *
Requires (Dev)
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2024-09-07 07:22:14 UTC
README
轻松将PHP应用程序与帕尔斯银行支付集成。
安装
$ composer require dpsoft/parsian-payment
实现
注意:帕尔斯银行Web服务仅在帕尔斯银行允许的IP上可用。
使用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(); }
在条件下验证交易或撤销交易
客户将被重定向到回调URL,并携带所有交易数据,您必须验证或回滚交易。
验证
<?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(); }
撤销交易
如果您不验证交易,您可以撤销它。
<?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(); }
许可证
版权(c)2018 dpsoft.ir