cybersource/sdk-php
Composer 安装命令:
composer require cybersource/sdk-php
包简介
CyberSource PHP SOAP client
关键字:
README 文档
README
This is the PHP client for the CyberSource Simple Order API.
Important Notice
From version 1.0.4, the CyberSource PHP SDK has completely shifted to P12 authentication.
You can upgrade to P12 Authentication in your application by doing the following:
- Create a P12 certificate.
- Update the files in your project directory.
- Add your certificate information to your code.
You must upgrade the SOAP Authentication to use P12 by February 13, 2025.
Prerequisites
You must create a P12 certificate. See the REST Getting Started Developer Guide.
IMPORTANT : This P12 certificate is considered as a sensitive data. It is advised to store this in a secure manner. If the certificate is compromised, immediately revoke the certificate from EBC and request a new certificate.
Packagist
The cybersource/sdk-php is available at Packagist.
If you want to install SDK from Packagist,add the following dependency to your application's composer.json.
"require": { "cybersource/sdk-php": "*" },
Prerequisites
-
PHP 7.3 or above
-
A CyberSource account. You can create an evaluation account here.
-
A P12 certificate. Instructions on obtaining a P12 certificate can be found here.
Installation
You can install the client either via Composer or manually.
Before installing, make sure that the following data is present in the cybs.ini file:
merchant_id = "YOUR_MERCHANT_ID"
; Modify the URL to point to either a live or test WSDL file with the desired API version.
wsdl = "https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/CyberSourceTransaction_1.219.wsdl"
; Modify the URL to point to either a live or test WSDL file with the desired API version for the name-value pairs transaction API.
nvp_wsdl = "https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/CyberSourceTransaction_NVP_1.219.wsdl"
[SSL]
KEY_ALIAS = 'YOUR_KEY_ALIAS'
KEY_FILE = 'YOUR_CERTIFICATE_FILE'
KEY_PASS = 'YOUR_KEY_PASS'
KEY_DIRECTORY = 'PATH_TO_CERTIFICATE'
By default, the WSDL file for the client is for API version 1.219. Available WSDL file URLs can be browsed at the following locations:
Installing with Composer
You'll first need to make sure you have Composer installed. You can follow the instructions on the official website.
Once Composer is installed, you can enter the project root and run:
-
On Windows:
composer install
-
On Linux:
composer.phar install
If you already have composer installed for the project, you'll need to run the update command as below:
-
On Windows:
composer update
-
On Linux:
composer.phar update
Then, to use the client, you'll need to include the Composer-generated autoload file:
require_once('/path/to/project/vendor/autoload.php');
Manual installation
To use the client manually, include the CyberSource client in your project:
require_once('/<path_to_vendor_folder>/lib/CybsSoapClient.php');
Getting Started
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.
$client = new CybsSoapClient(); $request = $client->createRequest(); $card = new stdClass(); $card->accountNumber = '4111111111111111'; $card->expirationMonth = '12'; $card->expirationYear = '2035'; $request->card = $card; // Populate $request here with other necessary properties $reply = $client->runTransaction($request);
Creating a request from XML
You can also 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:
$referenceCode = 'your_merchant_reference_code'; $client = new CybsSoapClient(); $reply = $client->runTransactionFromFile('path/to/file.xml', $referenceCode);
Or, you can create your own XML string and use that instead:
$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 follows:
$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);
Running the Samples
After configuring your merchant ID and transaction key in cybs.ini, the samples in the samples directory can be run from the project root.
For example:
php samples/Sale.php
The samples will output the response object for each request if successful.
Note that the samples contain test data and should NOT be run in a live environment.
Meta Key support
Meta Key is a key generated by an entity that can be used to authenticate on behalf of other entities provided that the entity which holds the key is a parent entity or associated as a partner.
SOAP PHP SDK supports meta key by default.
Additional detail regarding cybs.ini changes.
merchant_id = <Refers to portfolio or account MID>
[SSL]
KEY_ALIAS = 'KEY_ALIAS_GENERATED_FOR_CERTIFICATE'
KEY_FILE = 'CERTIFICATE_FILE_GENERATED_FOR_CERTIFICATE'
KEY_PASS = 'KEY_PASS_GENERATED_FOR_CERTIFICATE'
KEY_DIRECTORY = 'PATH_TO_CERTIFICATE_GENERATED_FOR_METAKEY'
Note that the transacting merchant ID needs to be sent in the sample request.
Tests
In order to run tests, you'll need PHPUnit.
You'll also need to use Composer for autoloading.
If you used Composer to install the client, this should already be set up.
Otherwise, to use Composer for autoloading only, from the project root run:
-
On Windows:
composer dump-autoload
-
On Linux:
composer.phar dump-autoload
If you installed PHPUnit with Composer, run the tests from the project root with the command vendor/bin/phpunit.
Documentation
For more information about CyberSource services, see http://www.cybersource.com/developers/documentation
For all other support needs, see http://www.cybersource.com/support
cybersource/sdk-php 适用场景与选型建议
cybersource/sdk-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.48M 次下载、GitHub Stars 达 60, 最近一次更新时间为 2014 年 12 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「payments」 「cybersource」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 cybersource/sdk-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 cybersource/sdk-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 cybersource/sdk-php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Connect-e payment driver for omnipay, aka Cybersource
CyberSource SOAP client by Nidux
Dealing with payments through the Egyptian payment gateway PayMob
Client SDK for CyberSource REST APIs
Librería para la gestión sencilla de pagos mediante TPV Redsys y Paypal
A PSR-7 compatible library for making CRUD API endpoints
统计信息
- 总下载量: 2.48M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 60
- 点击次数: 17
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: proprietary
- 更新时间: 2014-12-30