Skip to content

Commit 1020a69

Browse files
authored
Merge pull request #43 from CyberSource/authentication-changes
Authentication changes
2 parents ea0d378 + 63b4215 commit 1020a69

14 files changed

+470
-146
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@
77

88
# CyberSource config parameters
99
/lib/conf/cybs.ini
10+
11+
.vscode

README.md

Lines changed: 143 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,127 @@
11
# CyberSource PHP Client
2-
This is the PHP client for the [CyberSource SOAP Toolkit API](http://www.cybersource.com/developers/getting_started/integration_methods/soap_toolkit_api).
32

4-
[![Build Status](https://travis-ci.org/CyberSource/cybersource-sdk-php.png?branch=master)](https://travis-ci.org/CyberSource/cybersource-sdk-php)
3+
This is the PHP client for the [CyberSource Simple Order API](https://www.cybersource.com/en-us/support/technical-documentation/apis-and-integration.html#simple).
4+
5+
## Important Notice
6+
7+
From version 1.0.4, the CyberSource PHP SDK has completely shifted to P12 authentication.
8+
9+
You can upgrade to P12 Authentication in your application by doing the following:
10+
11+
- Create a P12 certificate.
12+
- Update the files in your project directory.
13+
- Add your certificate information to your code.
14+
15+
You must upgrade the SOAP Authentication to use P12 by February 13, 2025.
16+
17+
### Prerequisites
18+
19+
You must create a P12 certificate. See the [REST Getting Started Developer Guide](https://developer.cybersource.com/docs/cybs/en-us/platform/developer/all/rest/rest-getting-started/restgs-jwt-message-intro/restgs-security-p12-intro.html).
20+
21+
> > **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.**
522
623
## Packagist
24+
725
The cybersource/sdk-php is available at [Packagist](https://packagist.org/packages/cybersource/sdk-php).
8-
If you want to install SDK from Packagist,add the following dependency to your application's 'composer.json'.
26+
27+
If you want to install SDK from Packagist,add the following dependency to your application's `composer.json`.
28+
929
```json
1030
"require": {
1131
"cybersource/sdk-php": "*"
12-
},
32+
},
1333
```
34+
1435
## Prerequisites
1536

1637
- PHP 7.3 or above
38+
1739
- [curl](http://php.net/manual/en/book.curl.php), [openssl](http://php.net/manual/en/book.openssl.php), [soap](http://php.net/manual/en/book.soap.php) extensions must be enabled
40+
1841
- A CyberSource account. You can create an evaluation account [here](http://www.cybersource.com/register/).
19-
- 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](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.3.html).
42+
43+
- A P12 certificate. Instructions on obtaining a P12 certificate can be found [here](https://developer.cybersource.com/docs/cybs/en-us/platform/developer/all/rest/rest-getting-started/restgs-jwt-message-intro/restgs-security-p12-intro.html).
2044

2145
## Installation
22-
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:
2346

24-
- [test](https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/)
25-
- [live](https://ics2ws.ic3.com/commerce/1.x/transactionProcessor/)
47+
You can install the client either via [Composer](https://getcomposer.org/) or manually.
2648

27-
### Installing with Composer
28-
You'll first need to make sure you have Composer installed. You can follow the instructions on the [official web site](https://getcomposer.org/download/). Once Composer is installed, you can enter the project root and run:
29-
```
30-
Linux: composer.phar install
31-
Windows: composer install
32-
```
33-
If you already have composer installed for the project, you'll need to run the update command as below
34-
```
35-
Linux: composer.phar update
36-
Windows: composer update
49+
Before installing, make sure that the following data is present in the `cybs.ini` file:
50+
51+
```text
52+
merchant_id = "YOUR_MERCHANT_ID"
53+
54+
; Modify the URL to point to either a live or test WSDL file with the desired API version.
55+
wsdl = "https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/CyberSourceTransaction_1.219.wsdl"
56+
57+
; 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.
58+
nvp_wsdl = "https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/CyberSourceTransaction_NVP_1.219.wsdl"
59+
60+
[SSL]
61+
KEY_ALIAS = 'YOUR_KEY_ALIAS'
62+
KEY_FILE = 'YOUR_CERTIFICATE_FILE'
63+
KEY_PASS = 'YOUR_KEY_PASS'
64+
KEY_DIRECTORY = 'PATH_TO_CERTIFICATE'
3765
```
3866

67+
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:
68+
69+
- [Test Endpoints](https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/)
70+
- [Live Endpoints](https://ics2ws.ic3.com/commerce/1.x/transactionProcessor/)
71+
72+
### Installing with Composer
73+
74+
You'll first need to make sure you have Composer installed. You can follow the instructions on the [official website](https://getcomposer.org/download/).
75+
76+
Once Composer is installed, you can enter the project root and run:
77+
78+
- On Windows:
79+
```cmd
80+
composer install
81+
```
82+
83+
- On Linux:
84+
```bash
85+
composer.phar install
86+
```
87+
88+
If you already have composer installed for the project, you'll need to run the `update` command as below:
89+
90+
- On Windows:
91+
```cmd
92+
composer update
93+
```
94+
95+
- On Linux:
96+
```bash
97+
composer.phar update
98+
```
99+
39100
Then, to use the client, you'll need to include the Composer-generated autoload file:
40101

41102
```php
42103
require_once('/path/to/project/vendor/autoload.php');
43104
```
44105

45106
### Manual installation
107+
46108
To use the client manually, include the CyberSource client in your project:
47109

48110
```php
49-
require_once('/path/to/project/lib/CybsSoapClient.php');
50-
```
111+
require_once('/<path_to_vendor_folder>/lib/CybsSoapClient.php');
112+
```
51113

52114
## Getting Started
115+
53116
The PHP client will generate the request message headers for you, and will contain the methods specified by the WSDL file.
54117

55118
### Creating a simple request
56-
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.
119+
120+
The main method you'll use is `runTransaction()`.
121+
122+
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).
123+
124+
The object will be converted into XML, so the properties of the object will need to correspond to the correct XML format.
57125

58126
```php
59127
$client = new CybsSoapClient();
@@ -62,21 +130,24 @@ $request = $client->createRequest();
62130
$card = new stdClass();
63131
$card->accountNumber = '4111111111111111';
64132
$card->expirationMonth = '12';
65-
$card->expirationYear = '2020';
133+
$card->expirationYear = '2035';
66134
$request->card = $card;
67135

68136
// Populate $request here with other necessary properties
69-
70137
$reply = $client->runTransaction($request);
71138
```
72139

73140
### Creating a request from XML
74-
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:
141+
142+
You can also create a request from XML either in a file or from an XML string.
143+
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).
144+
145+
Here's how to run a transaction from an XML file:
75146

76147
```php
77148
$referenceCode = 'your_merchant_reference_code';
78149
$client = new CybsSoapClient();
79-
$reply = $client->runTransactionFromFile('path/to/my.xml', $referenceCode);
150+
$reply = $client->runTransactionFromFile('path/to/file.xml', $referenceCode);
80151
```
81152

82153
Or, you can create your own XML string and use that instead:
@@ -89,44 +160,77 @@ $client->runTransactionFromXml($xml);
89160
```
90161

91162
### Using name-value pairs
92-
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:
163+
164+
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`.
165+
166+
Then use the `CybsNameValuePairClient` as follows:
93167

94168
```php
95169
$client = new CybsNameValuePairClient();
96170
$request = array();
97171
$request['ccAuthService_run'] = 'true';
98172
$request['merchantID'] = 'my_merchant_id';
99173
$request['merchantReferenceCode'] = $'my_reference_code';
174+
100175
// Populate $request
101176
$reply = $client->runTransaction($request);
102177
```
103178

104179
## Running the Samples
105-
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:
106180

107-
```
181+
After configuring your merchant ID and transaction key in `cybs.ini`, the samples in the `samples` directory can be run from the project root.
182+
183+
For example:
184+
185+
```bash
108186
php samples/Sale.php
109187
```
110188

111-
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.
189+
The samples will output the response object for each request if successful.
190+
191+
> > **Note that the samples contain test data and should *NOT* be run in a live environment.**
112192
113193
## Meta Key support
114-
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 key is a parent entity or associated as a partner.
115194

116-
SOAP PHP SDK supports meta key by default. Additional detail regarding cybs.ini changes.
195+
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.
117196

118-
merchantID=\<Refers to portfolio or account MID> <br>
119-
transaction_key=\<Soap password generated for meta key><br>
120-
Send transacting merchantID in the sample request.
197+
SOAP PHP SDK supports meta key by default.
121198

122-
## Tests
199+
### Additional detail regarding `cybs.ini` changes.
123200

124-
In order to run tests, you'll need [PHPUnit](https://phpunit.de). You'll also need to use [Composer](https://getcomposer.org/) 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
125-
```
126-
composer.phar dump-autoload
201+
```text
202+
merchant_id = <Refers to portfolio or account MID>
203+
204+
[SSL]
205+
KEY_ALIAS = 'KEY_ALIAS_GENERATED_FOR_CERTIFICATE'
206+
KEY_FILE = 'CERTIFICATE_FILE_GENERATED_FOR_CERTIFICATE'
207+
KEY_PASS = 'KEY_PASS_GENERATED_FOR_CERTIFICATE'
208+
KEY_DIRECTORY = 'PATH_TO_CERTIFICATE_GENERATED_FOR_METAKEY'
127209
```
128210

129-
If you installed PHPUnit with Composer, run the tests from the project root with the command ````vendor/bin/phpunit````.
211+
Note that the transacting merchant ID needs to be sent in the sample request.
212+
213+
## Tests
214+
215+
In order to run tests, you'll need [PHPUnit](https://phpunit.de).
216+
217+
You'll also need to use [Composer](https://getcomposer.org/) for autoloading.
218+
219+
If you used Composer to install the client, this should already be set up.
220+
221+
Otherwise, to use Composer for autoloading only, from the project root run:
222+
223+
- On Windows:
224+
```cmd
225+
composer dump-autoload
226+
```
227+
228+
- On Linux:
229+
```bash
230+
composer.phar dump-autoload
231+
```
232+
233+
If you installed PHPUnit with Composer, run the tests from the project root with the command `vendor/bin/phpunit`.
130234

131235
## Documentation
132236

0 commit comments

Comments
 (0)