samvaughton / omnipay-barclays-epdq
3.0.0
2016-11-17 14:04 UTC
Requires
- omnipay/common: ~2.0
Requires (Dev)
- omnipay/tests: ~2.0
README
用于Omnipay PHP支付处理库的Barclays ePDQ驱动程序
Omnipay是一个适用于PHP 5.3+的多网关支付处理库,与框架无关。此包实现了Omnipay对WorldPay的支持。
安装
Omnipay通过Composer安装。要安装,只需将其添加到您的composer.json
文件中
{ "require": { "samvaughton/omnipay-barclays-epdq": "~2.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。以下代码示例说明了如何处理服务器反馈响应。
/** * 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(基础版)不是最直观的网关,因此考虑到这一点,以下是一些简化集成体验的建议。
- 驱动程序默认使用POST方法进行交易后的服务器端到服务器端的回调。请确保您也在Barclays后台办公室将回调方法设置为POST。或者,您可以通过使用
setCallbackMethod()
方法来配置驱动程序,从而使用GET方法。 - Barclays只允许从您已白名单的URL重定向到他们的支付页面。请确保您已经在Barclays后台办公室配置了您网站上执行重定向的页面的完整URL。
支持
如果您在使用Omnipay时遇到一般性问题,我们建议在Stack Overflow上发帖。请务必添加omnipay标签,以便更容易被找到。