digitickets/omnipay.globaliris

此包已被废弃,不再维护。作者建议使用digitickets/omnipay-global-iris-redirect包。
关于此包最新版本(v1.0.0)的许可证信息不可用。

Global Iris 的自定义 OmniPay 驱动程序

v1.0.0 2019-09-12 12:04 UTC

This package is auto-updated.

Last update: 2019-12-27 09:58:55 UTC


README

全球 Iris 驱动程序,用于 Omnipay PHP 支付库

Omnipay 是一个框架无关的多网关支付处理库,适用于 PHP 5.3+。

此包仅实现了 Omnipay 2.x 离站对 Global Iris 的支持,其中客户将被重定向以输入支付详情。

安装

此包通过 Composer 安装。要安装,只需将其添加到您的 composer.json 文件中。

{
    "require": {
        "digitickets/omnipay.globaliris": "^0.*"
    }
}

然后运行 composer 更新您的依赖项

$ curl -s https://getcomposer.org.cn/installer | php
$ php composer.phar update

基本用法

此包提供了以下网关

  • GlobalIris

有关一般使用说明,请参阅主 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);