cloudcogsio / omnipay-firstatlanticcommerce-gateway
Omnipay 的 First Atlantic Commerce (FAC) 支付网关驱动程序
v1.0.2.2
2023-12-06 22:57 UTC
Requires
- php: ^7.2
- league/iso3166: ~2.1.0
- omnipay/common: ^3
This package is auto-updated.
Last update: 2024-09-07 00:37:43 UTC
README
为 Omnipay PHP 支付处理库提供 First Atlantic Commerce (FAC) 网关
Omnipay 是一个与框架无关的多网关支付处理库,适用于 PHP 5.3+。此包实现了 Omnipay 的 First Atlantic Commerce (FAC) 支持。
安装
通过 Composer
$ composer require cloudcogsio/omnipay-firstatlanticcommerce-gateway
网关操作默认值
此网关驱动程序默认以 3DS 模式运行,需要通过 'setReturnUrl' 方法提供回调 URL。然后,必须实现 'acceptNotification' 方法以从 FAC 捕获交易响应。
可以通过在网关配置中显式关闭 3DS 来使网关处理非 3DS 交易。
$gateway->set3DS(false);
用法
有关一般用法说明,请参阅主要的 Omnipay 存储库。
非 3DS 交易(直接集成)
use Omnipay\Omnipay; try { $gateway = Omnipay::create('FirstAtlanticCommerce_FAC'); $gateway ->setTestMode(true) ->setIntegrationOption(\Omnipay\FirstAtlanticCommerce\Constants::GATEWAY_INTEGRATION_DIRECT) ->setFacId('xxxxxxxx') ->setFacPwd('xxxxxxxx') ->set3DS(false); $cardData = [ 'number' => '4111111111111111', 'expiryMonth' => '01', 'expiryYear' => '2025', 'cvv' => '123' ]; $transactionData = [ 'card' => $cardData, 'currency' => 'USD', 'amount' => '1.00', 'transactionId' => 'OrderNo-2100001' ]; $response = $gateway->purchase($transactionData)->send(); if($response->isSuccessful()) { // Verify response $response->verifySignature(); // Purchase was succussful, continue order processing ... } } catch (Exception $e){ $e->getMessage(); }
3DS 交易(直接集成)
'returnUrl' 必须提供。URL 必须是 https://
use Omnipay\Omnipay; try { $gateway = Omnipay::create('FirstAtlanticCommerce_FAC'); $gateway ->setTestMode(true) ->setIntegrationOption(\Omnipay\FirstAtlanticCommerce\Constants::GATEWAY_INTEGRATION_DIRECT) ->setFacId('xxxxxxxx') ->setFacPwd('xxxxxxxx') ->set3DS(true) // **Required and must be https:// ->setReturnUrl('https:///accept-notification.php'); $cardData = [ 'number' => '4111111111111111', 'expiryMonth' => '01', 'expiryYear' => '2025', 'cvv' => '123' ]; $transactionData = [ 'card' => $cardData, 'currency' => 'USD', 'amount' => '1.00', 'transactionId' => 'OrderNo-2100001' ]; $response = $gateway->purchase($transactionData)->send(); if($response->isRedirect()) { // Redirect to continue 3DS verification $response->redirect(); } else { // 3DS transaction failed setup, show error reason. echo $response->getMessage(); } } catch (Exception $e){ $e->getMessage(); }
accept-notification.php 接受 FAC 的交易响应。
$gateway = Omnipay::create('FirstAtlanticCommerce_FAC'); $gateway // Password is required to perform response signature verification ->setFacPwd('xxxxxxxx'); // Signature verification is performed implicitly once the gateway was initialized with the password. $response = $gateway->acceptNotification($_POST)->send(); if($response->isSuccessful()) { // Purchase was succussful, continue order processing ... } else { // Transaction failed echo $response->getMessage(); }
支持
如果您在使用 Omnipay 时遇到一般问题,我们建议在 Stack Overflow 上发表帖子。请确保添加 omnipay 标签,以便它易于查找。
如果您认为您已发现一个错误,请使用 GitHub 问题跟踪器 报告它,或者更好的是,分支库并提交一个 pull request。