定制 nidux/cybersource-soap-client 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nidux/cybersource-soap-client

最新稳定版本:1.0.5

Composer 安装命令:

composer require nidux/cybersource-soap-client

包简介

CyberSource SOAP client by Nidux

README 文档

README

This is an Unofficial SOAP client for the CyberSource SOAP Toolkit API but with some adjustments made by Nidux.

Packagist

The nidux/cybersource-soap-client is available at Packagist. If you want to install SDK from Packagist,add the following dependency to your application's 'composer.json'.

"require": {
  "nidux/cybersource-soap-client": "*"
  }, 

Prerequisites

  • PHP 7.0 or above
  • A CyberSource account. You can create an evaluation account here.
  • A CyberSource transaction key.

Installation

You can install the client either via Composer or manually. You can provide either a the location of a file with the merchant ID, transaction key, and the appropriate WSDL file URL in cybs.ini (the latest when this package was updated). Here are the latest WSDL available, you can use SOAPUI if you want to manually test it:

Installing with Composer

You'll first need to make sure you have Composer installed. You can follow the instructions on the official web site. Once Composer is installed, you can enter the project root and run:

composer.phar install

Then, to use the client, you'll need to include the Composer-generated autoload file:

require_once('/path/to/project/vendor/autoload.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 CybersourceSoapClient();
$request = $client->createRequest();

$card = new stdClass();
$card->accountNumber = '4111111111111111';
$card->expirationMonth = '12';
$card->expirationYear = '2020';
$request->card = $card;

// Populate $request here with other necessary properties

$reply = $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:

$referenceCode = 'your_merchant_reference_code';
$client = new CybersourceSoapClient();
$reply = $client->runTransactionFromFile('path/to/my.xml', $referenceCode);

Or, you can create your own XML string and use that instead:

$xml = "";
// Populate $xml
$client = new CybersourceSoapClient();
$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:

$client = new CybersourceNVPClient();
$request = array();
$request['ccAuthService_run'] = 'true';
$request['merchantID'] = 'my_merchant_id';
$request['merchantReferenceCode'] = $'my_reference_code';
// Populate $request
$reply = $client->runTransaction($request);

How to obtain the CardType

A helper class is available with the method getCardType($cardNumber). You need to provide card number and you will obtain the right CardType value to use in the XML/Object, it will return Null when cannot detect the brand of the card.

$cardTypeValue = CybersourceHelper::getCardType('4111111111111111'); //it will return 001 

统计信息

  • 总下载量: 4.29k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2019-03-21