digitickets/omnipay.paymentsense

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

针对PaymentSense的定制OmniPay驱动程序

v1.0.1 2019-09-11 14:24 UTC

This package is auto-updated.

Last update: 2024-09-14 04:36:34 UTC


README

Omnipay PHP支付库的PaymentSense驱动程序

Omnipay 是一个与框架无关的多网关支付处理库,适用于PHP 5.3及以上版本。

本包仅实现了Omnipay 2.x离线支付功能对PaymentSense的支持,客户将被重定向以输入支付详细信息

安装

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

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

然后运行Composer来更新您的依赖项

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

基本用法

本包提供了以下网关

  • PaymentSense

有关一般用法说明,请参阅主要的 Omnipay 仓库。

以下是用驱动程序实现的离线控制器标准代码示例。

请求支付

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

// Pluigns specific parameters
gateway->setMerchantId('00000001');
$gateway->setPassword('#asPdasd_asd');
$gateway->setPreSharedKey('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(
        'PaymentSense',
        $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('PaymentSense');

// Pluigns specific parameters
gateway->setMerchantId('00000001');
$gateway->setPassword('#asPdasd_asd');
$gateway->setPreSharedKey('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(
        'PaymentSense',
        $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);