dizatech/rayanpay_ipg
Composer 安装命令:
composer require dizatech/rayanpay_ipg
包简介
Rayanpay payment gateway for Laravel
README 文档
README
For a payment transaction we have to request a payment via web service. If our request is successful the IPG will return a token which we should use while redirecting customer to payment page. Customer will be redirected back to our desired URL(callback URL) from payment page via a GET request carrying data which may be used to check and verify customer's transaction using web service.
Request payment
For a payment transaction we should send a payment request to IPG and acquire a token. This may be accomplished by calling getToken method.
Instantiating an IPG object
for instantiating an IPG object we should call Dizatech\RayanpayIpg\RayanpayIpg constructor passing it an array of required arguments containing:
- merchantId: your payment gateway merchant id
Code sample:
$args = [ 'merchantId' => '4e1598fc-09b8-29e6-2edc-bf5494616b4d' ]; //Replace arguments with your gateway actual values $ipg = new RayanpayIpg($args);
getToken method
Arguments:
- amount: amount in Rials
- redirect_address: URL to which customer may be redirected after payment
Returns:
An object with the following properties:
- status:
successorerror - token: in case of a successful request contains the generated token which may be used while redirecting customer to payment page
- message: contains error message when
statusiserror
Redirecting customer to payment page
If status property of the result of calling getToken is success we can redirect customer to payment page URL which is currently https://pms.rayanpay.com/pg/startpay/. We have to redirect user to payment page via a GET request.
It is neccessary to save the acquired token token for further use
Code sample:
$args = [ 'merchantId' => '4e1598fc-09b8-29e6-2edc-bf5494616b4d' ]; //Replace arguments with your gateway actual values $ipg = new RayanpayIpg($args); $amount = 1000; //Replace with actual order amount in Rials $redirect_address = 'http://my.com/verify'; //Replace with your desired callback page URL $result = $ipg->getToken($amount, $redirect_address); if( $result->status == 'success' ){ header('Location: https://pms.rayanpay.com/pg/startpay/' . $result->token); die(); } else{ echo "Error: {$result->message}"; }
Payment verification and settle
After payment the customer will be redirected back to the callback URL provided in payment request phase via a GET request carrying all necessary data including:
- Authority: Payment token by which the user has been redirected to payment page
- Status: Payment status which should be
OKfor successful payments
If Status equals OK we can call the verifyRequest method to verify payment.
verifyRequest method
Arguments:
- amount: Original order amoun tused in payment request
- token: Authority parameter returned by IPG
Returns:
An object with the following properties:
- status:
successorerror - message: message describing the status
- ref_id: reference id in case of successful transaction
Code sample:
$args = [ 'merchantId' => '4e1598fc-09b8-29e6-2edc-bf5494616b4d' ]; //Replace arguments with your gateway actual values $ipg = new RayanpayIpg($args); $amount = 1000; //Replace with actual order amount in Rials $result = $ipg->verifyRequest($amount, $_GET['Authority']);
Getting success status in response means that the transction is successful and settled.
dizatech/rayanpay_ipg 适用场景与选型建议
dizatech/rayanpay_ipg 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 24 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 04 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 dizatech/rayanpay_ipg 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dizatech/rayanpay_ipg 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 24
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2023-04-20