dercoder/ omnipay-wirecard
适用于Omnipay支付处理库的Wirecard网关
dev-master / 1.x-dev
2020-09-18 19:24 UTC
Requires
- omnipay/common: ^2.3
Requires (Dev)
- omnipay/tests: ~2.0
- satooshi/php-coveralls: 1.0.0
This package is auto-updated.
Last update: 2024-09-19 04:18:04 UTC
README
Omnipay PHP支付处理库的Wirecard驱动程序
Omnipay是一个不依赖于框架、支持多网关的PHP 5.3+支付处理库。此包实现了Omnipay对Wirecard的支持。
此库仅支持 Wirecard Checkout Page支付。您可以在此处了解更多关于Checkout Page解决方案的信息。
安装
Omnipay通过Composer安装。要安装,只需将其添加到您的composer.json
文件中
{ "require": { "dercoder/omnipay-wirecard": "~1.0" } }
如果它不在自动加载中,它还会安装Omnipay包。
基本用法
此包提供了以下网关
- Wirecard (Wirecard Checkout Page)
有关一般使用说明,请参阅主Omnipay仓库。
首先创建网关
$gateway = Omnipay\Omnipay::create('Wirecard'); $gateway->setCustomerId('D200001'); // this is a valid demo customer id $gateway->setShopId('3D'); // this is optional $gateway->setSecret('B8AKTPWBRMNBV455FG6M2DANE99WU2'); // this is also valid for developing
其次准备所需参数
$parameters = [ 'paymentType' => 'CCARD', // optional, default SELECT 'transactionId' => 'TX54434', 'currency' => 'EUR', 'description' => 'Awesome Product', 'language' => 'EN', 'returnUrl' => 'http://your-website.com/response?type=success', 'cancelUrl' => 'http://your-website.com/response?type=cancel', 'pendingUrl' => 'http://your-website.com/response?type=pending', 'notifyUrl' => 'http://your-website.com/response?type=notify', 'serviceUrl' => 'http://your-website.com/response?type=service', 'imageUrl' => 'http://your-website.com/logo.png', // optional 'amount' => '100.00' ];
如果缺少任何必需参数,则在创建请求时您将获得InvalidRequestException异常
$request = $gateway->purchase($parameters);
发送请求
$response = $request->send();
最后处理响应
if ($response->isRedirect()) { $response->redirect(); // redirect the browser to the Wirecard Checkout Page } else { echo 'Error: ' . $response->getMessage(); }
如果您想处理Checkout页面返回的URL,请在响应页面上使用此功能
$gateway = Omnipay\Omnipay::create('Wirecard'); $gateway->setCustomerId('D200001'); $gateway->setSecret('B8AKTPWBRMNBV455FG6M2DANE99WU2'); $request = $gateway->completePurchase(); $response = $request->send(); if ($response->isSuccessful()) { echo 'Succesful payment!'; } else if ($response->isCancelled()) { echo 'Payment has been cancelled.'; } else if ($response->isPending()) { echo 'Your payment is in pending status.'; } else { echo $response->getMessage(); }
响应对象中提供了getMessage()
和getData()
方法以进行进一步操作。
可用支付类型列表
支付类型高度依赖于您与Wirecard的合同,但以下是目前可用的值