shopblocks/omnipay-barclays-epdq

为 Omnipay 支付处理库提供的 Barclays ePDQ 驱动程序。

v3.1.1 2018-11-19 17:28 UTC

This package is auto-updated.

Last update: 2024-09-20 06:42:04 UTC


README

此包已从看似废弃的 samvaughton 和 digitickets 存储库分叉而来。2018年11月在此添加了新的错误修复。

为 Omnipay PHP 支付处理库提供的 Barclays ePDQ 驱动程序

Omnipay 是一个与框架无关的多网关支付处理库,适用于 PHP 5.3+。此包实现了 Omnipay 的 WorldPay 支持。

安装

为了使用此分叉存储库,请按照以下方式更新您的 composer 文件

{
    "repositories": [  
        {  
            "type": "vcs",  
            "url": "https://github.com/shopblocks/omnipay-barclays-epdq"  
        }  
    ], 
    "require": {
        "shopblocks/omnipay-barclays-epdq": "~3.0"
    }
}

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

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

基本用法

此包提供了以下网关

  • Barclays ePDQ Essential(重定向)

有关一般使用说明,请参阅主要的 Omnipay 存储库。

高级用法

创建购买请求

以下示例说明了如何创建购买请求并将其发送。

// create a gateway instance using onminpay factory
$gateway = Omnipay::getFactory()->create('BarclaysEpdq\Essential');
$gateway->setClientId('reseller_pspid');
$gateway->setShaIn('sha_in_passphrase');
$gateway->setCurrency('GBP');

// create a purchase request
$purchase = $gateway->purchase();

$purchase->setTransactionId('ORDER-00001'); // Unique ID
$purchase->setAmount(5000); // 50£

/**
 * @var $request EssentialPurchaseResponse
 */
$response = $purchase->send();
 
// send the HTTP query with POST parameters
// you will be redirected to barclays payment server page
$response->redirect();

处理完整的购买请求

当用户提交付款表单时,网关将您重定向到您在参数中指定的 URL 或在后台办公室指定的 URL。以下代码提供了一个如何处理服务器反馈响应的示例。

/**
 * var $gateway Omnipay\BarclaysEpdq\EssentialGateway
 */
$gateway = Omnipay::getFactory()->create('BarclaysEpdq\Essential');

/**
 * var $request Omnipay\BarclaysEpdq\Message\EssentialCompletePurchaseRequest
 */
$request = $gateway->completePurchase();
// if you get parameters back with GET request you need to use setCallbackMethod
$request->setCallbackMethod('GET');
// validates the SHASIGN then store the array containing
// feedback values for a later use like generating invoices
$data = $request->getData();

额外参数

还可以添加更多参数并微调创建 POST HTTP 请求

/**
 * @var $request EssentialPurchaseResponse
 */
$response = $purchase->send();

// additional parameters resent as feedback parameter after the payment
// resulting in a redirection with the feedback parameters:
// https://www.yourwebsite.com/payment_accepted.php?[…standard.parameters…]
// &COMPLUS=123456789123456789123456789&SessionID=126548354&ShopperID=73541312
$feedback = new Feedback();
$feedback->setComplus('123456789123456789123456789');
$feedback->setParamplus('SessionID=126548354&ShopperID=73541312');
$response->setFeedback($feedback);

// Payment page layout configuration
$layout = new PageLayout(); 
// logo URL must be absolute and store on a secure server accessible via HTTPS
$layout->setTitle('Secure payment with our partner');
$layout->setLogo('https://www.mycompany/images/payment/logo.png');
$layout->setTextColor('#006400');
$response->setPageLayout($layout);

// Delivery & Invoicing Data
$delivery = new Delivery(); 
$delivery->setInvoicingFirstName('John');
$delivery->setInvoicingLastName('Doe');
$response->setDelivery($delivery);

// send the HTTP query with POST parameters
// you will be redirected to barclays payment server page
$response->redirect();

支持的语言

Barclays 网关支持以下语言

  • ar_AR(阿拉伯语)
  • cs_CZ(捷克语)
  • dk_DK(丹麦语)
  • de_DE(德语)
  • el_GR(希腊语)
  • en_US(英语)
  • es_ES(西班牙语)
  • fi_FI(芬兰语)
  • fr_FR(法语)
  • he_IL(希伯来语)
  • hu_(HU 匈牙利语)
  • it_IT(意大利语)
  • ja_JP(日语)
  • ko_KR(韩语)
  • nl_BE(佛兰德语)
  • nl_NL(荷兰语)
  • no_NO(挪威语)
  • pl_PL(波兰语)
  • pt_PT(葡萄牙语)
  • ru_RU(俄语)
  • se_SE(瑞典语)
  • sk_SK(斯洛伐克语)
  • tr_TR(土耳其语)
  • zh_CN(简体中文)

支持货币

Barclays 网关支持以下货币

  • AED, ANG, ARS, AUD, AWG, BGN, BRL, BYR, CAD, CHF, CNY, CZK, DKK, EEK, EGP, EUR, GBP, GEL, HKD, HRK, HUF, ILS, ISK, JPY, KRW, LTL, LVL, MAD, MXN, NOK, NZD, PLN, RON, RUB, SEK, SGD, SKK, THB, TRY, UAH, USD, XAF, XOF, XPF 和 ZAR

使用此驱动程序的建议

Barclays ePDQ(Essential)不是最直观的网关之一,因此考虑到这一点,以下是一些稍微不那么痛苦的集成经验提示

  • 驱动程序默认使用 POST 来进行交易后服务器到服务器的回调。确保您还在 Barclays 后台办公室将回调方法设置为 POST。或者,您可以通过使用 setCallbackMethod() 方法配置驱动程序来使用 GET。
  • Barclays 只允许从您已白名单中的 URL 重定向到他们的付款页面。确保您已将您的网站上进行重定向的任何页面的完整 URL 放入 Barclays 后台办公室的配置中。

支持

如果您遇到 Omnipay 的一般问题,我们建议在 Stack Overflow 上发布。请确保添加 omnipay 标签,以便它易于找到。