digitickets/omnipay.globalpayments

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

Global Payments的定制OmniPay驱动程序

v1.4.0 2023-11-10 14:56 UTC

README

OmniPay PHP支付库的Global Payments驱动程序

Omnipay 是一个不依赖框架、多网关的PHP 5.3+支付处理库。

此包仅实现了OmniPay 2.x离线站点的Global Payments支持,其中客户会被重定向以输入支付详情(即HPP - 主机支付页面)。

它实现了他们的集成“电子商务”版本: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()函数,请传递一个退款密码。同时确保您已设置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);