Steps to integrate CyberSource payment gateway with CakePHP 2.*:
1. Download zip file of CyberSource library from “https://github.com/chrismeller/cybersource”.
2. Extract cybersource-master folder into cakephp vendors folder.
3. Create tests/config.php for test transaction with code and add credentials like below:
<?php $merchant_id = 'xxx'; $transaction_id = 'yyy'; $username = 'zzz'; $password = 'vvv'; ?>
4. Run command from command line: >cd path/to/vendors/cybersource-master
5. Run command from command line: >path/to/project/composer.phar dump-autoload
6. Create new TestController and add your test method for testing transactions like below:
public function cs(){
require( ROOT.'/vendors/cybersource-master/tests/main.php' );
$c->card( '4111111111111111', '12', '2019', '123' )
->bill_to( array(
'firstName' => 'Kailash',
'lastName' => 'Kumar',
'street1' => 'abc',
'city' => 'Mohali',
'state' => 'Punjab',
'postalCode' => '160062',
'country' => 'IN',
'email' => 'abc@mail.com’',
) );
$c->authorize( '50.55' );
print_r( $c->request );
print_r( $c->response );
exit;
}
7. Make a test transaction: call TestConroller cs function from browser.
Example:
Project_path/Test/cs
Response: Request :stdClass Object
(
[merchantID] =>abc
[merchantReferenceCode] => Unknown
[clientLibrary] => CyberSourcePHP
[clientLibraryVersion] => 0.3
[clientEnvironment] =>~14.04.1-Ubuntu SMP Wed Jun 29 21:05:22 UTC 2016 x86_64
[purchaseTotals] => stdClass Object
(
[currency] => USD
[grandTotalAmount] => 155.05
)
[ccAuthService] => stdClass Object
(
[run] => true
)
[billTo] => stdClass Object
(
[firstName] => srty
[lastName] => srt
[street1] => 53 BI Bazar
[city] => Ambala
[state] => Haryana
[postalCode] => 133001
[country] => India
[email] =>abc@mail.com
[ipAddress] => 127.0.0.1
)
[card] => stdClass Object
(
[accountNumber] => 4111111111111111
[expirationMonth] => 12
[expirationYear] => 2019
[cvNumber] => 123
)
)
Response :stdClass Object
(
[merchantReferenceCode] => Unknown
[requestID] => 4998559471636370803009
[decision] => ACCEPT
[reasonCode] => 100
[requestToken] =>abc
[purchaseTotals] => stdClass Object
(
[currency] => USD
)
[ccAuthReply] => stdClass Object
(
[reasonCode] => 100
[amount] => 155.05
[authorizationCode] => 888888
[avsCode] => 1
[cvCode] =>
[authorizedDateTime] => 2017-07-12T10:39:07Z
[processorResponse] => 100
[reconciliationID] => abc
)
)
