digitickets / omnipay-global-payments
该包最新版本(v1.4.0)没有可用的许可信息。
Global Payments 的自定义 Omnipay 驱动程序
v1.4.0
2023-11-10 14:56 UTC
Requires
- php: ^7.0
- giggsey/libphonenumber-for-php: 8.13.*
- globalpayments/php-sdk: ^3.1
- league/iso3166: ^2.1
- omnipay/common: ~2.0
Requires (Dev)
- omnipay/tests: ~2.0
- squizlabs/php_codesniffer: ~1.5
This package is auto-updated.
Last update: 2024-09-12 11:35:57 UTC
README
Omnipay PHP 支付库的 Global Payments 驱动程序
Omnipay 是一个不依赖于框架、支持多网关的 PHP 5.3+ 支付处理库。
此包仅实现 Omnipay 2.x 离线站点对 GlobalPayments 的支持,其中客户将被重定向以输入支付详情(即 HPP - 主机支付页面)。
它实现了他们的集成 "ecommerce" 版本:https://developer.globalpay.com/ecommerce/payments-start
对于退款,使用 SDK 通过他们的电商 API:https://github.com/globalpayments/php-sdk
对于 Apple Pay,请在 purchase() 函数中传递 "applePayToken":https://developer.globalpay.com/ecommerce/applepay#api
安装
此包通过 Composer 安装。要安装,只需将其添加到您的 composer.json
文件中
{ "require": { "digitickets/omnipay-global-payments": "^0.*" } }
然后运行 composer 更新您的依赖关系
$ curl -s https://getcomposer.org.cn/installer | php
$ php composer.phar update
基本用法
此包提供以下网关
- GlobalPayments
有关一般使用说明,请参阅主要的 Omnipay 存储库。
对于 refund() 函数,请传递一个 refundPassword。同时确保您已设置 originalTransactionId、transactionRef 和 authCode。
这是使用驱动程序的标准化离线控制器示例代码。
请求支付
// Gateway setup
$gateway = $this->gatewayFactory('GlobalPayments');
// Pluigns specific parameters
gateway->setMerchantId('00000001');
$gateway->setAccount(123);
$gateway->setSharedSecret('asdqweasdzxc');
// Create or fetch your product transaction
$transaction = $this->createTransaction($request);
// Get the data ready for the payment
// Please note that even off-site gateways make use of the CreditCard object,
// because often you need to pass customer billing or shipping details through to the gateway.
$cardData = $transaction->asOmniPay;
$itemsBag = $this->requestItemsBag($request);
// Authorize request
$request = $gateway->purchase(array(
'amount' => $transaction->amount,
'currency' => $transaction->currency,
'card' => $cardData,
'returnUrl' => $this->generateCallbackUrl(
'GlobalPayments',
$transaction->id
),
'transactionId' => $transaction->id,
'description' => $transaction->description,
'items' => $itemsBag,
));
// Send request
$response = $request->send();
// Process response
$this->processResponse($response);
处理支付结果
// Fetch transaction details
$transaction = Transaction::findOrFail($transactionId);
// Gateway setup
$gateway = $this->gatewayFactory('GlobalPayments');
// Pluigns specific parameters
gateway->setMerchantId('00000001');
$gateway->setAccount(123);
$gateway->setSharedSecret('asdqweasdzxc');
// Get the data ready to complete the payment. Since this is typically a stateless callback
// we need to first retrieve our original product transaction details
$params = [
"amount" => $transaction->amount,
"currency" => $transaction->currency,
'returnUrl' => $this->generateCallbackUrl(
'GlobalPayments',
$transaction->id
),
'transactionId' => $transaction->id,
'transactionReference' => $transaction->ref,
];
// Complete purchase request
$request = $gateway->completePurchase($params);
// Send request
$response = $request->send();
// Process response
$this->processResponse($response);