Skip to content

Commit 6409731

Browse files
committed
Update readme for NVP and XML support. Update code comments
1 parent 1770b8f commit 6409731

3 files changed

Lines changed: 48 additions & 7 deletions

File tree

README.md

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This is the PHP client for the [CyberSource SOAP Toolkit API](http://www.cyberso
1515

1616
##Installation
1717

18-
You can install the client either via [Composer](https://getcomposer.org/) 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:
18+
You can install the client either via [Composer](https://getcomposer.org/) or manually. Before installing, make sure to configure the merchant ID, transaction key, and the appropriate WSDL file URL in ````cybs.ini````. By default, the WSDL file for the client is for API version 1.120 (the latest when this package was updated). Available WSDL file URLs can be browsed at the following locations:
1919

2020
- [test](https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/)
2121
- [live](https://ics2ws.ic3.com/commerce/1.x/transactionProcessor/)
@@ -40,7 +40,10 @@ require_once('/path/to/project/lib/CybsSoapClient.php');
4040

4141

4242
##Getting Started
43-
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](http://www.cybersource.com/developers/integration_methods/simple_order_and_soap_toolkit_api/soap_api/html/wwhelp/wwhimpl/js/html/wwhelp.htm#href=Intro.04.4.html) 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.
43+
The PHP client will generate the request message headers for you, and will contain the methods specified by the WSDL file.
44+
45+
###Creating a simple request
46+
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](http://www.cybersource.com/developers/integration_methods/simple_order_and_soap_toolkit_api/soap_api/html/wwhelp/wwhimpl/js/html/wwhelp.htm#href=Intro.04.4.html) 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.
4447

4548
```php
4649
$client = new CybsSoapClient();
@@ -57,6 +60,37 @@ $request->card = $card;
5760
$reply = $client->runTransaction($request);
5861
```
5962

63+
###Creating a request from XML
64+
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](http://apps.cybersource.com/library/documentation/dev_guides/Simple_Order_API_Clients/Client_SDK_SO_API.pdf). Here's how to run a transaction from an XML file:
65+
66+
```php
67+
$referenceCode = 'your_merchant_reference_code';
68+
$client = new CybsSoapClient();
69+
$reply = $client->runTransactionFromFile('path/to/my.xml', $referenceCode);
70+
```
71+
72+
Or, you can create your own XML string and use that instead:
73+
74+
```php
75+
$xml = "";
76+
// Populate $xml
77+
$client = new CybsSoapClient();
78+
$client->runTransactionFromXml($xml);
79+
```
80+
81+
###Using name-value pairs
82+
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:
83+
84+
```php
85+
$client = new CybsNameValuePairClient();
86+
$request = array();
87+
$request['ccAuthService_run'] = 'true';
88+
$request['merchantID'] = 'my_merchant_id';
89+
$request['merchantReferenceCode'] = $'my_reference_code';
90+
// Populate $request
91+
$reply = $client->runTransaction($request);
92+
```
93+
6094
##Running the Samples
6195
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:
6296

lib/CybsSoapClient.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,17 @@ function __construct($options=array())
1616
parent::__construct($options, $properties);
1717
}
1818

19-
public function simpleXmlToCybsRequest($simpleXml) {
20-
19+
/**
20+
* Returns a properly formatted request object from a SimpleXMLElement.
21+
*
22+
* @param SimpleXMLElement $simpleXml Representation of an XML structure
23+
* @return stdClass A request with the data from the SimpleXMLElement.
24+
*/
25+
public function simpleXmlToCybsRequest($simpleXml)
26+
{
2127
$vars = get_object_vars($simpleXml);
2228
$request = new stdClass();
29+
2330
foreach(array_keys($vars) as $key) {
2431
$element = $vars[$key];
2532
if ($key == 'comment') {
@@ -83,7 +90,7 @@ public function runTransactionFromXml($xml, $merchantReferenceCode)
8390
}
8491

8592
/**
86-
* Runs a transaction from an XML file
93+
* Runs a transaction from an XML file.
8794
*
8895
* @param string $filePath The path to the XML file
8996
* @param string $merchantReferenceCode Desired reference code for the request

samples/AuthFromNameValuePairs.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
$request = array();
1717
$request['ccAuthService_run'] = 'true';
18-
$request['merchantID'] = 'dvaldez';
19-
$request['merchantReferenceCode'] = 'MRC-14344';
18+
$request['merchantID'] = 'your_merchant_id';
19+
$request['merchantReferenceCode'] = $referenceCode;
2020
$request['billTo_firstName'] = 'Jane';
2121
$request['billTo_lastName'] = 'Smith';
2222
$request['billTo_street1'] = '1295 Charleston Road';

0 commit comments

Comments
 (0)