索塔尼霍塞因 / 萨曼支付
萨曼银行支付
v1.0.0
2020-08-08 15:11 UTC
Requires
- php: ^7.1
- ext-soap: *
Requires (Dev)
- phpunit/phpunit: ^6.5.6
This package is auto-updated.
Last update: 2024-09-09 00:53:34 UTC
README
轻松集成PHP应用程序与萨曼银行支付。
安装
$ composer require soltanihossein/saman-payment
实现
注意:萨曼银行的Web服务仅对允许的IP地址可用。
请求支付
<?php use SoltaniHossein\Saman\Saman; try{ /** * @param int $merchantId (required) The Saman gateway merchant id */ $saman = new Saman($merchantId); /** * @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 request Return array contain transaction `token` and you can save. * $token = $response; * */ $response = $saman->request($amount, $callbackUrl, $invoiceId); /** * Redirect user to payment gateway */ echo $saman->redirect(); }catch (\Throwable $exception){ echo $exception->getMessage(); }
验证交易
客户将被重定向到回调URL,并带有所有交易数据,您必须验证交易。
验证
<?php use SoltaniHossein\Saman\Saman; try{ /** * @param int $merchantId (required) The Saman gateway merchant id */ $saman = new Saman($merchantId); /** * * @method $verify return array of transaction data. * */ $response = $saman->verify($amount); echo "Successful payment ..."; }catch (\Throwable $exception){ echo $exception->getMessage(); }
许可证
版权(c)2020