shurjomukhi / shurjopay-plugin-php
shurjoPay 是一个在线支付网关和便捷的支付解决方案
0.1.1
2023-01-27 13:15 UTC
README
官方 shurjoPay PHP 插件,供商家或服务提供商连接到 shurjoPay 支付网关 v2.1,由 ShurjoMukhi Limited 开发和维护。
此插件包可用于任何 PHP 应用程序或框架(例如 Laravel、Lumen、CodeIgniter、Symfony、CakePHP、Yii 等)。在您的 CMS(Wordpress、Magento、Joomla、OpenCart、Drupal 等)项目中使用此插件,或查看我们针对知名 CMS 的专用插件。它使开发人员只需通过三个 API 调用即可轻松集成 shurjoPay v2.1
- authenticate:验证商家并生成令牌
- makePayment:创建并发送支付请求
- verifyPayment:在 shurjoPay 验证支付状态
同时减少了许多手动操作
- 处理 HTTP 请求和错误
- 在您偏好的路径生成日志
- 结账期间的认证和支付验证
目标受众
本文件旨在为想要使用 PHP 集成 shurjoPay 在线支付网关的商家和服务提供商的开发人员和技术人员。
如何使用此 shurjoPay 插件
要将 shurjoPay 支付网关集成到您的 PHP 项目中,请按以下任务顺序进行。
将 shurjopay-plugin-php 添加为您的项目依赖项。
$ composer require shurjomukhi/shurjopay-plugin-php
在您的应用程序中正确设置 shurjopay 插件的参数,如下所示配置文件。
# shurjopay merchant username SP_USERNAME='sp_sandbox' # shurjopay merchant password SP_PASSWORD='pyyk97hu&6u6' # Merchant prefix used to generate order id SP_PREFIX='NOK' # shurjopay payment gateway API endpoint SHURJOPAY_API='https://sandbox.shurjopayment.com' # URL to redirect after completion of a payment. Sample: https://sandbox.shurjopayment.com/response SP_CALLBACK='https:///your-php-app/return.php' # Log location of shurjopay php plugin SP_LOG_LOCATION='/var/log/shurjopay' # CURLOPT_SSL_VERIFYPEER=0 only for local and non-SSL environment CURLOPT_SSL_VERIFYPEER=1
注意:在生产之前,请记得在配置文件中使用实时凭据。
现在,使用 ShurjopayConfig
创建 Shurjopay
实例。要从配置或 env 文件中读取参数,您可以使用 ShurjopayEnvReader
。
查看测试类以查看示例。
$env = new ShurjopayEnvReader(__DIR__ . '/_env'); $sp_instance = new Shurjopay($env->getConfig());
之后,在您的应用程序中使用我们的插件向 shurjoPay 发起支付请求。以下是一个基本示例代码片段。
$request = new PaymentRequest(); # All the data will come from user end. $request->currency = 'BDT'; $request->amount = 100; $request->discountAmount = 0; $request->discPercent = 0; $request->customerName = 'Abdul Mannan'; $request->customerPhone = '01712345678'; $request->customerEmail = 'test@gmail.com'; $request->customerAddress = 'Dhaka'; $request->customerCity = 'Dhaka'; $request->customerState = 'Dhaka'; $request->customerPostcode = '1209'; $request->customerCountry = 'Bangladesh'; $request->shippingAddress = 'Sirajganj'; $request->shippingCity = 'Dhaka'; $request->shippingCountry = 'Bangladesh'; $request->receivedPersonName = 'Jalil Mia'; $request->shippingPhoneNumber = '01712345678'; # Custom data can be sent using these value[1-4] fields which will be returned back to you in response. Any type of data can be passed on; e.g. string, integer, array etc. $request->value1 = array("val1", "val2", "val3"); $request->value2 = 'value2'; $request->value3 = 'value3'; $request->value4 = 'value4'; $sp_instance->makePayment($request);
可以使用 shurjoPay 订单 ID 在每次交易后进行支付验证。
$sp_instance->verifyPayment($order_id);
查看我们的验证文档以获取更多详细信息。
参考
- PHP 示例项目 展示 PHP 插件的使用。
- 使用 PHP 插件的 Laravel 示例项目 以了解 shurjopay。
- OpenCart 插件
- OpenCart 示例项目
- 多种语言和框架中的示例应用程序和项目 展示 shurjoPay 集成。
- shurjoPay Postman 网站 使用沙盒系统说明请求和响应流程。
- shurjopay 插件 的 github 主页
许可证
此代码在 MIT 开源许可证 下。
请联系 shurjoPay 团队以获取更多详细信息。联系
版权 ©️2023 ShurjoMukhi Limited.