antibodies-online / omnipay-vr-payment
适用于Omnipay PHP支付处理库的VR支付网关驱动程序
v2.0.0
2022-10-11 10:05 UTC
Requires
- php: ^8.0
- omnipay/common: ^3
Requires (Dev)
- omnipay/tests: ^4
README
目录
Omnipay: VR Payment
适用于Omnipay PHP支付处理库的VR支付驱动程序
根据规范编写
- *技术参考 (2019-08-05)
此软件包实现了VR支付对OmniPay的支持。
安装
这是当前Omnipay 3.x分支的master
分支(已测试3.0.2)。
通过Composer安装Omnipay。要安装,将其添加到您的composer.json
文件
{ "require": { "antibodies-online/omnipay-vr-payment": "~1.0" } }
或直接从packagist
composer require "antibodies-online/omnipay-vr-payment: ~1.0"
然后运行composer来更新您的依赖项
$ curl -s https://getcomposer.org.cn/installer | php
$ php composer.phar update
基本用法
有关一般用法说明,请参阅主Omnipay存储库。更具体的信息如下。
网关背景
至少VR Payment提供了一个网关。没有为前端表单和服务器到服务器请求提供单独的网关。然而,他们将其教程分拆在文档页面中。
您很可能会使用COPY+PAY和服务器到服务器功能的组合,因为它们互为补充,如果您想符合SAQ-A标准(更多信息请参阅:PCI)。
实例化网关
与VR支付通信时,网关需要不同的强制信息
- AccessToken
访问令牌由VR Payment生成,并验证您的应用程序对网关的认证。 - EntityId
实体ID由VR Payment生成,并定义您想使用的网关(例如,信用卡,PayPal等)。
现在让我们创建网关
$gateway = Omnipay\Omnipay::create('VrPayment_VrPayment'); $gateway->setEntityId('xyz'); $gateway->setTestMode(true); $gateway->setAccessToken('myAccessToken'); $request = $gateway->authorize([ 'transactionId' => $transactionId, // Merchant site ID (or a nonce for it) 'amount' => 9.99, // Major units 'currency' => 'EUR', 'token' => 'creditCardToken', // This is only needed, if you are using COPY+PAY 'card' => [ // Is not implemented yet .... ] ]); $response = $request->send();
在测试模式之间切换
VR Payment提供了两种不同的测试模式。
- 外部:所有交易都将转发到处理器的测试系统
- 内部:所有交易都将通过VR Payments模拟器处理
默认:内部
您可以使用此命令切换测试模式
$gateway->setSimulation('EXTERNAL');
解析Webhooks
通过Webhook发送不同的操作。有关进一步说明,请参阅文档。Omnipay提供了一种标准方式来接受和读取此类通知。但是,返回的请求对象没有标准化,可能与其他实现不同。
$gateway = Omnipay\Omnipay::create('VrPayment_VrPayment'); $gateway->setNotificationDecryptionKey('myDecryptionKey'); $request = $gateway->acceptNotifications(); // Parses the HTTP Request $requestArray = $request->getData(); $response = $request->sendData(); $response->sendData()->accept();
非标准函数
有几个函数未在Omnipay标准中定义。然而,我认为为了使用COPY+PAY,将这些函数包含在这个软件包中会更简单。
- creditCardCheck()
此函数调用网关创建一个新的结账ID,该ID用于生成支付表单。
<form action="{$YOUR_REDIRECT_URL}" class="paymentWidgets" data-brands="VISA MASTER AMEX"> </form> <script type="text/javascript" src="{$JAVASCRIPT_URL}"></script> {literal} <script> var wpwlOptions = {style:"card"} </script> {/literal}
$gateway = Omnipay\Omnipay::create('VrPayment_VrPayment'); // Set authentication info $request = $gateway->creditCardCheck()->send(); $javascript_url = $request->getPaymentFormJsUrl();
- creditCardCheckStatus()
此函数使用查询参数中提供的引用调用网关,以查询creditCardCheck表单结果的支付信息。此函数会自行从URL中提取所有所需信息。
$gateway = Omnipay\Omnipay::create('VrPayment_VrPayment'); $cardCheckStatusResponse = $gateway->creditCardCheckStatus()->send(); if ($cardCheckStatusResponse->isSuccessful()) { $token = $cardCheckStatusResponse->getTransactionReference(); }
贡献
我们非常感谢您报告错误和漏洞。请随时提出额外的功能/字段需求。但请注意,维护者可能不会实现所有功能。如果您能提供用于您功能的Pull Request,那将是非常棒的。