soliantconsulting / soliant-payment
Authoize.net XML API 库
2.0.0
2016-11-26 17:29 UTC
Requires
- php: ^5.6 || ^7.0
- authorizenet/authorizenet: 1.9.1
- jms/serializer: serializer-master-dev as 1.0
- zendframework/zend-component-installer: ^1.0 || ^0.3 || ^1.0.0-dev@dev
- zendframework/zend-filter: ^2.7.1
- zendframework/zend-hydrator: ^2.2.1
- zendframework/zend-mvc: ^3.0.1
- zfcampus/zf-development-mode: ^3.0
Requires (Dev)
- phpunit/phpunit: ^5.3
- squizlabs/php_codesniffer: ^2.6
- zendframework/zend-debug: ^2.5.1
This package is auto-updated.
Last update: 2024-09-16 06:30:57 UTC
README
快速入门
安装
通过 composer
{
"require": {
"soliantconsulting/soliant-payment": "^2.0.0" // ZF2 v1.0.1
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/goetas/serializer.git"
}
],
"minimum-stability": "dev",
"prefer-stable": true
}
使用
ZF3 v2.0.0
将模块添加到 modules.config.php
return [
'Zend\Filter',
'Zend\Hydrator',
'Zend\Router',
'Zend\Validator',
'Soliant\Payment\Base',
'Soliant\Payment\Authnet',
'Soliant\Payment\Demo', // (Optional) Access demo via /soliant-payment route
];
ZF2 v1.0.1
将模块添加到项目配置 application.config.php。
'modules' => [
'Soliant\Payment\Base', // Required for all payment modules
'Soliant\Payment\[Payment Module]', // Where "Payment Module" is one of the following ("Authnet")
'Soliant\Payment\Demo', // Access demo via /soliant-payment route
],
将支付模块配置目录中的 local.php.dist 文件复制到项目自动加载目录。
$ cp vendor/soliantconsulting/soliant-payment/module/[Payment Module]/[Payment Module].payment.local.php.dist config/autoload/[Payment Module].payment.local.php
使用以下之一的有效别名通过工厂注入所需的支付服务。
"authorizeAndCapture" // 授权并捕获信用卡或电子支票
ZF3 v2.0.0
public function __invoke(ContainerInterface $sm)
{
return new MyService($sm->get("[Service Alias]"));
}
ZF2 v1.0.1
public function createService(ServiceLocatorInterface $serviceLocator)
{
return new MyService($serviceLocator->get("[Service Alias]"));
}
每个支付服务应实现以下请求结构。请求数据通过数组传递到 "sendRequest" 方法,该方法返回一个响应对象。(有关数据数组结构和重写数据字段名称的信息,请参阅已实现的支付模块 payment.local.php.dist 文件。例如,链接)。可以使用 "isSuccess" 方法测试响应对象的成功,该方法返回布尔响应。
如果请求成功,应通过 "getData" 方法访问请求服务返回的任何数据。
如果请求失败,"getMessages" 方法将被填充。
$response = $this->[Service Alias]->sendRequest([
'paymentType' => 'creditCard',
'amount' => '5.00',
'expirationDate' => '2017-01',
'cardNumber' => '4111111111111111'
]);
if ($response->isSuccess()) {
// get the response data
$data = $response->getData();
} else {
// get the errors
$errors = $response->getMessages();
}