2017 © Pedro Peláez
 

package cybersource

CyberSource Web Services laravel port

image

pinaadrian/cybersource

CyberSource Web Services laravel port

  • Tuesday, June 12, 2018
  • by pinaadrian
  • Repository
  • 1 Watchers
  • 1 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

CyberSource PHP Client (Laravel port)

Laravel port of the CyberSource SOAP Toolkit API., (*1)

The CyberSource library can be found here, (*2)

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., (*3)

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.php file in config/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:, (*4)

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., (*5)

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:, (*6)

Examples

The PHP client will generate the request message headers for you, and will contain the methods specified by the WSDL file., (*7)

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., (*8)

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:, (*9)

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:, (*10)

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:, (*11)

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, (*12)

The Versions

12/06 2018

dev-master

9999999-dev

CyberSource Web Services laravel port

  Sources   Download

MIT

The Requires

  • php >=7.1

 

by Adrian Piña

12/06 2018

v1.0.1

1.0.1.0

CyberSource Web Services laravel port

  Sources   Download

MIT

The Requires

  • php >=7.1

 

by Adrian Piña

12/06 2018

v1.0.0

1.0.0.0

CyberSource Web Services laravel port

  Sources   Download

MIT License

The Requires

  • php >=7.1

 

by Adrian Piña