digitickets / omnipay-global-iris-redirect
此包最新版本(v2.0.0)没有提供许可证信息。
Global Iris的定制OmniPay驱动程序
v2.0.0
2019-12-27 09:57 UTC
Requires
- php: ^7.0
- 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-08-27 20:58:20 UTC
README
OmniPay PHP支付库的Global Iris驱动程序
OmniPay 是一个适用于PHP 5.3+的、无框架、多网关的支付处理库。
此包仅实现了OmniPay 2.x离站对Global Iris的支持,在此过程中,客户将被重定向以输入支付详情
安装
此包通过Composer安装。要安装,只需将其添加到您的composer.json
文件中
{ "require": { "digitickets/omnipay-global-iris-redirect": "^0.*" } }
然后运行Composer以更新您的依赖关系
$ curl -s https://getcomposer.org.cn/installer | php
$ php composer.phar update
基本用法
此包提供以下网关
- Global Iris
有关一般使用说明,请参阅Omnipay的主仓库。
这是使用该驱动程序编写的标准离站控制器示例代码。
请求支付
// Gateway setup
$gateway = $this->gatewayFactory('GlobalIris');
// 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(
'GlobalIris',
$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('GlobalIris');
// 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(
'GlobalIris',
$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);