From d79f5003d740faf240f1bfef2707cd45749586fa Mon Sep 17 00:00:00 2001 From: rkesarwa Date: Wed, 28 Apr 2021 17:47:00 +0530 Subject: [PATCH 1/9] Add sender_id to support meta key support --- lib/CybsClient.php | 16 +++++++++++++++- lib/conf/cybs.ini | 5 +++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/CybsClient.php b/lib/CybsClient.php index f904e90..21434d1 100644 --- a/lib/CybsClient.php +++ b/lib/CybsClient.php @@ -14,6 +14,7 @@ class CybsClient extends SoapClient private $merchantId; private $transactionKey; + private $senderId; function __construct($options=array(), $properties, $nvp=false) { @@ -40,11 +41,16 @@ function __construct($options=array(), $properties, $nvp=false) parent::__construct($wsdl, $options); $this->merchantId = $properties['merchant_id']; $this->transactionKey = $properties['transaction_key']; + $this->senderId = $properties['sender_id']; + + if(!$this->senderId) { + $this->senderId = $this->merchantId; + } $nameSpace = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"; $soapUsername = new SoapVar( - $this->merchantId, + $this->senderId, XSD_STRING, NULL, $nameSpace, @@ -113,4 +119,12 @@ public function getTransactionKey() { return $this->transactionKey; } + + /** + * @return string The client's sender ID. + */ + public function getSenderId() + { + return $this->senderId; + } } \ No newline at end of file diff --git a/lib/conf/cybs.ini b/lib/conf/cybs.ini index c84f068..63bca2e 100644 --- a/lib/conf/cybs.ini +++ b/lib/conf/cybs.ini @@ -1,5 +1,6 @@ -merchant_id = your_merchant_id -transaction_key = "your_transaction_key" +merchant_id = rkesarwa +#sender_id = +transaction_key = "XmMOqP4SqI8GVaxtoKqQ1uEpNGTL5w6tU+Rz1GufHHbozZf5LbcBTQL0kMKwgAkhtWCttYdSk5UkG0BjHH3NsExdJR5Wjyauz8z6LfjP3ntYXejkhW6CTdB83OB/8qKyxdCKCHaYxfKsDSlvRoONuTg8Cgg11o2qebQrS+mapJODwwjlxesuDbqu7sKS0Ls2AwNkHdiH0N7T4ZOJnZ0z6lls7vuDQUfwOJoJWnhHQ/C1jTErw8jZRvh87tCGXD68m+u+satqdPlLSR1tZ4j0YldGsaRZ7ZNv4SjitiUqDs34xfBtL9TZqrH/VyT3OuBAjUI79JGDXTXgC1U4oinSFQ==" ; Modify the URL to point to either a live or test WSDL file with the desired API version. wsdl = "https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/CyberSourceTransaction_1.120.wsdl" From eb0d422db82815482f0c68f85805cacf431f0e57 Mon Sep 17 00:00:00 2001 From: rkesarwa Date: Wed, 28 Apr 2021 17:48:56 +0530 Subject: [PATCH 2/9] change card expiration year --- samples/AuthFollowOnCapture.php | 4 ++-- samples/AuthFromNameValuePairs.php | 4 ++-- samples/Sale.php | 2 +- samples/Subscription.php | 2 +- samples/xml/auth.xml | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/samples/AuthFollowOnCapture.php b/samples/AuthFollowOnCapture.php index fd81c8a..db9db9b 100644 --- a/samples/AuthFollowOnCapture.php +++ b/samples/AuthFollowOnCapture.php @@ -5,7 +5,7 @@ // Using Composer-generated autoload file. require __DIR__ . '/../vendor/autoload.php'; // Or, uncomment the line below if you're not using Composer autoloader. -// require_once(__DIR__ . '/../lib/CybsSoapClient.php'); +//require_once(__DIR__ . '/../lib/CybsSoapClient.php'); // Before using this example, you can use your own reference code for the transaction. @@ -35,7 +35,7 @@ $card = new stdClass(); $card->accountNumber = '4111111111111111'; $card->expirationMonth = '12'; -$card->expirationYear = '2020'; +$card->expirationYear = '2021'; $request->card = $card; $purchaseTotals = new stdClass(); diff --git a/samples/AuthFromNameValuePairs.php b/samples/AuthFromNameValuePairs.php index c6450d1..841479b 100644 --- a/samples/AuthFromNameValuePairs.php +++ b/samples/AuthFromNameValuePairs.php @@ -5,7 +5,7 @@ // Using Composer-generated autoload file. require __DIR__ . '/../vendor/autoload.php'; // Or, uncomment the line below if you're not using Composer autoloader. -// require_once(__DIR__ . '/../lib/CybsNameValuePairClient.php'); +//require_once(__DIR__ . '/../lib/CybsNameValuePairClient.php'); // Before using this example, you can use your own reference code for the transaction. @@ -26,7 +26,7 @@ $request['billTo_email'] = 'jsmith@example.com'; $request['card_accountNumber'] = '4111111111111111'; $request['card_expirationMonth'] = '12'; -$request['card_expirationYear'] = '2019'; +$request['card_expirationYear'] = '2021'; $request['purchaseTotals_currency'] = 'USD'; $request['item_0_unitPrice'] = '12.34'; $request['item_1_unitPrice'] = '56.78'; diff --git a/samples/Sale.php b/samples/Sale.php index 5d92cc7..95d6710 100644 --- a/samples/Sale.php +++ b/samples/Sale.php @@ -39,7 +39,7 @@ $card = new stdClass(); $card->accountNumber = '4111111111111111'; $card->expirationMonth = '12'; -$card->expirationYear = '2020'; +$card->expirationYear = '2021'; $request->card = $card; $purchaseTotals = new stdClass(); diff --git a/samples/Subscription.php b/samples/Subscription.php index 185906f..097ae5f 100644 --- a/samples/Subscription.php +++ b/samples/Subscription.php @@ -34,7 +34,7 @@ $card = new stdClass(); $card->accountNumber = '4111111111111111'; $card->expirationMonth = '12'; -$card->expirationYear = '2020'; +$card->expirationYear = '2021'; $card->cardType='001'; $request->card = $card; diff --git a/samples/xml/auth.xml b/samples/xml/auth.xml index 864f7ca..1ce0534 100644 --- a/samples/xml/auth.xml +++ b/samples/xml/auth.xml @@ -35,7 +35,7 @@ 4111111111111111 12 - 2020 + 2021 From 784aa004a6d9f5b3b4160a548399c16a3d83d5c2 Mon Sep 17 00:00:00 2001 From: rkesarwa Date: Wed, 28 Apr 2021 18:21:06 +0530 Subject: [PATCH 3/9] Revert "Add sender_id to support meta key support" This reverts commit d79f5003d740faf240f1bfef2707cd45749586fa. --- lib/CybsClient.php | 16 +--------------- lib/conf/cybs.ini | 5 ++--- 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/lib/CybsClient.php b/lib/CybsClient.php index 21434d1..f904e90 100644 --- a/lib/CybsClient.php +++ b/lib/CybsClient.php @@ -14,7 +14,6 @@ class CybsClient extends SoapClient private $merchantId; private $transactionKey; - private $senderId; function __construct($options=array(), $properties, $nvp=false) { @@ -41,16 +40,11 @@ function __construct($options=array(), $properties, $nvp=false) parent::__construct($wsdl, $options); $this->merchantId = $properties['merchant_id']; $this->transactionKey = $properties['transaction_key']; - $this->senderId = $properties['sender_id']; - - if(!$this->senderId) { - $this->senderId = $this->merchantId; - } $nameSpace = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"; $soapUsername = new SoapVar( - $this->senderId, + $this->merchantId, XSD_STRING, NULL, $nameSpace, @@ -119,12 +113,4 @@ public function getTransactionKey() { return $this->transactionKey; } - - /** - * @return string The client's sender ID. - */ - public function getSenderId() - { - return $this->senderId; - } } \ No newline at end of file diff --git a/lib/conf/cybs.ini b/lib/conf/cybs.ini index 63bca2e..c84f068 100644 --- a/lib/conf/cybs.ini +++ b/lib/conf/cybs.ini @@ -1,6 +1,5 @@ -merchant_id = rkesarwa -#sender_id = -transaction_key = "XmMOqP4SqI8GVaxtoKqQ1uEpNGTL5w6tU+Rz1GufHHbozZf5LbcBTQL0kMKwgAkhtWCttYdSk5UkG0BjHH3NsExdJR5Wjyauz8z6LfjP3ntYXejkhW6CTdB83OB/8qKyxdCKCHaYxfKsDSlvRoONuTg8Cgg11o2qebQrS+mapJODwwjlxesuDbqu7sKS0Ls2AwNkHdiH0N7T4ZOJnZ0z6lls7vuDQUfwOJoJWnhHQ/C1jTErw8jZRvh87tCGXD68m+u+satqdPlLSR1tZ4j0YldGsaRZ7ZNv4SjitiUqDs34xfBtL9TZqrH/VyT3OuBAjUI79JGDXTXgC1U4oinSFQ==" +merchant_id = your_merchant_id +transaction_key = "your_transaction_key" ; Modify the URL to point to either a live or test WSDL file with the desired API version. wsdl = "https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/CyberSourceTransaction_1.120.wsdl" From ab3f8c09f92c1793f63bb9105432d417bd1175ca Mon Sep 17 00:00:00 2001 From: rkesarwa Date: Wed, 28 Apr 2021 18:35:03 +0530 Subject: [PATCH 4/9] README changes and add merchantID in sample request --- README.md | 9 +++++++++ samples/AuthFollowOnCapture.php | 3 ++- samples/AuthFromNameValuePairs.php | 2 ++ samples/Sale.php | 1 + samples/xml/auth.xml | 1 + 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 938d054..500a84d 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,15 @@ php samples/Sale.php 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. +##Meta Key support +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. + +SOAP PHP SDK supports meta key by default. Additional detail regarding cybs.ini changes. + +merchantID=\
+transaction_key=\
+Send merchantID in request for nvl/xml/sales and followOnCapture request. + ## Tests 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 diff --git a/samples/AuthFollowOnCapture.php b/samples/AuthFollowOnCapture.php index db9db9b..2a2ee19 100644 --- a/samples/AuthFollowOnCapture.php +++ b/samples/AuthFollowOnCapture.php @@ -31,6 +31,7 @@ $billTo->email = 'null@cybersource.com'; $billTo->ipAddress = '10.7.111.111'; $request->billTo = $billTo; +//$request->merchantID = ''; $card = new stdClass(); $card->accountNumber = '4111111111111111'; @@ -73,7 +74,7 @@ $captureRequest->ccCaptureService = $ccCaptureService; $captureRequest->item = array($item0, $item1); $captureRequest->purchaseTotals = $purchaseTotals; - +//$captureRequest->merchantID = ''; $captureReply = $client->runTransaction($captureRequest); // This section will show all the reply fields. diff --git a/samples/AuthFromNameValuePairs.php b/samples/AuthFromNameValuePairs.php index 841479b..21956d4 100644 --- a/samples/AuthFromNameValuePairs.php +++ b/samples/AuthFromNameValuePairs.php @@ -30,6 +30,8 @@ $request['purchaseTotals_currency'] = 'USD'; $request['item_0_unitPrice'] = '12.34'; $request['item_1_unitPrice'] = '56.78'; +//$request['merchantID'] = ''; + $reply = $client->runTransaction($request); // This section will show all the reply fields. diff --git a/samples/Sale.php b/samples/Sale.php index 95d6710..9e8f7ec 100644 --- a/samples/Sale.php +++ b/samples/Sale.php @@ -46,6 +46,7 @@ $purchaseTotals->currency = 'USD'; $purchaseTotals->grandTotalAmount = '90.01'; $request->purchaseTotals = $purchaseTotals; +//$request->merchantID = ''; $reply = $client->runTransaction($request); diff --git a/samples/xml/auth.xml b/samples/xml/auth.xml index 1ce0534..c677315 100644 --- a/samples/xml/auth.xml +++ b/samples/xml/auth.xml @@ -2,6 +2,7 @@ --> your_merchant_reference_code + John Doe From 4779eccdef14a808b06b58b8cbebca627debd382 Mon Sep 17 00:00:00 2001 From: rkesarwa Date: Wed, 28 Apr 2021 19:05:23 +0530 Subject: [PATCH 5/9] update README file --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 500a84d..9f886ae 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,7 @@ php samples/Sale.php 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. -##Meta Key support +## Meta Key support 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. SOAP PHP SDK supports meta key by default. Additional detail regarding cybs.ini changes. From b3fff83ee083ec1aaff9d18f9e7b8ea088c6af9a Mon Sep 17 00:00:00 2001 From: rkesarwa Date: Wed, 26 May 2021 18:52:51 +0530 Subject: [PATCH 6/9] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9f886ae..54d573b 100644 --- a/README.md +++ b/README.md @@ -108,9 +108,9 @@ Meta Key is a key generated by an entity that can be used to authenticate on beh SOAP PHP SDK supports meta key by default. Additional detail regarding cybs.ini changes. -merchantID=\
-transaction_key=\
-Send merchantID in request for nvl/xml/sales and followOnCapture request. +merchantID=\
+transaction_key=\
+Send transacting merchantID in the sample request. ## Tests From 7c59b5c3c2fc4141175e760427fe6b77673b8d13 Mon Sep 17 00:00:00 2001 From: rkesarwa Date: Thu, 3 Jun 2021 10:50:26 +0530 Subject: [PATCH 7/9] Update readme.md for composer install in windows --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 54d573b..3d270f8 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,8 @@ You can install the client either via [Composer](https://getcomposer.org/) or ma ### Installing with Composer 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: ``` -composer.phar install +composer.phar install - Linux +composer install - Windows ``` Then, to use the client, you'll need to include the Composer-generated autoload file: From afe08c738fa5aee287acc4970a4fc62b53d14595 Mon Sep 17 00:00:00 2001 From: rkesarwa Date: Thu, 3 Jun 2021 10:57:47 +0530 Subject: [PATCH 8/9] Update readme.md for composer install in windows --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3d270f8..cc809b2 100644 --- a/README.md +++ b/README.md @@ -27,8 +27,8 @@ You can install the client either via [Composer](https://getcomposer.org/) or ma ### Installing with Composer 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: ``` -composer.phar install - Linux -composer install - Windows +Linux: composer.phar install +Windows: composer install ``` Then, to use the client, you'll need to include the Composer-generated autoload file: From 15a3d9bdbd6479d5678e27ee22cee05582acf1a4 Mon Sep 17 00:00:00 2001 From: rkesarwa Date: Thu, 19 Aug 2021 18:29:25 +0530 Subject: [PATCH 9/9] Update composer.json to use phpunit v9.5 --- README.md | 8 +++++++- composer.json | 4 ++-- test/CybsSoapClientTest.php | 4 +++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index cc809b2..d6892f4 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ If you want to install SDK from Packagist,add the following dependency to your a ``` ## Prerequisites -- PHP 5.3 or above +- PHP 7.3 or above - [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 - A CyberSource account. You can create an evaluation account [here](http://www.cybersource.com/register/). - 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). @@ -30,6 +30,12 @@ You'll first need to make sure you have Composer installed. You can follow the i Linux: composer.phar install Windows: composer install ``` +If you already have composer installed for the project, you'll need to run the update command as below +``` +Linux: composer.phar update +Windows: composer update +``` + Then, to use the client, you'll need to include the Composer-generated autoload file: ```php diff --git a/composer.json b/composer.json index b31cb78..d19969a 100644 --- a/composer.json +++ b/composer.json @@ -15,13 +15,13 @@ } ], "require": { - "php": ">=5.3", + "php": ">=7.3", "ext-curl": "*", "ext-openssl": "*", "ext-soap": "*" }, "require-dev": { - "phpunit/phpunit": "3.7.*" + "phpunit/phpunit": "9.5.*" }, "autoload": { "classmap": ["lib/"] diff --git a/test/CybsSoapClientTest.php b/test/CybsSoapClientTest.php index 1ecebba..5aea2d1 100644 --- a/test/CybsSoapClientTest.php +++ b/test/CybsSoapClientTest.php @@ -1,6 +1,8 @@