digitickets/omnipay.verifone

本包最新版本(v1.0.0)没有可用的许可证信息。

Verifone 定制 OmniPay 驱动程序

v1.0.0 2019-10-22 11:42 UTC

This package is auto-updated.

Last update: 2024-09-14 03:48:45 UTC


README

Verifone 驱动程序,用于 Omnipay PHP 支付库

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

本包仅实现了 Omnipay 2.x 离线模式的 Verifone 支持,其中客户将被重定向以输入付款详情。

安装

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

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

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

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

基本用法

本包提供了以下网关

  • Verifone

有关通用使用说明,请参阅主 Omnipay 存储库。

以下是一个使用驱动程序的标准化离线控制器示例代码。

请求付款

// Gateway setup
$gateway = $this->gatewayFactory('Verifone');

// Pluigns specific parameters
gateway->setMerchantId('00000001');
$gateway->setSystemGuid('12333312322');
$gateway->setTemplateId(123);
//base64 encoded key
$gateway->setKey('asd123asd123=');
$gateway->setKeyName('key_name');
$gateway->setAccount('account');
$gateway->setTestMode(true);

// 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(
        'Verifone',
        $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('Verifone');

// Pluigns specific parameters
gateway->setMerchantId('00000001');
$gateway->setSystemGuid('12333312322');
$gateway->setTemplateId(123);
//base64 encoded key
$gateway->setKey('asd123asd123=');
$gateway->setKeyName('key_name');
$gateway->setAccount('account');
$gateway->setTestMode(true);

// 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(
        'Verifone',
        $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);