pinaadrian/cybersource
Composer 安装命令:
composer require pinaadrian/cybersource
包简介
CyberSource Web Services laravel port
README 文档
README
Laravel port of the CyberSource SOAP Toolkit API.
The CyberSource library can be found here
Install with composer
The code is available at Packagist. If you want to install SDK from Packagist, use the following command to add the dependency to your app.
composer require pinaadrian/cybersource
Prerequisites
- Laravel 5.6 or above
- PHP 7.1 or above
- A CyberSource account. You can create an evaluation account here.
- A CyberSource transaction key. You will need to set your merchant ID and transaction key in the
cybersource.phpfile inconfig/cybersource.php. Instructions on obtaining a transaction key can be found here.
Configuration
Publishing vendor files
To publish the cybersource.php file to the config dir, run the following command:
php artisan vendor:publish --tag=cybersource
Before making any request, make sure to configure the merchant ID, transaction key, and the appropriate WSDL file URL in config/cybersource.php.
By default, the WSDL file for the client is for API version 1.120. Available WSDL file URLs can be browsed at the following locations:
Examples
The PHP client will generate the request message headers for you, and will contain the methods specified by the WSDL file.
Creating a simple request
The main method you'll use is runTransaction(). To run a transaction, you'll first need to construct a client to generate a request object, which you can populate with the necessary fields (see documentation for sample requests). The object will be converted into XML, so the properties of the object will need to correspond to the correct XML format.
use Pinaadrian\Cybersource\CybsSoapClient; $referenceCode = 'reference_code'; $client = new CybsSoapClient(); $request = $client->createRequest($referenceCode); $card = new stdClass(); $card->accountNumber = '4111111111111111'; $card->expirationMonth = '12'; $card->expirationYear = '2020'; $request->card = $card; // Populate $request here with other necessary properties $response = $client->runTransaction($request);
Creating a request from XML
You can create a request from XML either in a file or from an XML string. The XML request format is described in the Using XML section here. Here's how to run a transaction from an XML file:
use Pinaadrian\Cybersource\CybsSoapClient; $referenceCode = 'your_merchant_reference_code'; $client = new CybsSoapClient(); $reply = $client->runTransactionFromFile('path/to/my.xml', $referenceCode);
Or, you can create your own XML string and use that instead:
use Pinaadrian\Cybersource\CybsSoapClient; $xml = ""; // Populate $xml $client = new CybsSoapClient(); $client->runTransactionFromXml($xml);
Using name-value pairs
In order to run transactions using name-value pairs, make sure to set the value for the WSDL for the NVP transaction processor in cybs.ini. Then use the CybsNameValuePairClient as so:
use Pinaadrian\Cybersource\CybsNameValuePairClient; $client = new CybsNameValuePairClient(); $request = array(); $request['ccAuthService_run'] = 'true'; $request['merchantID'] = 'my_merchant_id'; $request['merchantReferenceCode'] = 'my_reference_code'; // Populate $request $reply = $client->runTransaction($request);
Documentation
For more information about CyberSource services, see http://www.cybersource.com/developers/documentation
pinaadrian/cybersource 适用场景与选型建议
pinaadrian/cybersource 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 105 次下载、GitHub Stars 达 2, 最近一次更新时间为 2018 年 06 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 pinaadrian/cybersource 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 pinaadrian/cybersource 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 105
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-06-12