Skip to content

PHP SDK for Cybersource SOAP Toolkit API

License

Notifications You must be signed in to change notification settings

CyberSource/cybersource-sdk-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#CyberSource PHP Client

This is the PHP client for the CyberSource SOAP Toolkit API.

##Prerequisites

  • PHP 5.3 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 cybs.ini file in lib/conf. Instructions on obtaining a transaction key can be found here.

##Installation

You can install the client either via Composer or manually. Before installing, make sure to configure the merchant ID, transaction key, and the WSDL file URL in cybs.ini. By default, the WSDL file for the client is for API version 1.109 (the latest when this package was created). 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 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');

###Manual installation To use the client manually, include the CyberSource client in your project:

require_once('/path/to/project/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. 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 = '2020';
$request->card = $card;

// Populate $request here with other necessary properties

$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.

##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

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