From a382848e7f1b3a05687fd4d6c484acfb5337de0a Mon Sep 17 00:00:00 2001 From: Gaurav Srikant Mokhasi Date: Tue, 31 Jan 2017 11:22:39 +0530 Subject: [PATCH 001/149] added extra information to prevent composer errors --- README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4b2b653..e4c762f 100644 --- a/README.md +++ b/README.md @@ -12,11 +12,21 @@ The samples are all completely independent and self-contained so you can look at ##Running the Samples Clone this repository. -Run "composer update" in the root directory. +Run "composer update" in the root directory. Run the individual samples e.g. ```` php PaymentTransactions/charge-credit-card.php ```` +Note: If during "composer update", you get the error "composer failed to open stream invalid argument", go to your php.ini file (present where you have installed PHP), and uncomment the following lines: +```` +extension=php_openssl.dll +extension=php_curl.dll +```` +On Windows systems, you also have to uncomment: +```` +extension_dir = "ext" +```` +Then run the composer update again. You might have to restart your machine before the changes take effect. ##What if I'm not using Composer? We provide a custom `SPL` autoloader, just [download the SDK.](https://github.com/AuthorizeNet/sdk-php/releases): From 8e427e62071cfc3bc27cd6fb3993fe200ab38e61 Mon Sep 17 00:00:00 2001 From: adavidw Date: Thu, 16 Feb 2017 10:08:11 -0700 Subject: [PATCH 002/149] add address to charge and authorize --- PaymentTransactions/authorize-credit-card.php | 23 ++- PaymentTransactions/charge-credit-card.php | 136 ++++++++++-------- 2 files changed, 95 insertions(+), 64 deletions(-) diff --git a/PaymentTransactions/authorize-credit-card.php b/PaymentTransactions/authorize-credit-card.php index ea75b01..c662ef4 100644 --- a/PaymentTransactions/authorize-credit-card.php +++ b/PaymentTransactions/authorize-credit-card.php @@ -21,11 +21,27 @@ function authorizeCreditCard($amount){ $paymentOne = new AnetAPI\PaymentType(); $paymentOne->setCreditCard($creditCard); - //create a transaction + $order = new AnetAPI\OrderType(); + $order->setDescription("New Item"); + + // Set the customer's Bill To address + $customerAddress = new AnetAPI\CustomerAddressType(); + $customerAddress->setFirstName("Ellen"); + $customerAddress->setLastName("Johnson"); + $customerAddress->setCompany("Souveniropolis"); + $customerAddress->setAddress("14 Main Street"); + $customerAddress->setCity("Pecan Springs"); + $customerAddress->setState("TX"); + $customerAddress->setZip("44628"); + $customerAddress->setCountry("USA"); + + // Create a TransactionRequestType object $transactionRequestType = new AnetAPI\TransactionRequestType(); - $transactionRequestType->setTransactionType( "authOnlyTransaction"); + $transactionRequestType->setTransactionType( "authCaptureTransaction"); $transactionRequestType->setAmount($amount); + $transactionRequestType->setOrder($order); $transactionRequestType->setPayment($paymentOne); + $transactionRequestType->setBillTo($customerAddress); $request = new AnetAPI\CreateTransactionRequest(); $request->setMerchantAuthentication($merchantAuthentication); @@ -35,6 +51,7 @@ function authorizeCreditCard($amount){ $controller = new AnetController\CreateTransactionController($request); $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + if ($response != null) { if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) @@ -84,5 +101,5 @@ function authorizeCreditCard($amount){ return $response; } if(!defined('DONT_RUN_SAMPLES')) - authorizeCreditCard( 23.32); + authorizeCreditCard(\SampleCode\Constants::SAMPLE_AMOUNT); ?> \ No newline at end of file diff --git a/PaymentTransactions/charge-credit-card.php b/PaymentTransactions/charge-credit-card.php index f80ee1d..0f79512 100644 --- a/PaymentTransactions/charge-credit-card.php +++ b/PaymentTransactions/charge-credit-card.php @@ -1,90 +1,104 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); - $refId = 'ref' . time(); + // Common setup for API credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $refId = 'ref' . time(); + + // Create the payment data for a credit card + $creditCard = new AnetAPI\CreditCardType(); + $creditCard->setCardNumber("4111111111111111"); + $creditCard->setExpirationDate("1226"); + $creditCard->setCardCode("123"); + $paymentOne = new AnetAPI\PaymentType(); + $paymentOne->setCreditCard($creditCard); - // Create the payment data for a credit card - $creditCard = new AnetAPI\CreditCardType(); - $creditCard->setCardNumber("4111111111111111"); - $creditCard->setExpirationDate("1226"); - $creditCard->setCardCode("123"); - $paymentOne = new AnetAPI\PaymentType(); - $paymentOne->setCreditCard($creditCard); + $order = new AnetAPI\OrderType(); + $order->setDescription("New Item"); - $order = new AnetAPI\OrderType(); - $order->setDescription("New Item"); + // Set the customer's Bill To address + $customerAddress = new AnetAPI\CustomerAddressType(); + $customerAddress->setFirstName("Ellen"); + $customerAddress->setLastName("Johnson"); + $customerAddress->setCompany("Souveniropolis"); + $customerAddress->setAddress("14 Main Street"); + $customerAddress->setCity("Pecan Springs"); + $customerAddress->setState("TX"); + $customerAddress->setZip("44628"); + $customerAddress->setCountry("USA"); - //create a transaction - $transactionRequestType = new AnetAPI\TransactionRequestType(); - $transactionRequestType->setTransactionType( "authCaptureTransaction"); - $transactionRequestType->setAmount($amount); - $transactionRequestType->setOrder($order); - $transactionRequestType->setPayment($paymentOne); - + // Create a TransactionRequestType object + $transactionRequestType = new AnetAPI\TransactionRequestType(); + $transactionRequestType->setTransactionType( "authCaptureTransaction"); + $transactionRequestType->setAmount($amount); + $transactionRequestType->setOrder($order); + $transactionRequestType->setPayment($paymentOne); + $transactionRequestType->setBillTo($customerAddress); - $request = new AnetAPI\CreateTransactionRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setRefId( $refId); - $request->setTransactionRequest( $transactionRequestType); - $controller = new AnetController\CreateTransactionController($request); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - + $request = new AnetAPI\CreateTransactionRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setRefId( $refId); + $request->setTransactionRequest( $transactionRequestType); - if ($response != null) + $controller = new AnetController\CreateTransactionController($request); + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + + + if ($response != null) + { + if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { - if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) + $tresponse = $response->getTransactionResponse(); + + if ($tresponse != null && $tresponse->getMessages() != null) { - $tresponse = $response->getTransactionResponse(); - - if ($tresponse != null && $tresponse->getMessages() != null) - { - echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; - echo "Charge Credit Card AUTH CODE : " . $tresponse->getAuthCode() . "\n"; - echo "Charge Credit Card TRANS ID : " . $tresponse->getTransId() . "\n"; - echo " Code : " . $tresponse->getMessages()[0]->getCode() . "\n"; - echo " Description : " . $tresponse->getMessages()[0]->getDescription() . "\n"; - } - else - { - echo "Transaction Failed \n"; - if($tresponse->getErrors() != null) - { - echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; - echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; - } - } + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + echo "Charge Credit Card AUTH CODE : " . $tresponse->getAuthCode() . "\n"; + echo "Charge Credit Card TRANS ID : " . $tresponse->getTransId() . "\n"; + echo " Code : " . $tresponse->getMessages()[0]->getCode() . "\n"; + echo " Description : " . $tresponse->getMessages()[0]->getDescription() . "\n"; } else { echo "Transaction Failed \n"; - $tresponse = $response->getTransactionResponse(); - if($tresponse != null && $tresponse->getErrors() != null) + if($tresponse->getErrors() != null) { echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; - echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; - } - else - { - echo " Error code : " . $response->getMessages()->getMessage()[0]->getCode() . "\n"; - echo " Error message : " . $response->getMessages()->getMessage()[0]->getText() . "\n"; + echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; } - } + } } else { - echo "No response returned \n"; - } + echo "Transaction Failed \n"; + $tresponse = $response->getTransactionResponse(); + + if($tresponse != null && $tresponse->getErrors() != null) + { + echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; + echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; + } + else + { + echo " Error code : " . $response->getMessages()->getMessage()[0]->getCode() . "\n"; + echo " Error message : " . $response->getMessages()->getMessage()[0]->getText() . "\n"; + } + } + } + else + { + echo "No response returned \n"; + } - return $response; + return $response; } if(!defined('DONT_RUN_SAMPLES')) chargeCreditCard(\SampleCode\Constants::SAMPLE_AMOUNT); From 346f86eb23abe1d06fdcae78c3e97217381bd852 Mon Sep 17 00:00:00 2001 From: adavidw Date: Thu, 16 Feb 2017 10:10:26 -0700 Subject: [PATCH 003/149] add address to charge and authorize --- PaymentTransactions/authorize-credit-card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PaymentTransactions/authorize-credit-card.php b/PaymentTransactions/authorize-credit-card.php index c662ef4..5fb010c 100644 --- a/PaymentTransactions/authorize-credit-card.php +++ b/PaymentTransactions/authorize-credit-card.php @@ -37,7 +37,7 @@ function authorizeCreditCard($amount){ // Create a TransactionRequestType object $transactionRequestType = new AnetAPI\TransactionRequestType(); - $transactionRequestType->setTransactionType( "authCaptureTransaction"); + $transactionRequestType->setTransactionType( "authOnlyTransaction"); $transactionRequestType->setAmount($amount); $transactionRequestType->setOrder($order); $transactionRequestType->setPayment($paymentOne); From 7074771b19172504d5bb2d1396bab373f800eb48 Mon Sep 17 00:00:00 2001 From: adavidw Date: Fri, 17 Feb 2017 10:23:36 -0700 Subject: [PATCH 004/149] update get-settled-batch-list.php --- TransactionReporting/get-settled-batch-list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TransactionReporting/get-settled-batch-list.php b/TransactionReporting/get-settled-batch-list.php index 150512b..c569c94 100644 --- a/TransactionReporting/get-settled-batch-list.php +++ b/TransactionReporting/get-settled-batch-list.php @@ -39,7 +39,7 @@ function getSettledBatchList() { echo "\n\n"; echo "Batch ID: " . $batch->getBatchId() . "\n"; echo "Batch settled on (UTC): " . $batch->getSettlementTimeUTC()->format('r') . "\n"; - echo "Batch settled on (Local): " . $batch->getSettlementTimeLocal()->format('r') . "\n"; + echo "Batch settled on (Local): " . $batch->getSettlementTimeLocal()->format('D, d M Y H:i:s') . "\n"; echo "Batch settlement state: " . $batch->getSettlementState() . "\n"; echo "Batch market type: " . $batch->getMarketType() . "\n"; echo "Batch product: " . $batch->getProduct() . "\n"; From f4ba451dbcd5b25b939e3c92bf66f1c071ac1914 Mon Sep 17 00:00:00 2001 From: skilar Date: Sun, 26 Feb 2017 18:13:49 -0500 Subject: [PATCH 005/149] Fix method call Line 76 called the wrong method. --- FraudManagement/approve-or-decline-held-transaction.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FraudManagement/approve-or-decline-held-transaction.php b/FraudManagement/approve-or-decline-held-transaction.php index e538b58..e815bbf 100644 --- a/FraudManagement/approve-or-decline-held-transaction.php +++ b/FraudManagement/approve-or-decline-held-transaction.php @@ -73,5 +73,5 @@ function approveOrDeclineHeldTransaction(){ return $response; } if(!defined('DONT_RUN_SAMPLES')) - updateHeldTransaction(); + approveOrDeclineHeldTransaction(); ?> From bf81b036f12b0abcbd764efc6e501fc66f875fd3 Mon Sep 17 00:00:00 2001 From: skilar Date: Sun, 26 Feb 2017 18:18:36 -0500 Subject: [PATCH 006/149] fix method name --- FraudManagement/get-held-transaction-list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FraudManagement/get-held-transaction-list.php b/FraudManagement/get-held-transaction-list.php index b6be049..3a51438 100644 --- a/FraudManagement/get-held-transaction-list.php +++ b/FraudManagement/get-held-transaction-list.php @@ -47,6 +47,6 @@ function getHeldTransactionList() { } if(!defined('DONT_RUN_SAMPLES')) - getHeldTransactions(); + getHeldTransactionList(); ?> From 1e1eb1c5fb9f781948597201d6c4e9520e3defbd Mon Sep 17 00:00:00 2001 From: Aaron Wright Date: Wed, 15 Mar 2017 10:30:06 -0600 Subject: [PATCH 007/149] cleanup formatting of README.md --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index e4c762f..bd81e07 100644 --- a/README.md +++ b/README.md @@ -6,29 +6,29 @@ This repository contains working code samples which demonstrate PHP integration The samples are organized just like our API, which you can also try out directly here: http://developer.authorize.net/api/reference -##Using the Sample Code +## Using the Sample Code The samples are all completely independent and self-contained so you can look at them to get a gist of how the method works, you can use the snippets to try in your own sample project, or you can run each sample from the command line. -##Running the Samples +## Running the Samples Clone this repository. Run "composer update" in the root directory. Run the individual samples e.g. -```` +``` php PaymentTransactions/charge-credit-card.php -```` +``` Note: If during "composer update", you get the error "composer failed to open stream invalid argument", go to your php.ini file (present where you have installed PHP), and uncomment the following lines: -```` +``` extension=php_openssl.dll extension=php_curl.dll -```` +``` On Windows systems, you also have to uncomment: -```` +``` extension_dir = "ext" -```` +``` Then run the composer update again. You might have to restart your machine before the changes take effect. -##What if I'm not using Composer? +## What if I'm not using Composer? We provide a custom `SPL` autoloader, just [download the SDK.](https://github.com/AuthorizeNet/sdk-php/releases): ```php From 7e84be36f49a2d890a879c44297c40dd68ad1794 Mon Sep 17 00:00:00 2001 From: adavidw Date: Wed, 15 Mar 2017 10:41:05 -0600 Subject: [PATCH 008/149] align authOnly and authCapture samples --- PaymentTransactions/authorize-credit-card.php | 6 +++--- PaymentTransactions/charge-credit-card.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/PaymentTransactions/authorize-credit-card.php b/PaymentTransactions/authorize-credit-card.php index 5fb010c..7700071 100644 --- a/PaymentTransactions/authorize-credit-card.php +++ b/PaymentTransactions/authorize-credit-card.php @@ -60,9 +60,9 @@ function authorizeCreditCard($amount){ if ($tresponse != null && $tresponse->getMessages() != null) { - echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; - echo " Successfully created a transaction with Auth code : " . $tresponse->getAuthCode() . "\n"; - echo " TRANS ID : " . $tresponse->getTransId() . "\n"; + echo " Transaction Response Code : " . $tresponse->getResponseCode() . "\n"; + echo " Successfully created an authOnly transaction with Auth Code : " . $tresponse->getAuthCode() . "\n"; + echo " Transaction ID : " . $tresponse->getTransId() . "\n"; echo " Code : " . $tresponse->getMessages()[0]->getCode() . "\n"; echo " Description : " . $tresponse->getMessages()[0]->getDescription() . "\n"; } diff --git a/PaymentTransactions/charge-credit-card.php b/PaymentTransactions/charge-credit-card.php index 0f79512..bad8608 100644 --- a/PaymentTransactions/charge-credit-card.php +++ b/PaymentTransactions/charge-credit-card.php @@ -60,9 +60,9 @@ function chargeCreditCard($amount){ if ($tresponse != null && $tresponse->getMessages() != null) { - echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; - echo "Charge Credit Card AUTH CODE : " . $tresponse->getAuthCode() . "\n"; - echo "Charge Credit Card TRANS ID : " . $tresponse->getTransId() . "\n"; + echo " Transaction Response Code : " . $tresponse->getResponseCode() . "\n"; + echo " Successfully created an authCapture transaction with Auth Code : " . $tresponse->getAuthCode() . "\n"; + echo " Transaction ID : " . $tresponse->getTransId() . "\n"; echo " Code : " . $tresponse->getMessages()[0]->getCode() . "\n"; echo " Description : " . $tresponse->getMessages()[0]->getDescription() . "\n"; } From 05c43c66bce7ddbd95d5e1aca84309f1ab44a936 Mon Sep 17 00:00:00 2001 From: adavidw Date: Wed, 15 Mar 2017 10:45:58 -0600 Subject: [PATCH 009/149] formatting --- PaymentTransactions/get-an-accept-payment-page.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PaymentTransactions/get-an-accept-payment-page.php b/PaymentTransactions/get-an-accept-payment-page.php index 05ebb64..3f560cd 100644 --- a/PaymentTransactions/get-an-accept-payment-page.php +++ b/PaymentTransactions/get-an-accept-payment-page.php @@ -51,7 +51,7 @@ function getAnAcceptPaymentPage() { echo "ERROR : Failed to get hosted payment page token\n"; $errorMessages = $response->getMessages()->getMessage(); - echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; + echo "RESPONSE : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } return $response; } From 199cf200af04caef1678823cfba735330121dfdc Mon Sep 17 00:00:00 2001 From: adavidw Date: Wed, 15 Mar 2017 12:15:27 -0600 Subject: [PATCH 010/149] match formatting of other samples --- .DS_Store | Bin 0 -> 6148 bytes .../get-an-accept-payment-page.php | 84 +++++++++--------- 2 files changed, 42 insertions(+), 42 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..e3773bec738fa0b09a5a3ac6ce7c5778016c3d1e GIT binary patch literal 6148 zcmeHK&2G~`5S~o~*lHw<+Cz~zSmMAXhadyJTBf}rQ8f`g@RQoL)fky|WIK&e6v?~* z4**>Gc@KC9UW7Z}?5-kc;8+A`C))YO}x`p=x9#si6^76t6{F$KS{R_il?0(65*Df`06uq#E86^fRXteXY-il`KkmiVSoc zkIW(BPiTg2SBQ~xN)fQYM;#^edYTkvg4l1#w8-mbF!(Au8{JEnuQ;x|*>ihWdryax zaz1S0W>!aW^_Y(i;%1V>)!4f+%+n0kQJyxFQ6~3`>@1THs|RtD>CjPG76?#jqd0k# zXY;YQeZQ1VoXf0IwRMdrN4ZSPc~s71TB~?d+;MJ($1T1ik?Xi)Z)dRxg1db`2nNf( zzu4U!^!+=*z2(w%uHOm{pFMx|`pw&S?>~I}^jRg5U@};)X;|qmu(r*Q;XIj4-4wJ| zie6B6j@(rdYgh&>1D1h{V8Fb%oXv|UZfjZwECc^E1N?sQu^2;xtw#0gfKnp>unV^m z*gQ*cj&CqD*lNTXh|sA(ohr( literal 0 HcmV?d00001 diff --git a/PaymentTransactions/get-an-accept-payment-page.php b/PaymentTransactions/get-an-accept-payment-page.php index 3f560cd..73322c4 100644 --- a/PaymentTransactions/get-an-accept-payment-page.php +++ b/PaymentTransactions/get-an-accept-payment-page.php @@ -7,54 +7,54 @@ function getAnAcceptPaymentPage() { - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + // Common setup for API credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); - //create a transaction - $transactionRequestType = new AnetAPI\TransactionRequestType(); - $transactionRequestType->setTransactionType( "authCaptureTransaction"); - $transactionRequestType->setAmount("12.23"); + //create a transaction + $transactionRequestType = new AnetAPI\TransactionRequestType(); + $transactionRequestType->setTransactionType("authCaptureTransaction"); + $transactionRequestType->setAmount("12.23"); - // Set Hosted Form options - $setting1 = new AnetAPI\SettingType(); - $setting1->setSettingName("hostedPaymentButtonOptions"); - $setting1->setSettingValue("{\"text\": \"Pay\"}"); + // Set Hosted Form options + $setting1 = new AnetAPI\SettingType(); + $setting1->setSettingName("hostedPaymentButtonOptions"); + $setting1->setSettingValue("{\"text\": \"Pay\"}"); - $setting2 = new AnetAPI\SettingType(); - $setting2->setSettingName("hostedPaymentOrderOptions"); - $setting2->setSettingValue("{\"show\": false}"); + $setting2 = new AnetAPI\SettingType(); + $setting2->setSettingName("hostedPaymentOrderOptions"); + $setting2->setSettingValue("{\"show\": false}"); - $setting3 = new AnetAPI\SettingType(); - $setting3->setSettingName("hostedPaymentReturnOptions"); - $setting3->setSettingValue("{\"url\": \"https://mysite.com/receipt\", \"cancelUrl\": \"https://mysite.com/cancel\", \"showReceipt\": true}"); + $setting3 = new AnetAPI\SettingType(); + $setting3->setSettingName("hostedPaymentReturnOptions"); + $setting3->setSettingValue("{\"url\": \"https://mysite.com/receipt\", \"cancelUrl\": \"https://mysite.com/cancel\", \"showReceipt\": true}"); - // Build transaction request - $request = new AnetAPI\GetHostedPaymentPageRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setTransactionRequest($transactionRequestType); + // Build transaction request + $request = new AnetAPI\GetHostedPaymentPageRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setTransactionRequest($transactionRequestType); - $request->addToHostedPaymentSettings($setting1); - $request->addToHostedPaymentSettings($setting2); - $request->addToHostedPaymentSettings($setting3); - - //execute request - $controller = new AnetController\GetHostedPaymentPageController($request); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - - if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) - { - echo $response->getToken()."\n"; - } - else - { - echo "ERROR : Failed to get hosted payment page token\n"; - $errorMessages = $response->getMessages()->getMessage(); - echo "RESPONSE : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; - } - return $response; + $request->addToHostedPaymentSettings($setting1); + $request->addToHostedPaymentSettings($setting2); + $request->addToHostedPaymentSettings($setting3); + + //execute request + $controller = new AnetController\GetHostedPaymentPageController($request); + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) + { + echo $response->getToken()."\n"; + } + else + { + echo "ERROR : Failed to get hosted payment page token\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "RESPONSE : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; + } + return $response; } if(!defined('DONT_RUN_SAMPLES')) - getAnAcceptPaymentPage(); + getAnAcceptPaymentPage(); ?> From 26a2ad96bce1ab7cdc05165260d6daa58332f22f Mon Sep 17 00:00:00 2001 From: adavidw Date: Wed, 15 Mar 2017 12:30:48 -0600 Subject: [PATCH 011/149] add examples of adding CustomerData --- PaymentTransactions/authorize-credit-card.php | 7 +++++++ PaymentTransactions/charge-credit-card.php | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/PaymentTransactions/authorize-credit-card.php b/PaymentTransactions/authorize-credit-card.php index 7700071..28e2d46 100644 --- a/PaymentTransactions/authorize-credit-card.php +++ b/PaymentTransactions/authorize-credit-card.php @@ -35,6 +35,12 @@ function authorizeCreditCard($amount){ $customerAddress->setZip("44628"); $customerAddress->setCountry("USA"); + // Set the customer's identifying information + $CustomerData = new AnetAPI\CustomerDataType(); + $CustomerData->setType("individual"); + $CustomerData->setId("99999456654"); + $CustomerData->setEmail("EllenJohnson@example.com"); + // Create a TransactionRequestType object $transactionRequestType = new AnetAPI\TransactionRequestType(); $transactionRequestType->setTransactionType( "authOnlyTransaction"); @@ -42,6 +48,7 @@ function authorizeCreditCard($amount){ $transactionRequestType->setOrder($order); $transactionRequestType->setPayment($paymentOne); $transactionRequestType->setBillTo($customerAddress); + $transactionRequestType->setCustomer($CustomerData); $request = new AnetAPI\CreateTransactionRequest(); $request->setMerchantAuthentication($merchantAuthentication); diff --git a/PaymentTransactions/charge-credit-card.php b/PaymentTransactions/charge-credit-card.php index bad8608..b73b0e0 100644 --- a/PaymentTransactions/charge-credit-card.php +++ b/PaymentTransactions/charge-credit-card.php @@ -35,6 +35,12 @@ function chargeCreditCard($amount){ $customerAddress->setZip("44628"); $customerAddress->setCountry("USA"); + // Set the customer's identifying information + $CustomerData = new AnetAPI\CustomerDataType(); + $CustomerData->setType("individual"); + $CustomerData->setId("99999456654"); + $CustomerData->setEmail("EllenJohnson@example.com"); + // Create a TransactionRequestType object $transactionRequestType = new AnetAPI\TransactionRequestType(); $transactionRequestType->setTransactionType( "authCaptureTransaction"); @@ -42,6 +48,7 @@ function chargeCreditCard($amount){ $transactionRequestType->setOrder($order); $transactionRequestType->setPayment($paymentOne); $transactionRequestType->setBillTo($customerAddress); + $transactionRequestType->setCustomer($CustomerData); $request = new AnetAPI\CreateTransactionRequest(); $request->setMerchantAuthentication($merchantAuthentication); From be989f067de3927e72b60720ececb644401c1602 Mon Sep 17 00:00:00 2001 From: Aaron Wright Date: Wed, 15 Mar 2017 12:41:05 -0600 Subject: [PATCH 012/149] Delete .DS_Store --- .DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index e3773bec738fa0b09a5a3ac6ce7c5778016c3d1e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK&2G~`5S~o~*lHw<+Cz~zSmMAXhadyJTBf}rQ8f`g@RQoL)fky|WIK&e6v?~* z4**>Gc@KC9UW7Z}?5-kc;8+A`C))YO}x`p=x9#si6^76t6{F$KS{R_il?0(65*Df`06uq#E86^fRXteXY-il`KkmiVSoc zkIW(BPiTg2SBQ~xN)fQYM;#^edYTkvg4l1#w8-mbF!(Au8{JEnuQ;x|*>ihWdryax zaz1S0W>!aW^_Y(i;%1V>)!4f+%+n0kQJyxFQ6~3`>@1THs|RtD>CjPG76?#jqd0k# zXY;YQeZQ1VoXf0IwRMdrN4ZSPc~s71TB~?d+;MJ($1T1ik?Xi)Z)dRxg1db`2nNf( zzu4U!^!+=*z2(w%uHOm{pFMx|`pw&S?>~I}^jRg5U@};)X;|qmu(r*Q;XIj4-4wJ| zie6B6j@(rdYgh&>1D1h{V8Fb%oXv|UZfjZwECc^E1N?sQu^2;xtw#0gfKnp>unV^m z*gQ*cj&CqD*lNTXh|sA(ohr( From e212b36de560f4b1ba7ceec8468caed254f2d3eb Mon Sep 17 00:00:00 2001 From: adavidw Date: Wed, 15 Mar 2017 14:10:59 -0600 Subject: [PATCH 013/149] add php 7.1 to TravisCI tests --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index f47fce1..d0befcd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ php: - 5.5 - 5.6 - 7.0 + - 7.1 sudo: false From d8239bc932b89094ed7977fc2835f39da858fe5c Mon Sep 17 00:00:00 2001 From: Aaron Wright Date: Wed, 15 Mar 2017 15:08:54 -0600 Subject: [PATCH 014/149] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d0befcd..c9dccb5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ language: php php: - 5.5 - 5.6 - - 7.0 + - 7.0.15 - 7.1 sudo: false From c1afc3d56503bdb6eb73c4b742841cb607c49709 Mon Sep 17 00:00:00 2001 From: Aaron Wright Date: Wed, 15 Mar 2017 15:33:59 -0600 Subject: [PATCH 015/149] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c9dccb5..d0befcd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ language: php php: - 5.5 - 5.6 - - 7.0.15 + - 7.0 - 7.1 sudo: false From 7ae4215e8ddcf18a5eec4bbd32a25cca1c330dc7 Mon Sep 17 00:00:00 2001 From: Aaron Wright Date: Wed, 15 Mar 2017 15:34:19 -0600 Subject: [PATCH 016/149] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index a0188d1..c77bfff 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "require": { "php": ">=5.5", "ext-curl": "*", - "phpunit/phpunit": "~4.0", + "phpunit/phpunit": "~4.0 || ~5.0", "authorizenet/authorizenet": "1.9.2" }, "autoload": { From 6e91ef6d7ead8f4d4dce03f5e0e8978f2c075e86 Mon Sep 17 00:00:00 2001 From: Aaron Wright Date: Wed, 15 Mar 2017 15:37:51 -0600 Subject: [PATCH 017/149] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c77bfff..3db1ca4 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "require": { "php": ">=5.5", "ext-curl": "*", - "phpunit/phpunit": "~4.0 || ~5.0", + "phpunit/phpunit": "~4.0 || ~6.0", "authorizenet/authorizenet": "1.9.2" }, "autoload": { From 7be7e48a23364578de719c0a00bca833fa5499f1 Mon Sep 17 00:00:00 2001 From: adavidw Date: Wed, 15 Mar 2017 16:21:06 -0600 Subject: [PATCH 018/149] commit --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 301b14c..1ed26d5 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,5 @@ # PHP Storm /.idea/* +# Operating system files +.DS_Store From b2085af0348a235d526dca3a165e9acee7b33845 Mon Sep 17 00:00:00 2001 From: adavidw Date: Wed, 15 Mar 2017 17:09:51 -0600 Subject: [PATCH 019/149] fix class for compatibility with PHPUnit 6.0 --- test-runner.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test-runner.php b/test-runner.php index e5ad2e5..bbe8ebe 100644 --- a/test-runner.php +++ b/test-runner.php @@ -2,6 +2,8 @@ define("DONT_RUN_SAMPLES", "true"); define("SAMPLE_CODE_NAME_HEADING", "SampleCodeName"); require 'vendor/autoload.php'; +echo ("starting"); +print_r ( $_SERVER ); if ( $_SERVER['argc'] != 3 ) { die('\n Usage: phpunit test-runner.php '); @@ -31,7 +33,7 @@ } error_reporting($errorlevel); -class TestRunner extends PHPUnit_Framework_TestCase +class TestRunner extends PHPUnit\Framework\TestCase { public static $apiLoginId = "5KP3u95bQpv"; public static $transactionKey = "346HZ32z3fP4hTG2"; From 25b0e37f575f5debd44dc264b95f2cfa3c0dce1a Mon Sep 17 00:00:00 2001 From: adavidw Date: Wed, 15 Mar 2017 17:15:59 -0600 Subject: [PATCH 020/149] use newer version of PHPUnit to get TravisCI working --- composer.json | 2 +- test-runner.php | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 3db1ca4..84d78e7 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "require": { "php": ">=5.5", "ext-curl": "*", - "phpunit/phpunit": "~4.0 || ~6.0", + "phpunit/phpunit": "~5.7", "authorizenet/authorizenet": "1.9.2" }, "autoload": { diff --git a/test-runner.php b/test-runner.php index bbe8ebe..e249c13 100644 --- a/test-runner.php +++ b/test-runner.php @@ -2,8 +2,6 @@ define("DONT_RUN_SAMPLES", "true"); define("SAMPLE_CODE_NAME_HEADING", "SampleCodeName"); require 'vendor/autoload.php'; -echo ("starting"); -print_r ( $_SERVER ); if ( $_SERVER['argc'] != 3 ) { die('\n Usage: phpunit test-runner.php '); From b1731f777760953714567da871a47461eccf2e0e Mon Sep 17 00:00:00 2001 From: Aaron Wright Date: Wed, 15 Mar 2017 17:23:59 -0600 Subject: [PATCH 021/149] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 84d78e7..6432f61 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "require": { "php": ">=5.5", "ext-curl": "*", - "phpunit/phpunit": "~5.7", + "phpunit/phpunit": "~4.8||~6.0", "authorizenet/authorizenet": "1.9.2" }, "autoload": { From 5a2976b4443367c8793a1077c8c0fdf5386be68c Mon Sep 17 00:00:00 2001 From: Aaron Wright Date: Wed, 15 Mar 2017 17:24:43 -0600 Subject: [PATCH 022/149] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d0befcd..a143ea1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ php: sudo: false before_script: - - composer install --prefer-dist --ignore-platform-reqs + - composer install --prefer-dist script: - phpunit test-runner.php . From 9c8418e1ab8ea11b301607df647f8812ad2450b5 Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Thu, 16 Mar 2017 07:42:15 -0700 Subject: [PATCH 023/149] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bd81e07..c16a905 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Sample PHP Code for Authorize.Net -[![Build Status](https://travis-ci.org/AuthorizeNet/sample-code-php.png?branch=master)] +[![Travis](https://img.shields.io/travis/AuthorizeNet/sample-code-php/master.svg)] (https://travis-ci.org/AuthorizeNet/sample-code-php) This repository contains working code samples which demonstrate PHP integration with the [Authorize.Net PHP SDK](https://github.com/AuthorizeNet/sdk-php). From 1d5e6c86d572dcc093c5df00555ac600cfc67861 Mon Sep 17 00:00:00 2001 From: Aaron Wright Date: Thu, 16 Mar 2017 09:49:12 -0600 Subject: [PATCH 024/149] fix markdown link formatting --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index c16a905..df345eb 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # Sample PHP Code for Authorize.Net -[![Travis](https://img.shields.io/travis/AuthorizeNet/sample-code-php/master.svg)] -(https://travis-ci.org/AuthorizeNet/sample-code-php) +[![Travis](https://img.shields.io/travis/AuthorizeNet/sample-code-php/master.svg)](https://travis-ci.org/AuthorizeNet/sample-code-php) This repository contains working code samples which demonstrate PHP integration with the [Authorize.Net PHP SDK](https://github.com/AuthorizeNet/sdk-php). The samples are organized just like our API, which you can also try out directly here: http://developer.authorize.net/api/reference From 1f09d9fbb0d90ed0671909af00bcf1e03d1f5eb7 Mon Sep 17 00:00:00 2001 From: adavidw Date: Mon, 20 Mar 2017 10:42:52 -0600 Subject: [PATCH 025/149] add duplicateWindow --- PaymentTransactions/authorize-credit-card.php | 16 +++++++++++----- PaymentTransactions/charge-credit-card.php | 16 +++++++++++----- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/PaymentTransactions/authorize-credit-card.php b/PaymentTransactions/authorize-credit-card.php index 28e2d46..283e9be 100644 --- a/PaymentTransactions/authorize-credit-card.php +++ b/PaymentTransactions/authorize-credit-card.php @@ -36,10 +36,15 @@ function authorizeCreditCard($amount){ $customerAddress->setCountry("USA"); // Set the customer's identifying information - $CustomerData = new AnetAPI\CustomerDataType(); - $CustomerData->setType("individual"); - $CustomerData->setId("99999456654"); - $CustomerData->setEmail("EllenJohnson@example.com"); + $customerData = new AnetAPI\CustomerDataType(); + $customerData->setType("individual"); + $customerData->setId("99999456654"); + $customerData->setEmail("EllenJohnson@example.com"); + + //Add values for transaction settings + $duplicateWindowSetting = new AnetAPI\SettingType(); + $duplicateWindowSetting->setSettingName("duplicateWindow"); + $duplicateWindowSetting->setSettingValue("600"); // Create a TransactionRequestType object $transactionRequestType = new AnetAPI\TransactionRequestType(); @@ -48,7 +53,8 @@ function authorizeCreditCard($amount){ $transactionRequestType->setOrder($order); $transactionRequestType->setPayment($paymentOne); $transactionRequestType->setBillTo($customerAddress); - $transactionRequestType->setCustomer($CustomerData); + $transactionRequestType->setCustomer($customerData); + $transactionRequestType->addToTransactionSettings($duplicateWindowSetting); $request = new AnetAPI\CreateTransactionRequest(); $request->setMerchantAuthentication($merchantAuthentication); diff --git a/PaymentTransactions/charge-credit-card.php b/PaymentTransactions/charge-credit-card.php index b73b0e0..c1515b1 100644 --- a/PaymentTransactions/charge-credit-card.php +++ b/PaymentTransactions/charge-credit-card.php @@ -36,10 +36,15 @@ function chargeCreditCard($amount){ $customerAddress->setCountry("USA"); // Set the customer's identifying information - $CustomerData = new AnetAPI\CustomerDataType(); - $CustomerData->setType("individual"); - $CustomerData->setId("99999456654"); - $CustomerData->setEmail("EllenJohnson@example.com"); + $customerData = new AnetAPI\CustomerDataType(); + $customerData->setType("individual"); + $customerData->setId("99999456654"); + $customerData->setEmail("EllenJohnson@example.com"); + + //Add values for transaction settings + $duplicateWindowSetting = new AnetAPI\SettingType(); + $duplicateWindowSetting->setSettingName("duplicateWindow"); + $duplicateWindowSetting->setSettingValue("600"); // Create a TransactionRequestType object $transactionRequestType = new AnetAPI\TransactionRequestType(); @@ -48,7 +53,8 @@ function chargeCreditCard($amount){ $transactionRequestType->setOrder($order); $transactionRequestType->setPayment($paymentOne); $transactionRequestType->setBillTo($customerAddress); - $transactionRequestType->setCustomer($CustomerData); + $transactionRequestType->setCustomer($customerData); + $transactionRequestType->addToTransactionSettings($duplicateWindowSetting); $request = new AnetAPI\CreateTransactionRequest(); $request->setMerchantAuthentication($merchantAuthentication); From e821e89cf3fa3cdf3fec9009ca154c6ac06c274b Mon Sep 17 00:00:00 2001 From: Aaron Wright Date: Mon, 20 Mar 2017 16:41:37 -0600 Subject: [PATCH 026/149] add isPaymentToken flag --- PaymentTransactions/charge-tokenized-credit-card.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PaymentTransactions/charge-tokenized-credit-card.php b/PaymentTransactions/charge-tokenized-credit-card.php index 72c4088..0e4436f 100644 --- a/PaymentTransactions/charge-tokenized-credit-card.php +++ b/PaymentTransactions/charge-tokenized-credit-card.php @@ -16,7 +16,8 @@ function chargeTokenizedCreditCard($amount){ $creditCard = new AnetAPI\CreditCardType(); $creditCard->setCardNumber("4111111111111111" ); $creditCard->setExpirationDate("2038-12"); - //Set the cryptogram + //Set the token specific info + $creditCard->setIsPaymentToken(true); $creditCard->setCryptogram("EjRWeJASNFZ4kBI0VniQEjRWeJA="); $paymentOne = new AnetAPI\PaymentType(); From b0a95e83b61cc8885c030f664b854d09fa3e6c7c Mon Sep 17 00:00:00 2001 From: adavidw Date: Mon, 20 Mar 2017 16:46:39 -0600 Subject: [PATCH 027/149] formatting --- PaymentTransactions/charge-tokenized-credit-card.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/PaymentTransactions/charge-tokenized-credit-card.php b/PaymentTransactions/charge-tokenized-credit-card.php index 0e4436f..d886aac 100644 --- a/PaymentTransactions/charge-tokenized-credit-card.php +++ b/PaymentTransactions/charge-tokenized-credit-card.php @@ -14,7 +14,7 @@ function chargeTokenizedCreditCard($amount){ // Create the payment data for a credit card $creditCard = new AnetAPI\CreditCardType(); - $creditCard->setCardNumber("4111111111111111" ); + $creditCard->setCardNumber("4111111111111111"); $creditCard->setExpirationDate("2038-12"); //Set the token specific info $creditCard->setIsPaymentToken(true); @@ -43,13 +43,13 @@ function chargeTokenizedCreditCard($amount){ { $tresponse = $response->getTransactionResponse(); - if ($tresponse != null && $tresponse->getMessages() != null) + if ($tresponse != null && $tresponse->getMessages() != null) { echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; echo "Charge Tokenized Credit Card AUTH CODE : " . $tresponse->getAuthCode() . "\n"; echo "Charge Tokenized Credit Card TRANS ID : " . $tresponse->getTransId() . "\n"; echo " Code : " . $tresponse->getMessages()[0]->getCode() . "\n"; - echo " Description : " . $tresponse->getMessages()[0]->getDescription() . "\n"; + echo " Description : " . $tresponse->getMessages()[0]->getDescription() . "\n"; } else { @@ -68,7 +68,7 @@ function chargeTokenizedCreditCard($amount){ if($tresponse != null && $tresponse->getErrors() != null) { echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; - echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; + echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; } else { From 653fe1b59e8fbe4050fd4b1e1d49c3da8b6dacab Mon Sep 17 00:00:00 2001 From: adavidw Date: Mon, 20 Mar 2017 16:53:55 -0600 Subject: [PATCH 028/149] formatting --- PaymentTransactions/charge-tokenized-credit-card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PaymentTransactions/charge-tokenized-credit-card.php b/PaymentTransactions/charge-tokenized-credit-card.php index d886aac..f698b57 100644 --- a/PaymentTransactions/charge-tokenized-credit-card.php +++ b/PaymentTransactions/charge-tokenized-credit-card.php @@ -16,7 +16,7 @@ function chargeTokenizedCreditCard($amount){ $creditCard = new AnetAPI\CreditCardType(); $creditCard->setCardNumber("4111111111111111"); $creditCard->setExpirationDate("2038-12"); - //Set the token specific info + // Set the token specific info $creditCard->setIsPaymentToken(true); $creditCard->setCryptogram("EjRWeJASNFZ4kBI0VniQEjRWeJA="); From 24acf6ebf48d8986be89fe3134cc468c196cb687 Mon Sep 17 00:00:00 2001 From: Aaron Wright Date: Wed, 22 Mar 2017 19:24:34 -0600 Subject: [PATCH 029/149] Create get-an-accept-payment-transaction.php --- .../get-an-accept-payment-transaction.php | 117 ++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 PaymentTransactions/get-an-accept-payment-transaction.php diff --git a/PaymentTransactions/get-an-accept-payment-transaction.php b/PaymentTransactions/get-an-accept-payment-transaction.php new file mode 100644 index 0000000..90e5805 --- /dev/null +++ b/PaymentTransactions/get-an-accept-payment-transaction.php @@ -0,0 +1,117 @@ +setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $refId = 'ref' . time(); + + // Create the payment object for a payment nonce + $paymentNonce = new AnetAPI\OpaqueDataType(); + $paymentNonce->setDataDescriptor("COMMON.ACCEPT.INAPP.PAYMENT"); + $paymentNonce->setDataValue("119eyJjb2RlIjoiNTBfMl8wNjAwMDUyN0JEODE4RjQxOUEyRjhGQkIxMkY0MzdGQjAxQUIwRTY2NjhFNEFCN0VENzE4NTUwMjlGRUU0M0JFMENERUIwQzM2M0ExOUEwMDAzNzlGRDNFMjBCODJEMDFCQjkyNEJDIiwidG9rZW4iOiI5NDkwMjMyMTAyOTQwOTk5NDA0NjAzIiwidiI6IjEuMSJ9"); + $paymentOne = new AnetAPI\PaymentType(); + $paymentOne->setOpaqueData($paymentNonce); + + $order = new AnetAPI\OrderType(); + $order->setDescription("New Item"); + + // Set the customer's Bill To address + $customerAddress = new AnetAPI\CustomerAddressType(); + $customerAddress->setFirstName("Ellen"); + $customerAddress->setLastName("Johnson"); + $customerAddress->setCompany("Souveniropolis"); + $customerAddress->setAddress("14 Main Street"); + $customerAddress->setCity("Pecan Springs"); + $customerAddress->setState("TX"); + $customerAddress->setZip("44628"); + $customerAddress->setCountry("USA"); + + // Set the customer's identifying information + $customerData = new AnetAPI\CustomerDataType(); + $customerData->setType("individual"); + $customerData->setId("99999456654"); + $customerData->setEmail("EllenJohnson@example.com"); + + //Add values for transaction settings + $duplicateWindowSetting = new AnetAPI\SettingType(); + $duplicateWindowSetting->setSettingName("duplicateWindow"); + $duplicateWindowSetting->setSettingValue("600"); + + // Create a TransactionRequestType object + $transactionRequestType = new AnetAPI\TransactionRequestType(); + $transactionRequestType->setTransactionType( "authCaptureTransaction"); + $transactionRequestType->setAmount($amount); + $transactionRequestType->setOrder($order); + $transactionRequestType->setPayment($paymentOne); + $transactionRequestType->setBillTo($customerAddress); + $transactionRequestType->setCustomer($customerData); + $transactionRequestType->addToTransactionSettings($duplicateWindowSetting); + + $request = new AnetAPI\CreateTransactionRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setRefId( $refId); + $request->setTransactionRequest( $transactionRequestType); + + $controller = new AnetController\CreateTransactionController($request); + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + + + if ($response != null) + { + if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) + { + $tresponse = $response->getTransactionResponse(); + + if ($tresponse != null && $tresponse->getMessages() != null) + { + echo " Transaction Response Code : " . $tresponse->getResponseCode() . "\n"; + echo " Successfully created an authCapture transaction with Auth Code : " . $tresponse->getAuthCode() . "\n"; + echo " Transaction ID : " . $tresponse->getTransId() . "\n"; + echo " Code : " . $tresponse->getMessages()[0]->getCode() . "\n"; + echo " Description : " . $tresponse->getMessages()[0]->getDescription() . "\n"; + } + else + { + echo "Transaction Failed \n"; + if($tresponse->getErrors() != null) + { + echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; + echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; + } + } + } + else + { + echo "Transaction Failed \n"; + $tresponse = $response->getTransactionResponse(); + + if($tresponse != null && $tresponse->getErrors() != null) + { + echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; + echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; + } + else + { + echo " Error code : " . $response->getMessages()->getMessage()[0]->getCode() . "\n"; + echo " Error message : " . $response->getMessages()->getMessage()[0]->getText() . "\n"; + } + } + } + else + { + echo "No response returned \n"; + } + + return $response; + } + if(!defined('DONT_RUN_SAMPLES')) + chargeCreditCard(\SampleCode\Constants::SAMPLE_AMOUNT); +?> From cff34f697d8ab310001f2cb556229f4c4deb132e Mon Sep 17 00:00:00 2001 From: Aaron Wright Date: Wed, 22 Mar 2017 19:27:18 -0600 Subject: [PATCH 030/149] Rename get-an-accept-payment-transaction.php to create-an-accept-payment-transaction.php --- ...t-transaction.php => create-an-accept-payment-transaction.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename PaymentTransactions/{get-an-accept-payment-transaction.php => create-an-accept-payment-transaction.php} (100%) diff --git a/PaymentTransactions/get-an-accept-payment-transaction.php b/PaymentTransactions/create-an-accept-payment-transaction.php similarity index 100% rename from PaymentTransactions/get-an-accept-payment-transaction.php rename to PaymentTransactions/create-an-accept-payment-transaction.php From fad04162a2008702f099c8aa5d84aff56efcf800 Mon Sep 17 00:00:00 2001 From: Aaron Wright Date: Wed, 22 Mar 2017 19:35:34 -0600 Subject: [PATCH 031/149] Update SampleCodeList.txt --- SampleCodeList.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/SampleCodeList.txt b/SampleCodeList.txt index ef5fe79..50dad36 100644 --- a/SampleCodeList.txt +++ b/SampleCodeList.txt @@ -55,3 +55,4 @@ ValidateCustomerPaymentProfile,1,0 GetMerchantDetails,0,1 UpdateHeldTransaction,1,0 GetAnAcceptPaymentPage,0,1 +CreateAnAcceptPaymentTransaction,0,0 From cd1e50b92744d09fbfda45fcc9312a23e83b3e41 Mon Sep 17 00:00:00 2001 From: Aaron Wright Date: Wed, 22 Mar 2017 19:38:30 -0600 Subject: [PATCH 032/149] Rename function --- PaymentTransactions/create-an-accept-payment-transaction.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PaymentTransactions/create-an-accept-payment-transaction.php b/PaymentTransactions/create-an-accept-payment-transaction.php index 90e5805..e418b72 100644 --- a/PaymentTransactions/create-an-accept-payment-transaction.php +++ b/PaymentTransactions/create-an-accept-payment-transaction.php @@ -6,7 +6,7 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function chargeCreditCard($amount){ + function createAnAcceptPaymentTransaction($amount){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); From a1678b28827239bba539e5a7b5d6b86c4eab008f Mon Sep 17 00:00:00 2001 From: Aaron Wright Date: Wed, 22 Mar 2017 19:39:00 -0600 Subject: [PATCH 033/149] rename function --- PaymentTransactions/create-an-accept-payment-transaction.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PaymentTransactions/create-an-accept-payment-transaction.php b/PaymentTransactions/create-an-accept-payment-transaction.php index e418b72..aedc8f9 100644 --- a/PaymentTransactions/create-an-accept-payment-transaction.php +++ b/PaymentTransactions/create-an-accept-payment-transaction.php @@ -113,5 +113,5 @@ function createAnAcceptPaymentTransaction($amount){ return $response; } if(!defined('DONT_RUN_SAMPLES')) - chargeCreditCard(\SampleCode\Constants::SAMPLE_AMOUNT); + CreateAnAcceptPaymentTransaction(\SampleCode\Constants::SAMPLE_AMOUNT); ?> From f20d04a66466ac0b23cf489e09b18ea5fd2b7f21 Mon Sep 17 00:00:00 2001 From: Aaron Wright Date: Wed, 22 Mar 2017 19:42:36 -0600 Subject: [PATCH 034/149] Update test-runner.php --- test-runner.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test-runner.php b/test-runner.php index e249c13..9bfc09a 100644 --- a/test-runner.php +++ b/test-runner.php @@ -135,6 +135,11 @@ public static function runChargeTokenizedCreditCard() { return chargeTokenizedCreditCard(self::getAmount()); } + + public static function runCreateAnAcceptPaymentTransaction() + { + return createAnAcceptPaymentTransaction(self::getAmount()); + } public static function runChargeCreditCard() { From bd1485d67aafc87756fd25c9c6e5a37d3a669087 Mon Sep 17 00:00:00 2001 From: Aaron Wright Date: Tue, 28 Mar 2017 09:42:59 -0700 Subject: [PATCH 035/149] Match the example in PaymentTransactions --- .../create-an-accept-transaction.php | 74 +++++++++++++------ 1 file changed, 53 insertions(+), 21 deletions(-) diff --git a/MobileInappTransactions/create-an-accept-transaction.php b/MobileInappTransactions/create-an-accept-transaction.php index 670dbe5..c741ca4 100644 --- a/MobileInappTransactions/create-an-accept-transaction.php +++ b/MobileInappTransactions/create-an-accept-transaction.php @@ -1,28 +1,59 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); $refId = 'ref' . time(); - $op = new AnetAPI\OpaqueDataType(); - $op->setDataDescriptor("COMMON.ACCEPT.INAPP.PAYMENT"); - $op->setDataValue("9471471570959063005001"); + // Create the payment object for a payment nonce + $paymentNonce = new AnetAPI\OpaqueDataType(); + $paymentNonce->setDataDescriptor("COMMON.ACCEPT.INAPP.PAYMENT"); + $paymentNonce->setDataValue("119eyJjb2RlIjoiNTBfMl8wNjAwMDUyN0JEODE4RjQxOUEyRjhGQkIxMkY0MzdGQjAxQUIwRTY2NjhFNEFCN0VENzE4NTUwMjlGRUU0M0JFMENERUIwQzM2M0ExOUEwMDAzNzlGRDNFMjBCODJEMDFCQjkyNEJDIiwidG9rZW4iOiI5NDkwMjMyMTAyOTQwOTk5NDA0NjAzIiwidiI6IjEuMSJ9"); $paymentOne = new AnetAPI\PaymentType(); - $paymentOne->setOpaqueData($op); + $paymentOne->setOpaqueData($paymentNonce); - //create a transaction + $order = new AnetAPI\OrderType(); + $order->setDescription("New Item"); + + // Set the customer's Bill To address + $customerAddress = new AnetAPI\CustomerAddressType(); + $customerAddress->setFirstName("Ellen"); + $customerAddress->setLastName("Johnson"); + $customerAddress->setCompany("Souveniropolis"); + $customerAddress->setAddress("14 Main Street"); + $customerAddress->setCity("Pecan Springs"); + $customerAddress->setState("TX"); + $customerAddress->setZip("44628"); + $customerAddress->setCountry("USA"); + + // Set the customer's identifying information + $customerData = new AnetAPI\CustomerDataType(); + $customerData->setType("individual"); + $customerData->setId("99999456654"); + $customerData->setEmail("EllenJohnson@example.com"); + + //Add values for transaction settings + $duplicateWindowSetting = new AnetAPI\SettingType(); + $duplicateWindowSetting->setSettingName("duplicateWindow"); + $duplicateWindowSetting->setSettingValue("600"); + + // Create a TransactionRequestType object $transactionRequestType = new AnetAPI\TransactionRequestType(); - $transactionRequestType->setTransactionType( "authCaptureTransaction"); - $transactionRequestType->setAmount(151); + $transactionRequestType->setTransactionType( "authCaptureTransaction"); + $transactionRequestType->setAmount($amount); + $transactionRequestType->setOrder($order); $transactionRequestType->setPayment($paymentOne); + $transactionRequestType->setBillTo($customerAddress); + $transactionRequestType->setCustomer($customerData); + $transactionRequestType->addToTransactionSettings($duplicateWindowSetting); $request = new AnetAPI\CreateTransactionRequest(); $request->setMerchantAuthentication($merchantAuthentication); @@ -31,6 +62,7 @@ function createAnAcceptTransaction(){ $controller = new AnetController\CreateTransactionController($request); $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + if ($response != null) { @@ -38,13 +70,13 @@ function createAnAcceptTransaction(){ { $tresponse = $response->getTransactionResponse(); - if ($tresponse != null && $tresponse->getMessages() != null) + if ($tresponse != null && $tresponse->getMessages() != null) { - echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; - echo " AUTH CODE : " . $tresponse->getAuthCode() . "\n"; - echo " TRANS ID : " . $tresponse->getTransId() . "\n"; + echo " Transaction Response Code : " . $tresponse->getResponseCode() . "\n"; + echo " Successfully created an authCapture transaction with Auth Code : " . $tresponse->getAuthCode() . "\n"; + echo " Transaction ID : " . $tresponse->getTransId() . "\n"; echo " Code : " . $tresponse->getMessages()[0]->getCode() . "\n"; - echo " Description : " . $tresponse->getMessages()[0]->getDescription() . "\n"; + echo " Description : " . $tresponse->getMessages()[0]->getDescription() . "\n"; } else { @@ -60,6 +92,7 @@ function createAnAcceptTransaction(){ { echo "Transaction Failed \n"; $tresponse = $response->getTransactionResponse(); + if($tresponse != null && $tresponse->getErrors() != null) { echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; @@ -78,8 +111,7 @@ function createAnAcceptTransaction(){ } return $response; -} - -if(!defined('DONT_RUN_SAMPLES')) - createAnAcceptTransaction(); + } + if(!defined('DONT_RUN_SAMPLES')) + CreateAnAcceptTransaction(\SampleCode\Constants::SAMPLE_AMOUNT); ?> From 6980808cfa8fe1acb0505d391f8a8de28f80eb68 Mon Sep 17 00:00:00 2001 From: Aaron Wright Date: Tue, 28 Mar 2017 10:00:46 -0700 Subject: [PATCH 036/149] Update README.md --- README.md | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index df345eb..a78485e 100644 --- a/README.md +++ b/README.md @@ -2,20 +2,29 @@ [![Travis](https://img.shields.io/travis/AuthorizeNet/sample-code-php/master.svg)](https://travis-ci.org/AuthorizeNet/sample-code-php) This repository contains working code samples which demonstrate PHP integration with the [Authorize.Net PHP SDK](https://github.com/AuthorizeNet/sdk-php). -The samples are organized just like our API, which you can also try out directly here: http://developer.authorize.net/api/reference +The samples are organized just like our API, which you can also try out directly at our [API Reference Guide](http://developer.authorize.net/api/reference). ## Using the Sample Code -The samples are all completely independent and self-contained so you can look at them to get a gist of how the method works, you can use the snippets to try in your own sample project, or you can run each sample from the command line. +The samples are all completely independent and self-contained. You can analyze them to get an understanding of how a particular method works, or you can use the snippets as a starting point for your own project. + +You can also run each sample directly from the command line. ## Running the Samples -Clone this repository. -Run "composer update" in the root directory. +Clone this repository. +``` + $ git clone https://github.com/AuthorizeNet/sample-code-php.git +``` +Run composer with the "update" option in the root directory of the repository. +``` + $ composer update +``` Run the individual samples e.g. ``` -php PaymentTransactions/charge-credit-card.php + $ php PaymentTransactions/charge-credit-card.php ``` +## Installation Notes Note: If during "composer update", you get the error "composer failed to open stream invalid argument", go to your php.ini file (present where you have installed PHP), and uncomment the following lines: ``` extension=php_openssl.dll @@ -25,10 +34,10 @@ On Windows systems, you also have to uncomment: ``` extension_dir = "ext" ``` -Then run the composer update again. You might have to restart your machine before the changes take effect. +Then run `composer update` again. You might have to restart your machine before the changes take effect. -## What if I'm not using Composer? -We provide a custom `SPL` autoloader, just [download the SDK.](https://github.com/AuthorizeNet/sdk-php/releases): +### What if I'm not using Composer? +We provide a custom `SPL` autoloader. Just [download the SDK](https://github.com/AuthorizeNet/sdk-php/releases) and point to its `autoload.php` file: ```php require 'path/to/anet_php_sdk/autoload.php'; From ff4d8beca74cd8c2c53105ac666c4b7302907060 Mon Sep 17 00:00:00 2001 From: Aaron Wright Date: Tue, 28 Mar 2017 10:23:35 -0700 Subject: [PATCH 037/149] Make consistent with other samples --- .../create-an-accept-transaction.php | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/MobileInappTransactions/create-an-accept-transaction.php b/MobileInappTransactions/create-an-accept-transaction.php index c741ca4..879c171 100644 --- a/MobileInappTransactions/create-an-accept-transaction.php +++ b/MobileInappTransactions/create-an-accept-transaction.php @@ -7,21 +7,26 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); function createAnAcceptTransaction($amount){ - // Common setup for API credentials + // Create a merchantAuthenticationType object with authentication details + // retrieved from the constants file $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); $refId = 'ref' . time(); // Create the payment object for a payment nonce - $paymentNonce = new AnetAPI\OpaqueDataType(); - $paymentNonce->setDataDescriptor("COMMON.ACCEPT.INAPP.PAYMENT"); - $paymentNonce->setDataValue("119eyJjb2RlIjoiNTBfMl8wNjAwMDUyN0JEODE4RjQxOUEyRjhGQkIxMkY0MzdGQjAxQUIwRTY2NjhFNEFCN0VENzE4NTUwMjlGRUU0M0JFMENERUIwQzM2M0ExOUEwMDAzNzlGRDNFMjBCODJEMDFCQjkyNEJDIiwidG9rZW4iOiI5NDkwMjMyMTAyOTQwOTk5NDA0NjAzIiwidiI6IjEuMSJ9"); + $opaqueData = new AnetAPI\OpaqueDataType(); + $opaqueData->setDataDescriptor("COMMON.ACCEPT.INAPP.PAYMENT"); + $opaqueData->setDataValue("119eyJjb2RlIjoiNTBfMl8wNjAwMDUyN0JEODE4RjQxOUEyRjhGQkIxMkY0MzdGQjAxQUIwRTY2NjhFNEFCN0VENzE4NTUwMjlGRUU0M0JFMENERUIwQzM2M0ExOUEwMDAzNzlGRDNFMjBCODJEMDFCQjkyNEJDIiwidG9rZW4iOiI5NDkwMjMyMTAyOTQwOTk5NDA0NjAzIiwidiI6IjEuMSJ9"); + + // Add the payment data to a paymentType object $paymentOne = new AnetAPI\PaymentType(); - $paymentOne->setOpaqueData($paymentNonce); + $paymentOne->setOpaqueData($opaqueData); + // Create order information $order = new AnetAPI\OrderType(); - $order->setDescription("New Item"); + $order->invoiceNumber("10101"); + $order->setDescription("Golf Shirts"); // Set the customer's Bill To address $customerAddress = new AnetAPI\CustomerAddressType(); @@ -45,7 +50,7 @@ function createAnAcceptTransaction($amount){ $duplicateWindowSetting->setSettingName("duplicateWindow"); $duplicateWindowSetting->setSettingValue("600"); - // Create a TransactionRequestType object + // Create a transactionRequestType object and add the previous objects to it $transactionRequestType = new AnetAPI\TransactionRequestType(); $transactionRequestType->setTransactionType( "authCaptureTransaction"); $transactionRequestType->setAmount($amount); @@ -55,19 +60,24 @@ function createAnAcceptTransaction($amount){ $transactionRequestType->setCustomer($customerData); $transactionRequestType->addToTransactionSettings($duplicateWindowSetting); + // Assemble the complete transaction request $request = new AnetAPI\CreateTransactionRequest(); $request->setMerchantAuthentication($merchantAuthentication); $request->setRefId( $refId); $request->setTransactionRequest( $transactionRequestType); + // Create the controller and get response $controller = new AnetController\CreateTransactionController($request); $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); if ($response != null) { + // Check to see if the API request was successfully received and acted upon if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { + # Since the API request was successful, look for a transaction response + # and parse it to display the results of authorizing the card $tresponse = $response->getTransactionResponse(); if ($tresponse != null && $tresponse->getMessages() != null) @@ -88,6 +98,7 @@ function createAnAcceptTransaction($amount){ } } } + // Or, print errors if the API request wasn't successful else { echo "Transaction Failed \n"; From 39e16895e15ccc164e133682b81542ab89c08283 Mon Sep 17 00:00:00 2001 From: Aaron Wright Date: Tue, 28 Mar 2017 10:38:14 -0700 Subject: [PATCH 038/149] Match sample in MobileInappTransactions --- .../create-an-accept-payment-transaction.php | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/PaymentTransactions/create-an-accept-payment-transaction.php b/PaymentTransactions/create-an-accept-payment-transaction.php index aedc8f9..30d8546 100644 --- a/PaymentTransactions/create-an-accept-payment-transaction.php +++ b/PaymentTransactions/create-an-accept-payment-transaction.php @@ -7,21 +7,26 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); function createAnAcceptPaymentTransaction($amount){ - // Common setup for API credentials + // Create a merchantAuthenticationType object with authentication details + // retrieved from the constants file $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); $refId = 'ref' . time(); // Create the payment object for a payment nonce - $paymentNonce = new AnetAPI\OpaqueDataType(); - $paymentNonce->setDataDescriptor("COMMON.ACCEPT.INAPP.PAYMENT"); - $paymentNonce->setDataValue("119eyJjb2RlIjoiNTBfMl8wNjAwMDUyN0JEODE4RjQxOUEyRjhGQkIxMkY0MzdGQjAxQUIwRTY2NjhFNEFCN0VENzE4NTUwMjlGRUU0M0JFMENERUIwQzM2M0ExOUEwMDAzNzlGRDNFMjBCODJEMDFCQjkyNEJDIiwidG9rZW4iOiI5NDkwMjMyMTAyOTQwOTk5NDA0NjAzIiwidiI6IjEuMSJ9"); + $opaqueData = new AnetAPI\OpaqueDataType(); + $opaqueData->setDataDescriptor("COMMON.ACCEPT.INAPP.PAYMENT"); + $opaqueData->setDataValue("119eyJjb2RlIjoiNTBfMl8wNjAwMDUyN0JEODE4RjQxOUEyRjhGQkIxMkY0MzdGQjAxQUIwRTY2NjhFNEFCN0VENzE4NTUwMjlGRUU0M0JFMENERUIwQzM2M0ExOUEwMDAzNzlGRDNFMjBCODJEMDFCQjkyNEJDIiwidG9rZW4iOiI5NDkwMjMyMTAyOTQwOTk5NDA0NjAzIiwidiI6IjEuMSJ9"); + + // Add the payment data to a paymentType object $paymentOne = new AnetAPI\PaymentType(); - $paymentOne->setOpaqueData($paymentNonce); + $paymentOne->setOpaqueData($opaqueData); + // Create order information $order = new AnetAPI\OrderType(); - $order->setDescription("New Item"); + $order->invoiceNumber("10101"); + $order->setDescription("Golf Shirts"); // Set the customer's Bill To address $customerAddress = new AnetAPI\CustomerAddressType(); @@ -45,7 +50,7 @@ function createAnAcceptPaymentTransaction($amount){ $duplicateWindowSetting->setSettingName("duplicateWindow"); $duplicateWindowSetting->setSettingValue("600"); - // Create a TransactionRequestType object + // Create a transactionRequestType object and add the previous objects to it $transactionRequestType = new AnetAPI\TransactionRequestType(); $transactionRequestType->setTransactionType( "authCaptureTransaction"); $transactionRequestType->setAmount($amount); @@ -55,19 +60,24 @@ function createAnAcceptPaymentTransaction($amount){ $transactionRequestType->setCustomer($customerData); $transactionRequestType->addToTransactionSettings($duplicateWindowSetting); + // Assemble the complete transaction request $request = new AnetAPI\CreateTransactionRequest(); $request->setMerchantAuthentication($merchantAuthentication); $request->setRefId( $refId); $request->setTransactionRequest( $transactionRequestType); + // Create the controller and get response $controller = new AnetController\CreateTransactionController($request); $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); if ($response != null) { + // Check to see if the API request was successfully received and acted upon if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { + # Since the API request was successful, look for a transaction response + # and parse it to display the results of authorizing the card $tresponse = $response->getTransactionResponse(); if ($tresponse != null && $tresponse->getMessages() != null) @@ -88,6 +98,7 @@ function createAnAcceptPaymentTransaction($amount){ } } } + // Or, print errors if the API request wasn't successful else { echo "Transaction Failed \n"; From a39b08146d890f94482da1a4e74482dc8cf60e7d Mon Sep 17 00:00:00 2001 From: Aaron Wright Date: Tue, 28 Mar 2017 11:11:07 -0700 Subject: [PATCH 039/149] clean up responses --- .../create-an-accept-transaction.php | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/MobileInappTransactions/create-an-accept-transaction.php b/MobileInappTransactions/create-an-accept-transaction.php index 879c171..35552bd 100644 --- a/MobileInappTransactions/create-an-accept-transaction.php +++ b/MobileInappTransactions/create-an-accept-transaction.php @@ -12,6 +12,8 @@ function createAnAcceptTransaction($amount){ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId $refId = 'ref' . time(); // Create the payment object for a payment nonce @@ -63,8 +65,8 @@ function createAnAcceptTransaction($amount){ // Assemble the complete transaction request $request = new AnetAPI\CreateTransactionRequest(); $request->setMerchantAuthentication($merchantAuthentication); - $request->setRefId( $refId); - $request->setTransactionRequest( $transactionRequestType); + $request->setRefId($refId); + $request->setTransactionRequest($transactionRequestType); // Create the controller and get response $controller = new AnetController\CreateTransactionController($request); @@ -82,19 +84,19 @@ function createAnAcceptTransaction($amount){ if ($tresponse != null && $tresponse->getMessages() != null) { - echo " Transaction Response Code : " . $tresponse->getResponseCode() . "\n"; - echo " Successfully created an authCapture transaction with Auth Code : " . $tresponse->getAuthCode() . "\n"; - echo " Transaction ID : " . $tresponse->getTransId() . "\n"; - echo " Code : " . $tresponse->getMessages()[0]->getCode() . "\n"; - echo " Description : " . $tresponse->getMessages()[0]->getDescription() . "\n"; + echo " Successfully created transaction with Transaction ID: " . $tresponse->getTransId() . "\n"; + echo " Transaction Response Code: " . $tresponse->getResponseCode() . "\n"; + echo " Message Code: " . $tresponse->getMessages()[0]->getCode() . "\n"; + echo " Auth Code: " . $tresponse->getAuthCode() . "\n"; + echo " Description: " . $tresponse->getMessages()[0]->getDescription() . "\n"; } else { echo "Transaction Failed \n"; if($tresponse->getErrors() != null) { - echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; - echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; + echo " Error Code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; + echo " Error Message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; } } } @@ -106,13 +108,13 @@ function createAnAcceptTransaction($amount){ if($tresponse != null && $tresponse->getErrors() != null) { - echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; - echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; + echo " Error Code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; + echo " Error Message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; } else { - echo " Error code : " . $response->getMessages()->getMessage()[0]->getCode() . "\n"; - echo " Error message : " . $response->getMessages()->getMessage()[0]->getText() . "\n"; + echo " Error Code : " . $response->getMessages()->getMessage()[0]->getCode() . "\n"; + echo " Error Message : " . $response->getMessages()->getMessage()[0]->getText() . "\n"; } } } @@ -123,6 +125,7 @@ function createAnAcceptTransaction($amount){ return $response; } + if(!defined('DONT_RUN_SAMPLES')) CreateAnAcceptTransaction(\SampleCode\Constants::SAMPLE_AMOUNT); ?> From a8a8841b0c1369d894cd862aa75fc5ebd62625ec Mon Sep 17 00:00:00 2001 From: Aaron Wright Date: Tue, 28 Mar 2017 11:11:18 -0700 Subject: [PATCH 040/149] clean up responses --- .../create-an-accept-payment-transaction.php | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/PaymentTransactions/create-an-accept-payment-transaction.php b/PaymentTransactions/create-an-accept-payment-transaction.php index 30d8546..683b725 100644 --- a/PaymentTransactions/create-an-accept-payment-transaction.php +++ b/PaymentTransactions/create-an-accept-payment-transaction.php @@ -12,6 +12,8 @@ function createAnAcceptPaymentTransaction($amount){ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId $refId = 'ref' . time(); // Create the payment object for a payment nonce @@ -63,8 +65,8 @@ function createAnAcceptPaymentTransaction($amount){ // Assemble the complete transaction request $request = new AnetAPI\CreateTransactionRequest(); $request->setMerchantAuthentication($merchantAuthentication); - $request->setRefId( $refId); - $request->setTransactionRequest( $transactionRequestType); + $request->setRefId($refId); + $request->setTransactionRequest($transactionRequestType); // Create the controller and get response $controller = new AnetController\CreateTransactionController($request); @@ -82,19 +84,19 @@ function createAnAcceptPaymentTransaction($amount){ if ($tresponse != null && $tresponse->getMessages() != null) { - echo " Transaction Response Code : " . $tresponse->getResponseCode() . "\n"; - echo " Successfully created an authCapture transaction with Auth Code : " . $tresponse->getAuthCode() . "\n"; - echo " Transaction ID : " . $tresponse->getTransId() . "\n"; - echo " Code : " . $tresponse->getMessages()[0]->getCode() . "\n"; - echo " Description : " . $tresponse->getMessages()[0]->getDescription() . "\n"; + echo " Successfully created transaction with Transaction ID: " . $tresponse->getTransId() . "\n"; + echo " Transaction Response Code: " . $tresponse->getResponseCode() . "\n"; + echo " Message Code: " . $tresponse->getMessages()[0]->getCode() . "\n"; + echo " Auth Code: " . $tresponse->getAuthCode() . "\n"; + echo " Description: " . $tresponse->getMessages()[0]->getDescription() . "\n"; } else { echo "Transaction Failed \n"; if($tresponse->getErrors() != null) { - echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; - echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; + echo " Error Code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; + echo " Error Message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; } } } @@ -106,13 +108,13 @@ function createAnAcceptPaymentTransaction($amount){ if($tresponse != null && $tresponse->getErrors() != null) { - echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; - echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; + echo " Error Code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; + echo " Error Message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; } else { - echo " Error code : " . $response->getMessages()->getMessage()[0]->getCode() . "\n"; - echo " Error message : " . $response->getMessages()->getMessage()[0]->getText() . "\n"; + echo " Error Code : " . $response->getMessages()->getMessage()[0]->getCode() . "\n"; + echo " Error Message : " . $response->getMessages()->getMessage()[0]->getText() . "\n"; } } } @@ -123,6 +125,7 @@ function createAnAcceptPaymentTransaction($amount){ return $response; } + if(!defined('DONT_RUN_SAMPLES')) CreateAnAcceptPaymentTransaction(\SampleCode\Constants::SAMPLE_AMOUNT); ?> From 65c9c8ad828c7dd2d367bcfb9ab23f4e40b4d921 Mon Sep 17 00:00:00 2001 From: devkale Date: Fri, 21 Apr 2017 10:49:32 +0530 Subject: [PATCH 041/149] Pepper 2017 Q2 API Enhancements --- .../get-customer-profile-transaction-list.php | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 TransactionReporting/get-customer-profile-transaction-list.php diff --git a/TransactionReporting/get-customer-profile-transaction-list.php b/TransactionReporting/get-customer-profile-transaction-list.php new file mode 100644 index 0000000..e5ba9aa --- /dev/null +++ b/TransactionReporting/get-customer-profile-transaction-list.php @@ -0,0 +1,50 @@ +setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + $refId = 'ref' . time(); + + $request = new AnetAPI\GetTransactionListForCustomerRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setCustomerProfileId($customerProfileId); + + $controller = new AnetController\GetTransactionListForCustomerController($request); + + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok")) + { + if(null != $response->getTransactions()) + { + foreach($response->getTransactions() as $tx) + { + echo "SUCCESS: TransactionID: " . $tx->getTransId() . "\n"; + } + } + else{ + echo "No transactions associated with given customer profile" . "\n"; + } + } + else + { + echo "ERROR : Invalid response\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; + } + + return $response; + } + + if(!defined('DONT_RUN_SAMPLES')) + getTransactionListForCustomerRequest("36152127"); +?> \ No newline at end of file From 33f94e9184675a21623476db56f0a0c3dcbb6252 Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Tue, 25 Apr 2017 11:49:53 +0530 Subject: [PATCH 042/149] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 6432f61..52209ea 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "php": ">=5.5", "ext-curl": "*", "phpunit/phpunit": "~4.8||~6.0", - "authorizenet/authorizenet": "1.9.2" + "authorizenet/authorizenet": "1.9.3" }, "autoload": { "classmap": ["constants"] From 2fd4492e49ccd635c7bdf6a530e5dd33c6ac1750 Mon Sep 17 00:00:00 2001 From: Aaron Wright Date: Mon, 15 May 2017 14:59:20 -0600 Subject: [PATCH 043/149] formatting and comments (#87) * formatting and comments * formatting and comments * formatting and comments * formatting and comments * formatting and comments --- .../create-customer-payment-profile.php | 126 +++++++++------- ...eate-customer-profile-from-transaction.php | 73 +++++----- ...ate-customer-profile-with-accept-nonce.php | 137 ++++++++++-------- CustomerProfiles/create-customer-profile.php | 137 ++++++++++-------- .../create-customer-shipping-address.php | 82 ++++++----- .../create-an-accept-transaction.php | 95 ++++++------ .../create-an-accept-payment-transaction.php | 99 ++++++------- 7 files changed, 390 insertions(+), 359 deletions(-) diff --git a/CustomerProfiles/create-customer-payment-profile.php b/CustomerProfiles/create-customer-payment-profile.php index b61c8d4..451a641 100644 --- a/CustomerProfiles/create-customer-payment-profile.php +++ b/CustomerProfiles/create-customer-payment-profile.php @@ -1,68 +1,84 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); - $refId = 'ref' . time(); +function createCustomerPaymentProfile($existingcustomerprofileid, $phoneNumber) +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId + $refId = 'ref' . time(); + + // Create a Customer Profile Request + // 1. (Optionally) create a Payment Profile + // 2. (Optionally) create a Shipping Profile + // 3. Create a Customer Profile (or specify an existing profile) + // 4. Submit a CreateCustomerProfile Request + // 5. Validate Profile ID returned + + // Set credit card information for payment profile + $creditCard = new AnetAPI\CreditCardType(); + $creditCard->setCardNumber("4242424242424242"); + $creditCard->setExpirationDate("2038-12"); + $creditCard->setCardCode("142"); + $paymentCreditCard = new AnetAPI\PaymentType(); + $paymentCreditCard->setCreditCard($creditCard); + + // Create the Bill To info for new payment type + $billto = new AnetAPI\CustomerAddressType(); + $billto->setFirstName("Ellen".$phoneNumber); + $billto->setLastName("Johnson"); + $billto->setCompany("Souveniropolis"); + $billto->setAddress("14 Main Street"); + $billto->setCity("Pecan Springs"); + $billto->setState("TX"); + $billto->setZip("44628"); + $billto->setCountry("USA"); + $billto->setPhoneNumber($phoneNumber); + $billto->setfaxNumber("999-999-9999"); + + // Create a new Customer Payment Profile object + $paymentprofile = new AnetAPI\CustomerPaymentProfileType(); + $paymentprofile->setCustomerType('individual'); + $paymentprofile->setBillTo($billto); + $paymentprofile->setPayment($paymentCreditCard); + $paymentprofile->setDefaultPaymentProfile(true); + + $paymentprofiles[] = $paymentprofile; + + // Assemble the complete transaction request + $paymentprofilerequest = new AnetAPI\CreateCustomerPaymentProfileRequest(); + $paymentprofilerequest->setMerchantAuthentication($merchantAuthentication); - $creditCard = new AnetAPI\CreditCardType(); - $creditCard->setCardNumber( "4242424242424242"); - $creditCard->setExpirationDate( "2038-12"); - $creditCard->setCardCode( "142"); - $paymentCreditCard = new AnetAPI\PaymentType(); - $paymentCreditCard->setCreditCard($creditCard); + // Add an existing profile id to the request + $paymentprofilerequest->setCustomerProfileId($existingcustomerprofileid); + $paymentprofilerequest->setPaymentProfile($paymentprofile); + $paymentprofilerequest->setValidationMode("liveMode"); - // Create the Bill To info for new payment type - $billto = new AnetAPI\CustomerAddressType(); - $billto->setFirstName("Mrs Mary".$phoneNumber); - $billto->setLastName("Doe"); - $billto->setCompany("My company"); - $billto->setAddress("123 Main St."); - $billto->setCity("Bellevue"); - $billto->setState("WA"); - $billto->setZip("98004"); - $billto->setPhoneNumber($phoneNumber); - $billto->setfaxNumber("999-999-9999"); - $billto->setCountry("USA"); + // Create the controller and get the response + $controller = new AnetController\CreateCustomerPaymentProfileController($paymentprofilerequest); + $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); - // Create a new Customer Payment Profile - $paymentprofile = new AnetAPI\CustomerPaymentProfileType(); - $paymentprofile->setCustomerType('individual'); - $paymentprofile->setBillTo($billto); - $paymentprofile->setPayment($paymentCreditCard); - $paymentprofile->setDefaultPaymentProfile(true); + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) { + echo "Create Customer Payment Profile SUCCESS: " . $response->getCustomerPaymentProfileId() . "\n"; + } else { + echo "Create Customer Payment Profile: ERROR Invalid response\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; - $paymentprofiles[] = $paymentprofile; + } + return $response; +} - // Submit a CreateCustomerPaymentProfileRequest to create a new Customer Payment Profile - $paymentprofilerequest = new AnetAPI\CreateCustomerPaymentProfileRequest(); - $paymentprofilerequest->setMerchantAuthentication($merchantAuthentication); - //Use an existing profile id - $paymentprofilerequest->setCustomerProfileId( $existingcustomerprofileid ); - $paymentprofilerequest->setPaymentProfile( $paymentprofile ); - $paymentprofilerequest->setValidationMode("liveMode"); - $controller = new AnetController\CreateCustomerPaymentProfileController($paymentprofilerequest); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) - { - echo "Create Customer Payment Profile SUCCESS: " . $response->getCustomerPaymentProfileId() . "\n"; - } - else - { - echo "Create Customer Payment Profile: ERROR Invalid response\n"; - $errorMessages = $response->getMessages()->getMessage(); - echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; - - } - return $response; - } - if(!defined('DONT_RUN_SAMPLES')) - createCustomerPaymentProfile("1807545561","000-000-0009"); +if (!defined('DONT_RUN_SAMPLES')) { + createCustomerPaymentProfile("1807545561", "000-000-0009"); +} ?> diff --git a/CustomerProfiles/create-customer-profile-from-transaction.php b/CustomerProfiles/create-customer-profile-from-transaction.php index 86683e6..6b4ae51 100644 --- a/CustomerProfiles/create-customer-profile-from-transaction.php +++ b/CustomerProfiles/create-customer-profile-from-transaction.php @@ -5,44 +5,49 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function createCustomerProfileFromTransaction($transId= "2249066517") - { - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); +function createCustomerProfileFromTransaction($transId= "2249066517") +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId + $refId = 'ref' . time(); - $customerProfile = new AnetAPI\CustomerProfileBaseType(); - $customerProfile->setMerchantCustomerId("123212"); - $customerProfile->setEmail(rand(0,10000) . "@test" .".com"); - $customerProfile->setDescription(rand(0,10000) ."sample description"); + $customerProfile = new AnetAPI\CustomerProfileBaseType(); + $customerProfile->setMerchantCustomerId("123212"); + $customerProfile->setEmail(rand(0, 10000) . "@test" .".com"); + $customerProfile->setDescription(rand(0, 10000) ."sample description"); - $request = new AnetAPI\CreateCustomerProfileFromTransactionRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setTransId($transId); - // You can either specify the customer information in form of customerProfileBaseType object - $request->setCustomer($customerProfile); - // OR - // You can just provide the customer Profile ID - //$request->setCustomerProfileId("123343"); + $request = new AnetAPI\CreateCustomerProfileFromTransactionRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setTransId($transId); - $controller = new AnetController\CreateCustomerProfileFromTransactionController($request); + // You can either specify the customer information in form of customerProfileBaseType object + $request->setCustomer($customerProfile); + // OR + // You can just provide the customer Profile ID + //$request->setCustomerProfileId("123343"); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + $controller = new AnetController\CreateCustomerProfileFromTransactionController($request); - if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) - { - echo "SUCCESS: PROFILE ID : " . $response->getCustomerProfileId() . "\n"; - } - else - { - echo "ERROR : Invalid response\n"; - $errorMessages = $response->getMessages()->getMessage(); - echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; - } - return $response; - } - //provide a transaction that has customer information - if(!defined('DONT_RUN_SAMPLES')) + $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); + + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) { + echo "SUCCESS: PROFILE ID : " . $response->getCustomerProfileId() . "\n"; + } else { + echo "ERROR : Invalid response\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; + } + return $response; +} + +// Provide a transaction that has customer information +if (!defined('DONT_RUN_SAMPLES')) { createCustomerProfileFromTransaction("2249066517"); +} + ?> diff --git a/CustomerProfiles/create-customer-profile-with-accept-nonce.php b/CustomerProfiles/create-customer-profile-with-accept-nonce.php index 41ab983..9a72398 100644 --- a/CustomerProfiles/create-customer-profile-with-accept-nonce.php +++ b/CustomerProfiles/create-customer-profile-with-accept-nonce.php @@ -1,75 +1,90 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); - $refId = 'ref' . time(); +function createCustomerProfileWithAcceptNonce($email) +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId + $refId = 'ref' . time(); + + // Create a Customer Profile Request + // 1. (Optionally) create a Payment Profile + // 2. (Optionally) create a Shipping Profile + // 3. Create a Customer Profile (or specify an existing profile) + // 4. Submit a CreateCustomerProfile Request + // 5. Validate Profile ID returned + + // Set the payment data for the payment profile to a token obtained from Accept.js + $op = new AnetAPI\OpaqueDataType(); + $op->setDataDescriptor("COMMON.ACCEPT.INAPP.PAYMENT"); + $op->setDataValue("119eyJjb2RlIjoiNTBfMl8wNjAwMDUyN0JEODE4RjQxOUEyRjhGQkIxMkY0MzdGQjAxQUIwRTY2NjhFNEFCN0VENzE4NTUwMjlGRUU0M0JFMENERUIwQzM2M0ExOUEwMDAzNzlGRDNFMjBCODJEMDFCQjkyNEJDIiwidG9rZW4iOiI5NDkwMjMyMTAyOTQwOTk5NDA0NjAzIiwidiI6IjEuMSJ9"); + $paymentOne = new AnetAPI\PaymentType(); + $paymentOne->setOpaqueData($op); + + + // Create the Bill To info for new payment type + $billto = new AnetAPI\CustomerAddressType(); + $billto->setFirstName("Ellen"); + $billto->setLastName("Johnson"); + $billto->setCompany("Souveniropolis"); + $billto->setAddress("14 Main Street"); + $billto->setCity("Pecan Springs"); + $billto->setState("TX"); + $billto->setZip("44628"); + $billto->setCountry("USA"); + $billto->setPhoneNumber($phoneNumber); + $billto->setfaxNumber("999-999-9999"); + + // Create a new Customer Payment Profile object + $paymentprofile = new AnetAPI\CustomerPaymentProfileType(); + $paymentprofile->setCustomerType('individual'); + $paymentprofile->setBillTo($billto); + $paymentprofile->setPayment($paymentOne); + $paymentprofile->setDefaultPaymentProfile(true); + + $paymentprofiles[] = $paymentprofile; - // Create the payment data for an accept token - $op = new AnetAPI\OpaqueDataType(); - $op->setDataDescriptor("COMMON.ACCEPT.INAPP.PAYMENT"); - $op->setDataValue("9475089993864215505001"); - $paymentOne = new AnetAPI\PaymentType(); - $paymentOne->setOpaqueData($op); + // Create a new CustomerProfileType and add the payment profile object + $customerprofile = new AnetAPI\CustomerProfileType(); + $customerprofile->setDescription("Customer Test PHP Accept Test"); - // Create the Bill To info - $billto = new AnetAPI\CustomerAddressType(); - $billto->setFirstName("Ellen"); - $billto->setLastName("Johnson"); - $billto->setCompany("Souveniropolis"); - $billto->setAddress("14 Main Street"); - $billto->setCity("Pecan Springs"); - $billto->setState("TX"); - $billto->setZip("44628"); - $billto->setCountry("USA"); - - // Create a Customer Profile Request - // 1. create a Payment Profile - // 2. create a Customer Profile - // 3. Submit a CreateCustomerProfile Request - // 4. Validate Profiiel ID returned + $customerprofile->setMerchantCustomerId("M_".$email); + $customerprofile->setEmail($email); + $customerprofile->setPaymentProfiles($paymentprofiles); - $paymentprofile = new AnetAPI\CustomerPaymentProfileType(); + // Assemble the complete transaction request + $request = new AnetAPI\CreateCustomerProfileRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setRefId($refId); + $request->setProfile($customerprofile); - $paymentprofile->setCustomerType('individual'); - $paymentprofile->setBillTo($billto); - $paymentprofile->setPayment($paymentOne); - $paymentprofiles[] = $paymentprofile; - $customerprofile = new AnetAPI\CustomerProfileType(); - $customerprofile->setDescription("Customer Test PHP Accept Test"); + // Create the controller and get the response + $controller = new AnetController\CreateCustomerProfileController($request); + $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); - $customerprofile->setMerchantCustomerId("M_".$email); - $customerprofile->setEmail($email); - $customerprofile->setPaymentProfiles($paymentprofiles); + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) { + echo "Succesfully created customer profile : " . $response->getCustomerProfileId() . "\n"; + $paymentProfiles = $response->getCustomerPaymentProfileIdList(); + echo "SUCCESS: PAYMENT PROFILE ID : " . $paymentProfiles[0] . "\n"; + } else { + echo "ERROR : Invalid response\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; + } + return $response; +} - $request = new AnetAPI\CreateCustomerProfileRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setRefId( $refId); - $request->setProfile($customerprofile); - $controller = new AnetController\CreateCustomerProfileController($request); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) - { - echo "Succesfully create customer profile : " . $response->getCustomerProfileId() . "\n"; - $paymentProfiles = $response->getCustomerPaymentProfileIdList(); - echo "SUCCESS: PAYMENT PROFILE ID : " . $paymentProfiles[0] . "\n"; - } - else - { - echo "ERROR : Invalid response\n"; - $errorMessages = $response->getMessages()->getMessage(); - echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; - } - return $response; - } - if(!defined('DONT_RUN_SAMPLES')) - createCustomerProfileWithAcceptNonce("test123@test.com"); +if (!defined('DONT_RUN_SAMPLES')) { + createCustomerProfileWithAcceptNonce("test123@test.com"); +} ?> diff --git a/CustomerProfiles/create-customer-profile.php b/CustomerProfiles/create-customer-profile.php index ffaf655..4857207 100644 --- a/CustomerProfiles/create-customer-profile.php +++ b/CustomerProfiles/create-customer-profile.php @@ -1,75 +1,90 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); - $refId = 'ref' . time(); +function createCustomerProfile($email) +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId + $refId = 'ref' . time(); + + // Create a Customer Profile Request + // 1. (Optionally) create a Payment Profile + // 2. (Optionally) create a Shipping Profile + // 3. Create a Customer Profile (or specify an existing profile) + // 4. Submit a CreateCustomerProfile Request + // 5. Validate Profile ID returned + + // Set credit card information for payment profile + $creditCard = new AnetAPI\CreditCardType(); + $creditCard->setCardNumber("4242424242424242"); + $creditCard->setExpirationDate("2038-12"); + $creditCard->setCardCode("142"); + $paymentCreditCard = new AnetAPI\PaymentType(); + $paymentCreditCard->setCreditCard($creditCard); + + // Create the Bill To info for new payment type + $billto = new AnetAPI\CustomerAddressType(); + $billto->setFirstName("Ellen"); + $billto->setLastName("Johnson"); + $billto->setCompany("Souveniropolis"); + $billto->setAddress("14 Main Street"); + $billto->setCity("Pecan Springs"); + $billto->setState("TX"); + $billto->setZip("44628"); + $billto->setCountry("USA"); + $billto->setPhoneNumber("888-888-8888"); + $billto->setfaxNumber("999-999-9999"); + + // Create a new Customer Payment Profile object + $paymentprofile = new AnetAPI\CustomerPaymentProfileType(); + $paymentprofile->setCustomerType('individual'); + $paymentprofile->setBillTo($billto); + $paymentprofile->setPayment($paymentCreditCard); + $paymentprofile->setDefaultPaymentProfile(true); - // Create the payment data for a credit card - $creditCard = new AnetAPI\CreditCardType(); - $creditCard->setCardNumber( "4111111111111111"); - $creditCard->setExpirationDate( "2038-12"); - $paymentCreditCard = new AnetAPI\PaymentType(); - $paymentCreditCard->setCreditCard($creditCard); + $paymentprofiles[] = $paymentprofile; - // Create the Bill To info - $billto = new AnetAPI\CustomerAddressType(); - $billto->setFirstName("Ellen"); - $billto->setLastName("Johnson"); - $billto->setCompany("Souveniropolis"); - $billto->setAddress("14 Main Street"); - $billto->setCity("Pecan Springs"); - $billto->setState("TX"); - $billto->setZip("44628"); - $billto->setCountry("USA"); - - // Create a Customer Profile Request - // 1. create a Payment Profile - // 2. create a Customer Profile - // 3. Submit a CreateCustomerProfile Request - // 4. Validate Profiiel ID returned + // Create a new CustomerProfileType and add the payment profile object + $customerprofile = new AnetAPI\CustomerProfileType(); + $customerprofile->setDescription("Customer 2 Test PHP"); - $paymentprofile = new AnetAPI\CustomerPaymentProfileType(); + $customerprofile->setMerchantCustomerId("M_".$email); + $customerprofile->setEmail($email); + $customerprofile->setPaymentProfiles($paymentprofiles); - $paymentprofile->setCustomerType('individual'); - $paymentprofile->setBillTo($billto); - $paymentprofile->setPayment($paymentCreditCard); - $paymentprofiles[] = $paymentprofile; - $customerprofile = new AnetAPI\CustomerProfileType(); - $customerprofile->setDescription("Customer 2 Test PHP"); + // Assemble the complete transaction request + $request = new AnetAPI\CreateCustomerProfileRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setRefId($refId); + $request->setProfile($customerprofile); - $customerprofile->setMerchantCustomerId("M_".$email); - $customerprofile->setEmail($email); - $customerprofile->setPaymentProfiles($paymentprofiles); + // Create the controller and get the response + $controller = new AnetController\CreateCustomerProfileController($request); + $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); + + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) { + echo "Succesfully created customer profile : " . $response->getCustomerProfileId() . "\n"; + $paymentProfiles = $response->getCustomerPaymentProfileIdList(); + echo "SUCCESS: PAYMENT PROFILE ID : " . $paymentProfiles[0] . "\n"; + } else { + echo "ERROR : Invalid response\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; + } + return $response; +} - $request = new AnetAPI\CreateCustomerProfileRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setRefId( $refId); - $request->setProfile($customerprofile); - $controller = new AnetController\CreateCustomerProfileController($request); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) - { - echo "Succesfully create customer profile : " . $response->getCustomerProfileId() . "\n"; - $paymentProfiles = $response->getCustomerPaymentProfileIdList(); - echo "SUCCESS: PAYMENT PROFILE ID : " . $paymentProfiles[0] . "\n"; - } - else - { - echo "ERROR : Invalid response\n"; - $errorMessages = $response->getMessages()->getMessage(); - echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; - } - return $response; - } - if(!defined('DONT_RUN_SAMPLES')) - createCustomerProfile("test123@test.com"); +if (!defined('DONT_RUN_SAMPLES')) { + createCustomerProfile("test123@test.com"); +} ?> diff --git a/CustomerProfiles/create-customer-shipping-address.php b/CustomerProfiles/create-customer-shipping-address.php index 7ee5536..d1f9579 100644 --- a/CustomerProfiles/create-customer-shipping-address.php +++ b/CustomerProfiles/create-customer-shipping-address.php @@ -5,49 +5,51 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function createCustomerShippingAddress($existingcustomerprofileid = "36152127", - $phoneNumber="000-000-0000") - { - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); +function createCustomerShippingAddress($existingcustomerprofileid = "36152127", + $phoneNumber="000-000-0000" +) { + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); - // Use An existing customer profile id for this merchant name and transaction key + // Set the transaction's refId + $refId = 'ref' . time(); + + // Use An existing customer profile id for this merchant name and transaction key - // Create the customer shipping address - $customershippingaddress = new AnetAPI\CustomerAddressType(); - $customershippingaddress->setFirstName("James"); - $customershippingaddress->setLastName("White"); - $customershippingaddress->setCompany("Addresses R Us"); - $customershippingaddress->setAddress(rand() . " North Spring Street"); - $customershippingaddress->setCity("Toms River"); - $customershippingaddress->setState("NJ"); - $customershippingaddress->setZip("08753"); - $customershippingaddress->setCountry("USA"); - $customershippingaddress->setPhoneNumber($phoneNumber); - $customershippingaddress->setFaxNumber("999-999-9999"); + // Create the customer shipping address + $customershippingaddress = new AnetAPI\CustomerAddressType(); + $customershippingaddress->setFirstName("James"); + $customershippingaddress->setLastName("White"); + $customershippingaddress->setCompany("Addresses R Us"); + $customershippingaddress->setAddress(rand() . " North Spring Street"); + $customershippingaddress->setCity("Toms River"); + $customershippingaddress->setState("NJ"); + $customershippingaddress->setZip("08753"); + $customershippingaddress->setCountry("USA"); + $customershippingaddress->setPhoneNumber($phoneNumber); + $customershippingaddress->setFaxNumber("999-999-9999"); - // Create a new customer shipping address for an existing customer profile + // Create a new customer shipping address for an existing customer profile - $request = new AnetAPI\CreateCustomerShippingAddressRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setCustomerProfileId($existingcustomerprofileid); - $request->setAddress($customershippingaddress); - $controller = new AnetController\CreateCustomerShippingAddressController($request); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) - { - echo "Create Customer Shipping Address SUCCESS: ADDRESS ID : " . $response-> getCustomerAddressId() . "\n"; - } - else - { - echo "Create Customer Shipping Address ERROR : Invalid response\n"; - $errorMessages = $response->getMessages()->getMessage(); - echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; - } - return $response; - } - if(!defined('DONT_RUN_SAMPLES')) + $request = new AnetAPI\CreateCustomerShippingAddressRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setCustomerProfileId($existingcustomerprofileid); + $request->setAddress($customershippingaddress); + $controller = new AnetController\CreateCustomerShippingAddressController($request); + $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) { + echo "Create Customer Shipping Address SUCCESS: ADDRESS ID : " . $response-> getCustomerAddressId() . "\n"; + } else { + echo "Create Customer Shipping Address ERROR : Invalid response\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; + } + return $response; +} +if (!defined('DONT_RUN_SAMPLES')) { createCustomerShippingAddress(); +} ?> diff --git a/MobileInappTransactions/create-an-accept-transaction.php b/MobileInappTransactions/create-an-accept-transaction.php index 35552bd..926614b 100644 --- a/MobileInappTransactions/create-an-accept-transaction.php +++ b/MobileInappTransactions/create-an-accept-transaction.php @@ -6,9 +6,10 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function createAnAcceptTransaction($amount){ - // Create a merchantAuthenticationType object with authentication details - // retrieved from the constants file +function createAnAcceptTransaction($amount) +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); @@ -68,64 +69,52 @@ function createAnAcceptTransaction($amount){ $request->setRefId($refId); $request->setTransactionRequest($transactionRequestType); - // Create the controller and get response + // Create the controller and get the response $controller = new AnetController\CreateTransactionController($request); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); - if ($response != null) - { - // Check to see if the API request was successfully received and acted upon - if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) - { - # Since the API request was successful, look for a transaction response - # and parse it to display the results of authorizing the card - $tresponse = $response->getTransactionResponse(); + if ($response != null) { + // Check to see if the API request was successfully received and acted upon + if ($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { + // Since the API request was successful, look for a transaction response + // and parse it to display the results of authorizing the card + $tresponse = $response->getTransactionResponse(); - if ($tresponse != null && $tresponse->getMessages() != null) - { - echo " Successfully created transaction with Transaction ID: " . $tresponse->getTransId() . "\n"; - echo " Transaction Response Code: " . $tresponse->getResponseCode() . "\n"; - echo " Message Code: " . $tresponse->getMessages()[0]->getCode() . "\n"; - echo " Auth Code: " . $tresponse->getAuthCode() . "\n"; - echo " Description: " . $tresponse->getMessages()[0]->getDescription() . "\n"; - } - else - { - echo "Transaction Failed \n"; - if($tresponse->getErrors() != null) - { - echo " Error Code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; - echo " Error Message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; - } - } - } - // Or, print errors if the API request wasn't successful - else - { - echo "Transaction Failed \n"; - $tresponse = $response->getTransactionResponse(); + if ($tresponse != null && $tresponse->getMessages() != null) { + echo " Successfully created transaction with Transaction ID: " . $tresponse->getTransId() . "\n"; + echo " Transaction Response Code: " . $tresponse->getResponseCode() . "\n"; + echo " Message Code: " . $tresponse->getMessages()[0]->getCode() . "\n"; + echo " Auth Code: " . $tresponse->getAuthCode() . "\n"; + echo " Description: " . $tresponse->getMessages()[0]->getDescription() . "\n"; + } else { + echo "Transaction Failed \n"; + if ($tresponse->getErrors() != null) { + echo " Error Code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; + echo " Error Message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; + } + } + // Or, print errors if the API request wasn't successful + } else { + echo "Transaction Failed \n"; + $tresponse = $response->getTransactionResponse(); - if($tresponse != null && $tresponse->getErrors() != null) - { - echo " Error Code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; - echo " Error Message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; - } - else - { - echo " Error Code : " . $response->getMessages()->getMessage()[0]->getCode() . "\n"; - echo " Error Message : " . $response->getMessages()->getMessage()[0]->getText() . "\n"; - } - } - } - else - { - echo "No response returned \n"; + if ($tresponse != null && $tresponse->getErrors() != null) { + echo " Error Code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; + echo " Error Message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; + } else { + echo " Error Code : " . $response->getMessages()->getMessage()[0]->getCode() . "\n"; + echo " Error Message : " . $response->getMessages()->getMessage()[0]->getText() . "\n"; + } + } + } else { + echo "No response returned \n"; } return $response; - } +} - if(!defined('DONT_RUN_SAMPLES')) +if (!defined('DONT_RUN_SAMPLES')) { CreateAnAcceptTransaction(\SampleCode\Constants::SAMPLE_AMOUNT); +} ?> diff --git a/PaymentTransactions/create-an-accept-payment-transaction.php b/PaymentTransactions/create-an-accept-payment-transaction.php index 683b725..beba8f0 100644 --- a/PaymentTransactions/create-an-accept-payment-transaction.php +++ b/PaymentTransactions/create-an-accept-payment-transaction.php @@ -6,9 +6,10 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function createAnAcceptPaymentTransaction($amount){ - // Create a merchantAuthenticationType object with authentication details - // retrieved from the constants file +function createAnAcceptPaymentTransaction($amount) +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); @@ -68,64 +69,52 @@ function createAnAcceptPaymentTransaction($amount){ $request->setRefId($refId); $request->setTransactionRequest($transactionRequestType); - // Create the controller and get response + // Create the controller and get the response $controller = new AnetController\CreateTransactionController($request); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); - if ($response != null) - { - // Check to see if the API request was successfully received and acted upon - if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) - { - # Since the API request was successful, look for a transaction response - # and parse it to display the results of authorizing the card - $tresponse = $response->getTransactionResponse(); + if ($response != null) { + // Check to see if the API request was successfully received and acted upon + if ($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { + // Since the API request was successful, look for a transaction response + // and parse it to display the results of authorizing the card + $tresponse = $response->getTransactionResponse(); - if ($tresponse != null && $tresponse->getMessages() != null) - { - echo " Successfully created transaction with Transaction ID: " . $tresponse->getTransId() . "\n"; - echo " Transaction Response Code: " . $tresponse->getResponseCode() . "\n"; - echo " Message Code: " . $tresponse->getMessages()[0]->getCode() . "\n"; - echo " Auth Code: " . $tresponse->getAuthCode() . "\n"; - echo " Description: " . $tresponse->getMessages()[0]->getDescription() . "\n"; - } - else - { - echo "Transaction Failed \n"; - if($tresponse->getErrors() != null) - { - echo " Error Code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; - echo " Error Message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; - } - } - } - // Or, print errors if the API request wasn't successful - else - { - echo "Transaction Failed \n"; - $tresponse = $response->getTransactionResponse(); + if ($tresponse != null && $tresponse->getMessages() != null) { + echo " Successfully created transaction with Transaction ID: " . $tresponse->getTransId() . "\n"; + echo " Transaction Response Code: " . $tresponse->getResponseCode() . "\n"; + echo " Message Code: " . $tresponse->getMessages()[0]->getCode() . "\n"; + echo " Auth Code: " . $tresponse->getAuthCode() . "\n"; + echo " Description: " . $tresponse->getMessages()[0]->getDescription() . "\n"; + } else { + echo "Transaction Failed \n"; + if ($tresponse->getErrors() != null) { + echo " Error Code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; + echo " Error Message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; + } + } + // Or, print errors if the API request wasn't successful + } else { + echo "Transaction Failed \n"; + $tresponse = $response->getTransactionResponse(); - if($tresponse != null && $tresponse->getErrors() != null) - { - echo " Error Code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; - echo " Error Message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; - } - else - { - echo " Error Code : " . $response->getMessages()->getMessage()[0]->getCode() . "\n"; - echo " Error Message : " . $response->getMessages()->getMessage()[0]->getText() . "\n"; - } - } - } - else - { - echo "No response returned \n"; + if ($tresponse != null && $tresponse->getErrors() != null) { + echo " Error Code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; + echo " Error Message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; + } else { + echo " Error Code : " . $response->getMessages()->getMessage()[0]->getCode() . "\n"; + echo " Error Message : " . $response->getMessages()->getMessage()[0]->getText() . "\n"; + } + } + } else { + echo "No response returned \n"; } return $response; - } +} - if(!defined('DONT_RUN_SAMPLES')) - CreateAnAcceptPaymentTransaction(\SampleCode\Constants::SAMPLE_AMOUNT); -?> +if (!defined('DONT_RUN_SAMPLES')) { + CreateAnAcceptTransaction(\SampleCode\Constants::SAMPLE_AMOUNT); +} +?> \ No newline at end of file From 3f65c1ba843bc1e3789b202a8d2e38ea6c4cc841 Mon Sep 17 00:00:00 2001 From: Aaron Wright Date: Tue, 16 May 2017 02:07:40 -0600 Subject: [PATCH 044/149] standardize merchant authentication block (#88) * formatting and comments * formatting and comments * formatting and comments * formatting and comments * formatting and comments * standardized merchant authentication block * standardize merchant authentication block * standardize merchant authentication block * standardize merchant authentication block * standardize merchant authentication block * standardize merchant authentication block --- .../delete-customer-payment-profile.php | 18 +++++++---- CustomerProfiles/delete-customer-profile.php | 17 ++++++---- .../delete-customer-shipping-address.php | 16 ++++++---- .../get-accept-customer-profile-page.php | 16 ++++++---- .../get-customer-payment-profile-list.php | 17 ++++++---- .../get-customer-payment-profile.php | 17 ++++++---- CustomerProfiles/get-customer-profile-ids.php | 9 ++++-- CustomerProfiles/get-customer-profile.php | 15 +++++---- .../get-customer-shipping-address.php | 16 ++++++---- .../update-customer-payment-profile.php | 19 ++++++----- CustomerProfiles/update-customer-profile.php | 8 +++-- .../update-customer-shipping-address.php | 16 ++++++---- .../validate-customer-payment-profile.php | 18 +++++++---- .../approve-or-decline-held-transaction.php | 16 ++++++---- FraudManagement/get-held-transaction-list.php | 9 ++++-- .../create-an-android-pay-transaction.php | 7 +++- .../create-an-apple-pay-transaction.php | 7 +++- PaymentTransactions/authorize-credit-card.php | 8 +++-- ...nds-authorized-through-another-channel.php | 8 +++-- .../capture-previously-authorized-amount.php | 8 +++-- PaymentTransactions/charge-credit-card.php | 8 +++-- .../charge-customer-profile.php | 8 +++-- .../charge-tokenized-credit-card.php | 8 +++-- PaymentTransactions/credit-bank-account.php | 9 ++++-- PaymentTransactions/debit-bank-account.php | 8 +++-- .../get-an-accept-payment-page.php | 10 ++++-- PaymentTransactions/refund-transaction.php | 10 ++++-- .../update-split-tender-group.php | 12 ++++--- PaymentTransactions/void-transaction.php | 10 ++++-- .../authorization-and-capture-continue.php | 21 +++++++----- .../authorization-and-capture.php | 32 +++++++++++-------- .../authorization-only-continued.php | 17 +++++++--- PaypalExpressCheckout/authorization-only.php | 8 +++-- PaypalExpressCheckout/credit.php | 13 +++++--- PaypalExpressCheckout/get-details.php | 7 ++-- .../prior-authorization-capture.php | 9 ++++-- PaypalExpressCheckout/void.php | 9 ++++-- RecurringBilling/cancel-subscription.php | 9 ++++-- ...ate-subscription-from-customer-profile.php | 9 ++++-- RecurringBilling/create-subscription.php | 8 +++-- .../get-list-of-subscriptions.php | 8 +++-- RecurringBilling/get-subscription-status.php | 8 +++-- RecurringBilling/get-subscription.php | 16 ++++++---- RecurringBilling/update-subscription.php | 8 +++-- TransactionReporting/get-batch-statistics.php | 9 ++++-- .../get-customer-profile-transaction-list.php | 10 +++--- TransactionReporting/get-merchant-details.php | 10 +++--- .../get-settled-batch-list.php | 10 ++++-- .../get-transaction-details.php | 10 +++--- TransactionReporting/get-transaction-list.php | 9 ++++-- .../get-unsettled-transaction-list.php | 9 ++++-- .../create-visa-checkout-transaction.php | 8 +++-- VisaCheckout/decrypt-visa-checkout-data.php | 8 +++-- 53 files changed, 400 insertions(+), 213 deletions(-) diff --git a/CustomerProfiles/delete-customer-payment-profile.php b/CustomerProfiles/delete-customer-payment-profile.php index 8f9d309..a763e38 100644 --- a/CustomerProfiles/delete-customer-payment-profile.php +++ b/CustomerProfiles/delete-customer-payment-profile.php @@ -5,13 +5,17 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function deleteCustomerPaymentProfile($customerProfileId= "36152127", - $customerpaymentprofileid = "32689274") - { - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); +function deleteCustomerPaymentProfile($customerProfileId= "36152127", + $customerpaymentprofileid = "32689274" +) { + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId + $refId = 'ref' . time(); // Use an existing payment profile ID for this Merchant name and Transaction key diff --git a/CustomerProfiles/delete-customer-profile.php b/CustomerProfiles/delete-customer-profile.php index ea33cc7..bf6c6e6 100644 --- a/CustomerProfiles/delete-customer-profile.php +++ b/CustomerProfiles/delete-customer-profile.php @@ -5,13 +5,16 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function deleteCustomerProfile($customerProfileId) - { - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); - $refId = 'ref' . time(); +function deleteCustomerProfile($customerProfileId) +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId + $refId = 'ref' . time(); // Delete an existing customer profile $request = new AnetAPI\DeleteCustomerProfileRequest(); diff --git a/CustomerProfiles/delete-customer-shipping-address.php b/CustomerProfiles/delete-customer-shipping-address.php index fedfac3..48a03c4 100644 --- a/CustomerProfiles/delete-customer-shipping-address.php +++ b/CustomerProfiles/delete-customer-shipping-address.php @@ -5,12 +5,16 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function deleteCustomerShippingAddress($customerprofileid = "36731856", $customeraddressid = "36976434") - { - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); +function deleteCustomerShippingAddress($customerprofileid = "36731856", $customeraddressid = "36976434") +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId + $refId = 'ref' . time(); // Use an existing customer profile and address id for this merchant name and transaction key // Delete an existing customer shipping address for an existing customer profile diff --git a/CustomerProfiles/get-accept-customer-profile-page.php b/CustomerProfiles/get-accept-customer-profile-page.php index a1450af..35e7293 100644 --- a/CustomerProfiles/get-accept-customer-profile-page.php +++ b/CustomerProfiles/get-accept-customer-profile-page.php @@ -5,12 +5,16 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function getAcceptCustomerProfilePage($customerprofileid = "123212") - { - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); +function getAcceptCustomerProfilePage($customerprofileid = "123212") +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId + $refId = 'ref' . time(); // Use an existing payment profile ID for this Merchant name and Transaction key diff --git a/CustomerProfiles/get-customer-payment-profile-list.php b/CustomerProfiles/get-customer-payment-profile-list.php index 1e337e9..cf64086 100644 --- a/CustomerProfiles/get-customer-payment-profile-list.php +++ b/CustomerProfiles/get-customer-payment-profile-list.php @@ -6,13 +6,16 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function getCustomerPaymentProfileList() - { - // Common setup for API credentials (merchant) - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); - $refId = 'ref' . time(); +function getCustomerPaymentProfileList() +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId + $refId = 'ref' . time(); //Setting the paging $paging = new AnetAPI\PagingType(); diff --git a/CustomerProfiles/get-customer-payment-profile.php b/CustomerProfiles/get-customer-payment-profile.php index 9279a1b..1def906 100644 --- a/CustomerProfiles/get-customer-payment-profile.php +++ b/CustomerProfiles/get-customer-payment-profile.php @@ -8,13 +8,16 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); function getCustomerPaymentProfile($customerProfileId="36731856", - $customerPaymentProfileId= "33211899") -{ - // Common setup for API credentials (merchant) - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); - $refId = 'ref' . time(); + $customerPaymentProfileId= "33211899" +) { + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId + $refId = 'ref' . time(); //request requires customerProfileId and customerPaymentProfileId $request = new AnetAPI\GetCustomerPaymentProfileRequest(); diff --git a/CustomerProfiles/get-customer-profile-ids.php b/CustomerProfiles/get-customer-profile-ids.php index d1ac23d..6480821 100644 --- a/CustomerProfiles/get-customer-profile-ids.php +++ b/CustomerProfiles/get-customer-profile-ids.php @@ -5,12 +5,15 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function getCustomerProfileIds() - { - // Common setup for API credentials +function getCustomerProfileIds() +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId $refId = 'ref' . time(); // Get all existing customer profile ID's diff --git a/CustomerProfiles/get-customer-profile.php b/CustomerProfiles/get-customer-profile.php index 6af433a..26cf654 100644 --- a/CustomerProfiles/get-customer-profile.php +++ b/CustomerProfiles/get-customer-profile.php @@ -5,13 +5,16 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function getCustomerProfile(){ - // Common setup for API credentials +function getCustomerProfile() +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); - $refId = 'ref' . time(); + // Set the transaction's refId + $refId = 'ref' . time(); // Create the payment data for a credit card $creditCard = new AnetAPI\CreditCardType(); diff --git a/CustomerProfiles/get-customer-shipping-address.php b/CustomerProfiles/get-customer-shipping-address.php index 53b9b66..2ec8601 100644 --- a/CustomerProfiles/get-customer-shipping-address.php +++ b/CustomerProfiles/get-customer-shipping-address.php @@ -5,12 +5,16 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function getCustomerShippingAddress($customerprofileid, $customeraddressid) - { - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); +function getCustomerShippingAddress($customerprofileid, $customeraddressid) +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId + $refId = 'ref' . time(); // An existing customer profile id and shipping address id for this merchant name and transaction key $customerProfileId = $customerprofileid; diff --git a/CustomerProfiles/update-customer-payment-profile.php b/CustomerProfiles/update-customer-payment-profile.php index ecf034f..36dfe0f 100644 --- a/CustomerProfiles/update-customer-payment-profile.php +++ b/CustomerProfiles/update-customer-payment-profile.php @@ -5,14 +5,17 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function updateCustomerPaymentProfile($customerProfileId = "36731856", - $customerPaymentProfileId = "33211899") - { - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); - $refId = 'ref' . time(); +function updateCustomerPaymentProfile($customerProfileId = "36731856", + $customerPaymentProfileId = "33211899" +) { + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId + $refId = 'ref' . time(); //Set profile ids of profile to be updated $request = new AnetAPI\UpdateCustomerPaymentProfileRequest(); diff --git a/CustomerProfiles/update-customer-profile.php b/CustomerProfiles/update-customer-profile.php index 87e61ac..5b6daf5 100644 --- a/CustomerProfiles/update-customer-profile.php +++ b/CustomerProfiles/update-customer-profile.php @@ -5,11 +5,15 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function updateCustomerProfile() { - // Common setup for API credentials +function updateCustomerProfile() +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId $refId = 'ref' . time(); // Create the payment data for a credit card diff --git a/CustomerProfiles/update-customer-shipping-address.php b/CustomerProfiles/update-customer-shipping-address.php index ea4b496..67b18e5 100644 --- a/CustomerProfiles/update-customer-shipping-address.php +++ b/CustomerProfiles/update-customer-shipping-address.php @@ -5,12 +5,16 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function updateCustomerShippingAddress($customerprofileid, $customeraddressid) - { - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); +function updateCustomerShippingAddress($customerprofileid, $customeraddressid) +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId + $refId = 'ref' . time(); // An existing customer profile id for this merchant name and transaction key $existingcustomerprofileid = $customerprofileid; diff --git a/CustomerProfiles/validate-customer-payment-profile.php b/CustomerProfiles/validate-customer-payment-profile.php index 565d03a..63215fc 100644 --- a/CustomerProfiles/validate-customer-payment-profile.php +++ b/CustomerProfiles/validate-customer-payment-profile.php @@ -5,13 +5,17 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function validateCustomerPaymentProfile($customerProfileId= "36731856", - $customerPaymentProfileId= "33211899") - { - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); +function validateCustomerPaymentProfile($customerProfileId= "36731856", + $customerPaymentProfileId= "33211899" +) { + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId + $refId = 'ref' . time(); // Use an existing payment profile ID for this Merchant name and Transaction key //validationmode tests , does not send an email receipt diff --git a/FraudManagement/approve-or-decline-held-transaction.php b/FraudManagement/approve-or-decline-held-transaction.php index e815bbf..abe8ec9 100644 --- a/FraudManagement/approve-or-decline-held-transaction.php +++ b/FraudManagement/approve-or-decline-held-transaction.php @@ -5,12 +5,16 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function approveOrDeclineHeldTransaction(){ - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); - $refId = 'ref' . time(); +function approveOrDeclineHeldTransaction() +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId + $refId = 'ref' . time(); //create a transaction $transactionRequestType = new AnetAPI\HeldTransactionRequestType(); diff --git a/FraudManagement/get-held-transaction-list.php b/FraudManagement/get-held-transaction-list.php index 3a51438..872056b 100644 --- a/FraudManagement/get-held-transaction-list.php +++ b/FraudManagement/get-held-transaction-list.php @@ -5,12 +5,15 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function getHeldTransactionList() { - // Common Set Up for API Credentials +function getHeldTransactionList() +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); - + + // Set the transaction's refId $refId = 'ref' . time(); diff --git a/MobileInappTransactions/create-an-android-pay-transaction.php b/MobileInappTransactions/create-an-android-pay-transaction.php index ebd0176..52a2fe6 100644 --- a/MobileInappTransactions/create-an-android-pay-transaction.php +++ b/MobileInappTransactions/create-an-android-pay-transaction.php @@ -6,10 +6,15 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); -function createAnAndroidPayTransaction(){ +function createAnAndroidPayTransaction() +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId $refId = 'ref' . time(); $op = new AnetAPI\OpaqueDataType(); diff --git a/MobileInappTransactions/create-an-apple-pay-transaction.php b/MobileInappTransactions/create-an-apple-pay-transaction.php index 387d33f..1325942 100644 --- a/MobileInappTransactions/create-an-apple-pay-transaction.php +++ b/MobileInappTransactions/create-an-apple-pay-transaction.php @@ -6,10 +6,15 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); -function createAnApplePayTransaction(){ +function createAnApplePayTransaction() +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId $refId = 'ref' . time(); $op = new AnetAPI\OpaqueDataType(); diff --git a/PaymentTransactions/authorize-credit-card.php b/PaymentTransactions/authorize-credit-card.php index 283e9be..98ae9ba 100644 --- a/PaymentTransactions/authorize-credit-card.php +++ b/PaymentTransactions/authorize-credit-card.php @@ -6,11 +6,15 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function authorizeCreditCard($amount){ - // Common setup for API credentials +function authorizeCreditCard($amount) +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId $refId = 'ref' . time(); // Create the payment data for a credit card diff --git a/PaymentTransactions/capture-funds-authorized-through-another-channel.php b/PaymentTransactions/capture-funds-authorized-through-another-channel.php index 791cc60..607cc3e 100644 --- a/PaymentTransactions/capture-funds-authorized-through-another-channel.php +++ b/PaymentTransactions/capture-funds-authorized-through-another-channel.php @@ -5,11 +5,15 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); -function captureFundsAuthorizedThroughAnotherChannel($amount){ - // Common setup for API credentials +function captureFundsAuthorizedThroughAnotherChannel($amount) +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId $refId = 'ref' . time(); $creditCard = new AnetAPI\CreditCardType(); diff --git a/PaymentTransactions/capture-previously-authorized-amount.php b/PaymentTransactions/capture-previously-authorized-amount.php index 0221eb6..bb311dd 100644 --- a/PaymentTransactions/capture-previously-authorized-amount.php +++ b/PaymentTransactions/capture-previously-authorized-amount.php @@ -5,11 +5,15 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function capturePreviouslyAuthorizedAmount($transactionid){ - // Common setup for API credentials + function capturePreviouslyAuthorizedAmount($transactionid) +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId $refId = 'ref' . time(); // Now capture the previously authorized amount diff --git a/PaymentTransactions/charge-credit-card.php b/PaymentTransactions/charge-credit-card.php index c1515b1..af9de5e 100644 --- a/PaymentTransactions/charge-credit-card.php +++ b/PaymentTransactions/charge-credit-card.php @@ -6,11 +6,15 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function chargeCreditCard($amount){ - // Common setup for API credentials +function chargeCreditCard($amount) +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId $refId = 'ref' . time(); // Create the payment data for a credit card diff --git a/PaymentTransactions/charge-customer-profile.php b/PaymentTransactions/charge-customer-profile.php index e90e41f..12a91ef 100644 --- a/PaymentTransactions/charge-customer-profile.php +++ b/PaymentTransactions/charge-customer-profile.php @@ -5,11 +5,15 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function chargeCustomerProfile($profileid, $paymentprofileid, $amount){ - // Common setup for API credentials +function chargeCustomerProfile($profileid, $paymentprofileid, $amount) +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId $refId = 'ref' . time(); $profileToCharge = new AnetAPI\CustomerProfilePaymentType(); diff --git a/PaymentTransactions/charge-tokenized-credit-card.php b/PaymentTransactions/charge-tokenized-credit-card.php index f698b57..fd6dafd 100644 --- a/PaymentTransactions/charge-tokenized-credit-card.php +++ b/PaymentTransactions/charge-tokenized-credit-card.php @@ -5,11 +5,15 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function chargeTokenizedCreditCard($amount){ - // Common setup for API credentials +function chargeTokenizedCreditCard($amount) +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId $refId = 'ref' . time(); // Create the payment data for a credit card diff --git a/PaymentTransactions/credit-bank-account.php b/PaymentTransactions/credit-bank-account.php index 0ba4d07..b5da67e 100644 --- a/PaymentTransactions/credit-bank-account.php +++ b/PaymentTransactions/credit-bank-account.php @@ -5,12 +5,17 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function creditBankAccount($amount){ - // Common setup for API credentials +function creditBankAccount($amount) +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId $refId = 'ref' . time(); + // Create the payment data for a Bank Account $bankAccount = new AnetAPI\BankAccountType(); $bankAccount->setRoutingNumber('125000024'); diff --git a/PaymentTransactions/debit-bank-account.php b/PaymentTransactions/debit-bank-account.php index e2d0fc6..6ab85d2 100644 --- a/PaymentTransactions/debit-bank-account.php +++ b/PaymentTransactions/debit-bank-account.php @@ -5,11 +5,15 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function debitBankAccount($amount){ - // Common setup for API credentials +function debitBankAccount($amount) +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId $refId = 'ref' . time(); // Create the payment data for a Bank Account diff --git a/PaymentTransactions/get-an-accept-payment-page.php b/PaymentTransactions/get-an-accept-payment-page.php index 73322c4..461c1e5 100644 --- a/PaymentTransactions/get-an-accept-payment-page.php +++ b/PaymentTransactions/get-an-accept-payment-page.php @@ -5,12 +5,16 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function getAnAcceptPaymentPage() - { - // Common setup for API credentials +function getAnAcceptPaymentPage() +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId + $refId = 'ref' . time(); //create a transaction $transactionRequestType = new AnetAPI\TransactionRequestType(); diff --git a/PaymentTransactions/refund-transaction.php b/PaymentTransactions/refund-transaction.php index 3de5edf..6050ca8 100644 --- a/PaymentTransactions/refund-transaction.php +++ b/PaymentTransactions/refund-transaction.php @@ -5,12 +5,16 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function refundTransaction($amount){ - // Common setup for API credentials +function refundTransaction($amount) +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); - $refId = 'ref' . time(); + + // Set the transaction's refId + $refId = 'ref' . time(); // Create the payment data for a credit card $creditCard = new AnetAPI\CreditCardType(); diff --git a/PaymentTransactions/update-split-tender-group.php b/PaymentTransactions/update-split-tender-group.php index 2805bf6..1e1b1fd 100644 --- a/PaymentTransactions/update-split-tender-group.php +++ b/PaymentTransactions/update-split-tender-group.php @@ -5,12 +5,16 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function updateSplitTenderGroup(){ - // Common Set Up for API Credentials +function updateSplitTenderGroup() +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName( \SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); - $refId = 'ref' . time(); + + // Set the transaction's refId + $refId = 'ref' . time(); $request = new AnetAPI\UpdateSplitTenderGroupRequest(); $request->setMerchantAuthentication($merchantAuthentication); diff --git a/PaymentTransactions/void-transaction.php b/PaymentTransactions/void-transaction.php index 82af5ae..29ea2e4 100644 --- a/PaymentTransactions/void-transaction.php +++ b/PaymentTransactions/void-transaction.php @@ -5,12 +5,16 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function voidTransaction($transactionid){ - // Common setup for API credentials +function voidTransaction($transactionid) +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); - $refId = 'ref' . time(); + + // Set the transaction's refId + $refId = 'ref' . time(); //create a transaction $transactionRequestType = new AnetAPI\TransactionRequestType(); diff --git a/PaypalExpressCheckout/authorization-and-capture-continue.php b/PaypalExpressCheckout/authorization-and-capture-continue.php index aff5f46..10b5fe2 100644 --- a/PaypalExpressCheckout/authorization-and-capture-continue.php +++ b/PaypalExpressCheckout/authorization-and-capture-continue.php @@ -5,15 +5,20 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function payPalAuthorizeCaptureContinue($refTransId, $payerID) { +function payPalAuthorizeCaptureContinue($refTransId, $payerID) +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId + $refId = 'ref' . time(); - // Common setup for API credentials (with PayPal compatible merchant credentials) - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); - - $payPalType=new AnetAPI\PayPalType(); - $payPalType->setPayerID($payerID); + // Set PayPal compatible merchant credentials + $payPalType=new AnetAPI\PayPalType(); + $payPalType->setPayerID($payerID); $paymentOne = new AnetAPI\PaymentType(); $paymentOne->setPayPal($payPalType); diff --git a/PaypalExpressCheckout/authorization-and-capture.php b/PaypalExpressCheckout/authorization-and-capture.php index 562bfeb..f064942 100644 --- a/PaypalExpressCheckout/authorization-and-capture.php +++ b/PaypalExpressCheckout/authorization-and-capture.php @@ -1,23 +1,27 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId + $refId = 'ref' . time(); - // Common setup for API credentials (with PayPal compatible merchant credentials) - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $payPalType=new AnetAPI\PayPalType(); + $payPalType->setCancelUrl("http://www.merchanteCommerceSite.com/Success/TC25262"); + $payPalType->setSuccessUrl("http://www.merchanteCommerceSite.com/Success/TC25262"); - $payPalType=new AnetAPI\PayPalType(); - $payPalType->setCancelUrl("http://www.merchanteCommerceSite.com/Success/TC25262"); - $payPalType->setSuccessUrl("http://www.merchanteCommerceSite.com/Success/TC25262"); - - $paymentOne = new AnetAPI\PaymentType(); - $paymentOne->setPayPal($payPalType); + $paymentOne = new AnetAPI\PaymentType(); + $paymentOne->setPayPal($payPalType); // Create an authorize and capture transaction $transactionRequestType = new AnetAPI\TransactionRequestType(); diff --git a/PaypalExpressCheckout/authorization-only-continued.php b/PaypalExpressCheckout/authorization-only-continued.php index 0664290..fb04c99 100644 --- a/PaypalExpressCheckout/authorization-only-continued.php +++ b/PaypalExpressCheckout/authorization-only-continued.php @@ -6,17 +6,24 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function payPalAuthorizeOnlyContinue($transactionId, $payerId) { - echo "PayPal Authorize Only Continue Transaction\n"; +function payPalAuthorizeOnlyContinue($transactionId, $payerId) +{ + + echo "PayPal Authorize Only Continue Transaction\n"; - // Common setup for API credentials + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId $refId = 'ref' . time(); - $paypal_type = new AnetAPI\PayPalType(); - $paypal_type->setPayerID($payerId); + // Set PayPal compatible merchant credentials + $payPalType=new AnetAPI\PayPalType(); + $payPalType->setPayerID($payerID); + $paypal_type->setSuccessUrl("http://www.merchanteCommerceSite.com/Success/TC25262"); $paypal_type->setCancelUrl("http://www.merchanteCommerceSite.com/Success/TC25262"); diff --git a/PaypalExpressCheckout/authorization-only.php b/PaypalExpressCheckout/authorization-only.php index f95f47f..7436cd1 100644 --- a/PaypalExpressCheckout/authorization-only.php +++ b/PaypalExpressCheckout/authorization-only.php @@ -6,11 +6,15 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); -function payPalAuthorizeOnly($amount) { - // Common setup for API credentials (Paypal compatible merchant) +function payPalAuthorizeOnly($amount) +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId $refId = 'ref' . time(); // Create the payment data for a paypal account diff --git a/PaypalExpressCheckout/credit.php b/PaypalExpressCheckout/credit.php index 0a19fa8..1277807 100644 --- a/PaypalExpressCheckout/credit.php +++ b/PaypalExpressCheckout/credit.php @@ -6,15 +6,18 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); -function payPalCredit($transactionId) { - - // Common setup for API credentials (Paypal compatible merchant) +function payPalCredit($transactionId) +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); - + + // Set the transaction's refId $refId = 'ref' . time(); - //use transaction of already settled paypal checkout transaction + + //use transaction of already settled paypal checkout transaction $refTransId = $transactionId; // Create the payment data for a paypal account diff --git a/PaypalExpressCheckout/get-details.php b/PaypalExpressCheckout/get-details.php index 683f774..98fefab 100644 --- a/PaypalExpressCheckout/get-details.php +++ b/PaypalExpressCheckout/get-details.php @@ -6,15 +6,18 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function payPalGetDetails($transactionId) { +function payPalGetDetails($transactionId) +{ echo "PayPal Get Details Transaction\n"; - // Common setup for API credentials + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + // Set the transaction's refId $refId = 'ref' . time(); //create a transaction of type get details diff --git a/PaypalExpressCheckout/prior-authorization-capture.php b/PaypalExpressCheckout/prior-authorization-capture.php index 679af87..be4dc43 100644 --- a/PaypalExpressCheckout/prior-authorization-capture.php +++ b/PaypalExpressCheckout/prior-authorization-capture.php @@ -5,12 +5,15 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function payPalPriorAuthorizationCapture($transactionId) { - - // Common setup for API credentials +function payPalPriorAuthorizationCapture($transactionId) +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId $refId = 'ref' . time(); $payPalType = new AnetAPI\PayPalType(); diff --git a/PaypalExpressCheckout/void.php b/PaypalExpressCheckout/void.php index bd3c67c..c6d7e3f 100644 --- a/PaypalExpressCheckout/void.php +++ b/PaypalExpressCheckout/void.php @@ -5,12 +5,15 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function payPalVoid($transactionId) { - - // Common setup for API credentials +function payPalVoid($transactionId) +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId $refId = 'ref' . time(); $payPalType = new AnetAPI\PayPalType(); diff --git a/RecurringBilling/cancel-subscription.php b/RecurringBilling/cancel-subscription.php index bfe1adb..378345b 100644 --- a/RecurringBilling/cancel-subscription.php +++ b/RecurringBilling/cancel-subscription.php @@ -5,12 +5,15 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function cancelSubscription($subscriptionId) { - - // Common Set Up for API Credentials +function cancelSubscription($subscriptionId) +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId $refId = 'ref' . time(); $request = new AnetAPI\ARBCancelSubscriptionRequest(); diff --git a/RecurringBilling/create-subscription-from-customer-profile.php b/RecurringBilling/create-subscription-from-customer-profile.php index 33c7419..9a53131 100644 --- a/RecurringBilling/create-subscription-from-customer-profile.php +++ b/RecurringBilling/create-subscription-from-customer-profile.php @@ -6,13 +6,16 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function createSubscriptionFromCustomerProfile($intervalLength, $customerProfileId, $customerPaymentProfileId, $customerAddressId) { - - // Common Set Up for API Credentials +function createSubscriptionFromCustomerProfile($intervalLength, $customerProfileId, + $customerPaymentProfileId, $customerAddressId +) { + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + // Set the transaction's refId $refId = 'ref' . time(); // Subscription Type Info diff --git a/RecurringBilling/create-subscription.php b/RecurringBilling/create-subscription.php index e635f9a..68b80f8 100644 --- a/RecurringBilling/create-subscription.php +++ b/RecurringBilling/create-subscription.php @@ -6,13 +6,15 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function createSubscription($intervalLength) { - - // Common Set Up for API Credentials +function createSubscription($intervalLength) +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + // Set the transaction's refId $refId = 'ref' . time(); // Subscription Type Info diff --git a/RecurringBilling/get-list-of-subscriptions.php b/RecurringBilling/get-list-of-subscriptions.php index 74fdab8..e76cfc1 100644 --- a/RecurringBilling/get-list-of-subscriptions.php +++ b/RecurringBilling/get-list-of-subscriptions.php @@ -5,13 +5,15 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function getListOfSubscriptions() { - - // Common Set Up for API Credentials +function getListOfSubscriptions() +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + // Set the transaction's refId $refId = 'ref' . time(); $sorting = new AnetAPI\ARBGetSubscriptionListSortingType(); diff --git a/RecurringBilling/get-subscription-status.php b/RecurringBilling/get-subscription-status.php index 4b8d7fa..fd5af2f 100644 --- a/RecurringBilling/get-subscription-status.php +++ b/RecurringBilling/get-subscription-status.php @@ -5,13 +5,15 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function getSubscriptionStatus($subscriptionId) { - - // Common Set Up for API Credentials +function getSubscriptionStatus($subscriptionId) +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + // Set the transaction's refId $refId = 'ref' . time(); $request = new AnetAPI\ARBGetSubscriptionStatusRequest(); diff --git a/RecurringBilling/get-subscription.php b/RecurringBilling/get-subscription.php index 35dcb11..742d607 100644 --- a/RecurringBilling/get-subscription.php +++ b/RecurringBilling/get-subscription.php @@ -6,14 +6,16 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function getSubscription($subscriptionId) { - - // Common Set Up for API Credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); +function getSubscription($subscriptionId) +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); - $refId = 'ref' . time(); + // Set the transaction's refId + $refId = 'ref' . time(); // Creating the API Request with required parameters $request = new AnetAPI\ARBGetSubscriptionRequest(); diff --git a/RecurringBilling/update-subscription.php b/RecurringBilling/update-subscription.php index 703b369..9f4a49d 100644 --- a/RecurringBilling/update-subscription.php +++ b/RecurringBilling/update-subscription.php @@ -5,13 +5,15 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function updateSubscription($subscriptionId) { - - // Common Set Up for API Credentials +function updateSubscription($subscriptionId) +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + // Set the transaction's refId $refId = 'ref' . time(); $subscription = new AnetAPI\ARBSubscriptionType(); diff --git a/TransactionReporting/get-batch-statistics.php b/TransactionReporting/get-batch-statistics.php index def63e8..79f621c 100644 --- a/TransactionReporting/get-batch-statistics.php +++ b/TransactionReporting/get-batch-statistics.php @@ -5,12 +5,15 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function getBatchStatistics() { - - // Common Set Up for API Credentials +function getBatchStatistics() +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId $refId = 'ref' . time(); //Setting a valid batch Id for the Merchant diff --git a/TransactionReporting/get-customer-profile-transaction-list.php b/TransactionReporting/get-customer-profile-transaction-list.php index e5ba9aa..1f209a6 100644 --- a/TransactionReporting/get-customer-profile-transaction-list.php +++ b/TransactionReporting/get-customer-profile-transaction-list.php @@ -5,13 +5,15 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function getTransactionListForCustomerRequest($customerProfileId) { - - // Common Set Up for API Credentials +function getTransactionListForCustomerRequest($customerProfileId) +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); - + + // Set the transaction's refId $refId = 'ref' . time(); $request = new AnetAPI\GetTransactionListForCustomerRequest(); diff --git a/TransactionReporting/get-merchant-details.php b/TransactionReporting/get-merchant-details.php index 1ec4714..542ae6c 100644 --- a/TransactionReporting/get-merchant-details.php +++ b/TransactionReporting/get-merchant-details.php @@ -5,13 +5,15 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function getMerchantDetails() { - - // Common Set Up for API Credentials +function getMerchantDetails() +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); - + + // Set the transaction's refId $refId = 'ref' . time(); $request = new AnetAPI\GetMerchantDetailsRequest(); diff --git a/TransactionReporting/get-settled-batch-list.php b/TransactionReporting/get-settled-batch-list.php index c569c94..8fc22df 100644 --- a/TransactionReporting/get-settled-batch-list.php +++ b/TransactionReporting/get-settled-batch-list.php @@ -5,12 +5,16 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function getSettledBatchList() { - - // Common Set Up for API Credentials +function getSettledBatchList() +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId + $refId = 'ref' . time(); $request = new AnetAPI\GetSettledBatchListRequest(); $request->setMerchantAuthentication($merchantAuthentication); diff --git a/TransactionReporting/get-transaction-details.php b/TransactionReporting/get-transaction-details.php index 89ef217..25cdcb1 100644 --- a/TransactionReporting/get-transaction-details.php +++ b/TransactionReporting/get-transaction-details.php @@ -5,13 +5,15 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function getTransactionDetails($transactionId) { - - // Common Set Up for API Credentials +function getTransactionDetails($transactionId) +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); - + + // Set the transaction's refId $refId = 'ref' . time(); $request = new AnetAPI\GetTransactionDetailsRequest(); diff --git a/TransactionReporting/get-transaction-list.php b/TransactionReporting/get-transaction-list.php index db83004..af6886b 100644 --- a/TransactionReporting/get-transaction-list.php +++ b/TransactionReporting/get-transaction-list.php @@ -5,12 +5,15 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function getTransactionList() { - // Common Set Up for API Credentials +function getTransactionList() +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); - + + // Set the transaction's refId $refId = 'ref' . time(); //Setting a valid batch Id for the Merchant diff --git a/TransactionReporting/get-unsettled-transaction-list.php b/TransactionReporting/get-unsettled-transaction-list.php index 2793fd8..e472349 100644 --- a/TransactionReporting/get-unsettled-transaction-list.php +++ b/TransactionReporting/get-unsettled-transaction-list.php @@ -5,12 +5,15 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function getUnsettledTransactionList() { - // Common Set Up for API Credentials +function getUnsettledTransactionList() +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); - + + // Set the transaction's refId $refId = 'ref' . time(); diff --git a/VisaCheckout/create-visa-checkout-transaction.php b/VisaCheckout/create-visa-checkout-transaction.php index f9debcf..e39795f 100644 --- a/VisaCheckout/create-visa-checkout-transaction.php +++ b/VisaCheckout/create-visa-checkout-transaction.php @@ -6,11 +6,15 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function createVisaCheckoutTransaction(){ - // Common setup for API credentials +function createVisaCheckoutTransaction() +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId $refId = 'ref' . time(); // Create the payment data from a Visa Checkout blob diff --git a/VisaCheckout/decrypt-visa-checkout-data.php b/VisaCheckout/decrypt-visa-checkout-data.php index 0f9b633..21f8e94 100644 --- a/VisaCheckout/decrypt-visa-checkout-data.php +++ b/VisaCheckout/decrypt-visa-checkout-data.php @@ -6,11 +6,15 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function decryptVisaCheckoutData(){ - // Common setup for API credentials +function decryptVisaCheckoutData() +{ + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId $refId = 'ref' . time(); // Create the payment data from a Visa Checkout blob From 69fd9c37382189a26aab39097f95bdc34db7b323 Mon Sep 17 00:00:00 2001 From: Aaron Wright Date: Mon, 19 Jun 2017 11:34:03 -0600 Subject: [PATCH 045/149] Changes to make PHP 5.6 the minimum (#90) * Update README.md * Update composer.json update required php version constrain authorizenet version to work with newer SDKs * Update .travis.yml remove PHP 5.5 from testing --- .travis.yml | 1 - README.md | 2 +- composer.json | 4 ++-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index a143ea1..0d096c4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: php php: - - 5.5 - 5.6 - 7.0 - 7.1 diff --git a/README.md b/README.md index a78485e..5c11440 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ The samples are all completely independent and self-contained. You can analyze t You can also run each sample directly from the command line. -## Running the Samples +## Running the Samples From the Command Line Clone this repository. ``` $ git clone https://github.com/AuthorizeNet/sample-code-php.git diff --git a/composer.json b/composer.json index 52209ea..997e6d8 100644 --- a/composer.json +++ b/composer.json @@ -1,9 +1,9 @@ { "require": { - "php": ">=5.5", + "php": ">=5.6", "ext-curl": "*", "phpunit/phpunit": "~4.8||~6.0", - "authorizenet/authorizenet": "1.9.3" + "authorizenet/authorizenet": ">=1.9.3 || <2.0" }, "autoload": { "classmap": ["constants"] From 008d1fe094497317bb20ee20eb05cdffe1e4d975 Mon Sep 17 00:00:00 2001 From: adavidw Date: Mon, 19 Jun 2017 12:58:41 -0600 Subject: [PATCH 046/149] Rename directory to match online API Reference guide --- .../create-an-accept-transaction.php | 0 .../create-an-android-pay-transaction.php | 0 .../create-an-apple-pay-transaction.php | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename {MobileInappTransactions => MobileInAppTransactions}/create-an-accept-transaction.php (100%) rename {MobileInappTransactions => MobileInAppTransactions}/create-an-android-pay-transaction.php (100%) rename {MobileInappTransactions => MobileInAppTransactions}/create-an-apple-pay-transaction.php (100%) diff --git a/MobileInappTransactions/create-an-accept-transaction.php b/MobileInAppTransactions/create-an-accept-transaction.php similarity index 100% rename from MobileInappTransactions/create-an-accept-transaction.php rename to MobileInAppTransactions/create-an-accept-transaction.php diff --git a/MobileInappTransactions/create-an-android-pay-transaction.php b/MobileInAppTransactions/create-an-android-pay-transaction.php similarity index 100% rename from MobileInappTransactions/create-an-android-pay-transaction.php rename to MobileInAppTransactions/create-an-android-pay-transaction.php diff --git a/MobileInappTransactions/create-an-apple-pay-transaction.php b/MobileInAppTransactions/create-an-apple-pay-transaction.php similarity index 100% rename from MobileInappTransactions/create-an-apple-pay-transaction.php rename to MobileInAppTransactions/create-an-apple-pay-transaction.php From 14526f0928f79e5e35cb4f073721ba65b3a178e1 Mon Sep 17 00:00:00 2001 From: adavidw Date: Mon, 19 Jun 2017 13:26:18 -0600 Subject: [PATCH 047/149] better commenting --- PaymentTransactions/charge-credit-card.php | 101 +++++++++--------- .../create-an-accept-payment-transaction.php | 5 +- 2 files changed, 53 insertions(+), 53 deletions(-) diff --git a/PaymentTransactions/charge-credit-card.php b/PaymentTransactions/charge-credit-card.php index af9de5e..c0a0f6f 100644 --- a/PaymentTransactions/charge-credit-card.php +++ b/PaymentTransactions/charge-credit-card.php @@ -22,11 +22,15 @@ function chargeCreditCard($amount) $creditCard->setCardNumber("4111111111111111"); $creditCard->setExpirationDate("1226"); $creditCard->setCardCode("123"); + + // Add the payment data to a paymentType object $paymentOne = new AnetAPI\PaymentType(); - $paymentOne->setCreditCard($creditCard); + $paymentOne->setOpaqueData($opaqueData); + // Create order information $order = new AnetAPI\OrderType(); - $order->setDescription("New Item"); + $order->invoiceNumber("10101"); + $order->setDescription("Golf Shirts"); // Set the customer's Bill To address $customerAddress = new AnetAPI\CustomerAddressType(); @@ -50,9 +54,9 @@ function chargeCreditCard($amount) $duplicateWindowSetting->setSettingName("duplicateWindow"); $duplicateWindowSetting->setSettingValue("600"); - // Create a TransactionRequestType object + // Create a transactionRequestType object and add the previous objects to it $transactionRequestType = new AnetAPI\TransactionRequestType(); - $transactionRequestType->setTransactionType( "authCaptureTransaction"); + $transactionRequestType->setTransactionType("authCaptureTransaction"); $transactionRequestType->setAmount($amount); $transactionRequestType->setOrder($order); $transactionRequestType->setPayment($paymentOne); @@ -60,63 +64,58 @@ function chargeCreditCard($amount) $transactionRequestType->setCustomer($customerData); $transactionRequestType->addToTransactionSettings($duplicateWindowSetting); + // Assemble the complete transaction request $request = new AnetAPI\CreateTransactionRequest(); $request->setMerchantAuthentication($merchantAuthentication); - $request->setRefId( $refId); - $request->setTransactionRequest( $transactionRequestType); + $request->setRefId($refId); + $request->setTransactionRequest($transactionRequestType); + // Create the controller and get the response $controller = new AnetController\CreateTransactionController($request); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); - if ($response != null) - { - if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) - { - $tresponse = $response->getTransactionResponse(); + if ($response != null) { + // Check to see if the API request was successfully received and acted upon + if ($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { + // Since the API request was successful, look for a transaction response + // and parse it to display the results of authorizing the card + $tresponse = $response->getTransactionResponse(); - if ($tresponse != null && $tresponse->getMessages() != null) - { - echo " Transaction Response Code : " . $tresponse->getResponseCode() . "\n"; - echo " Successfully created an authCapture transaction with Auth Code : " . $tresponse->getAuthCode() . "\n"; - echo " Transaction ID : " . $tresponse->getTransId() . "\n"; - echo " Code : " . $tresponse->getMessages()[0]->getCode() . "\n"; - echo " Description : " . $tresponse->getMessages()[0]->getDescription() . "\n"; - } - else - { - echo "Transaction Failed \n"; - if($tresponse->getErrors() != null) - { - echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; - echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; - } - } - } - else - { - echo "Transaction Failed \n"; - $tresponse = $response->getTransactionResponse(); + if ($tresponse != null && $tresponse->getMessages() != null) { + echo " Successfully created transaction with Transaction ID: " . $tresponse->getTransId() . "\n"; + echo " Transaction Response Code: " . $tresponse->getResponseCode() . "\n"; + echo " Message Code: " . $tresponse->getMessages()[0]->getCode() . "\n"; + echo " Auth Code: " . $tresponse->getAuthCode() . "\n"; + echo " Description: " . $tresponse->getMessages()[0]->getDescription() . "\n"; + } else { + echo "Transaction Failed \n"; + if ($tresponse->getErrors() != null) { + echo " Error Code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; + echo " Error Message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; + } + } + // Or, print errors if the API request wasn't successful + } else { + echo "Transaction Failed \n"; + $tresponse = $response->getTransactionResponse(); - if($tresponse != null && $tresponse->getErrors() != null) - { - echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; - echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; - } - else - { - echo " Error code : " . $response->getMessages()->getMessage()[0]->getCode() . "\n"; - echo " Error message : " . $response->getMessages()->getMessage()[0]->getText() . "\n"; - } - } - } - else - { - echo "No response returned \n"; + if ($tresponse != null && $tresponse->getErrors() != null) { + echo " Error Code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; + echo " Error Message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; + } else { + echo " Error Code : " . $response->getMessages()->getMessage()[0]->getCode() . "\n"; + echo " Error Message : " . $response->getMessages()->getMessage()[0]->getText() . "\n"; + } + } + } else { + echo "No response returned \n"; } return $response; - } - if(!defined('DONT_RUN_SAMPLES')) +} + +if (!defined('DONT_RUN_SAMPLES')) { chargeCreditCard(\SampleCode\Constants::SAMPLE_AMOUNT); +} ?> diff --git a/PaymentTransactions/create-an-accept-payment-transaction.php b/PaymentTransactions/create-an-accept-payment-transaction.php index beba8f0..201e4cc 100644 --- a/PaymentTransactions/create-an-accept-payment-transaction.php +++ b/PaymentTransactions/create-an-accept-payment-transaction.php @@ -21,7 +21,8 @@ function createAnAcceptPaymentTransaction($amount) $opaqueData = new AnetAPI\OpaqueDataType(); $opaqueData->setDataDescriptor("COMMON.ACCEPT.INAPP.PAYMENT"); $opaqueData->setDataValue("119eyJjb2RlIjoiNTBfMl8wNjAwMDUyN0JEODE4RjQxOUEyRjhGQkIxMkY0MzdGQjAxQUIwRTY2NjhFNEFCN0VENzE4NTUwMjlGRUU0M0JFMENERUIwQzM2M0ExOUEwMDAzNzlGRDNFMjBCODJEMDFCQjkyNEJDIiwidG9rZW4iOiI5NDkwMjMyMTAyOTQwOTk5NDA0NjAzIiwidiI6IjEuMSJ9"); - + + // Add the payment data to a paymentType object $paymentOne = new AnetAPI\PaymentType(); $paymentOne->setOpaqueData($opaqueData); @@ -55,7 +56,7 @@ function createAnAcceptPaymentTransaction($amount) // Create a transactionRequestType object and add the previous objects to it $transactionRequestType = new AnetAPI\TransactionRequestType(); - $transactionRequestType->setTransactionType( "authCaptureTransaction"); + $transactionRequestType->setTransactionType("authCaptureTransaction"); $transactionRequestType->setAmount($amount); $transactionRequestType->setOrder($order); $transactionRequestType->setPayment($paymentOne); From da2a0d2e1e3de03c4b99c5c842e49ac18e043102 Mon Sep 17 00:00:00 2001 From: adavidw Date: Mon, 19 Jun 2017 13:28:06 -0600 Subject: [PATCH 048/149] better commenting --- PaymentTransactions/charge-credit-card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PaymentTransactions/charge-credit-card.php b/PaymentTransactions/charge-credit-card.php index c0a0f6f..2db9898 100644 --- a/PaymentTransactions/charge-credit-card.php +++ b/PaymentTransactions/charge-credit-card.php @@ -25,7 +25,7 @@ function chargeCreditCard($amount) // Add the payment data to a paymentType object $paymentOne = new AnetAPI\PaymentType(); - $paymentOne->setOpaqueData($opaqueData); + $paymentOne->setCreditCard($creditCard); // Create order information $order = new AnetAPI\OrderType(); @@ -54,7 +54,7 @@ function chargeCreditCard($amount) $duplicateWindowSetting->setSettingName("duplicateWindow"); $duplicateWindowSetting->setSettingValue("600"); - // Create a transactionRequestType object and add the previous objects to it + // Create a TransactionRequestType object and add the previous objects to it $transactionRequestType = new AnetAPI\TransactionRequestType(); $transactionRequestType->setTransactionType("authCaptureTransaction"); $transactionRequestType->setAmount($amount); From 7aa688a12f9361b96618d25ddc61772b0d3efc4f Mon Sep 17 00:00:00 2001 From: adavidw Date: Mon, 19 Jun 2017 13:31:28 -0600 Subject: [PATCH 049/149] remove extra linebreak --- PaymentTransactions/charge-credit-card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PaymentTransactions/charge-credit-card.php b/PaymentTransactions/charge-credit-card.php index 2db9898..ad1bc7f 100644 --- a/PaymentTransactions/charge-credit-card.php +++ b/PaymentTransactions/charge-credit-card.php @@ -118,4 +118,4 @@ function chargeCreditCard($amount) if (!defined('DONT_RUN_SAMPLES')) { chargeCreditCard(\SampleCode\Constants::SAMPLE_AMOUNT); } -?> +?> \ No newline at end of file From 79703e970b42bd89fc6f9b2a16e1dcb837cc9ab3 Mon Sep 17 00:00:00 2001 From: adavidw Date: Mon, 19 Jun 2017 14:07:55 -0600 Subject: [PATCH 050/149] correct call to setInvoiceNumber --- PaymentTransactions/charge-credit-card.php | 2 +- PaymentTransactions/create-an-accept-payment-transaction.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PaymentTransactions/charge-credit-card.php b/PaymentTransactions/charge-credit-card.php index ad1bc7f..0ce7c37 100644 --- a/PaymentTransactions/charge-credit-card.php +++ b/PaymentTransactions/charge-credit-card.php @@ -29,7 +29,7 @@ function chargeCreditCard($amount) // Create order information $order = new AnetAPI\OrderType(); - $order->invoiceNumber("10101"); + $order->setInvoiceNumber("10101"); $order->setDescription("Golf Shirts"); // Set the customer's Bill To address diff --git a/PaymentTransactions/create-an-accept-payment-transaction.php b/PaymentTransactions/create-an-accept-payment-transaction.php index 201e4cc..2cf0940 100644 --- a/PaymentTransactions/create-an-accept-payment-transaction.php +++ b/PaymentTransactions/create-an-accept-payment-transaction.php @@ -29,7 +29,7 @@ function createAnAcceptPaymentTransaction($amount) // Create order information $order = new AnetAPI\OrderType(); - $order->invoiceNumber("10101"); + $order->setInvoiceNumber("10101"); $order->setDescription("Golf Shirts"); // Set the customer's Bill To address From 41a51c0620047d7035fb4142bfe5784610e43545 Mon Sep 17 00:00:00 2001 From: adavidw Date: Mon, 19 Jun 2017 14:21:21 -0600 Subject: [PATCH 051/149] minor text fixes --- TransactionReporting/get-transaction-list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TransactionReporting/get-transaction-list.php b/TransactionReporting/get-transaction-list.php index af6886b..3ca299d 100644 --- a/TransactionReporting/get-transaction-list.php +++ b/TransactionReporting/get-transaction-list.php @@ -13,7 +13,7 @@ function getTransactionList() $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); - // Set the transaction's refId + // Set the request's refId $refId = 'ref' . time(); //Setting a valid batch Id for the Merchant @@ -31,7 +31,7 @@ function getTransactionList() { echo "SUCCESS: Get Transaction List for BatchID : " . $batchId . "\n\n"; if ($response->getTransactions() == null) { - echo "No Transaction to dispaly in this Batch."; + echo "No Transaction to display in this Batch."; return ; } //Displaying the details of each transaction in the list From cb90033954345377c02bbabfd9a90f6d55bad5c1 Mon Sep 17 00:00:00 2001 From: adavidw Date: Wed, 21 Jun 2017 15:12:20 -0600 Subject: [PATCH 052/149] add examples of merchant defined fields; other cleanup --- PaymentTransactions/authorize-credit-card.php | 117 ++++++++++-------- PaymentTransactions/charge-credit-card.php | 20 ++- .../create-an-accept-payment-transaction.php | 18 ++- 3 files changed, 95 insertions(+), 60 deletions(-) diff --git a/PaymentTransactions/authorize-credit-card.php b/PaymentTransactions/authorize-credit-card.php index 98ae9ba..baf2978 100644 --- a/PaymentTransactions/authorize-credit-card.php +++ b/PaymentTransactions/authorize-credit-card.php @@ -22,11 +22,15 @@ function authorizeCreditCard($amount) $creditCard->setCardNumber("4111111111111111"); $creditCard->setExpirationDate("1226"); $creditCard->setCardCode("123"); + + // Add the payment data to a paymentType object $paymentOne = new AnetAPI\PaymentType(); $paymentOne->setCreditCard($creditCard); + // Create order information $order = new AnetAPI\OrderType(); - $order->setDescription("New Item"); + $order->setInvoiceNumber("10101"); + $order->setDescription("Golf Shirts"); // Set the customer's Bill To address $customerAddress = new AnetAPI\CustomerAddressType(); @@ -45,78 +49,85 @@ function authorizeCreditCard($amount) $customerData->setId("99999456654"); $customerData->setEmail("EllenJohnson@example.com"); - //Add values for transaction settings + // Add values for transaction settings $duplicateWindowSetting = new AnetAPI\SettingType(); $duplicateWindowSetting->setSettingName("duplicateWindow"); - $duplicateWindowSetting->setSettingValue("600"); + $duplicateWindowSetting->setSettingValue("60"); + + // Add some merchant defined fields. These fields won't be stored with the transaction, + // but will be echoed back in the response. + $merchantDefinedField1 = new AnetAPI\UserFieldType(); + $merchantDefinedField1->setName("customerLoyaltyNum"); + $merchantDefinedField1->setValue("1128836273"); - // Create a TransactionRequestType object + $merchantDefinedField2 = new AnetAPI\UserFieldType(); + $merchantDefinedField2->setName("favoriteColor"); + $merchantDefinedField2->setValue("blue"); + + // Create a TransactionRequestType object and add the previous objects to it $transactionRequestType = new AnetAPI\TransactionRequestType(); - $transactionRequestType->setTransactionType( "authOnlyTransaction"); + $transactionRequestType->setTransactionType("authOnlyTransaction"); $transactionRequestType->setAmount($amount); $transactionRequestType->setOrder($order); $transactionRequestType->setPayment($paymentOne); $transactionRequestType->setBillTo($customerAddress); $transactionRequestType->setCustomer($customerData); $transactionRequestType->addToTransactionSettings($duplicateWindowSetting); + $transactionRequestType->addToUserFields($merchantDefinedField1); + $transactionRequestType->addToUserFields($merchantDefinedField2); + // Assemble the complete transaction request $request = new AnetAPI\CreateTransactionRequest(); $request->setMerchantAuthentication($merchantAuthentication); - $request->setRefId( $refId); - $request->setTransactionRequest( $transactionRequestType); + $request->setRefId($refId); + $request->setTransactionRequest($transactionRequestType); + // Create the controller and get the response $controller = new AnetController\CreateTransactionController($request); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); - if ($response != null) - { - if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) - { - $tresponse = $response->getTransactionResponse(); + if ($response != null) { + // Check to see if the API request was successfully received and acted upon + if ($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { + // Since the API request was successful, look for a transaction response + // and parse it to display the results of authorizing the card + $tresponse = $response->getTransactionResponse(); - if ($tresponse != null && $tresponse->getMessages() != null) - { - echo " Transaction Response Code : " . $tresponse->getResponseCode() . "\n"; - echo " Successfully created an authOnly transaction with Auth Code : " . $tresponse->getAuthCode() . "\n"; - echo " Transaction ID : " . $tresponse->getTransId() . "\n"; - echo " Code : " . $tresponse->getMessages()[0]->getCode() . "\n"; - echo " Description : " . $tresponse->getMessages()[0]->getDescription() . "\n"; - } - else - { - echo "Transaction Failed \n"; - if($tresponse->getErrors() != null) - { - echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; - echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; - } - } - } - else - { - echo "Transaction Failed \n"; - $tresponse = $response->getTransactionResponse(); + if ($tresponse != null && $tresponse->getMessages() != null) { + echo " Successfully created transaction with Transaction ID: " . $tresponse->getTransId() . "\n"; + echo " Transaction Response Code: " . $tresponse->getResponseCode() . "\n"; + echo " Message Code: " . $tresponse->getMessages()[0]->getCode() . "\n"; + echo " Auth Code: " . $tresponse->getAuthCode() . "\n"; + echo " Description: " . $tresponse->getMessages()[0]->getDescription() . "\n"; + } else { + echo "Transaction Failed \n"; + if ($tresponse->getErrors() != null) { + echo " Error Code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; + echo " Error Message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; + } + } + // Or, print errors if the API request wasn't successful + } else { + echo "Transaction Failed \n"; + $tresponse = $response->getTransactionResponse(); - if($tresponse != null && $tresponse->getErrors() != null) - { - echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; - echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; - } - else - { - echo " Error code : " . $response->getMessages()->getMessage()[0]->getCode() . "\n"; - echo " Error message : " . $response->getMessages()->getMessage()[0]->getText() . "\n"; - } - } - } - else - { - echo "No response returned \n"; + if ($tresponse != null && $tresponse->getErrors() != null) { + echo " Error Code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; + echo " Error Message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; + } else { + echo " Error Code : " . $response->getMessages()->getMessage()[0]->getCode() . "\n"; + echo " Error Message : " . $response->getMessages()->getMessage()[0]->getText() . "\n"; + } + } + } else { + echo "No response returned \n"; } - + return $response; - } - if(!defined('DONT_RUN_SAMPLES')) +} + +if (!defined('DONT_RUN_SAMPLES')) { authorizeCreditCard(\SampleCode\Constants::SAMPLE_AMOUNT); +} ?> \ No newline at end of file diff --git a/PaymentTransactions/charge-credit-card.php b/PaymentTransactions/charge-credit-card.php index 0ce7c37..dc2f6a5 100644 --- a/PaymentTransactions/charge-credit-card.php +++ b/PaymentTransactions/charge-credit-card.php @@ -22,7 +22,7 @@ function chargeCreditCard($amount) $creditCard->setCardNumber("4111111111111111"); $creditCard->setExpirationDate("1226"); $creditCard->setCardCode("123"); - + // Add the payment data to a paymentType object $paymentOne = new AnetAPI\PaymentType(); $paymentOne->setCreditCard($creditCard); @@ -49,10 +49,20 @@ function chargeCreditCard($amount) $customerData->setId("99999456654"); $customerData->setEmail("EllenJohnson@example.com"); - //Add values for transaction settings + // Add values for transaction settings $duplicateWindowSetting = new AnetAPI\SettingType(); $duplicateWindowSetting->setSettingName("duplicateWindow"); - $duplicateWindowSetting->setSettingValue("600"); + $duplicateWindowSetting->setSettingValue("60"); + + // Add some merchant defined fields. These fields won't be stored with the transaction, + // but will be echoed back in the response. + $merchantDefinedField1 = new AnetAPI\UserFieldType(); + $merchantDefinedField1->setName("customerLoyaltyNum"); + $merchantDefinedField1->setValue("1128836273"); + + $merchantDefinedField2 = new AnetAPI\UserFieldType(); + $merchantDefinedField2->setName("favoriteColor"); + $merchantDefinedField2->setValue("blue"); // Create a TransactionRequestType object and add the previous objects to it $transactionRequestType = new AnetAPI\TransactionRequestType(); @@ -63,6 +73,8 @@ function chargeCreditCard($amount) $transactionRequestType->setBillTo($customerAddress); $transactionRequestType->setCustomer($customerData); $transactionRequestType->addToTransactionSettings($duplicateWindowSetting); + $transactionRequestType->addToUserFields($merchantDefinedField1); + $transactionRequestType->addToUserFields($merchantDefinedField2); // Assemble the complete transaction request $request = new AnetAPI\CreateTransactionRequest(); @@ -116,6 +128,6 @@ function chargeCreditCard($amount) } if (!defined('DONT_RUN_SAMPLES')) { - chargeCreditCard(\SampleCode\Constants::SAMPLE_AMOUNT); + chargeCreditCard(\SampleCode\Constants::SAMPLE_AMOUNT); } ?> \ No newline at end of file diff --git a/PaymentTransactions/create-an-accept-payment-transaction.php b/PaymentTransactions/create-an-accept-payment-transaction.php index 2cf0940..caa2fb2 100644 --- a/PaymentTransactions/create-an-accept-payment-transaction.php +++ b/PaymentTransactions/create-an-accept-payment-transaction.php @@ -49,12 +49,22 @@ function createAnAcceptPaymentTransaction($amount) $customerData->setId("99999456654"); $customerData->setEmail("EllenJohnson@example.com"); - //Add values for transaction settings + // Add values for transaction settings $duplicateWindowSetting = new AnetAPI\SettingType(); $duplicateWindowSetting->setSettingName("duplicateWindow"); - $duplicateWindowSetting->setSettingValue("600"); + $duplicateWindowSetting->setSettingValue("60"); - // Create a transactionRequestType object and add the previous objects to it + // Add some merchant defined fields. These fields won't be stored with the transaction, + // but will be echoed back in the response. + $merchantDefinedField1 = new AnetAPI\UserFieldType(); + $merchantDefinedField1->setName("customerLoyaltyNum"); + $merchantDefinedField1->setValue("1128836273"); + + $merchantDefinedField2 = new AnetAPI\UserFieldType(); + $merchantDefinedField2->setName("favoriteColor"); + $merchantDefinedField2->setValue("blue"); + + // Create a TransactionRequestType object and add the previous objects to it $transactionRequestType = new AnetAPI\TransactionRequestType(); $transactionRequestType->setTransactionType("authCaptureTransaction"); $transactionRequestType->setAmount($amount); @@ -63,6 +73,8 @@ function createAnAcceptPaymentTransaction($amount) $transactionRequestType->setBillTo($customerAddress); $transactionRequestType->setCustomer($customerData); $transactionRequestType->addToTransactionSettings($duplicateWindowSetting); + $transactionRequestType->addToUserFields($merchantDefinedField1); + $transactionRequestType->addToUserFields($merchantDefinedField2); // Assemble the complete transaction request $request = new AnetAPI\CreateTransactionRequest(); From 4bb92dbfaaaa43ef8d499728d164db9d1120d276 Mon Sep 17 00:00:00 2001 From: adavidw Date: Thu, 22 Jun 2017 12:48:29 -0600 Subject: [PATCH 053/149] add sample code for Account Updater Reporting APIs --- .../get-account-updater-job-details.php | 82 +++++++++++++++++++ .../get-account-updater-job-summary.php | 62 ++++++++++++++ 2 files changed, 144 insertions(+) create mode 100644 TransactionReporting/get-account-updater-job-details.php create mode 100644 TransactionReporting/get-account-updater-job-summary.php diff --git a/TransactionReporting/get-account-updater-job-details.php b/TransactionReporting/get-account-updater-job-details.php new file mode 100644 index 0000000..e4c5157 --- /dev/null +++ b/TransactionReporting/get-account-updater-job-details.php @@ -0,0 +1,82 @@ +setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the request's refId + $refId = 'ref' . time(); + + // Set a valid month (and other parameters) for the request + $month = "2017-06"; + $modifedTypeFilter = "all"; + $paging = new AnetAPI\PagingType; + $paging->setLimit("1000"); + $paging->setOffset("1"); + + // Build tbe request object + $request = new AnetAPI\GetAUJobDetailsRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setMonth($month); + $request->setModifiedTypeFilter($modifedTypeFilter); + $request->setPaging($paging); + + $controller = new AnetController\GetAUJobDetailsController($request); + + // Retrieving details for the given month and parameters + $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); + + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok")) { + echo "SUCCESS: Get Account Updater Details for Month : " . $month . "\n\n"; + if ($response->getAuDetails() == null) { + echo "No Account Updater Details for this month.\n"; + return ; + } else { + $details = new AnetAPI\ListOfAUDetailsType; + $details = $response->getAuDetails(); + if (($details->getAuUpdate() == null) && ($details->getAuDelete() == null)) { + echo "No Account Updater Details for this month.\n"; + return ; + } + } + // Displaying the details of each response in the list + echo "Total Num in Result Set : " . $response->getTotalNumInResultSet() . "\n\n"; + $details = new AnetAPI\ListOfAUDetailsType; + $details = $response->getAuDetails(); + echo "Updates:\n"; + foreach ($details->getAuUpdate() as $update) { + echo " Profile ID / Payment Profile ID : " . $update->getCustomerProfileID() . " / " . $update->getCustomerPaymentProfileID() . "\n"; + echo " Update Time (UTC) : " . date_format($update->getUpdateTimeUTC(), 'Y-m-d H:i:s') . "\n"; + echo " Reason Code : " . $update->getAuReasonCode() . "\n"; + echo " Reason Description : " . number_format($update->getReasonDescription(), 2, '.', '') . "\n"; + echo "\n"; + } + echo "\nDeletes:\n"; + foreach ($details->getAuDelete() as $delete) { + echo " Profile ID / Payment Profile ID : " . $delete->getCustomerProfileID() . " / " . $update->getCustomerPaymentProfileID() . "\n"; + echo " Update Time (UTC) : " . date_format($delete->getUpdateTimeUTC(), 'Y-m-d H:i:s') . "\n"; + echo " Reason Code : " . $delete->getAuReasonCode() . "\n"; + echo " Reason Description : " . number_format($delete->getReasonDescription(), 2, '.', '') . "\n"; + echo "\n"; + } + } else { + echo "ERROR : Invalid response\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; + } + + return $response; +} + +if (!defined('DONT_RUN_SAMPLES')) { + getAccountUpdaterJobDetails(); +} diff --git a/TransactionReporting/get-account-updater-job-summary.php b/TransactionReporting/get-account-updater-job-summary.php new file mode 100644 index 0000000..0711dfd --- /dev/null +++ b/TransactionReporting/get-account-updater-job-summary.php @@ -0,0 +1,62 @@ +setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the request's refId + $refId = 'ref' . time(); + + // Set a valid month for the request + $month = "2017-06"; + + + + + + // Build tbe request object + $request = new AnetAPI\GetAUJobSummaryRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setMonth($month); + + + + $controller = new AnetController\GetAUJobSummaryController($request); + + // Retrieving summary for the given month + $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); + + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok")) { + echo "SUCCESS: Get Account Updater Summary for Month : " . $month . "\n\n"; + if ($response->getAuSummary() == null) { + echo "No Account Updater summary for this month.\n"; + return ; + } + // Displaying the summary of each response in the list + + foreach ($response->getAuSummary() as $result) { + echo " Reason Code : " . $result->getAuReasonCode() . "\n"; + echo " Reason Description : " . $result->getReasonDescription() . "\n"; + echo " Profiles updated for this reason : " . $result->getProfileCount() . "\n"; + } + } else { + echo "ERROR : Invalid response\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; + } + + return $response; +} + +if (!defined('DONT_RUN_SAMPLES')) { + getAccountUpdaterJobSummary(); +} From 254fc7dc6481df8c0d5c6dc2f283729ff51eee51 Mon Sep 17 00:00:00 2001 From: adavidw Date: Thu, 22 Jun 2017 13:03:58 -0600 Subject: [PATCH 054/149] formatting fixes --- .../get-account-updater-job-details.php | 7 ++++--- .../get-account-updater-job-summary.php | 14 ++++---------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/TransactionReporting/get-account-updater-job-details.php b/TransactionReporting/get-account-updater-job-details.php index e4c5157..f7037e3 100644 --- a/TransactionReporting/get-account-updater-job-details.php +++ b/TransactionReporting/get-account-updater-job-details.php @@ -1,7 +1,7 @@ getTotalNumInResultSet() . "\n\n"; $details = new AnetAPI\ListOfAUDetailsType; diff --git a/TransactionReporting/get-account-updater-job-summary.php b/TransactionReporting/get-account-updater-job-summary.php index 0711dfd..cd1c8eb 100644 --- a/TransactionReporting/get-account-updater-job-summary.php +++ b/TransactionReporting/get-account-updater-job-summary.php @@ -1,7 +1,7 @@ setMerchantAuthentication($merchantAuthentication); $request->setMonth($month); - - $controller = new AnetController\GetAUJobSummaryController($request); // Retrieving summary for the given month @@ -41,8 +35,8 @@ function getAccountUpdaterJobSummary() echo "No Account Updater summary for this month.\n"; return ; } - // Displaying the summary of each response in the list + // Displaying the summary of each response in the list foreach ($response->getAuSummary() as $result) { echo " Reason Code : " . $result->getAuReasonCode() . "\n"; echo " Reason Description : " . $result->getReasonDescription() . "\n"; From f00f8e3e4b41c3d25424d3e2f0512a8e4e0a3892 Mon Sep 17 00:00:00 2001 From: Aaron Wright Date: Thu, 22 Jun 2017 13:46:15 -0600 Subject: [PATCH 055/149] Update get-account-updater-job-summary.php minor text fixes --- TransactionReporting/get-account-updater-job-summary.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TransactionReporting/get-account-updater-job-summary.php b/TransactionReporting/get-account-updater-job-summary.php index cd1c8eb..eb87931 100644 --- a/TransactionReporting/get-account-updater-job-summary.php +++ b/TransactionReporting/get-account-updater-job-summary.php @@ -40,7 +40,7 @@ function getAccountUpdaterJobSummary() foreach ($response->getAuSummary() as $result) { echo " Reason Code : " . $result->getAuReasonCode() . "\n"; echo " Reason Description : " . $result->getReasonDescription() . "\n"; - echo " Profiles updated for this reason : " . $result->getProfileCount() . "\n"; + echo " # of Profiles updated for this reason : " . $result->getProfileCount() . "\n"; } } else { echo "ERROR : Invalid response\n"; From b181cf1a552184baacec018e0a0a3d151c86c82a Mon Sep 17 00:00:00 2001 From: Aaron Wright Date: Thu, 22 Jun 2017 13:53:15 -0600 Subject: [PATCH 056/149] Update get-account-updater-job-details.php remove unnecessary format commands --- TransactionReporting/get-account-updater-job-details.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TransactionReporting/get-account-updater-job-details.php b/TransactionReporting/get-account-updater-job-details.php index f7037e3..18bd5eb 100644 --- a/TransactionReporting/get-account-updater-job-details.php +++ b/TransactionReporting/get-account-updater-job-details.php @@ -58,7 +58,7 @@ function getAccountUpdaterJobDetails() echo " Profile ID / Payment Profile ID : " . $update->getCustomerProfileID() . " / " . $update->getCustomerPaymentProfileID() . "\n"; echo " Update Time (UTC) : " . date_format($update->getUpdateTimeUTC(), 'Y-m-d H:i:s') . "\n"; echo " Reason Code : " . $update->getAuReasonCode() . "\n"; - echo " Reason Description : " . number_format($update->getReasonDescription(), 2, '.', '') . "\n"; + echo " Reason Description : " . $update->getReasonDescription() . "\n"; echo "\n"; } echo "\nDeletes:\n"; @@ -66,7 +66,7 @@ function getAccountUpdaterJobDetails() echo " Profile ID / Payment Profile ID : " . $delete->getCustomerProfileID() . " / " . $update->getCustomerPaymentProfileID() . "\n"; echo " Update Time (UTC) : " . date_format($delete->getUpdateTimeUTC(), 'Y-m-d H:i:s') . "\n"; echo " Reason Code : " . $delete->getAuReasonCode() . "\n"; - echo " Reason Description : " . number_format($delete->getReasonDescription(), 2, '.', '') . "\n"; + echo " Reason Description : " . ($delete->getReasonDescription() . "\n"; echo "\n"; } } else { From e0a81124b9943e1572b01c7aeb6e47e75b5d333a Mon Sep 17 00:00:00 2001 From: Aaron Wright Date: Thu, 22 Jun 2017 13:54:32 -0600 Subject: [PATCH 057/149] Update get-account-updater-job-details.php remove unnecessary format commands --- TransactionReporting/get-account-updater-job-details.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TransactionReporting/get-account-updater-job-details.php b/TransactionReporting/get-account-updater-job-details.php index 18bd5eb..a085178 100644 --- a/TransactionReporting/get-account-updater-job-details.php +++ b/TransactionReporting/get-account-updater-job-details.php @@ -66,7 +66,7 @@ function getAccountUpdaterJobDetails() echo " Profile ID / Payment Profile ID : " . $delete->getCustomerProfileID() . " / " . $update->getCustomerPaymentProfileID() . "\n"; echo " Update Time (UTC) : " . date_format($delete->getUpdateTimeUTC(), 'Y-m-d H:i:s') . "\n"; echo " Reason Code : " . $delete->getAuReasonCode() . "\n"; - echo " Reason Description : " . ($delete->getReasonDescription() . "\n"; + echo " Reason Description : " . $delete->getReasonDescription() . "\n"; echo "\n"; } } else { From 8bf2d2d1d4891a93b408dd85106d2bfdca5e8d53 Mon Sep 17 00:00:00 2001 From: adavidw Date: Fri, 30 Jun 2017 00:54:30 -0600 Subject: [PATCH 058/149] fixes to work with actual responses --- TransactionReporting/get-account-updater-job-details.php | 6 +++--- TransactionReporting/get-account-updater-job-summary.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/TransactionReporting/get-account-updater-job-details.php b/TransactionReporting/get-account-updater-job-details.php index f7037e3..c4ccf50 100644 --- a/TransactionReporting/get-account-updater-job-details.php +++ b/TransactionReporting/get-account-updater-job-details.php @@ -17,7 +17,7 @@ function getAccountUpdaterJobDetails() $refId = 'ref' . time(); // Set a valid month (and other parameters) for the request - $month = "2017-06"; + $month = "2017-05"; $modifedTypeFilter = "all"; $paging = new AnetAPI\PagingType; $paging->setLimit("1000"); @@ -64,9 +64,9 @@ function getAccountUpdaterJobDetails() echo "\nDeletes:\n"; foreach ($details->getAuDelete() as $delete) { echo " Profile ID / Payment Profile ID : " . $delete->getCustomerProfileID() . " / " . $update->getCustomerPaymentProfileID() . "\n"; - echo " Update Time (UTC) : " . date_format($delete->getUpdateTimeUTC(), 'Y-m-d H:i:s') . "\n"; + echo " Update Time (UTC) : " . $delete->getUpdateTimeUTC() . "\n"; echo " Reason Code : " . $delete->getAuReasonCode() . "\n"; - echo " Reason Description : " . number_format($delete->getReasonDescription(), 2, '.', '') . "\n"; + echo " Reason Description : " . $delete->getReasonDescription() . "\n"; echo "\n"; } } else { diff --git a/TransactionReporting/get-account-updater-job-summary.php b/TransactionReporting/get-account-updater-job-summary.php index cd1c8eb..a08e905 100644 --- a/TransactionReporting/get-account-updater-job-summary.php +++ b/TransactionReporting/get-account-updater-job-summary.php @@ -17,7 +17,7 @@ function getAccountUpdaterJobSummary() $refId = 'ref' . time(); // Set a valid month for the request - $month = "2017-06"; + $month = "2017-05"; // Build tbe request object $request = new AnetAPI\GetAUJobSummaryRequest(); From 766fc897e1e302910a73ee2869bcd808d26b1e8a Mon Sep 17 00:00:00 2001 From: adavidw Date: Tue, 11 Jul 2017 16:41:11 -0600 Subject: [PATCH 059/149] fix sorting parameter --- .../get-list-of-subscriptions.php | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/RecurringBilling/get-list-of-subscriptions.php b/RecurringBilling/get-list-of-subscriptions.php index e76cfc1..444c9f5 100644 --- a/RecurringBilling/get-list-of-subscriptions.php +++ b/RecurringBilling/get-list-of-subscriptions.php @@ -18,7 +18,7 @@ function getListOfSubscriptions() $sorting = new AnetAPI\ARBGetSubscriptionListSortingType(); $sorting->setOrderBy("id"); - $sorting->setOrderDescending("false"); + $sorting->setOrderDescending(false); $paging = new AnetAPI\PagingType(); $paging->setLimit("1000"); @@ -34,23 +34,23 @@ function getListOfSubscriptions() $controller = new AnetController\ARBGetSubscriptionListController($request); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); - if (($response != null) && ($response->getMessages()->getResultCode() == "Ok")) - { - //echo "SUCCESS: Subscription Details:" . $response->getSubscriptionDetails() . "\n"; + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok")) { + echo "SUCCESS: Subscription Details:" . "\n"; + foreach ($response->getSubscriptionDetails() as $subscriptionDetails) { + echo "Subscription ID: " . $subscriptionDetails->getId() . "\n"; + } echo "Total Number In Results:" . $response->getTotalNumInResultSet() . "\n"; - } - else - { + } else { echo "ERROR : Invalid response\n"; $errorMessages = $response->getMessages()->getMessage(); echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } return $response; - } +} - if(!defined('DONT_RUN_SAMPLES')) +if (!defined('DONT_RUN_SAMPLES')) { getListOfSubscriptions(); -?> +} From d5e58cd3d86efa38c198c9e92b22299ca357b8a4 Mon Sep 17 00:00:00 2001 From: adavidw Date: Tue, 11 Jul 2017 16:43:57 -0600 Subject: [PATCH 060/149] fix formatting --- TransactionReporting/get-account-updater-job-details.php | 4 ++-- TransactionReporting/get-account-updater-job-summary.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/TransactionReporting/get-account-updater-job-details.php b/TransactionReporting/get-account-updater-job-details.php index c4ccf50..277f612 100644 --- a/TransactionReporting/get-account-updater-job-details.php +++ b/TransactionReporting/get-account-updater-job-details.php @@ -56,9 +56,9 @@ function getAccountUpdaterJobDetails() echo "Updates:\n"; foreach ($details->getAuUpdate() as $update) { echo " Profile ID / Payment Profile ID : " . $update->getCustomerProfileID() . " / " . $update->getCustomerPaymentProfileID() . "\n"; - echo " Update Time (UTC) : " . date_format($update->getUpdateTimeUTC(), 'Y-m-d H:i:s') . "\n"; + echo " Update Time (UTC) : " . $update->getUpdateTimeUTC() . "\n"; echo " Reason Code : " . $update->getAuReasonCode() . "\n"; - echo " Reason Description : " . number_format($update->getReasonDescription(), 2, '.', '') . "\n"; + echo " Reason Description : " . $update->getReasonDescription() . "\n"; echo "\n"; } echo "\nDeletes:\n"; diff --git a/TransactionReporting/get-account-updater-job-summary.php b/TransactionReporting/get-account-updater-job-summary.php index a08e905..4c3eb7b 100644 --- a/TransactionReporting/get-account-updater-job-summary.php +++ b/TransactionReporting/get-account-updater-job-summary.php @@ -38,9 +38,9 @@ function getAccountUpdaterJobSummary() // Displaying the summary of each response in the list foreach ($response->getAuSummary() as $result) { - echo " Reason Code : " . $result->getAuReasonCode() . "\n"; + echo " Reason Code : " . $result->getAuReasonCode() . "\n"; echo " Reason Description : " . $result->getReasonDescription() . "\n"; - echo " Profiles updated for this reason : " . $result->getProfileCount() . "\n"; + echo " Profiles updated for this reason : " . $result->getProfileCount() . "\n\n"; } } else { echo "ERROR : Invalid response\n"; From fb30e553bd13e7b60bad91e640c747112d49c826 Mon Sep 17 00:00:00 2001 From: adavidw Date: Tue, 11 Jul 2017 16:47:35 -0600 Subject: [PATCH 061/149] fix to work correctly (since it's boolean) --- CustomerProfiles/get-customer-payment-profile-list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CustomerProfiles/get-customer-payment-profile-list.php b/CustomerProfiles/get-customer-payment-profile-list.php index cf64086..4c2a2a4 100644 --- a/CustomerProfiles/get-customer-payment-profile-list.php +++ b/CustomerProfiles/get-customer-payment-profile-list.php @@ -25,7 +25,7 @@ function getCustomerPaymentProfileList() //Setting the sorting $sorting = new AnetAPI\CustomerPaymentProfileSortingType(); $sorting->setOrderBy("id"); - $sorting->setOrderDescending("false"); + $sorting->setOrderDescending(false); //Creating the request with the required parameters $request = new AnetAPI\GetCustomerPaymentProfileListRequest(); From c496426963582b28dee84abec1c98bd1f3f7f496 Mon Sep 17 00:00:00 2001 From: adavidw Date: Wed, 12 Jul 2017 00:47:06 -0600 Subject: [PATCH 062/149] changes to get tests to pass again --- PaymentTransactions/debit-bank-account.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/PaymentTransactions/debit-bank-account.php b/PaymentTransactions/debit-bank-account.php index 6ab85d2..dc919b2 100644 --- a/PaymentTransactions/debit-bank-account.php +++ b/PaymentTransactions/debit-bank-account.php @@ -18,11 +18,11 @@ function debitBankAccount($amount) // Create the payment data for a Bank Account $bankAccount = new AnetAPI\BankAccountType(); - //$bankAccount->setAccountType('CHECKING'); + $bankAccount->setAccountType('checking'); $bankAccount->setEcheckType('WEB'); $bankAccount->setRoutingNumber('121042882'); - $bankAccount->setAccountNumber('123456789123'); - $bankAccount->setNameOnAccount('Jane Doe'); + $bankAccount->setAccountNumber('12345678'); + $bankAccount->setNameOnAccount('John Doe'); $bankAccount->setBankName('Bank of the Earth'); $paymentBank= new AnetAPI\PaymentType(); @@ -54,7 +54,7 @@ function debitBankAccount($amount) echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; echo "Debit Bank Account APPROVED :" . "\n"; echo " Debit Bank Account AUTH CODE : " . $tresponse->getAuthCode() . "\n"; - echo " Debit Banlk Account TRANS ID : " . $tresponse->getTransId() . "\n"; + echo " Debit Bank Account TRANS ID : " . $tresponse->getTransId() . "\n"; echo " Code : " . $tresponse->getMessages()[0]->getCode() . "\n"; echo " Description : " . $tresponse->getMessages()[0]->getDescription() . "\n"; } @@ -92,5 +92,4 @@ function debitBankAccount($amount) return $response; } if(!defined('DONT_RUN_SAMPLES')) - debitBankAccount(12.23); -?> + debitBankAccount(5.29); From afb1a70fc04b7aafae57572f877a192d253faa46 Mon Sep 17 00:00:00 2001 From: adavidw Date: Wed, 12 Jul 2017 01:32:06 -0600 Subject: [PATCH 063/149] changes to help tests pass --- PaymentTransactions/credit-bank-account.php | 100 +++++++++----------- PaymentTransactions/debit-bank-account.php | 95 +++++++++---------- 2 files changed, 89 insertions(+), 106 deletions(-) diff --git a/PaymentTransactions/credit-bank-account.php b/PaymentTransactions/credit-bank-account.php index b5da67e..8127183 100644 --- a/PaymentTransactions/credit-bank-account.php +++ b/PaymentTransactions/credit-bank-account.php @@ -18,81 +18,71 @@ function creditBankAccount($amount) // Create the payment data for a Bank Account $bankAccount = new AnetAPI\BankAccountType(); - $bankAccount->setRoutingNumber('125000024'); + $bankAccount->setAccountType('checking'); + // $bankAccount->setEcheckType('WEB'); + $bankAccount->setRoutingNumber('121042882'); $bankAccount->setAccountNumber('12345678'); - $bankAccount->setNameOnAccount('Jane Doe'); + $bankAccount->setNameOnAccount('John Doe'); + $bankAccount->setBankName('Bank of the Earth'); $paymentBank= new AnetAPI\PaymentType(); $paymentBank->setBankAccount($bankAccount); - // Order info + // Order info $order = new AnetAPI\OrderType(); $order->setInvoiceNumber("101"); $order->setDescription("Golf Shirts"); - //create a debit card Bank transaction + //create a bank credit transaction $transactionRequestType = new AnetAPI\TransactionRequestType(); - $transactionRequestType->setTransactionType( "refundTransaction"); + $transactionRequestType->setTransactionType("refundTransaction"); $transactionRequestType->setAmount($amount); $transactionRequestType->setPayment($paymentBank); $transactionRequestType->setOrder($order); $request = new AnetAPI\CreateTransactionRequest(); $request->setMerchantAuthentication($merchantAuthentication); - $request->setRefId( $refId); - $request->setTransactionRequest( $transactionRequestType); + $request->setRefId($refId); + $request->setTransactionRequest($transactionRequestType); $controller = new AnetController\CreateTransactionController($request); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); - - if ($response != null) - { - if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) - { - $tresponse = $response->getTransactionResponse(); + if ($response != null) { + if ($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { + $tresponse = $response->getTransactionResponse(); - if ($tresponse != null && $tresponse->getMessages() != null) - { - echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; - echo "Credit Bank Account APPROVED :" . "\n"; - echo "Credit Bank Account AUTH CODE : " . $tresponse->getAuthCode() . "\n"; - echo "Credit Bank Account TRANS ID : " . $tresponse->getTransId() . "\n"; - echo " Code : " . $tresponse->getMessages()[0]->getCode() . "\n"; - echo " Description : " . $tresponse->getMessages()[0]->getDescription() . "\n"; - } - else - { - echo "Transaction Failed \n"; - if($tresponse->getErrors() != null) - { - echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; - echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; - } - } - } - else - { - echo "Transaction Failed \n"; - $tresponse = $response->getTransactionResponse(); - if($tresponse != null && $tresponse->getErrors() != null) - { - echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; - echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) { + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + echo "Credit Bank Account APPROVED :" . "\n"; + echo "Credit Bank Account AUTH CODE : " . $tresponse->getAuthCode() . "\n"; + echo "Credit Bank Account TRANS ID : " . $tresponse->getTransId() . "\n"; + echo " Code : " . $tresponse->getMessages()[0]->getCode() . "\n"; + echo " Description : " . $tresponse->getMessages()[0]->getDescription() . "\n"; + } else { + echo "Transaction Failed \n"; + if ($tresponse->getErrors() != null) { + echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; + echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; + } + } + } else { + echo "Transaction Failed \n"; + $tresponse = $response->getTransactionResponse(); + if ($tresponse != null && $tresponse->getErrors() != null) { + echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; + echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; + } else { + echo " Error code : " . $response->getMessages()->getMessage()[0]->getCode() . "\n"; + echo " Error message : " . $response->getMessages()->getMessage()[0]->getText() . "\n"; + } } - else - { - echo " Error code : " . $response->getMessages()->getMessage()[0]->getCode() . "\n"; - echo " Error message : " . $response->getMessages()->getMessage()[0]->getText() . "\n"; - } - } - } - else - { - echo "No response returned \n"; + } else { + echo "No response returned \n"; } return $response; - } - if(!defined('DONT_RUN_SAMPLES')) - creditBankAccount(12.23); -?> +} + +if (!defined('DONT_RUN_SAMPLES')) { + creditBankAccount(5.29); +} diff --git a/PaymentTransactions/debit-bank-account.php b/PaymentTransactions/debit-bank-account.php index dc919b2..a53f111 100644 --- a/PaymentTransactions/debit-bank-account.php +++ b/PaymentTransactions/debit-bank-account.php @@ -19,7 +19,7 @@ function debitBankAccount($amount) // Create the payment data for a Bank Account $bankAccount = new AnetAPI\BankAccountType(); $bankAccount->setAccountType('checking'); - $bankAccount->setEcheckType('WEB'); + // $bankAccount->setEcheckType('WEB'); $bankAccount->setRoutingNumber('121042882'); $bankAccount->setAccountNumber('12345678'); $bankAccount->setNameOnAccount('John Doe'); @@ -28,68 +28,61 @@ function debitBankAccount($amount) $paymentBank= new AnetAPI\PaymentType(); $paymentBank->setBankAccount($bankAccount); + // Order info + $order = new AnetAPI\OrderType(); + $order->setInvoiceNumber("101"); + $order->setDescription("Golf Shirts"); - //create a debit card Bank transaction + //create a bank debit transaction $transactionRequestType = new AnetAPI\TransactionRequestType(); - $transactionRequestType->setTransactionType( "authCaptureTransaction"); + $transactionRequestType->setTransactionType("authCaptureTransaction"); $transactionRequestType->setAmount($amount); $transactionRequestType->setPayment($paymentBank); - + $transactionRequestType->setOrder($order); $request = new AnetAPI\CreateTransactionRequest(); $request->setMerchantAuthentication($merchantAuthentication); - $request->setRefId( $refId); - $request->setTransactionRequest( $transactionRequestType); + $request->setRefId($refId); + $request->setTransactionRequest($transactionRequestType); $controller = new AnetController\CreateTransactionController($request); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); - if ($response != null) - { - if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) - { - $tresponse = $response->getTransactionResponse(); + if ($response != null) { + if ($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { + $tresponse = $response->getTransactionResponse(); - if ($tresponse != null && $tresponse->getMessages() != null) - { - echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; - echo "Debit Bank Account APPROVED :" . "\n"; - echo " Debit Bank Account AUTH CODE : " . $tresponse->getAuthCode() . "\n"; - echo " Debit Bank Account TRANS ID : " . $tresponse->getTransId() . "\n"; - echo " Code : " . $tresponse->getMessages()[0]->getCode() . "\n"; - echo " Description : " . $tresponse->getMessages()[0]->getDescription() . "\n"; - } - else - { - echo "Transaction Failed \n"; - if($tresponse->getErrors() != null) - { - echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; - echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; - } - } - } - else - { - echo "Transaction Failed \n"; - $tresponse = $response->getTransactionResponse(); - if($tresponse != null && $tresponse->getErrors() != null) - { - echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; - echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) { + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + echo " Debit Bank Account APPROVED :" . "\n"; + echo " Debit Bank Account AUTH CODE : " . $tresponse->getAuthCode() . "\n"; + echo " Debit Bank Account TRANS ID : " . $tresponse->getTransId() . "\n"; + echo " Code : " . $tresponse->getMessages()[0]->getCode() . "\n"; + echo " Description : " . $tresponse->getMessages()[0]->getDescription() . "\n"; + } else { + echo "Transaction Failed \n"; + if ($tresponse->getErrors() != null) { + echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; + echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; + } + } + } else { + echo "Transaction Failed \n"; + $tresponse = $response->getTransactionResponse(); + if ($tresponse != null && $tresponse->getErrors() != null) { + echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; + echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; + } else { + echo " Error code : " . $response->getMessages()->getMessage()[0]->getCode() . "\n"; + echo " Error message : " . $response->getMessages()->getMessage()[0]->getText() . "\n"; + } } - else - { - echo " Error code : " . $response->getMessages()->getMessage()[0]->getCode() . "\n"; - echo " Error message : " . $response->getMessages()->getMessage()[0]->getText() . "\n"; - } - } - } - else - { - echo "No response returned \n"; + } else { + echo "No response returned \n"; } return $response; - } - if(!defined('DONT_RUN_SAMPLES')) +} + +if (!defined('DONT_RUN_SAMPLES')) { debitBankAccount(5.29); +} From d969103f56ab99f7f0380581697d64e384b35ab2 Mon Sep 17 00:00:00 2001 From: adavidw Date: Sun, 16 Jul 2017 09:55:34 -0700 Subject: [PATCH 064/149] add example of setting shipping addresses --- CustomerProfiles/create-customer-profile.php | 73 ++++++++++++-------- 1 file changed, 45 insertions(+), 28 deletions(-) diff --git a/CustomerProfiles/create-customer-profile.php b/CustomerProfiles/create-customer-profile.php index 4857207..c58c197 100644 --- a/CustomerProfiles/create-customer-profile.php +++ b/CustomerProfiles/create-customer-profile.php @@ -33,46 +33,64 @@ function createCustomerProfile($email) $paymentCreditCard->setCreditCard($creditCard); // Create the Bill To info for new payment type - $billto = new AnetAPI\CustomerAddressType(); - $billto->setFirstName("Ellen"); - $billto->setLastName("Johnson"); - $billto->setCompany("Souveniropolis"); - $billto->setAddress("14 Main Street"); - $billto->setCity("Pecan Springs"); - $billto->setState("TX"); - $billto->setZip("44628"); - $billto->setCountry("USA"); - $billto->setPhoneNumber("888-888-8888"); - $billto->setfaxNumber("999-999-9999"); - - // Create a new Customer Payment Profile object - $paymentprofile = new AnetAPI\CustomerPaymentProfileType(); - $paymentprofile->setCustomerType('individual'); - $paymentprofile->setBillTo($billto); - $paymentprofile->setPayment($paymentCreditCard); - $paymentprofile->setDefaultPaymentProfile(true); - - $paymentprofiles[] = $paymentprofile; + $billTo = new AnetAPI\CustomerAddressType(); + $billTo->setFirstName("Ellen"); + $billTo->setLastName("Johnson"); + $billTo->setCompany("Souveniropolis"); + $billTo->setAddress("14 Main Street"); + $billTo->setCity("Pecan Springs"); + $billTo->setState("TX"); + $billTo->setZip("44628"); + $billTo->setCountry("USA"); + $billTo->setPhoneNumber("888-888-8888"); + $billTo->setfaxNumber("999-999-9999"); + + // Create a customer shipping address + $customerShippingAddress = new AnetAPI\CustomerAddressType(); + $customerShippingAddress->setFirstName("James"); + $customerShippingAddress->setLastName("White"); + $customerShippingAddress->setCompany("Addresses R Us"); + $customerShippingAddress->setAddress(rand() . " North Spring Street"); + $customerShippingAddress->setCity("Toms River"); + $customerShippingAddress->setState("NJ"); + $customerShippingAddress->setZip("08753"); + $customerShippingAddress->setCountry("USA"); + $customerShippingAddress->setPhoneNumber("888-888-8888"); + $customerShippingAddress->setFaxNumber("999-999-9999"); + + // Create an array of any shipping addresses + $shippingProfiles[] = $customerShippingAddress; + + + // Create a new CustomerPaymentProfile object + $paymentProfile = new AnetAPI\CustomerPaymentProfileType(); + $paymentProfile->setCustomerType('individual'); + $paymentProfile->setBillTo($billTo); + $paymentProfile->setPayment($paymentCreditCard); + $paymentProfile->setDefaultpaymentProfile(true); + $paymentProfiles[] = $paymentProfile; + // Create a new CustomerProfileType and add the payment profile object - $customerprofile = new AnetAPI\CustomerProfileType(); - $customerprofile->setDescription("Customer 2 Test PHP"); + $customerProfile = new AnetAPI\CustomerProfileType(); + $customerProfile->setDescription("Customer 2 Test PHP"); + $customerProfile->setMerchantCustomerId("M_" . time()); + $customerProfile->setEmail($email); + $customerProfile->setpaymentProfiles($paymentProfiles); + $customerProfile->setShipToList($shippingProfiles); - $customerprofile->setMerchantCustomerId("M_".$email); - $customerprofile->setEmail($email); - $customerprofile->setPaymentProfiles($paymentprofiles); // Assemble the complete transaction request $request = new AnetAPI\CreateCustomerProfileRequest(); $request->setMerchantAuthentication($merchantAuthentication); $request->setRefId($refId); - $request->setProfile($customerprofile); + $request->setProfile($customerProfile); // Create the controller and get the response $controller = new AnetController\CreateCustomerProfileController($request); $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); - if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) { + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok")) { echo "Succesfully created customer profile : " . $response->getCustomerProfileId() . "\n"; $paymentProfiles = $response->getCustomerPaymentProfileIdList(); echo "SUCCESS: PAYMENT PROFILE ID : " . $paymentProfiles[0] . "\n"; @@ -87,4 +105,3 @@ function createCustomerProfile($email) if (!defined('DONT_RUN_SAMPLES')) { createCustomerProfile("test123@test.com"); } -?> From 4e3da20746ed5a3a142a0056fa1a9ebb932e2826 Mon Sep 17 00:00:00 2001 From: adavidw Date: Fri, 28 Jul 2017 17:16:19 -0600 Subject: [PATCH 065/149] consistent expiration date --- CustomerProfiles/get-customer-profile.php | 2 +- CustomerProfiles/update-customer-payment-profile.php | 2 +- CustomerProfiles/update-customer-profile.php | 2 +- PaymentTransactions/authorize-credit-card.php | 2 +- PaymentTransactions/charge-credit-card.php | 7 +++---- RecurringBilling/create-subscription.php | 2 +- RecurringBilling/update-subscription.php | 2 +- 7 files changed, 9 insertions(+), 10 deletions(-) diff --git a/CustomerProfiles/get-customer-profile.php b/CustomerProfiles/get-customer-profile.php index 26cf654..2ecab4d 100644 --- a/CustomerProfiles/get-customer-profile.php +++ b/CustomerProfiles/get-customer-profile.php @@ -19,7 +19,7 @@ function getCustomerProfile() // Create the payment data for a credit card $creditCard = new AnetAPI\CreditCardType(); $creditCard->setCardNumber( "4111111111111111" ); - $creditCard->setExpirationDate( "2038-12"); + $creditCard->setExpirationDate("2038-12"); $paymentCreditCard = new AnetAPI\PaymentType(); $paymentCreditCard->setCreditCard($creditCard); diff --git a/CustomerProfiles/update-customer-payment-profile.php b/CustomerProfiles/update-customer-payment-profile.php index 36dfe0f..ab2c2ec 100644 --- a/CustomerProfiles/update-customer-payment-profile.php +++ b/CustomerProfiles/update-customer-payment-profile.php @@ -29,7 +29,7 @@ function updateCustomerPaymentProfile($customerProfileId = "36731856", // if you don't need to update that info $creditCard = new AnetAPI\CreditCardType(); $creditCard->setCardNumber( "4111111111111111" ); - $creditCard->setExpirationDate( "0718"); + $creditCard->setExpirationDate("2038-12"); $paymentCreditCard = new AnetAPI\PaymentType(); $paymentCreditCard->setCreditCard($creditCard); diff --git a/CustomerProfiles/update-customer-profile.php b/CustomerProfiles/update-customer-profile.php index 5b6daf5..9c0e814 100644 --- a/CustomerProfiles/update-customer-profile.php +++ b/CustomerProfiles/update-customer-profile.php @@ -19,7 +19,7 @@ function updateCustomerProfile() // Create the payment data for a credit card $creditCard = new AnetAPI\CreditCardType(); $creditCard->setCardNumber( "4111111111111111" ); - $creditCard->setExpirationDate( "2038-12"); + $creditCard->setExpirationDate("2038-12"); $paymentCreditCard = new AnetAPI\PaymentType(); $paymentCreditCard->setCreditCard($creditCard); diff --git a/PaymentTransactions/authorize-credit-card.php b/PaymentTransactions/authorize-credit-card.php index baf2978..d7cc566 100644 --- a/PaymentTransactions/authorize-credit-card.php +++ b/PaymentTransactions/authorize-credit-card.php @@ -20,7 +20,7 @@ function authorizeCreditCard($amount) // Create the payment data for a credit card $creditCard = new AnetAPI\CreditCardType(); $creditCard->setCardNumber("4111111111111111"); - $creditCard->setExpirationDate("1226"); + $creditCard->setExpirationDate("2038-12"); $creditCard->setCardCode("123"); // Add the payment data to a paymentType object diff --git a/PaymentTransactions/charge-credit-card.php b/PaymentTransactions/charge-credit-card.php index dc2f6a5..c401d81 100644 --- a/PaymentTransactions/charge-credit-card.php +++ b/PaymentTransactions/charge-credit-card.php @@ -20,7 +20,7 @@ function chargeCreditCard($amount) // Create the payment data for a credit card $creditCard = new AnetAPI\CreditCardType(); $creditCard->setCardNumber("4111111111111111"); - $creditCard->setExpirationDate("1226"); + $creditCard->setExpirationDate("2038-12"); $creditCard->setCardCode("123"); // Add the payment data to a paymentType object @@ -66,7 +66,7 @@ function chargeCreditCard($amount) // Create a TransactionRequestType object and add the previous objects to it $transactionRequestType = new AnetAPI\TransactionRequestType(); - $transactionRequestType->setTransactionType("authCaptureTransaction"); + $transactionRequestType->setTransactionType("authCaptureTransaction"); $transactionRequestType->setAmount($amount); $transactionRequestType->setOrder($order); $transactionRequestType->setPayment($paymentOne); @@ -119,7 +119,7 @@ function chargeCreditCard($amount) echo " Error Code : " . $response->getMessages()->getMessage()[0]->getCode() . "\n"; echo " Error Message : " . $response->getMessages()->getMessage()[0]->getText() . "\n"; } - } + } } else { echo "No response returned \n"; } @@ -130,4 +130,3 @@ function chargeCreditCard($amount) if (!defined('DONT_RUN_SAMPLES')) { chargeCreditCard(\SampleCode\Constants::SAMPLE_AMOUNT); } -?> \ No newline at end of file diff --git a/RecurringBilling/create-subscription.php b/RecurringBilling/create-subscription.php index 68b80f8..fa6b675 100644 --- a/RecurringBilling/create-subscription.php +++ b/RecurringBilling/create-subscription.php @@ -37,7 +37,7 @@ function createSubscription($intervalLength) $creditCard = new AnetAPI\CreditCardType(); $creditCard->setCardNumber("4111111111111111"); - $creditCard->setExpirationDate("2020-12"); + $creditCard->setExpirationDate("2038-12"); $payment = new AnetAPI\PaymentType(); $payment->setCreditCard($creditCard); diff --git a/RecurringBilling/update-subscription.php b/RecurringBilling/update-subscription.php index 9f4a49d..e8e05d9 100644 --- a/RecurringBilling/update-subscription.php +++ b/RecurringBilling/update-subscription.php @@ -20,7 +20,7 @@ function updateSubscription($subscriptionId) $creditCard = new AnetAPI\CreditCardType(); $creditCard->setCardNumber("4111111111111111"); - $creditCard->setExpirationDate("2020-12"); + $creditCard->setExpirationDate("2038-12"); $payment = new AnetAPI\PaymentType(); $payment->setCreditCard($creditCard); From 04dece5024588f0b2718d46488d47f19830b0715 Mon Sep 17 00:00:00 2001 From: adavidw Date: Tue, 1 Aug 2017 15:21:01 -0600 Subject: [PATCH 066/149] update AU samples --- TransactionReporting/get-account-updater-job-details.php | 4 ++-- TransactionReporting/get-account-updater-job-summary.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/TransactionReporting/get-account-updater-job-details.php b/TransactionReporting/get-account-updater-job-details.php index 277f612..12f9d81 100644 --- a/TransactionReporting/get-account-updater-job-details.php +++ b/TransactionReporting/get-account-updater-job-details.php @@ -17,7 +17,7 @@ function getAccountUpdaterJobDetails() $refId = 'ref' . time(); // Set a valid month (and other parameters) for the request - $month = "2017-05"; + $month = "2017-07"; $modifedTypeFilter = "all"; $paging = new AnetAPI\PagingType; $paging->setLimit("1000"); @@ -63,7 +63,7 @@ function getAccountUpdaterJobDetails() } echo "\nDeletes:\n"; foreach ($details->getAuDelete() as $delete) { - echo " Profile ID / Payment Profile ID : " . $delete->getCustomerProfileID() . " / " . $update->getCustomerPaymentProfileID() . "\n"; + echo " Profile ID / Payment Profile ID : " . $delete->getCustomerProfileID() . " / " . $delete->getCustomerPaymentProfileID() . "\n"; echo " Update Time (UTC) : " . $delete->getUpdateTimeUTC() . "\n"; echo " Reason Code : " . $delete->getAuReasonCode() . "\n"; echo " Reason Description : " . $delete->getReasonDescription() . "\n"; diff --git a/TransactionReporting/get-account-updater-job-summary.php b/TransactionReporting/get-account-updater-job-summary.php index 010aa8d..7c59b99 100644 --- a/TransactionReporting/get-account-updater-job-summary.php +++ b/TransactionReporting/get-account-updater-job-summary.php @@ -17,7 +17,7 @@ function getAccountUpdaterJobSummary() $refId = 'ref' . time(); // Set a valid month for the request - $month = "2017-05"; + $month = "2017-07"; // Build tbe request object $request = new AnetAPI\GetAUJobSummaryRequest(); From eb787982d2ed4def0933748d87ab14d8c02e1c52 Mon Sep 17 00:00:00 2001 From: adavidw Date: Fri, 4 Aug 2017 07:08:17 -0600 Subject: [PATCH 067/149] add refId; formatting fixes --- .../get-an-accept-payment-page.php | 32 +++++++++---------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/PaymentTransactions/get-an-accept-payment-page.php b/PaymentTransactions/get-an-accept-payment-page.php index 461c1e5..d740970 100644 --- a/PaymentTransactions/get-an-accept-payment-page.php +++ b/PaymentTransactions/get-an-accept-payment-page.php @@ -18,10 +18,10 @@ function getAnAcceptPaymentPage() //create a transaction $transactionRequestType = new AnetAPI\TransactionRequestType(); - $transactionRequestType->setTransactionType("authCaptureTransaction"); + $transactionRequestType->setTransactionType("authCaptureTransaction"); $transactionRequestType->setAmount("12.23"); - // Set Hosted Form options + // Set Hosted Form options $setting1 = new AnetAPI\SettingType(); $setting1->setSettingName("hostedPaymentButtonOptions"); $setting1->setSettingValue("{\"text\": \"Pay\"}"); @@ -34,9 +34,10 @@ function getAnAcceptPaymentPage() $setting3->setSettingName("hostedPaymentReturnOptions"); $setting3->setSettingValue("{\"url\": \"https://mysite.com/receipt\", \"cancelUrl\": \"https://mysite.com/cancel\", \"showReceipt\": true}"); - // Build transaction request + // Build transaction request $request = new AnetAPI\GetHostedPaymentPageRequest(); $request->setMerchantAuthentication($merchantAuthentication); + $request->setRefId($refId); $request->setTransactionRequest($transactionRequestType); $request->addToHostedPaymentSettings($setting1); @@ -45,20 +46,17 @@ function getAnAcceptPaymentPage() //execute request $controller = new AnetController\GetHostedPaymentPageController($request); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); - if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) - { - echo $response->getToken()."\n"; - } - else - { - echo "ERROR : Failed to get hosted payment page token\n"; - $errorMessages = $response->getMessages()->getMessage(); - echo "RESPONSE : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok")) { + echo $response->getToken()."\n"; + } else { + echo "ERROR : Failed to get hosted payment page token\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "RESPONSE : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } return $response; - } - if(!defined('DONT_RUN_SAMPLES')) - getAnAcceptPaymentPage(); -?> +} +if (!defined('DONT_RUN_SAMPLES')) { + getAnAcceptPaymentPage(); +} From 54edfa85ab35b8a199ac792835bc6296ee355a6c Mon Sep 17 00:00:00 2001 From: adavidw Date: Tue, 26 Sep 2017 12:10:57 -0600 Subject: [PATCH 068/149] Rename directory to match the names used in the online API Reference guide --- .../authorization-and-capture-continue.php | 0 .../authorization-and-capture.php | 0 .../authorization-only-continued.php | 0 .../authorization-only.php | 0 {PaypalExpressCheckout => PayPalExpressCheckout}/credit.php | 0 .../get-details.php | 0 .../prior-authorization-capture.php | 0 {PaypalExpressCheckout => PayPalExpressCheckout}/void.php | 0 test-runner.php | 2 +- 9 files changed, 1 insertion(+), 1 deletion(-) rename {PaypalExpressCheckout => PayPalExpressCheckout}/authorization-and-capture-continue.php (100%) rename {PaypalExpressCheckout => PayPalExpressCheckout}/authorization-and-capture.php (100%) rename {PaypalExpressCheckout => PayPalExpressCheckout}/authorization-only-continued.php (100%) rename {PaypalExpressCheckout => PayPalExpressCheckout}/authorization-only.php (100%) rename {PaypalExpressCheckout => PayPalExpressCheckout}/credit.php (100%) rename {PaypalExpressCheckout => PayPalExpressCheckout}/get-details.php (100%) rename {PaypalExpressCheckout => PayPalExpressCheckout}/prior-authorization-capture.php (100%) rename {PaypalExpressCheckout => PayPalExpressCheckout}/void.php (100%) diff --git a/PaypalExpressCheckout/authorization-and-capture-continue.php b/PayPalExpressCheckout/authorization-and-capture-continue.php similarity index 100% rename from PaypalExpressCheckout/authorization-and-capture-continue.php rename to PayPalExpressCheckout/authorization-and-capture-continue.php diff --git a/PaypalExpressCheckout/authorization-and-capture.php b/PayPalExpressCheckout/authorization-and-capture.php similarity index 100% rename from PaypalExpressCheckout/authorization-and-capture.php rename to PayPalExpressCheckout/authorization-and-capture.php diff --git a/PaypalExpressCheckout/authorization-only-continued.php b/PayPalExpressCheckout/authorization-only-continued.php similarity index 100% rename from PaypalExpressCheckout/authorization-only-continued.php rename to PayPalExpressCheckout/authorization-only-continued.php diff --git a/PaypalExpressCheckout/authorization-only.php b/PayPalExpressCheckout/authorization-only.php similarity index 100% rename from PaypalExpressCheckout/authorization-only.php rename to PayPalExpressCheckout/authorization-only.php diff --git a/PaypalExpressCheckout/credit.php b/PayPalExpressCheckout/credit.php similarity index 100% rename from PaypalExpressCheckout/credit.php rename to PayPalExpressCheckout/credit.php diff --git a/PaypalExpressCheckout/get-details.php b/PayPalExpressCheckout/get-details.php similarity index 100% rename from PaypalExpressCheckout/get-details.php rename to PayPalExpressCheckout/get-details.php diff --git a/PaypalExpressCheckout/prior-authorization-capture.php b/PayPalExpressCheckout/prior-authorization-capture.php similarity index 100% rename from PaypalExpressCheckout/prior-authorization-capture.php rename to PayPalExpressCheckout/prior-authorization-capture.php diff --git a/PaypalExpressCheckout/void.php b/PayPalExpressCheckout/void.php similarity index 100% rename from PaypalExpressCheckout/void.php rename to PayPalExpressCheckout/void.php diff --git a/test-runner.php b/test-runner.php index 9bfc09a..587f5e9 100644 --- a/test-runner.php +++ b/test-runner.php @@ -14,7 +14,7 @@ $directories = array( 'CustomerProfiles/', 'RecurringBilling/', - 'PaypalExpressCheckout/', + 'PayPalExpressCheckout/', 'PaymentTransactions/', 'TransactionReporting/', 'MobileInappTransactions/', From 9a1f224124f472d512682de4f755c09f0ed64988 Mon Sep 17 00:00:00 2001 From: adavidw Date: Tue, 10 Oct 2017 11:47:04 -0600 Subject: [PATCH 069/149] formatting --- .../get-customer-payment-profile-list.php | 130 +++++++++--------- .../get-an-accept-payment-page.php | 4 +- .../get-account-updater-job-summary.php | 2 +- 3 files changed, 67 insertions(+), 69 deletions(-) diff --git a/CustomerProfiles/get-customer-payment-profile-list.php b/CustomerProfiles/get-customer-payment-profile-list.php index 4c2a2a4..71aa92b 100644 --- a/CustomerProfiles/get-customer-payment-profile-list.php +++ b/CustomerProfiles/get-customer-payment-profile-list.php @@ -1,10 +1,11 @@ setLimit("1000"); - $paging->setOffset("1"); - - //Setting the sorting - $sorting = new AnetAPI\CustomerPaymentProfileSortingType(); - $sorting->setOrderBy("id"); - $sorting->setOrderDescending(false); - - //Creating the request with the required parameters - $request = new AnetAPI\GetCustomerPaymentProfileListRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setRefId($refId); - $request->setPaging($paging); - $request->setSorting($sorting); - $request->setSearchType("cardsExpiringInMonth"); - $request->setMonth("2020-12"); - - // Controller - $controller = new AnetController\GetCustomerPaymentProfileListController($request); - // Getting the response - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - - if(($response != null)) - { - if ($response->getMessages()->getResultCode() == "Ok") - { - // Success - echo "GetCustomerPaymentProfileList SUCCESS: " . "\n"; - $errorMessages = $response->getMessages()->getMessage(); - echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; - echo "Total number of Results in the result set" . $response->getTotalNumInResultSet() . "\n"; - // Displaying the customer payment profile list - foreach($response->getPaymentProfiles() as $paymentProfile ) - { - echo "\nCustomer Profile id: " . $paymentProfile->getCustomerProfileId() . "\n"; - echo "Payment profile id: " . $paymentProfile->getCustomerPaymentProfileId() . "\n"; - echo "Credit Card Number: " . $paymentProfile->getPayment()->getCreditCard()->getCardNumber() . "\n"; - if($paymentProfile->getBillTo() != null) - echo "First Name in Billing Address: " . $paymentProfile->getBillTo()->getFirstName() . "\n"; - } - } - else - { - // Error - echo "GetCustomerPaymentProfileList ERROR : Invalid response\n"; - $errorMessages = $response->getMessages()->getMessage(); - echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; - } - } - else - { - // Failed to get the response - echo "NULL Response Error"; - } - return $response; - } - if(!defined('DONT_RUN_SAMPLES')) - getCustomerPaymentProfileList(); -?> + + //Setting the paging + $paging = new AnetAPI\PagingType(); + $paging->setLimit("1000"); + $paging->setOffset("1"); + + //Setting the sorting + $sorting = new AnetAPI\CustomerPaymentProfileSortingType(); + $sorting->setOrderBy("id"); + $sorting->setOrderDescending(false); + + //Creating the request with the required parameters + $request = new AnetAPI\GetCustomerPaymentProfileListRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setRefId($refId); + $request->setPaging($paging); + $request->setSorting($sorting); + $request->setSearchType("cardsExpiringInMonth"); + $request->setMonth("2020-12"); + + // Controller + $controller = new AnetController\GetCustomerPaymentProfileListController($request); + // Getting the response + $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); + + if (($response != null)) { + if ($response->getMessages()->getResultCode() == "Ok") { + // Success + echo "GetCustomerPaymentProfileList SUCCESS: " . "\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; + echo "Total number of Results in the result set" . $response->getTotalNumInResultSet() . "\n"; + // Displaying the customer payment profile list + foreach ($response->getPaymentProfiles() as $paymentProfile) { + echo "\nCustomer Profile ID: " . $paymentProfile->getCustomerProfileId() . "\n"; + echo "Payment profile ID: " . $paymentProfile->getCustomerPaymentProfileId() . "\n"; + echo "Credit Card Number: " . $paymentProfile->getPayment()->getCreditCard()->getCardNumber() . "\n"; + if ($paymentProfile->getBillTo() != null) { + echo "First Name in Billing Address: " . $paymentProfile->getBillTo()->getFirstName() . "\n"; + } + } + } else { + // Error + echo "GetCustomerPaymentProfileList ERROR : Invalid response\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; + } + } else { + // Failed to get the response + echo "NULL Response Error"; + } + return $response; +} + +if (!defined('DONT_RUN_SAMPLES')) { + getCustomerPaymentProfileList(); +} diff --git a/PaymentTransactions/get-an-accept-payment-page.php b/PaymentTransactions/get-an-accept-payment-page.php index d740970..6d600be 100644 --- a/PaymentTransactions/get-an-accept-payment-page.php +++ b/PaymentTransactions/get-an-accept-payment-page.php @@ -32,7 +32,9 @@ function getAnAcceptPaymentPage() $setting3 = new AnetAPI\SettingType(); $setting3->setSettingName("hostedPaymentReturnOptions"); - $setting3->setSettingValue("{\"url\": \"https://mysite.com/receipt\", \"cancelUrl\": \"https://mysite.com/cancel\", \"showReceipt\": true}"); + $setting3->setSettingValue( + "{\"url\": \"https://mysite.com/receipt\", \"cancelUrl\": \"https://mysite.com/cancel\", \"showReceipt\": true}" + ); // Build transaction request $request = new AnetAPI\GetHostedPaymentPageRequest(); diff --git a/TransactionReporting/get-account-updater-job-summary.php b/TransactionReporting/get-account-updater-job-summary.php index 7c59b99..cca6160 100644 --- a/TransactionReporting/get-account-updater-job-summary.php +++ b/TransactionReporting/get-account-updater-job-summary.php @@ -26,7 +26,7 @@ function getAccountUpdaterJobSummary() $controller = new AnetController\GetAUJobSummaryController($request); - // Retrieving summary for the given month + // Get the response from the service (errors contained if any) $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); if (($response != null) && ($response->getMessages()->getResultCode() == "Ok")) { From 2fdff6a84fa9d92b0e8aaadafa9a1886ffa739ec Mon Sep 17 00:00:00 2001 From: adavidw Date: Wed, 11 Oct 2017 10:34:48 -0600 Subject: [PATCH 070/149] update banking information for echeck transactions --- PaymentTransactions/credit-bank-account.php | 7 ++++--- PaymentTransactions/debit-bank-account.php | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/PaymentTransactions/credit-bank-account.php b/PaymentTransactions/credit-bank-account.php index 8127183..656e320 100644 --- a/PaymentTransactions/credit-bank-account.php +++ b/PaymentTransactions/credit-bank-account.php @@ -19,11 +19,12 @@ function creditBankAccount($amount) // Create the payment data for a Bank Account $bankAccount = new AnetAPI\BankAccountType(); $bankAccount->setAccountType('checking'); - // $bankAccount->setEcheckType('WEB'); + // see eCheck documentation for proper echeck type to use for each situation + $bankAccount->setEcheckType('PPD'); $bankAccount->setRoutingNumber('121042882'); - $bankAccount->setAccountNumber('12345678'); + $bankAccount->setAccountNumber('123456789'); $bankAccount->setNameOnAccount('John Doe'); - $bankAccount->setBankName('Bank of the Earth'); + $bankAccount->setBankName('Wells Fargo Bank NA'); $paymentBank= new AnetAPI\PaymentType(); $paymentBank->setBankAccount($bankAccount); diff --git a/PaymentTransactions/debit-bank-account.php b/PaymentTransactions/debit-bank-account.php index a53f111..98d1d37 100644 --- a/PaymentTransactions/debit-bank-account.php +++ b/PaymentTransactions/debit-bank-account.php @@ -19,11 +19,12 @@ function debitBankAccount($amount) // Create the payment data for a Bank Account $bankAccount = new AnetAPI\BankAccountType(); $bankAccount->setAccountType('checking'); - // $bankAccount->setEcheckType('WEB'); + // see eCheck documentation for proper echeck type to use for each situation + $bankAccount->setEcheckType('WEB'); $bankAccount->setRoutingNumber('121042882'); - $bankAccount->setAccountNumber('12345678'); + $bankAccount->setAccountNumber('123456789'); $bankAccount->setNameOnAccount('John Doe'); - $bankAccount->setBankName('Bank of the Earth'); + $bankAccount->setBankName('Wells Fargo Bank NA'); $paymentBank= new AnetAPI\PaymentType(); $paymentBank->setBankAccount($bankAccount); From a48aaafeee1fdfbeb4c1e62b7bf2a28788f9e07d Mon Sep 17 00:00:00 2001 From: adavidw Date: Tue, 17 Oct 2017 12:27:12 -0600 Subject: [PATCH 071/149] unify format and wording of README files --- README.md | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 5c11440..e2d07b6 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,9 @@ -# Sample PHP Code for Authorize.Net -[![Travis](https://img.shields.io/travis/AuthorizeNet/sample-code-php/master.svg)](https://travis-ci.org/AuthorizeNet/sample-code-php) +# Sample PHP Sample Code for the Authorize.Net SDK +[![Travis CI Status](https://travis-ci.org/AuthorizeNet/sample-code-php.svg?branch=master)](https://travis-ci.org/AuthorizeNet/sample-code-php) This repository contains working code samples which demonstrate PHP integration with the [Authorize.Net PHP SDK](https://github.com/AuthorizeNet/sdk-php). -The samples are organized just like our API, which you can also try out directly at our [API Reference Guide](http://developer.authorize.net/api/reference). + +The samples are organized into categories and common usage examples, just like our [API Reference Guide](http://developer.authorize.net/api/reference). Our API Reference Guide is an interactive reference for the Authorize.Net API. It explains the request and response parameters for each API method and has embedded code windows to allow you to send actual requests right within the API Reference Guide. ## Using the Sample Code @@ -12,19 +13,24 @@ The samples are all completely independent and self-contained. You can analyze t You can also run each sample directly from the command line. ## Running the Samples From the Command Line -Clone this repository. +* Clone this repository: ``` $ git clone https://github.com/AuthorizeNet/sample-code-php.git -``` -Run composer with the "update" option in the root directory of the repository. +``` +* Run composer with the "update" option in the root directory of the repository. ``` $ composer update -``` -Run the individual samples e.g. +``` +* Run the individual samples by name. For example: +``` + $ php PaymentTransactions/[CodeSampleName] +``` +e.g. ``` $ php PaymentTransactions/charge-credit-card.php ``` -## Installation Notes + +### Installation Notes Note: If during "composer update", you get the error "composer failed to open stream invalid argument", go to your php.ini file (present where you have installed PHP), and uncomment the following lines: ``` extension=php_openssl.dll From 5172f525729826fe9b1a4a5a5791cdf20c8d6ce8 Mon Sep 17 00:00:00 2001 From: adavidw Date: Tue, 17 Oct 2017 14:27:53 -0600 Subject: [PATCH 072/149] remove extra word --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e2d07b6..99bb4ff 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Sample PHP Sample Code for the Authorize.Net SDK +# PHP Sample Code for the Authorize.Net SDK [![Travis CI Status](https://travis-ci.org/AuthorizeNet/sample-code-php.svg?branch=master)](https://travis-ci.org/AuthorizeNet/sample-code-php) This repository contains working code samples which demonstrate PHP integration with the [Authorize.Net PHP SDK](https://github.com/AuthorizeNet/sdk-php). From 8efa59d116a9c42d8de9b0b43b950cb38243970e Mon Sep 17 00:00:00 2001 From: truefusion Date: Thu, 26 Oct 2017 14:28:42 -0400 Subject: [PATCH 073/149] Transaction ID required! Without the transaction ID passed to $transactionRequest, the request will fail every time, saying, "The credit card number is invalid." --- PaymentTransactions/refund-transaction.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/PaymentTransactions/refund-transaction.php b/PaymentTransactions/refund-transaction.php index 6050ca8..5ea21d0 100644 --- a/PaymentTransactions/refund-transaction.php +++ b/PaymentTransactions/refund-transaction.php @@ -5,7 +5,7 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); -function refundTransaction($amount) +function refundTransaction($refTransId, $amount) { /* Create a merchantAuthenticationType object with authentication details retrieved from the constants file */ @@ -27,6 +27,7 @@ function refundTransaction($amount) $transactionRequest->setTransactionType( "refundTransaction"); $transactionRequest->setAmount($amount); $transactionRequest->setPayment($paymentOne); + $transactionRequest->setRefTransId($refTransId); $request = new AnetAPI\CreateTransactionRequest(); @@ -84,4 +85,4 @@ function refundTransaction($amount) } if(!defined('DONT_RUN_SAMPLES')) refundTransaction( \SampleCode\Constants::SAMPLE_AMOUNT_REFUND); -?> \ No newline at end of file +?> From abf946682e4c1d2a6ca788d8afd049b4141e9e47 Mon Sep 17 00:00:00 2001 From: adavidw Date: Wed, 8 Nov 2017 11:32:01 -0700 Subject: [PATCH 074/149] Match the names as used in the API Reference --- ...e-continue.php => authorization-and-capture-continued.php} | 4 ++-- test-runner.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) rename PayPalExpressCheckout/{authorization-and-capture-continue.php => authorization-and-capture-continued.php} (96%) diff --git a/PayPalExpressCheckout/authorization-and-capture-continue.php b/PayPalExpressCheckout/authorization-and-capture-continued.php similarity index 96% rename from PayPalExpressCheckout/authorization-and-capture-continue.php rename to PayPalExpressCheckout/authorization-and-capture-continued.php index 10b5fe2..763a365 100644 --- a/PayPalExpressCheckout/authorization-and-capture-continue.php +++ b/PayPalExpressCheckout/authorization-and-capture-continued.php @@ -5,7 +5,7 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); -function payPalAuthorizeCaptureContinue($refTransId, $payerID) +function payPalAuthorizeCaptureContinued($refTransId, $payerID) { /* Create a merchantAuthenticationType object with authentication details retrieved from the constants file */ @@ -86,5 +86,5 @@ function payPalAuthorizeCaptureContinue($refTransId, $payerID) } if(!defined('DONT_RUN_SAMPLES')) - payPalAuthorizeCaptureContinue("2241708986","6ZSCSYG33VP8Q"); + payPalAuthorizeCaptureContinued("2241708986","6ZSCSYG33VP8Q"); ?> diff --git a/test-runner.php b/test-runner.php index 587f5e9..981f950 100644 --- a/test-runner.php +++ b/test-runner.php @@ -190,10 +190,10 @@ private static function runPayPalAuthorizeCapture() return payPalAuthorizeCapture(self::getAmount()); } - private static function runPayPalAuthorizeCaptureContinue() + private static function runPayPalAuthorizeCaptureContinued() { $response = payPalAuthorizeCapture(self::getAmount()); - return payPalAuthorizeCaptureContinue($response->getTransactionResponse()->getTransId(), self::$payerID); + return payPalAuthorizeCaptureContinued($response->getTransactionResponse()->getTransId(), self::$payerID); } public static function runPayPalAuthorizeOnlyContinue() From f513ad21675a88a2af547688f8ca37010e800652 Mon Sep 17 00:00:00 2001 From: adavidw Date: Wed, 8 Nov 2017 12:10:12 -0700 Subject: [PATCH 075/149] Match the names as used in the API Reference --- .../authorization-and-capture-continued.php | 119 ++- .../authorization-only-continued.php | 98 +-- SampleCodeList.txt | 4 +- test-runner.php | 803 +++++++++--------- 4 files changed, 518 insertions(+), 506 deletions(-) diff --git a/PayPalExpressCheckout/authorization-and-capture-continued.php b/PayPalExpressCheckout/authorization-and-capture-continued.php index 763a365..9318235 100644 --- a/PayPalExpressCheckout/authorization-and-capture-continued.php +++ b/PayPalExpressCheckout/authorization-and-capture-continued.php @@ -1,7 +1,7 @@ setPayerID($payerID); - $paymentOne = new AnetAPI\PaymentType(); - $paymentOne->setPayPal($payPalType); + $paymentOne = new AnetAPI\PaymentType(); + $paymentOne->setPayPal($payPalType); - // Create an authorize and capture continue transaction - $transactionRequestType = new AnetAPI\TransactionRequestType(); - $transactionRequestType->setTransactionType( "authCaptureContinueTransaction"); - $transactionRequestType->setPayment($paymentOne); - $transactionRequestType->setRefTransId($refTransId); + // Create an authorize and capture continued transaction + $transactionRequestType = new AnetAPI\TransactionRequestType(); + $transactionRequestType->setTransactionType("authCaptureContinueTransaction"); + $transactionRequestType->setPayment($paymentOne); + $transactionRequestType->setRefTransId($refTransId); - $request = new AnetAPI\CreateTransactionRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setTransactionRequest( $transactionRequestType); - $controller = new AnetController\CreateTransactionController($request); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + $request = new AnetAPI\CreateTransactionRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setTransactionRequest($transactionRequestType); + $controller = new AnetController\CreateTransactionController($request); + $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); - if ($response != null) - { - if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) - { - $tresponse = $response->getTransactionResponse(); - - if ($tresponse != null && $tresponse->getMessages() != null) - { - echo "Transaction Response...\n"; - echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; - //Valid response codes: 1=Approved, 2=Declined, 3=Error, 5=Need Payer Consent - echo "Secure acceptance URL: ".$tresponse->getSecureAcceptance()->getSecureAcceptanceUrl()."\n"; - echo "Transaction ID: ".$tresponse->getTransId()."\n"; - echo " Code : " . $tresponse->getMessages()[0]->getCode() . "\n"; - echo " Description : " . $tresponse->getMessages()[0]->getDescription() . "\n"; - } - else - { - echo "Transaction Failed \n"; - if($tresponse->getErrors() != null) - { - echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; - echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; - } - } - } - else - { - echo "Transaction Failed \n"; - $tresponse = $response->getTransactionResponse(); - if($tresponse != null && $tresponse->getErrors() != null) - { - echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; - echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; - } - else - { - echo " Error code : " . $response->getMessages()->getMessage()[0]->getCode() . "\n"; - echo " Error message : " . $response->getMessages()->getMessage()[0]->getText() . "\n"; - } - } - } - else - { - echo "No response returned \n"; - } + if ($response != null) { + if ($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { + $tresponse = $response->getTransactionResponse(); + + if ($tresponse != null && $tresponse->getMessages() != null) { + echo "Transaction Response...\n"; + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + //Valid response codes: 1=Approved, 2=Declined, 3=Error, 5=Need Payer Consent + echo "Secure acceptance URL: ".$tresponse->getSecureAcceptance()->getSecureAcceptanceUrl()."\n"; + echo "Transaction ID: ".$tresponse->getTransId()."\n"; + echo " Code : " . $tresponse->getMessages()[0]->getCode() . "\n"; + echo " Description : " . $tresponse->getMessages()[0]->getDescription() . "\n"; + } else { + echo "Transaction Failed \n"; + if ($tresponse->getErrors() != null) { + echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; + echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; + } + } + } else { + echo "Transaction Failed \n"; + $tresponse = $response->getTransactionResponse(); + if ($tresponse != null && $tresponse->getErrors() != null) { + echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; + echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; + } else { + echo " Error code : " . $response->getMessages()->getMessage()[0]->getCode() . "\n"; + echo " Error message : " . $response->getMessages()->getMessage()[0]->getText() . "\n"; + } + } + } else { + echo "No response returned \n"; + } - return $response; - } + return $response; +} - if(!defined('DONT_RUN_SAMPLES')) - payPalAuthorizeCaptureContinued("2241708986","6ZSCSYG33VP8Q"); -?> +if (!defined('DONT_RUN_SAMPLES')) { + payPalAuthorizeCaptureContinued("2241708986", "6ZSCSYG33VP8Q"); +} diff --git a/PayPalExpressCheckout/authorization-only-continued.php b/PayPalExpressCheckout/authorization-only-continued.php index fb04c99..d276772 100644 --- a/PayPalExpressCheckout/authorization-only-continued.php +++ b/PayPalExpressCheckout/authorization-only-continued.php @@ -1,15 +1,15 @@ setPayerID($payerID); - $paypal_type->setSuccessUrl("http://www.merchanteCommerceSite.com/Success/TC25262"); + $paypal_type->setSuccessUrl("http://www.merchanteCommerceSite.com/Success/TC25262"); $paypal_type->setCancelUrl("http://www.merchanteCommerceSite.com/Success/TC25262"); $payment_type = new AnetAPI\PaymentType(); @@ -32,68 +32,54 @@ function payPalAuthorizeOnlyContinue($transactionId, $payerId) //create a transaction $transactionRequestType = new AnetAPI\TransactionRequestType(); - $transactionRequestType->setTransactionType( "authOnlyContinueTransaction"); + $transactionRequestType->setTransactionType("authOnlyContinueTransaction"); $transactionRequestType->setRefTransId($transactionId); $transactionRequestType->setAmount(125.34); $transactionRequestType->setPayment($payment_type); $request = new AnetAPI\CreateTransactionRequest(); $request->setMerchantAuthentication($merchantAuthentication); - $request->setRefId( $refId); - $request->setTransactionRequest( $transactionRequestType); + $request->setRefId($refId); + $request->setTransactionRequest($transactionRequestType); $controller = new AnetController\CreateTransactionController($request); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); - if ($response != null) - { - if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) - { - $tresponse = $response->getTransactionResponse(); + if ($response != null) { + if ($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { + $tresponse = $response->getTransactionResponse(); - if ($tresponse != null && $tresponse->getMessages() != null) - { - echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; - echo "TRANS ID : " . $tresponse->getTransId() . "\n"; - echo "Payer ID : " . $tresponse->getSecureAcceptance()->getPayerID(); - echo "Description : " . $tresponse->getMessages()[0]->getDescription() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) { + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + echo "TRANS ID : " . $tresponse->getTransId() . "\n"; + echo "Payer ID : " . $tresponse->getSecureAcceptance()->getPayerID(); + echo "Description : " . $tresponse->getMessages()[0]->getDescription() . "\n"; + } else { + echo "Transaction Failed \n"; + if ($tresponse->getErrors() != null) { + echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; + echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; + } + } + } else { + echo "Transaction Failed \n"; + $tresponse = $response->getTransactionResponse(); + if ($tresponse != null && $tresponse->getErrors() != null) { + echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; + echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; + } else { + echo " Error code : " . $response->getMessages()->getMessage()[0]->getCode() . "\n"; + echo " Error message : " . $response->getMessages()->getMessage()[0]->getText() . "\n"; + } } - else - { - echo "Transaction Failed \n"; - if($tresponse->getErrors() != null) - { - echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; - echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; - } - } - } - else - { - echo "Transaction Failed \n"; - $tresponse = $response->getTransactionResponse(); - if($tresponse != null && $tresponse->getErrors() != null) - { - echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; - echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; - } - else - { - echo " Error code : " . $response->getMessages()->getMessage()[0]->getCode() . "\n"; - echo " Error message : " . $response->getMessages()->getMessage()[0]->getText() . "\n"; - } - } - } - else - { - echo "No response returned \n"; + } else { + echo "No response returned \n"; } return $response; - } +} - if(!defined('DONT_RUN_SAMPLES')) - payPalAuthorizeOnlyContinue("2241711631", "JJLRRB29QC7RU"); - -?> +if (!defined('DONT_RUN_SAMPLES')) { + payPalAuthorizeOnlyContinued("2241711631", "JJLRRB29QC7RU"); +} diff --git a/SampleCodeList.txt b/SampleCodeList.txt index 50dad36..8f524f3 100644 --- a/SampleCodeList.txt +++ b/SampleCodeList.txt @@ -40,8 +40,8 @@ CreditBankAccount,1,0 ChargeCustomerProfile,1,1 PayPalVoid,1,0 PayPalAuthorizeCapture,1,1 -PayPalAuthorizeCaptureContinue,1,1 -PayPalAuthorizeOnlyContinue,1,0 +PayPalAuthorizeCaptureContinued,1,1 +PayPalAuthorizeOnlyContinued,1,0 PayPalCredit,1,0 PayPalGetDetails,1,1 PayPalPriorAuthorizationCapture,1,0 diff --git a/test-runner.php b/test-runner.php index 981f950..0dd0391 100644 --- a/test-runner.php +++ b/test-runner.php @@ -3,13 +3,14 @@ define("SAMPLE_CODE_NAME_HEADING", "SampleCodeName"); require 'vendor/autoload.php'; -if ( $_SERVER['argc'] != 3 ) { - die('\n Usage: phpunit test-runner.php '); -} +if ($_SERVER['argc'] != 3) { + die('\n Usage: phpunit test-runner.php '); +} $dirPath = $_SERVER['argv'][2]; echo $dirPath; -if(substr($dirPath, -1) != "/") - $dirPath = $dirPath."/"; +if (substr($dirPath, -1) != "/") { + $dirPath = $dirPath."/"; +} $directories = array( 'CustomerProfiles/', @@ -24,388 +25,426 @@ $errorlevel=error_reporting(); error_reporting($errorlevel & ~E_NOTICE); //turn off constant re-defined and other notices foreach ($directories as $directory) { - foreach(glob($dirPath.$directory . "*.php") as $sample) { + foreach (glob($dirPath.$directory . "*.php") as $sample) { require_once $sample; - //echo $sample; + //echo $sample; } } error_reporting($errorlevel); class TestRunner extends PHPUnit\Framework\TestCase { - public static $apiLoginId = "5KP3u95bQpv"; - public static $transactionKey = "346HZ32z3fP4hTG2"; - public static $transactionID = "2245440957"; - public static $payerID = "LM6NCLZ5RAKBY"; - //random amount for transactions/subscriptions - public static function getAmount(){ - return 12 + (rand(1, 900000)/12); - } - //random email for a new customer profile - public static function getEmail(){ - return rand(0,10000) . "@test" .rand(0,10000) .".com"; - } - //random phonenumber for customer payment profile - public static function getPhoneNumber(){ - return self::toPhoneNumber(rand(0,9999999999)); - } - public static function getDay(){ - return rand(7, 365); - } - public function testAllSampleCodes(){ - $runTests = 0; - - $file = $GLOBALS["dirPath"]."SampleCodeList.txt"; - $data = file($file) or die('\nCould not read SampleCodeList.'); - foreach ($data as $line) - { - $line=trim($line); - if(trim($line)) - { - list($apiName, $isDependent, $shouldRun)=explode(",",$line); - $apiName = trim($apiName); - echo "\nApi name: " . $apiName."\n"; - } - if($apiName && (false === strpos($apiName,SAMPLE_CODE_NAME_HEADING))) - { - - - echo "should run:".$shouldRun."\n"; - if("0" === $shouldRun) - { - echo ":Skipping " . $sampleMethodName . "\n"; - } - else - { - for($i=0; $i<=1; $i++) - { - if("0" === $isDependent) - { - echo "not dependent\n"; - $sampleMethodName = $apiName; - $sampleMethodName[0] = strtolower($sampleMethodName[0]); - } - else - { - $sampleMethodName = "TestRunner::run" . $apiName; - echo " is dependent\n"; - } - - //request the api - echo "Running sample: " . $sampleMethodName . "\n"; - - $response = call_user_func($sampleMethodName); - - if(($response != null) && ($response->getMessages()->getResultCode() == "Ok")) - break; - } - - //response must be successful - $this->assertNotNull($response); - $this->assertEquals($response->getMessages()->getResultCode(), "Ok"); - $runTests++; - } - } - } - echo "Number of sample codes run: ". $runTests; - } - - private static function toPhoneNumber($num) - { - $zeroPadded = sprintf("%10d", $num); - return substr($zeroPadded,0,3)."-".substr($zeroPadded,3,3)."-".substr(6,4); - } - - public static function runAuthorizeCreditCard() - { - return authorizeCreditCard(self::getAmount()); - } - - public static function runCaptureFundsAuthorizedThroughAnotherChannel() - { - return captureFundsAuthorizedThroughAnotherChannel(self::getAmount()); - } - - public static function runDebitBankAccount() - { - return debitBankAccount(self::getAmount()%98+1); //cannot debit more than 100 - } - - public static function runChargeTokenizedCreditCard() - { - return chargeTokenizedCreditCard(self::getAmount()); - } - - public static function runCreateAnAcceptPaymentTransaction() - { - return createAnAcceptPaymentTransaction(self::getAmount()); - } - - public static function runChargeCreditCard() - { - return chargeCreditCard(self::getAmount()); - } - - public static function runCapturePreviouslyAuthorizedAmount() - { - $response = authorizeCreditCard(self::getAmount()); - return capturePreviouslyAuthorizedAmount($response->getTransactionResponse()->getTransId()); - } - - public static function runRefundTransaction() - { - $response = authorizeCreditCard.run(self::getAmount()); - $response = capturePreviouslyAuthorizedAmount($response->getTransactionResponse()->getTransId()); - return refundTransaction(self::getAmount()); - } - - public static function runVoidTransaction() - { - $response = authorizeCreditCard(self::getAmount()); - return voidTransaction($response->getTransactionResponse()->getTransId()); - } - - public static function runCreditBankAccount() - { - return creditBankAccount(self::getAmount()); - } - - public static function runChargeCustomerProfile() - { - $response = createCustomerProfile(self::getEmail()); - $paymentProfileResponse = createCustomerPaymentProfile($response->getCustomerProfileId(), self::getPhoneNumber()); - $chargeResponse = chargeCustomerProfile($response->getCustomerProfileId(), $paymentProfileResponse->getCustomerPaymentProfileId(), self::getAmount()); - deleteCustomerProfile($response->getCustomerProfileId()); - - return $chargeResponse; - } - - private static function runPayPalVoid() { - $response = payPalAuthorizeCapture(self::getAmount()); - return payPalVoid($response->getTransactionResponse()->getTransId()); - } - - private static function runPayPalAuthorizeCapture() - { - return payPalAuthorizeCapture(self::getAmount()); - } - - private static function runPayPalAuthorizeCaptureContinued() - { - $response = payPalAuthorizeCapture(self::getAmount()); - return payPalAuthorizeCaptureContinued($response->getTransactionResponse()->getTransId(), self::$payerID); - } - - public static function runPayPalAuthorizeOnlyContinue() - { - return payPalAuthorizeOnlyContinue(self::$transactionID, self::$payerID); - } - - public static function runPayPalCredit() { - return payPalCredit(self::$transactionID); - } - - public static function runPayPalAuthorizeOnly() - { - return payPalAuthorizeOnly(self::getAmount()); - } - - public static function runPayPalGetDetails() - { - $response = payPalAuthorizeCapture(self::getAmount()); - return payPalGetDetails($response->getTransactionResponse()->getTransId()); - } - - public static function runPayPalPriorAuthorizationCapture() - { - $response = payPalAuthorizeCapture(self::getAmount()); - return payPalPriorAuthorizationCapture($response->getTransactionResponse()->getTransId()); - } - - public static function runGetTransactionDetails() - { - $response = authorizeCreditCard(self::getAmount()); - return getTransactionDetails($response->getTransactionResponse()->getTransId()); - } - - - public static function runCreateSubscription() - { - $response = createSubscription(self::getDay()); - cancelSubscription($response->getSubscriptionId()); - - return $response; - } - - public static function runCreateSubscriptionFromCustomerProfile() - { - $responseCustomerProfile = createCustomerProfile(self::getEmail()); - $responseCustomerPaymentProfile = createCustomerPaymentProfile($responseCustomerProfile->getCustomerProfileId(), self::getPhoneNumber()); - $responseCustomerShippingAddress = createCustomerShippingAddress($responseCustomerProfile->getCustomerProfileId(), self::getPhoneNumber()); - - $response = createSubscription(self::getDay(), $responseCustomerProfile->getCustomerProfileId(), - $responseCustomerPaymentProfile->getCustomerPaymentProfileId(), $responseCustomerShippingAddress->getCustomerAddressId()); - - cancelSubscription($response->getSubscriptionId()); - deleteCustomerProfile($responseCustomerProfile->getCustomerProfileId()); - - return $response; - } - - public static function runCancelSubscription() - { - $response = createSubscription(self::getDay()); - return cancelSubscription($response->getSubscriptionId()); - } - - public static function runGetSubscriptionStatus() - { - $response = createSubscription(self::getDay()); - $status_response = getSubscriptionStatus($response->getSubscriptionId()); - cancelSubscription($response->getSubscriptionId()); - - return $status_response; - } - - public static function runGetSubscription() - { - $response = createSubscription(self::getDay()); - $status_response = getSubscription($response->getSubscriptionId()); - cancelSubscription($response->getSubscriptionId()); - - return $status_response; - } - - public static function runUpdateSubscription() - { - $response = createSubscription(self::getDay()); - $update_response = updateSubscription($response->getSubscriptionId()); - cancelSubscription($response->getSubscriptionId()); - - return $update_response; - } - - //customer profiles methods - public static function runCreateCustomerProfile(){ - - $response = createCustomerProfile(self::getEmail()); - deleteCustomerProfile($response->getCustomerProfileId()); - return $response; - } - - public static function runDeleteCustomerProfile(){ - - $responseCustomerProfile = createCustomerProfile(self::getEmail()); - return deleteCustomerProfile($responseCustomerProfile->getCustomerProfileId()); - } - - public static function runGetCustomerProfile(){ - - $responseCustomerProfile = createCustomerProfile(self::getEmail()); - $response = getCustomerProfile($responseCustomerProfile->getCustomerProfileId()); - deleteCustomerProfile($responseCustomerProfile->getCustomerProfileId()); - return $response; - } - - // public static function runUpdateCustomerProfile(){ - // $responseCustomerProfile = createCustomerProfile(self::getEmail()); - // $customerProfileId = $responseCustomerProfile->getCustomerProfileId(); - // $response = updateCustomerProfileById($customerProfileId); - // deleteCustomerProfile($customerProfileId); - // return $response; - // } - //customer profiles - payment profiles methods - - public static function runCreateCustomerPaymentProfile() - { - $responseCustomerProfile = createCustomerProfile(self::getEmail()); - $response=createCustomerPaymentProfile($responseCustomerProfile->getCustomerProfileId(), self::getPhoneNumber()); - deleteCustomerProfile($responseCustomerProfile->getCustomerProfileId()); - return $response; - } - - public static function runGetCustomerPaymentProfile() - { - $customerProfileId = createCustomerProfile(self::getEmail())->getCustomerProfileId(); - $customerPaymentProfileId = createCustomerPaymentProfile($customerProfileId, self::getPhoneNumber())->getCustomerPaymentProfileId(); - $response= getCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId); - deleteCustomerProfile($customerProfileId); - return $response; - } - - public static function runValidateCustomerPaymentProfile() - { - $customerProfileId = createCustomerProfile(self::getEmail())->getCustomerProfileId(); - $customerPaymentProfileId = createCustomerPaymentProfile($customerProfileId, self::getPhoneNumber())->getCustomerPaymentProfileId(); - $response = validateCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId); - deleteCustomerProfile($customerProfileId); - return $response; - } - - public static function runUpdateCustomerPaymentProfile() - { - $customerProfileId = createCustomerProfile(self::getEmail())->getCustomerProfileId(); - $customerPaymentProfileId = createCustomerPaymentProfile($customerProfileId, self::getPhoneNumber())->getCustomerPaymentProfileId(); - $response = updateCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId); - deleteCustomerProfile($customerProfileId); - return $response; - } - - public static function runDeleteCustomerPaymentProfile() - { - $customerProfileId = createCustomerProfile(self::getEmail())->getCustomerProfileId(); - $customerPaymentProfileId = createCustomerPaymentProfile($customerProfileId, self::getPhoneNumber())->getCustomerPaymentProfileId(); - $response = deleteCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId); - deleteCustomerProfile($customerProfileId); - return $response; - } - - //customer profiles - shipping address - public static function runCreateCustomerShippingAddress() - { - $customerProfileId = createCustomerProfile(self::getEmail())->getCustomerProfileId(); - $response = createCustomerShippingAddress($customerProfileId, self::getPhoneNumber()); - deleteCustomerProfile($customerProfileId); - return $response; - } - - public static function runDeleteCustomerShippingAddress() - { - $customerProfileId = createCustomerProfile(self::getEmail())->getCustomerProfileId(); - $responseCreateShipping = createCustomerShippingAddress($customerProfileId, self::getPhoneNumber()); - $response = deleteCustomerShippingAddress($customerProfileId, $responseCreateShipping->getCustomerAddressId()); - deleteCustomerProfile($customerProfileId); - return $response; - } - - public static function runUpdateCustomerShippingAddress() - { - $response = createCustomerProfile(self::getEmail()); - $shippingResponse = createCustomerShippingAddress($response->getCustomerProfileId()); - $updateResponse = updateCustomerShippingAddress($response->getCustomerProfileId(), $shippingResponse->getCustomerAddressId()); - deleteCustomerProfile($response->getCustomerProfileId()); - - return $updateResponse; - } - - public static function runGetCustomerShippingAddress() - { - $response = createCustomerProfile(self::getEmail()); - $shippingResponse = createCustomerShippingAddress($response->getCustomerProfileId()); - - $getResponse = getCustomerShippingAddress($response->getCustomerProfileId(), $shippingResponse->getCustomerAddressId()); - - deleteCustomerProfile($response->getCustomerProfileId()); - - return $getResponse; - } - - public static function runGetAcceptCustomerProfilePage() - { - $response = createCustomerProfile(self::getEmail()); - $profileResponse = GetAcceptCustomerProfilePage($response->getCustomerProfileId()); - deleteCustomerProfile($response->getCustomerProfileId()); - - return $profileResponse; - } + public static $apiLoginId = "5KP3u95bQpv"; + public static $transactionKey = "346HZ32z3fP4hTG2"; + public static $transactionID = "2245440957"; + public static $payerID = "LM6NCLZ5RAKBY"; + //random amount for transactions/subscriptions + public static function getAmount() + { + return 12 + (rand(1, 900000)/12); + } + //random email for a new customer profile + public static function getEmail() + { + return rand(0, 10000) . "@test" .rand(0, 10000) .".com"; + } + //random phonenumber for customer payment profile + public static function getPhoneNumber() + { + return self::toPhoneNumber(rand(0, 9999999999)); + } + public static function getDay() + { + return rand(7, 365); + } + public function testAllSampleCodes() + { + $runTests = 0; + + $file = $GLOBALS["dirPath"]."SampleCodeList.txt"; + $data = file($file) or die('\nCould not read SampleCodeList.'); + foreach ($data as $line) { + $line=trim($line); + if (trim($line)) { + list($apiName, $isDependent, $shouldRun)=explode(",", $line); + $apiName = trim($apiName); + echo "\nApi name: " . $apiName."\n"; + } + if ($apiName && (false === strpos($apiName, SAMPLE_CODE_NAME_HEADING))) { + echo "should run:".$shouldRun."\n"; + if ("0" === $shouldRun) { + echo ":Skipping " . $sampleMethodName . "\n"; + } else { + for ($i=0; $i<=1; $i++) { + if ("0" === $isDependent) { + echo "not dependent\n"; + $sampleMethodName = $apiName; + $sampleMethodName[0] = strtolower($sampleMethodName[0]); + } else { + $sampleMethodName = "TestRunner::run" . $apiName; + echo " is dependent\n"; + } + + //request the api + echo "Running sample: " . $sampleMethodName . "\n"; + + $response = call_user_func($sampleMethodName); + + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok")) { + break; + } + } + + //response must be successful + $this->assertNotNull($response); + $this->assertEquals($response->getMessages()->getResultCode(), "Ok"); + $runTests++; + } + } + } + echo "Number of sample codes run: ". $runTests; + } + + private static function toPhoneNumber($num) + { + $zeroPadded = sprintf("%10d", $num); + return substr($zeroPadded, 0, 3)."-".substr($zeroPadded, 3, 3)."-".substr(6, 4); + } + + public static function runAuthorizeCreditCard() + { + return authorizeCreditCard(self::getAmount()); + } + + public static function runCaptureFundsAuthorizedThroughAnotherChannel() + { + return captureFundsAuthorizedThroughAnotherChannel(self::getAmount()); + } + + public static function runDebitBankAccount() + { + return debitBankAccount(self::getAmount()%98+1); //cannot debit more than 100 + } + + public static function runChargeTokenizedCreditCard() + { + return chargeTokenizedCreditCard(self::getAmount()); + } + + public static function runCreateAnAcceptPaymentTransaction() + { + return createAnAcceptPaymentTransaction(self::getAmount()); + } + + public static function runChargeCreditCard() + { + return chargeCreditCard(self::getAmount()); + } + + public static function runCapturePreviouslyAuthorizedAmount() + { + $response = authorizeCreditCard(self::getAmount()); + return capturePreviouslyAuthorizedAmount($response->getTransactionResponse()->getTransId()); + } + + public static function runRefundTransaction() + { + $response = authorizeCreditCard.run(self::getAmount()); + $response = capturePreviouslyAuthorizedAmount($response->getTransactionResponse()->getTransId()); + return refundTransaction(self::getAmount()); + } + + public static function runVoidTransaction() + { + $response = authorizeCreditCard(self::getAmount()); + return voidTransaction($response->getTransactionResponse()->getTransId()); + } + + public static function runCreditBankAccount() + { + return creditBankAccount(self::getAmount()); + } + + public static function runChargeCustomerProfile() + { + $response = createCustomerProfile(self::getEmail()); + $paymentProfileResponse = createCustomerPaymentProfile( + $response->getCustomerProfileId(), + self::getPhoneNumber() + ); + $chargeResponse = chargeCustomerProfile( + $response->getCustomerProfileId(), + $paymentProfileResponse->getCustomerPaymentProfileId(), + self::getAmount() + ); + deleteCustomerProfile($response->getCustomerProfileId()); + + return $chargeResponse; + } + + private static function runPayPalVoid() + { + $response = payPalAuthorizeCapture(self::getAmount()); + return payPalVoid($response->getTransactionResponse()->getTransId()); + } + + private static function runPayPalAuthorizeCapture() + { + return payPalAuthorizeCapture(self::getAmount()); + } + + private static function runPayPalAuthorizeCaptureContinued() + { + $response = payPalAuthorizeCapture(self::getAmount()); + return payPalAuthorizeCaptureContinued($response->getTransactionResponse()->getTransId(), self::$payerID); + } + + public static function runPayPalAuthorizeOnlyContinued() + { + return payPalAuthorizeOnlyContinued(self::$transactionID, self::$payerID); + } + + public static function runPayPalCredit() + { + return payPalCredit(self::$transactionID); + } + + public static function runPayPalAuthorizeOnly() + { + return payPalAuthorizeOnly(self::getAmount()); + } + + public static function runPayPalGetDetails() + { + $response = payPalAuthorizeCapture(self::getAmount()); + return payPalGetDetails($response->getTransactionResponse()->getTransId()); + } + + public static function runPayPalPriorAuthorizationCapture() + { + $response = payPalAuthorizeCapture(self::getAmount()); + return payPalPriorAuthorizationCapture($response->getTransactionResponse()->getTransId()); + } + + public static function runGetTransactionDetails() + { + $response = authorizeCreditCard(self::getAmount()); + return getTransactionDetails($response->getTransactionResponse()->getTransId()); + } + + + public static function runCreateSubscription() + { + $response = createSubscription(self::getDay()); + cancelSubscription($response->getSubscriptionId()); + + return $response; + } + + public static function runCreateSubscriptionFromCustomerProfile() + { + $responseCustomerProfile = createCustomerProfile(self::getEmail()); + $responseCustomerPaymentProfile = createCustomerPaymentProfile( + $responseCustomerProfile->getCustomerProfileId(), + self::getPhoneNumber() + ); + $responseCustomerShippingAddress = createCustomerShippingAddress( + $responseCustomerProfile->getCustomerProfileId(), + self::getPhoneNumber() + ); + + $response = createSubscription( + self::getDay(), + $responseCustomerProfile->getCustomerProfileId(), + $responseCustomerPaymentProfile->getCustomerPaymentProfileId(), + $responseCustomerShippingAddress->getCustomerAddressId() + ); + + cancelSubscription($response->getSubscriptionId()); + deleteCustomerProfile($responseCustomerProfile->getCustomerProfileId()); + + return $response; + } + + public static function runCancelSubscription() + { + $response = createSubscription(self::getDay()); + return cancelSubscription($response->getSubscriptionId()); + } + + public static function runGetSubscriptionStatus() + { + $response = createSubscription(self::getDay()); + $status_response = getSubscriptionStatus($response->getSubscriptionId()); + cancelSubscription($response->getSubscriptionId()); + + return $status_response; + } + + public static function runGetSubscription() + { + $response = createSubscription(self::getDay()); + $status_response = getSubscription($response->getSubscriptionId()); + cancelSubscription($response->getSubscriptionId()); + + return $status_response; + } + + public static function runUpdateSubscription() + { + $response = createSubscription(self::getDay()); + $update_response = updateSubscription($response->getSubscriptionId()); + cancelSubscription($response->getSubscriptionId()); + + return $update_response; + } + + //customer profiles methods + public static function runCreateCustomerProfile() + { + + $response = createCustomerProfile(self::getEmail()); + deleteCustomerProfile($response->getCustomerProfileId()); + return $response; + } + + public static function runDeleteCustomerProfile() + { + + $responseCustomerProfile = createCustomerProfile(self::getEmail()); + return deleteCustomerProfile($responseCustomerProfile->getCustomerProfileId()); + } + + public static function runGetCustomerProfile() + { + + $responseCustomerProfile = createCustomerProfile(self::getEmail()); + $response = getCustomerProfile($responseCustomerProfile->getCustomerProfileId()); + deleteCustomerProfile($responseCustomerProfile->getCustomerProfileId()); + return $response; + } + + // public static function runUpdateCustomerProfile() + // { + // $responseCustomerProfile = createCustomerProfile(self::getEmail()); + // $customerProfileId = $responseCustomerProfile->getCustomerProfileId(); + // $response = updateCustomerProfileById($customerProfileId); + // deleteCustomerProfile($customerProfileId); + // return $response; + // } + //customer profiles - payment profiles methods + + public static function runCreateCustomerPaymentProfile() + { + $responseCustomerProfile = createCustomerProfile(self::getEmail()); + $response=createCustomerPaymentProfile( + $responseCustomerProfile->getCustomerProfileId(), + self::getPhoneNumber() + ); + deleteCustomerProfile($responseCustomerProfile->getCustomerProfileId()); + return $response; + } + + public static function runGetCustomerPaymentProfile() + { + $customerProfileId = createCustomerProfile(self::getEmail())->getCustomerProfileId(); + $customerPaymentProfileId = createCustomerPaymentProfile( + $customerProfileId, + self::getPhoneNumber() + )->getCustomerPaymentProfileId(); + $response= getCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId); + deleteCustomerProfile($customerProfileId); + return $response; + } + + public static function runValidateCustomerPaymentProfile() + { + $customerProfileId = createCustomerProfile(self::getEmail())->getCustomerProfileId(); + $customerPaymentProfileId = createCustomerPaymentProfile( + $customerProfileId, + self::getPhoneNumber() + )->getCustomerPaymentProfileId(); + $response = validateCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId); + deleteCustomerProfile($customerProfileId); + return $response; + } + + public static function runUpdateCustomerPaymentProfile() + { + $customerProfileId = createCustomerProfile(self::getEmail())->getCustomerProfileId(); + $customerPaymentProfileId = createCustomerPaymentProfile( + $customerProfileId, + self::getPhoneNumber() + )->getCustomerPaymentProfileId(); + $response = updateCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId); + deleteCustomerProfile($customerProfileId); + return $response; + } + + public static function runDeleteCustomerPaymentProfile() + { + $customerProfileId = createCustomerProfile(self::getEmail())->getCustomerProfileId(); + $customerPaymentProfileId = createCustomerPaymentProfile( + $customerProfileId, + self::getPhoneNumber() + )->getCustomerPaymentProfileId(); + $response = deleteCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId); + deleteCustomerProfile($customerProfileId); + return $response; + } + + //customer profiles - shipping address + public static function runCreateCustomerShippingAddress() + { + $customerProfileId = createCustomerProfile(self::getEmail())->getCustomerProfileId(); + $response = createCustomerShippingAddress($customerProfileId, self::getPhoneNumber()); + deleteCustomerProfile($customerProfileId); + return $response; + } + + public static function runDeleteCustomerShippingAddress() + { + $customerProfileId = createCustomerProfile(self::getEmail())->getCustomerProfileId(); + $responseCreateShipping = createCustomerShippingAddress($customerProfileId, self::getPhoneNumber()); + $response = deleteCustomerShippingAddress($customerProfileId, $responseCreateShipping->getCustomerAddressId()); + deleteCustomerProfile($customerProfileId); + return $response; + } + + public static function runUpdateCustomerShippingAddress() + { + $response = createCustomerProfile(self::getEmail()); + $shippingResponse = createCustomerShippingAddress($response->getCustomerProfileId()); + $updateResponse = updateCustomerShippingAddress( + $response->getCustomerProfileId(), + $shippingResponse->getCustomerAddressId() + ); + deleteCustomerProfile($response->getCustomerProfileId()); + + return $updateResponse; + } + + public static function runGetCustomerShippingAddress() + { + $response = createCustomerProfile(self::getEmail()); + $shippingResponse = createCustomerShippingAddress($response->getCustomerProfileId()); + + $getResponse = getCustomerShippingAddress( + $response->getCustomerProfileId(), + $shippingResponse->getCustomerAddressId() + ); + + deleteCustomerProfile($response->getCustomerProfileId()); + + return $getResponse; + } + + public static function runGetAcceptCustomerProfilePage() + { + $response = createCustomerProfile(self::getEmail()); + $profileResponse = GetAcceptCustomerProfilePage($response->getCustomerProfileId()); + deleteCustomerProfile($response->getCustomerProfileId()); + + return $profileResponse; + } } From 45b884965b5ab6b90b4c97c849bd33c0e575ae05 Mon Sep 17 00:00:00 2001 From: adavidw Date: Thu, 16 Nov 2017 00:16:09 -0800 Subject: [PATCH 076/149] update bank account --- PaymentTransactions/credit-bank-account.php | 2 +- PaymentTransactions/debit-bank-account.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PaymentTransactions/credit-bank-account.php b/PaymentTransactions/credit-bank-account.php index 656e320..00b512e 100644 --- a/PaymentTransactions/credit-bank-account.php +++ b/PaymentTransactions/credit-bank-account.php @@ -22,7 +22,7 @@ function creditBankAccount($amount) // see eCheck documentation for proper echeck type to use for each situation $bankAccount->setEcheckType('PPD'); $bankAccount->setRoutingNumber('121042882'); - $bankAccount->setAccountNumber('123456789'); + $bankAccount->setAccountNumber('1234567890'); $bankAccount->setNameOnAccount('John Doe'); $bankAccount->setBankName('Wells Fargo Bank NA'); diff --git a/PaymentTransactions/debit-bank-account.php b/PaymentTransactions/debit-bank-account.php index 98d1d37..ab258cb 100644 --- a/PaymentTransactions/debit-bank-account.php +++ b/PaymentTransactions/debit-bank-account.php @@ -22,7 +22,7 @@ function debitBankAccount($amount) // see eCheck documentation for proper echeck type to use for each situation $bankAccount->setEcheckType('WEB'); $bankAccount->setRoutingNumber('121042882'); - $bankAccount->setAccountNumber('123456789'); + $bankAccount->setAccountNumber('1234567890'); $bankAccount->setNameOnAccount('John Doe'); $bankAccount->setBankName('Wells Fargo Bank NA'); From 03853b82840818f8e45205a89f26df3d48ba3dcc Mon Sep 17 00:00:00 2001 From: khaaldrogo <35258595+khaaldrogo@users.noreply.github.com> Date: Wed, 21 Feb 2018 15:17:01 +0530 Subject: [PATCH 077/149] Update debit-bank-account.php Updating routing number to resolved failures in debit-bank-acccount.php: Transaction Failed Error code : 101 Error message : The given name on the account and/or the account type does not match the actual account. --- PaymentTransactions/debit-bank-account.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PaymentTransactions/debit-bank-account.php b/PaymentTransactions/debit-bank-account.php index ab258cb..7c3d94a 100644 --- a/PaymentTransactions/debit-bank-account.php +++ b/PaymentTransactions/debit-bank-account.php @@ -21,7 +21,7 @@ function debitBankAccount($amount) $bankAccount->setAccountType('checking'); // see eCheck documentation for proper echeck type to use for each situation $bankAccount->setEcheckType('WEB'); - $bankAccount->setRoutingNumber('121042882'); + $bankAccount->setRoutingNumber('122105155'); $bankAccount->setAccountNumber('1234567890'); $bankAccount->setNameOnAccount('John Doe'); $bankAccount->setBankName('Wells Fargo Bank NA'); From 94dcd2309aa990cc9354a678ef5016b14024dcbb Mon Sep 17 00:00:00 2001 From: khaaldrogo <35258595+khaaldrogo@users.noreply.github.com> Date: Wed, 21 Feb 2018 16:19:00 +0530 Subject: [PATCH 078/149] Update get-settled-batch-list.php to use settlement date range First and last settlement dates are passed as parameters. Sample code shows two methods for creating DateTime objects for the same. --- .../get-settled-batch-list.php | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/TransactionReporting/get-settled-batch-list.php b/TransactionReporting/get-settled-batch-list.php index 8fc22df..c46f761 100644 --- a/TransactionReporting/get-settled-batch-list.php +++ b/TransactionReporting/get-settled-batch-list.php @@ -5,7 +5,7 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); -function getSettledBatchList() +function getSettledBatchList($firstSettlementDate, $lastSettlementDate) { /* Create a merchantAuthenticationType object with authentication details retrieved from the constants file */ @@ -21,15 +21,7 @@ function getSettledBatchList() $request->setIncludeStatistics(true); // both the first and last dates must be in the same time zone - $firstSettlementDate=new DateTime("2015-08-25T06:00:00Z"); - // a date constructed from an ISO8601 format date string $request->setFirstSettlementDate($firstSettlementDate); - - // a date constructed manually - $lastSettlementDate=new DateTime(); - $lastSettlementDate->setDate(2015,9,20); - $lastSettlementDate->setTime(13,33,59); - $lastSettlementDate->setTimezone(new DateTimeZone('UTC')); $request->setLastSettlementDate($lastSettlementDate); $controller = new AnetController\GetSettledBatchListController ($request); @@ -69,8 +61,17 @@ function getSettledBatchList() return $response; } - + + // both the first and last dates must be in the same time zone + // a date constructed from an ISO8601 format date string + $firstSettlementDate=new DateTime("2018-01-23T06:00:00Z"); + // a date constructed manually + $lastSettlementDate=new DateTime(); + $lastSettlementDate->setDate(2018,2,19); + $lastSettlementDate->setTime(13,33,59); + $lastSettlementDate->setTimezone(new DateTimeZone('UTC')); + if(!defined('DONT_RUN_SAMPLES')) - getSettledBatchList(); + getSettledBatchList($firstSettlementDate, $lastSettlementDate); ?> From 41fdf41a62d20b426eceb79b8e1eefdf7683b9e5 Mon Sep 17 00:00:00 2001 From: khaaldrogo <35258595+khaaldrogo@users.noreply.github.com> Date: Wed, 21 Feb 2018 16:31:08 +0530 Subject: [PATCH 079/149] Update get-batch-statistics.php Add a new batch id, as batches older than 6 months return no records. --- TransactionReporting/get-batch-statistics.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/TransactionReporting/get-batch-statistics.php b/TransactionReporting/get-batch-statistics.php index 79f621c..4038762 100644 --- a/TransactionReporting/get-batch-statistics.php +++ b/TransactionReporting/get-batch-statistics.php @@ -5,7 +5,7 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); -function getBatchStatistics() +function getBatchStatistics($batchId = "7927817") //only shows results for batches not older than 6 months { /* Create a merchantAuthenticationType object with authentication details retrieved from the constants file */ @@ -15,9 +15,6 @@ function getBatchStatistics() // Set the transaction's refId $refId = 'ref' . time(); - - //Setting a valid batch Id for the Merchant - $batchId = "4532808"; // Creating a request $request = new AnetAPI\GetBatchStatisticsRequest(); @@ -64,4 +61,4 @@ function getBatchStatistics() if(!defined('DONT_RUN_SAMPLES')) getBatchStatistics(); -?> \ No newline at end of file +?> From ee0015d464041f38133d685bc3108a79bbcf5b7e Mon Sep 17 00:00:00 2001 From: khaaldrogo <35258595+khaaldrogo@users.noreply.github.com> Date: Wed, 21 Feb 2018 16:34:38 +0530 Subject: [PATCH 080/149] Update SampleCodeList.txt for TransactionReporting GetBatchStatistics and GetSettledBatchList require parameters to be passed. --- SampleCodeList.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SampleCodeList.txt b/SampleCodeList.txt index 8f524f3..621aa28 100644 --- a/SampleCodeList.txt +++ b/SampleCodeList.txt @@ -16,8 +16,8 @@ ChargeTokenizedCreditCard,0,0 PayPalAuthorizeOnly,1,1 GetListOfSubscriptions,0,1 GetUnsettledTransactionList,0,1 -GetBatchStatistics,0,1 -GetSettledBatchList,0,1 +GetBatchStatistics,1,1 +GetSettledBatchList,1,1 UpdateSplitTenderGroup,0,1 UpdateCustomerShippingAddress,1,1 UpdateCustomerProfile,0,1 From 0d27f5965f65f6efc79c26a8f55251625212660a Mon Sep 17 00:00:00 2001 From: khaaldrogo <35258595+khaaldrogo@users.noreply.github.com> Date: Wed, 21 Feb 2018 17:28:53 +0530 Subject: [PATCH 081/149] Update get-settled-batch-list.php --- TransactionReporting/get-settled-batch-list.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/TransactionReporting/get-settled-batch-list.php b/TransactionReporting/get-settled-batch-list.php index c46f761..3fe7902 100644 --- a/TransactionReporting/get-settled-batch-list.php +++ b/TransactionReporting/get-settled-batch-list.php @@ -20,7 +20,8 @@ function getSettledBatchList($firstSettlementDate, $lastSettlementDate) $request->setMerchantAuthentication($merchantAuthentication); $request->setIncludeStatistics(true); - // both the first and last dates must be in the same time zone + // Both the first and last dates must be in the same time zone + // The time between first and last dates, inclusively, cannot exceed 31 days. $request->setFirstSettlementDate($firstSettlementDate); $request->setLastSettlementDate($lastSettlementDate); From c53083b87ac23b1ebb6119aaf78e9d4161393eb9 Mon Sep 17 00:00:00 2001 From: khaaldrogo <35258595+khaaldrogo@users.noreply.github.com> Date: Wed, 21 Feb 2018 17:33:03 +0530 Subject: [PATCH 082/149] Update test-runner.php Added runGetSettledBatchList with first and last settlement dates. Added runGetBatchStatistics to use the batch id of one of the active batches. --- test-runner.php | 46 ++++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/test-runner.php b/test-runner.php index 0dd0391..71aa2ae 100644 --- a/test-runner.php +++ b/test-runner.php @@ -226,13 +226,8 @@ public static function runPayPalPriorAuthorizationCapture() return payPalPriorAuthorizationCapture($response->getTransactionResponse()->getTransId()); } - public static function runGetTransactionDetails() - { - $response = authorizeCreditCard(self::getAmount()); - return getTransactionDetails($response->getTransactionResponse()->getTransId()); - } - + // ****ARB Subscription methods****** public static function runCreateSubscription() { $response = createSubscription(self::getDay()); @@ -299,7 +294,7 @@ public static function runUpdateSubscription() return $update_response; } - //customer profiles methods + //*****Customer Profiles methods******** public static function runCreateCustomerProfile() { @@ -324,15 +319,7 @@ public static function runGetCustomerProfile() return $response; } - // public static function runUpdateCustomerProfile() - // { - // $responseCustomerProfile = createCustomerProfile(self::getEmail()); - // $customerProfileId = $responseCustomerProfile->getCustomerProfileId(); - // $response = updateCustomerProfileById($customerProfileId); - // deleteCustomerProfile($customerProfileId); - // return $response; - // } - //customer profiles - payment profiles methods + // *******Customer Profiles - Payment Profiles methods****** public static function runCreateCustomerPaymentProfile() { @@ -393,7 +380,7 @@ public static function runDeleteCustomerPaymentProfile() return $response; } - //customer profiles - shipping address + // ****Customer Profiles - Shipping Address***** public static function runCreateCustomerShippingAddress() { $customerProfileId = createCustomerProfile(self::getEmail())->getCustomerProfileId(); @@ -438,7 +425,7 @@ public static function runGetCustomerShippingAddress() return $getResponse; } - + //*****Accept - Accept Customer Profile Page******** public static function runGetAcceptCustomerProfilePage() { $response = createCustomerProfile(self::getEmail()); @@ -447,4 +434,27 @@ public static function runGetAcceptCustomerProfilePage() return $profileResponse; } + + // *****Transaction Reporting methods******** + public static function runGetTransactionDetails() + { + $response = authorizeCreditCard(self::getAmount()); + return getTransactionDetails($response->getTransactionResponse()->getTransId()); + } + + public static function runGetSettledBatchList() + { + $lastSettlementDate=gmdate("Y-m-d\TH:i:s\Z"); // UTC time now + $firstSettlementDate=new DateTime(); // use DateTime object + $firstSettlementDate->format("Y-m-d\TH:i:s\Z"); + $firstSettlementDate->setTimezone(new DateTimeZone('UTC')); + $firstSettlementDate->sub(new DateInterval('P28D')); + return getSettledBatchList($firstSettlementDate->format("Y-m-d\TH:i:s\Z"), $lastSettlementDate); + } + + public static function runGetBatchStatistics() + { + $response = getBatchStatistics(runGetSettledBatchList()->getBatchList()[0]->getBatchId()); + return $response; + } } From 25e6f8050a3c952c5f059145c9045e95828471cf Mon Sep 17 00:00:00 2001 From: khaaldrogo <35258595+khaaldrogo@users.noreply.github.com> Date: Wed, 21 Feb 2018 18:03:10 +0530 Subject: [PATCH 083/149] Update test-runner.php --- test-runner.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-runner.php b/test-runner.php index 71aa2ae..0a8a2bb 100644 --- a/test-runner.php +++ b/test-runner.php @@ -454,7 +454,7 @@ public static function runGetSettledBatchList() public static function runGetBatchStatistics() { - $response = getBatchStatistics(runGetSettledBatchList()->getBatchList()[0]->getBatchId()); + $response = getBatchStatistics(self::runGetSettledBatchList()->getBatchList()[0]->getBatchId()); return $response; } } From 64a8b1b69a96c6f8c90617bc632bdffdc5c8f451 Mon Sep 17 00:00:00 2001 From: khaaldrogo <35258595+khaaldrogo@users.noreply.github.com> Date: Wed, 21 Feb 2018 18:07:07 +0530 Subject: [PATCH 084/149] Update test-runner.php --- test-runner.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test-runner.php b/test-runner.php index 0a8a2bb..806e1cc 100644 --- a/test-runner.php +++ b/test-runner.php @@ -444,11 +444,15 @@ public static function runGetTransactionDetails() public static function runGetSettledBatchList() { - $lastSettlementDate=gmdate("Y-m-d\TH:i:s\Z"); // UTC time now - $firstSettlementDate=new DateTime(); // use DateTime object + $lastSettlementDate=new DateTime(); // current time + $lastSettlementDate->format("Y-m-d\TH:i:s\Z"); + $lastSettlementDate->setTimezone(new DateTimeZone('UTC')); + + $firstSettlementDate=new DateTime(); $firstSettlementDate->format("Y-m-d\TH:i:s\Z"); $firstSettlementDate->setTimezone(new DateTimeZone('UTC')); $firstSettlementDate->sub(new DateInterval('P28D')); + return getSettledBatchList($firstSettlementDate->format("Y-m-d\TH:i:s\Z"), $lastSettlementDate); } From 8884cdf587c2016a882d4bb49de931f79c6acd42 Mon Sep 17 00:00:00 2001 From: khaaldrogo <35258595+khaaldrogo@users.noreply.github.com> Date: Wed, 21 Feb 2018 18:11:50 +0530 Subject: [PATCH 085/149] Update test-runner.php --- test-runner.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-runner.php b/test-runner.php index 806e1cc..db4864e 100644 --- a/test-runner.php +++ b/test-runner.php @@ -453,7 +453,7 @@ public static function runGetSettledBatchList() $firstSettlementDate->setTimezone(new DateTimeZone('UTC')); $firstSettlementDate->sub(new DateInterval('P28D')); - return getSettledBatchList($firstSettlementDate->format("Y-m-d\TH:i:s\Z"), $lastSettlementDate); + return getSettledBatchList($firstSettlementDate, $lastSettlementDate); } public static function runGetBatchStatistics() From d22b9728d12a54abd877775d4750222f68518824 Mon Sep 17 00:00:00 2001 From: khaaldrogo <35258595+khaaldrogo@users.noreply.github.com> Date: Wed, 21 Feb 2018 13:32:43 +0000 Subject: [PATCH 086/149] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 997e6d8..bf12637 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "php": ">=5.6", "ext-curl": "*", "phpunit/phpunit": "~4.8||~6.0", - "authorizenet/authorizenet": ">=1.9.3 || <2.0" + "authorizenet/authorizenet": ">=1.9.5 || <2.0" }, "autoload": { "classmap": ["constants"] From 263905bfd96dd1a1469296a41d5a3e359f94e325 Mon Sep 17 00:00:00 2001 From: khaaldrogo <35258595+khaaldrogo@users.noreply.github.com> Date: Thu, 22 Feb 2018 13:03:19 +0530 Subject: [PATCH 087/149] Added includeTransactions --- RecurringBilling/get-subscription.php | 89 +++++++++++++-------------- 1 file changed, 44 insertions(+), 45 deletions(-) diff --git a/RecurringBilling/get-subscription.php b/RecurringBilling/get-subscription.php index 742d607..8704b7f 100644 --- a/RecurringBilling/get-subscription.php +++ b/RecurringBilling/get-subscription.php @@ -1,13 +1,12 @@ setMerchantAuthentication($merchantAuthentication); - $request->setRefId($refId); - $request->setSubscriptionId($subscriptionId); + // Creating the API Request with required parameters + $request = new AnetAPI\ARBGetSubscriptionRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setRefId($refId); + $request->setSubscriptionId($subscriptionId); - // Controller - $controller = new AnetController\ARBGetSubscriptionController($request); + // Controller + $controller = new AnetController\ARBGetSubscriptionController($request); - // Getting the response - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + // Getting the response + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - if ($response != null) - { - if($response->getMessages()->getResultCode() == "Ok") - { - // Success - echo "SUCCESS: GetSubscription:" . "\n"; - // Displaying the details - echo "Subscription Name: " . $response->getSubscription()->getName(). "\n"; - echo "Subscription amount: " . $response->getSubscription()->getAmount(). "\n"; - echo "Subscription status: " . $response->getSubscription()->getStatus(). "\n"; - echo "Subscription Description: " . $response->getSubscription()->getProfile()->getDescription(). "\n"; - echo "Customer Profile ID: " . $response->getSubscription()->getProfile()->getCustomerProfileId() . "\n"; - echo "Customer payment Profile ID: ". $response->getSubscription()->getProfile()->getPaymentProfile()->getCustomerPaymentProfileId() . "\n"; - } - else - { - // Error - echo "ERROR : Invalid response\n"; - $errorMessages = $response->getMessages()->getMessage(); - echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; - } - } - else - { - // Failed to get response - echo "Null Response Error"; - } + if ($response != null) + { + if($response->getMessages()->getResultCode() == "Ok") + { + // Success + echo "SUCCESS: GetSubscription:" . "\n"; + // Displaying the details + echo "Subscription Name: " . $response->getSubscription()->getName(). "\n"; + echo "Subscription amount: " . $response->getSubscription()->getAmount(). "\n"; + echo "Subscription status: " . $response->getSubscription()->getStatus(). "\n"; + echo "Subscription Description: " . $response->getSubscription()->getProfile()->getDescription(). "\n"; + echo "Customer Profile ID: " . $response->getSubscription()->getProfile()->getCustomerProfileId() . "\n"; + echo "Customer payment Profile ID: ". $response->getSubscription()->getProfile()->getPaymentProfile()->getCustomerPaymentProfileId() . "\n"; + } + else + { + // Error + echo "ERROR : Invalid response\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; + } + } + else + { + // Failed to get response + echo "Null Response Error"; + } - return $response; + return $response; } if(!defined('DONT_RUN_SAMPLES')) From e15a77bdb6954c6626a745212a33c9f84042bc0b Mon Sep 17 00:00:00 2001 From: khaaldrogo <35258595+khaaldrogo@users.noreply.github.com> Date: Thu, 22 Feb 2018 07:44:06 +0000 Subject: [PATCH 088/149] Added includeTransactions and formatting changes --- RecurringBilling/get-subscription.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/RecurringBilling/get-subscription.php b/RecurringBilling/get-subscription.php index 8704b7f..b5281e7 100644 --- a/RecurringBilling/get-subscription.php +++ b/RecurringBilling/get-subscription.php @@ -21,7 +21,8 @@ function getSubscription($subscriptionId) $request->setMerchantAuthentication($merchantAuthentication); $request->setRefId($refId); $request->setSubscriptionId($subscriptionId); - +    $request->setIncludeTransactions(true); + // Controller $controller = new AnetController\ARBGetSubscriptionController($request); From f53b4609d0374cd8f667433f95f1944ce8232428 Mon Sep 17 00:00:00 2001 From: khaaldrogo <35258595+khaaldrogo@users.noreply.github.com> Date: Thu, 22 Feb 2018 07:44:14 +0000 Subject: [PATCH 089/149] Added includeTransactions and formatting changes From df6dc1b63ca761deb4c79c89f3db17fa3e4fbd8c Mon Sep 17 00:00:00 2001 From: Kaushik Kumar Mahato Date: Fri, 23 Feb 2018 17:52:17 +0530 Subject: [PATCH 090/149] Update get-subscription.php --- RecurringBilling/get-subscription.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RecurringBilling/get-subscription.php b/RecurringBilling/get-subscription.php index b5281e7..909d7f3 100644 --- a/RecurringBilling/get-subscription.php +++ b/RecurringBilling/get-subscription.php @@ -21,7 +21,7 @@ function getSubscription($subscriptionId) $request->setMerchantAuthentication($merchantAuthentication); $request->setRefId($refId); $request->setSubscriptionId($subscriptionId); -    $request->setIncludeTransactions(true); + $request->setIncludeTransactions(true); // Controller $controller = new AnetController\ARBGetSubscriptionController($request); From e6516b07fd17a61c137c8f7c4cf21e7c89cc1ea1 Mon Sep 17 00:00:00 2001 From: Kaushik Kumar Mahato Date: Fri, 23 Feb 2018 18:54:00 +0530 Subject: [PATCH 091/149] Update get-subscription.php Add sample to get list of transactions --- RecurringBilling/get-subscription.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/RecurringBilling/get-subscription.php b/RecurringBilling/get-subscription.php index 909d7f3..93e30c6 100644 --- a/RecurringBilling/get-subscription.php +++ b/RecurringBilling/get-subscription.php @@ -42,6 +42,10 @@ function getSubscription($subscriptionId) echo "Subscription Description: " . $response->getSubscription()->getProfile()->getDescription(). "\n"; echo "Customer Profile ID: " . $response->getSubscription()->getProfile()->getCustomerProfileId() . "\n"; echo "Customer payment Profile ID: ". $response->getSubscription()->getProfile()->getPaymentProfile()->getCustomerPaymentProfileId() . "\n"; + $transactions = $response->getSubscription()->getArbTransactions(); + foreach ($transactions as $transaction) { + echo "Transaction ID : ".$transaction->getTransId()." -- ".$transaction->getResponse()." -- Pay Number : ".$transaction->getPayNum()."\n"; + } } else { @@ -61,5 +65,5 @@ function getSubscription($subscriptionId) } if(!defined('DONT_RUN_SAMPLES')) - getSubscription("2930242"); + getSubscription("2942461"); ?> From 643363a7c1edad4e8029c3033902db4b0a6c07c2 Mon Sep 17 00:00:00 2001 From: Ashutosh Singh Date: Sat, 24 Mar 2018 15:33:58 +0000 Subject: [PATCH 092/149] Include constants file --- test-runner.php | 1 + 1 file changed, 1 insertion(+) diff --git a/test-runner.php b/test-runner.php index db4864e..e381c5b 100644 --- a/test-runner.php +++ b/test-runner.php @@ -2,6 +2,7 @@ define("DONT_RUN_SAMPLES", "true"); define("SAMPLE_CODE_NAME_HEADING", "SampleCodeName"); require 'vendor/autoload.php'; +require_once 'constants/Constants.php'; if ($_SERVER['argc'] != 3) { die('\n Usage: phpunit test-runner.php '); From 1613f87960b8dc0cdd2b09fc299e5e6ba41a4909 Mon Sep 17 00:00:00 2001 From: Ashutosh Singh Date: Sat, 24 Mar 2018 19:43:18 +0000 Subject: [PATCH 093/149] Update to SDK 1.9.6 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index bf12637..34b5710 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "php": ">=5.6", "ext-curl": "*", "phpunit/phpunit": "~4.8||~6.0", - "authorizenet/authorizenet": ">=1.9.5 || <2.0" + "authorizenet/authorizenet": ">=1.9.6 || <2.0" }, "autoload": { "classmap": ["constants"] From 9f8363a6fd72f6248bd9017339563c49926a92b3 Mon Sep 17 00:00:00 2001 From: Kaushik Kumar Mahato Date: Fri, 6 Apr 2018 16:58:38 +0530 Subject: [PATCH 094/149] Update debit-bank-account.php --- PaymentTransactions/debit-bank-account.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PaymentTransactions/debit-bank-account.php b/PaymentTransactions/debit-bank-account.php index 7c3d94a..0a09c05 100644 --- a/PaymentTransactions/debit-bank-account.php +++ b/PaymentTransactions/debit-bank-account.php @@ -21,7 +21,7 @@ function debitBankAccount($amount) $bankAccount->setAccountType('checking'); // see eCheck documentation for proper echeck type to use for each situation $bankAccount->setEcheckType('WEB'); - $bankAccount->setRoutingNumber('122105155'); + $bankAccount->setRoutingNumber('125000105'); $bankAccount->setAccountNumber('1234567890'); $bankAccount->setNameOnAccount('John Doe'); $bankAccount->setBankName('Wells Fargo Bank NA'); From 10ad56c6af50ae27ae64dbc288d461438a763b66 Mon Sep 17 00:00:00 2001 From: Kaushik Kumar Mahato Date: Fri, 6 Apr 2018 16:59:19 +0530 Subject: [PATCH 095/149] Update credit-bank-account.php --- PaymentTransactions/credit-bank-account.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PaymentTransactions/credit-bank-account.php b/PaymentTransactions/credit-bank-account.php index 00b512e..6c8bae9 100644 --- a/PaymentTransactions/credit-bank-account.php +++ b/PaymentTransactions/credit-bank-account.php @@ -21,7 +21,7 @@ function creditBankAccount($amount) $bankAccount->setAccountType('checking'); // see eCheck documentation for proper echeck type to use for each situation $bankAccount->setEcheckType('PPD'); - $bankAccount->setRoutingNumber('121042882'); + $bankAccount->setRoutingNumber('125000105'); $bankAccount->setAccountNumber('1234567890'); $bankAccount->setNameOnAccount('John Doe'); $bankAccount->setBankName('Wells Fargo Bank NA'); From fab1d60efb51fe75fbd49786bafd198be16456e7 Mon Sep 17 00:00:00 2001 From: Kaushik Date: Wed, 2 May 2018 17:39:25 +0530 Subject: [PATCH 096/149] Updating Bank Routing Number --- PaymentTransactions/credit-bank-account.php | 4 ++-- PaymentTransactions/debit-bank-account.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/PaymentTransactions/credit-bank-account.php b/PaymentTransactions/credit-bank-account.php index 6c8bae9..9b9bcd6 100644 --- a/PaymentTransactions/credit-bank-account.php +++ b/PaymentTransactions/credit-bank-account.php @@ -20,8 +20,8 @@ function creditBankAccount($amount) $bankAccount = new AnetAPI\BankAccountType(); $bankAccount->setAccountType('checking'); // see eCheck documentation for proper echeck type to use for each situation - $bankAccount->setEcheckType('PPD'); - $bankAccount->setRoutingNumber('125000105'); + $bankAccount->setEcheckType('WEB'); + $bankAccount->setRoutingNumber('122235821'); $bankAccount->setAccountNumber('1234567890'); $bankAccount->setNameOnAccount('John Doe'); $bankAccount->setBankName('Wells Fargo Bank NA'); diff --git a/PaymentTransactions/debit-bank-account.php b/PaymentTransactions/debit-bank-account.php index 0a09c05..7820a57 100644 --- a/PaymentTransactions/debit-bank-account.php +++ b/PaymentTransactions/debit-bank-account.php @@ -21,7 +21,7 @@ function debitBankAccount($amount) $bankAccount->setAccountType('checking'); // see eCheck documentation for proper echeck type to use for each situation $bankAccount->setEcheckType('WEB'); - $bankAccount->setRoutingNumber('125000105'); + $bankAccount->setRoutingNumber('122235821'); $bankAccount->setAccountNumber('1234567890'); $bankAccount->setNameOnAccount('John Doe'); $bankAccount->setBankName('Wells Fargo Bank NA'); From becf662d4a93d829a743acadeb828bb447725f79 Mon Sep 17 00:00:00 2001 From: khaaldrogo <35258595+khaaldrogo@users.noreply.github.com> Date: Tue, 29 May 2018 07:24:29 +0000 Subject: [PATCH 097/149] Update debit-bank-account.php --- PaymentTransactions/debit-bank-account.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PaymentTransactions/debit-bank-account.php b/PaymentTransactions/debit-bank-account.php index 7820a57..46580df 100644 --- a/PaymentTransactions/debit-bank-account.php +++ b/PaymentTransactions/debit-bank-account.php @@ -1,4 +1,4 @@ -setAccountType('checking'); // see eCheck documentation for proper echeck type to use for each situation $bankAccount->setEcheckType('WEB'); - $bankAccount->setRoutingNumber('122235821'); + $bankAccount->setRoutingNumber('125008547'); $bankAccount->setAccountNumber('1234567890'); $bankAccount->setNameOnAccount('John Doe'); $bankAccount->setBankName('Wells Fargo Bank NA'); From 6704bd967ce13f2f764f09f7d5f3cbc6d94630e8 Mon Sep 17 00:00:00 2001 From: khaaldrogo <35258595+khaaldrogo@users.noreply.github.com> Date: Tue, 29 May 2018 07:32:16 +0000 Subject: [PATCH 098/149] Update credit-bank-account.php --- PaymentTransactions/credit-bank-account.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/PaymentTransactions/credit-bank-account.php b/PaymentTransactions/credit-bank-account.php index 9b9bcd6..5f2ca99 100644 --- a/PaymentTransactions/credit-bank-account.php +++ b/PaymentTransactions/credit-bank-account.php @@ -20,8 +20,8 @@ function creditBankAccount($amount) $bankAccount = new AnetAPI\BankAccountType(); $bankAccount->setAccountType('checking'); // see eCheck documentation for proper echeck type to use for each situation - $bankAccount->setEcheckType('WEB'); - $bankAccount->setRoutingNumber('122235821'); + //$bankAccount->setEcheckType('WEB'); + $bankAccount->setRoutingNumber('125008547'); //('122235821'); //('125008547'); $bankAccount->setAccountNumber('1234567890'); $bankAccount->setNameOnAccount('John Doe'); $bankAccount->setBankName('Wells Fargo Bank NA'); @@ -84,6 +84,6 @@ function creditBankAccount($amount) return $response; } -if (!defined('DONT_RUN_SAMPLES')) { - creditBankAccount(5.29); -} + + + From 0161bcdb114923a49eb74f59f2252b365c314d94 Mon Sep 17 00:00:00 2001 From: khaaldrogo <35258595+khaaldrogo@users.noreply.github.com> Date: Tue, 29 May 2018 07:34:47 +0000 Subject: [PATCH 099/149] Update credit-bank-account.php --- PaymentTransactions/credit-bank-account.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/PaymentTransactions/credit-bank-account.php b/PaymentTransactions/credit-bank-account.php index 5f2ca99..cb04582 100644 --- a/PaymentTransactions/credit-bank-account.php +++ b/PaymentTransactions/credit-bank-account.php @@ -84,6 +84,7 @@ function creditBankAccount($amount) return $response; } - - +if (!defined('DONT_RUN_SAMPLES')) { + creditBankAccount(5.29); +} From d1bd10a7ff1596cbe4a22f034bf1317cf8451738 Mon Sep 17 00:00:00 2001 From: Ashutosh Singh Date: Thu, 7 Jun 2018 23:35:42 +0530 Subject: [PATCH 100/149] Create composer.json.sdk-dev Composer file to be used to test local sdk changes. --- composer.json.sdk-dev | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 composer.json.sdk-dev diff --git a/composer.json.sdk-dev b/composer.json.sdk-dev new file mode 100644 index 0000000..12fdd53 --- /dev/null +++ b/composer.json.sdk-dev @@ -0,0 +1,11 @@ +{ + "require": { + "php": ">=5.6", + "ext-curl": "*", + "phpunit/phpunit": "~4.8||~6.0", + "authorizenet/authorizenet": ">=1.9.6 || <2.0" + }, + "autoload": { + "classmap": ["constants", "lib"] + } +} From 15983be0c1cf5cb3cb24e4f8621791761bc6b5c7 Mon Sep 17 00:00:00 2001 From: Ashutosh Singh Date: Thu, 14 Jun 2018 16:17:46 +0530 Subject: [PATCH 101/149] Update to SDK 1.9.7 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 34b5710..1ffb837 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "php": ">=5.6", "ext-curl": "*", "phpunit/phpunit": "~4.8||~6.0", - "authorizenet/authorizenet": ">=1.9.6 || <2.0" + "authorizenet/authorizenet": ">=1.9.7 || <2.0" }, "autoload": { "classmap": ["constants"] From 0ac94b1b798f54bfcf260ecc62c3b2331fcaca9d Mon Sep 17 00:00:00 2001 From: ashtru Date: Mon, 2 Jul 2018 14:57:56 +0530 Subject: [PATCH 102/149] Change routing number --- PaymentTransactions/credit-bank-account.php | 2 +- PaymentTransactions/debit-bank-account.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PaymentTransactions/credit-bank-account.php b/PaymentTransactions/credit-bank-account.php index cb04582..a7c861c 100644 --- a/PaymentTransactions/credit-bank-account.php +++ b/PaymentTransactions/credit-bank-account.php @@ -21,7 +21,7 @@ function creditBankAccount($amount) $bankAccount->setAccountType('checking'); // see eCheck documentation for proper echeck type to use for each situation //$bankAccount->setEcheckType('WEB'); - $bankAccount->setRoutingNumber('125008547'); //('122235821'); //('125008547'); + $bankAccount->setRoutingNumber('122000661'); //('122235821'); //('125008547'); $bankAccount->setAccountNumber('1234567890'); $bankAccount->setNameOnAccount('John Doe'); $bankAccount->setBankName('Wells Fargo Bank NA'); diff --git a/PaymentTransactions/debit-bank-account.php b/PaymentTransactions/debit-bank-account.php index 46580df..2b91678 100644 --- a/PaymentTransactions/debit-bank-account.php +++ b/PaymentTransactions/debit-bank-account.php @@ -21,7 +21,7 @@ function debitBankAccount($amount) $bankAccount->setAccountType('checking'); // see eCheck documentation for proper echeck type to use for each situation $bankAccount->setEcheckType('WEB'); - $bankAccount->setRoutingNumber('125008547'); + $bankAccount->setRoutingNumber('122000661'); $bankAccount->setAccountNumber('1234567890'); $bankAccount->setNameOnAccount('John Doe'); $bankAccount->setBankName('Wells Fargo Bank NA'); From 678ae9c140b988a39f94330eb5c1e67588ab0fb3 Mon Sep 17 00:00:00 2001 From: Kaushik Kumar Mahato Date: Mon, 16 Jul 2018 17:09:37 +0530 Subject: [PATCH 103/149] Null check for transactions --- RecurringBilling/get-subscription.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/RecurringBilling/get-subscription.php b/RecurringBilling/get-subscription.php index 93e30c6..fa9be72 100644 --- a/RecurringBilling/get-subscription.php +++ b/RecurringBilling/get-subscription.php @@ -43,9 +43,11 @@ function getSubscription($subscriptionId) echo "Customer Profile ID: " . $response->getSubscription()->getProfile()->getCustomerProfileId() . "\n"; echo "Customer payment Profile ID: ". $response->getSubscription()->getProfile()->getPaymentProfile()->getCustomerPaymentProfileId() . "\n"; $transactions = $response->getSubscription()->getArbTransactions(); - foreach ($transactions as $transaction) { - echo "Transaction ID : ".$transaction->getTransId()." -- ".$transaction->getResponse()." -- Pay Number : ".$transaction->getPayNum()."\n"; - } + if($transactions != null){ + foreach ($transactions as $transaction) { + echo "Transaction ID : ".$transaction->getTransId()." -- ".$transaction->getResponse()." -- Pay Number : ".$transaction->getPayNum()."\n"; + } + } } else { From 11fa72392b6aafd7eeed2a4681d3ff81aa490395 Mon Sep 17 00:00:00 2001 From: Basu Date: Fri, 20 Jul 2018 14:00:51 +0530 Subject: [PATCH 104/149] Fix_for_Class-SampleCode-Constants-not-found_issue --- .../create-customer-payment-profile.php | 6 +++--- ...eate-customer-profile-from-transaction.php | 5 +++-- ...ate-customer-profile-with-accept-nonce.php | 6 +++--- CustomerProfiles/create-customer-profile.php | 6 +++--- .../create-customer-shipping-address.php | 5 +++-- .../delete-customer-payment-profile.php | 5 +++-- CustomerProfiles/delete-customer-profile.php | 7 ++++--- .../delete-customer-shipping-address.php | 5 +++-- .../get-accept-customer-profile-page.php | 5 +++-- .../get-customer-payment-profile-list.php | 6 +++--- .../get-customer-payment-profile.php | 6 +++--- CustomerProfiles/get-customer-profile-ids.php | 5 +++-- CustomerProfiles/get-customer-profile.php | 5 +++-- .../get-customer-shipping-address.php | 5 +++-- .../update-customer-payment-profile.php | 5 +++-- CustomerProfiles/update-customer-profile.php | 5 +++-- .../update-customer-shipping-address.php | 5 +++-- .../validate-customer-payment-profile.php | 5 +++-- .../approve-or-decline-held-transaction.php | 7 ++++--- FraudManagement/get-held-transaction-list.php | 5 +++-- .../create-an-accept-transaction.php | 10 ++++----- .../create-an-android-pay-transaction.php | 8 +++---- .../create-an-apple-pay-transaction.php | 8 +++---- .../authorization-and-capture-continued.php | 7 ++++--- .../authorization-and-capture.php | 9 ++++---- .../authorization-only-continued.php | 8 +++---- PayPalExpressCheckout/authorization-only.php | 8 +++---- PayPalExpressCheckout/credit.php | 8 +++---- PayPalExpressCheckout/get-details.php | 8 +++---- .../prior-authorization-capture.php | 7 ++++--- PayPalExpressCheckout/void.php | 7 ++++--- PaymentTransactions/authorize-credit-card.php | 10 ++++----- ...nds-authorized-through-another-channel.php | 7 ++++--- .../capture-previously-authorized-amount.php | 7 ++++--- PaymentTransactions/charge-credit-card.php | 10 ++++----- .../charge-customer-profile.php | 7 ++++--- .../charge-tokenized-credit-card.php | 7 ++++--- .../create-an-accept-payment-transaction.php | 10 ++++----- PaymentTransactions/credit-bank-account.php | 7 ++++--- PaymentTransactions/debit-bank-account.php | 7 ++++--- .../get-an-accept-payment-page.php | 5 +++-- PaymentTransactions/refund-transaction.php | 9 ++++---- .../update-split-tender-group.php | 5 +++-- PaymentTransactions/void-transaction.php | 7 ++++--- RecurringBilling/cancel-subscription.php | 5 +++-- ...ate-subscription-from-customer-profile.php | 5 +++-- RecurringBilling/create-subscription.php | 5 +++-- .../get-list-of-subscriptions.php | 5 +++-- RecurringBilling/get-subscription-status.php | 5 +++-- RecurringBilling/get-subscription.php | 5 +++-- RecurringBilling/update-subscription.php | 5 +++-- .../get-account-updater-job-details.php | 5 +++-- .../get-account-updater-job-summary.php | 5 +++-- TransactionReporting/get-batch-statistics.php | 5 +++-- .../get-customer-profile-transaction-list.php | 5 +++-- TransactionReporting/get-merchant-details.php | 5 +++-- .../get-settled-batch-list.php | 5 +++-- .../get-transaction-details.php | 5 +++-- TransactionReporting/get-transaction-list.php | 5 +++-- .../get-unsettled-transaction-list.php | 5 +++-- .../create-visa-checkout-transaction.php | 8 +++---- VisaCheckout/decrypt-visa-checkout-data.php | 6 +++--- constants/Constants.php | 21 ------------------- constants/SampleCodeConstants.php | 9 ++++++++ test-runner.php | 2 +- 65 files changed, 227 insertions(+), 194 deletions(-) delete mode 100644 constants/Constants.php create mode 100644 constants/SampleCodeConstants.php diff --git a/CustomerProfiles/create-customer-payment-profile.php b/CustomerProfiles/create-customer-payment-profile.php index 451a641..1acb10c 100644 --- a/CustomerProfiles/create-customer-payment-profile.php +++ b/CustomerProfiles/create-customer-payment-profile.php @@ -1,6 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); diff --git a/CustomerProfiles/create-customer-profile-from-transaction.php b/CustomerProfiles/create-customer-profile-from-transaction.php index 6b4ae51..fa9c002 100644 --- a/CustomerProfiles/create-customer-profile-from-transaction.php +++ b/CustomerProfiles/create-customer-profile-from-transaction.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); diff --git a/CustomerProfiles/create-customer-profile-with-accept-nonce.php b/CustomerProfiles/create-customer-profile-with-accept-nonce.php index 9a72398..d9d0375 100644 --- a/CustomerProfiles/create-customer-profile-with-accept-nonce.php +++ b/CustomerProfiles/create-customer-profile-with-accept-nonce.php @@ -1,6 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); diff --git a/CustomerProfiles/create-customer-profile.php b/CustomerProfiles/create-customer-profile.php index c58c197..91390da 100644 --- a/CustomerProfiles/create-customer-profile.php +++ b/CustomerProfiles/create-customer-profile.php @@ -1,6 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); diff --git a/CustomerProfiles/create-customer-shipping-address.php b/CustomerProfiles/create-customer-shipping-address.php index d1f9579..22ce6fb 100644 --- a/CustomerProfiles/create-customer-shipping-address.php +++ b/CustomerProfiles/create-customer-shipping-address.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); diff --git a/CustomerProfiles/delete-customer-payment-profile.php b/CustomerProfiles/delete-customer-payment-profile.php index a763e38..2ddf876 100644 --- a/CustomerProfiles/delete-customer-payment-profile.php +++ b/CustomerProfiles/delete-customer-payment-profile.php @@ -1,5 +1,6 @@ ]setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); diff --git a/CustomerProfiles/delete-customer-profile.php b/CustomerProfiles/delete-customer-profile.php index bf6c6e6..9044d0c 100644 --- a/CustomerProfiles/delete-customer-profile.php +++ b/CustomerProfiles/delete-customer-profile.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); diff --git a/CustomerProfiles/delete-customer-shipping-address.php b/CustomerProfiles/delete-customer-shipping-address.php index 48a03c4..9d3cb2f 100644 --- a/CustomerProfiles/delete-customer-shipping-address.php +++ b/CustomerProfiles/delete-customer-shipping-address.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); diff --git a/CustomerProfiles/get-accept-customer-profile-page.php b/CustomerProfiles/get-accept-customer-profile-page.php index 35e7293..e784f06 100644 --- a/CustomerProfiles/get-accept-customer-profile-page.php +++ b/CustomerProfiles/get-accept-customer-profile-page.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); diff --git a/CustomerProfiles/get-customer-payment-profile-list.php b/CustomerProfiles/get-customer-payment-profile-list.php index 71aa92b..51da3b3 100644 --- a/CustomerProfiles/get-customer-payment-profile-list.php +++ b/CustomerProfiles/get-customer-payment-profile-list.php @@ -1,7 +1,7 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); diff --git a/CustomerProfiles/get-customer-payment-profile.php b/CustomerProfiles/get-customer-payment-profile.php index 1def906..c059bc5 100644 --- a/CustomerProfiles/get-customer-payment-profile.php +++ b/CustomerProfiles/get-customer-payment-profile.php @@ -1,7 +1,7 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); diff --git a/CustomerProfiles/get-customer-profile-ids.php b/CustomerProfiles/get-customer-profile-ids.php index 6480821..20b68a0 100644 --- a/CustomerProfiles/get-customer-profile-ids.php +++ b/CustomerProfiles/get-customer-profile-ids.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); diff --git a/CustomerProfiles/get-customer-profile.php b/CustomerProfiles/get-customer-profile.php index 2ecab4d..c69efc6 100644 --- a/CustomerProfiles/get-customer-profile.php +++ b/CustomerProfiles/get-customer-profile.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); diff --git a/CustomerProfiles/get-customer-shipping-address.php b/CustomerProfiles/get-customer-shipping-address.php index 2ec8601..1e1b541 100644 --- a/CustomerProfiles/get-customer-shipping-address.php +++ b/CustomerProfiles/get-customer-shipping-address.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); diff --git a/CustomerProfiles/update-customer-payment-profile.php b/CustomerProfiles/update-customer-payment-profile.php index ab2c2ec..38b504c 100644 --- a/CustomerProfiles/update-customer-payment-profile.php +++ b/CustomerProfiles/update-customer-payment-profile.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); diff --git a/CustomerProfiles/update-customer-profile.php b/CustomerProfiles/update-customer-profile.php index 9c0e814..4a2c708 100644 --- a/CustomerProfiles/update-customer-profile.php +++ b/CustomerProfiles/update-customer-profile.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); diff --git a/CustomerProfiles/update-customer-shipping-address.php b/CustomerProfiles/update-customer-shipping-address.php index 67b18e5..3c7cb7f 100644 --- a/CustomerProfiles/update-customer-shipping-address.php +++ b/CustomerProfiles/update-customer-shipping-address.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); diff --git a/CustomerProfiles/validate-customer-payment-profile.php b/CustomerProfiles/validate-customer-payment-profile.php index 63215fc..b262186 100644 --- a/CustomerProfiles/validate-customer-payment-profile.php +++ b/CustomerProfiles/validate-customer-payment-profile.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); diff --git a/FraudManagement/approve-or-decline-held-transaction.php b/FraudManagement/approve-or-decline-held-transaction.php index abe8ec9..c3e6df5 100644 --- a/FraudManagement/approve-or-decline-held-transaction.php +++ b/FraudManagement/approve-or-decline-held-transaction.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); @@ -31,7 +32,7 @@ function approveOrDeclineHeldTransaction() if ($response != null) { - if($response->getMessages()->getResultCode() == 'Ok') + if($response->getMessages()->getResultCode() == "Ok") { $tresponse = $response->getTransactionResponse(); diff --git a/FraudManagement/get-held-transaction-list.php b/FraudManagement/get-held-transaction-list.php index 872056b..9405614 100644 --- a/FraudManagement/get-held-transaction-list.php +++ b/FraudManagement/get-held-transaction-list.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); diff --git a/MobileInAppTransactions/create-an-accept-transaction.php b/MobileInAppTransactions/create-an-accept-transaction.php index 926614b..ea7650e 100644 --- a/MobileInAppTransactions/create-an-accept-transaction.php +++ b/MobileInAppTransactions/create-an-accept-transaction.php @@ -1,6 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); @@ -76,7 +76,7 @@ function createAnAcceptTransaction($amount) if ($response != null) { // Check to see if the API request was successfully received and acted upon - if ($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { + if ($response->getMessages()->getResultCode() == "Ok") { // Since the API request was successful, look for a transaction response // and parse it to display the results of authorizing the card $tresponse = $response->getTransactionResponse(); @@ -115,6 +115,6 @@ function createAnAcceptTransaction($amount) } if (!defined('DONT_RUN_SAMPLES')) { - CreateAnAcceptTransaction(\SampleCode\Constants::SAMPLE_AMOUNT); + CreateAnAcceptTransaction("2.23"); } ?> diff --git a/MobileInAppTransactions/create-an-android-pay-transaction.php b/MobileInAppTransactions/create-an-android-pay-transaction.php index 52a2fe6..175a0a4 100644 --- a/MobileInAppTransactions/create-an-android-pay-transaction.php +++ b/MobileInAppTransactions/create-an-android-pay-transaction.php @@ -1,6 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); @@ -39,7 +39,7 @@ function createAnAndroidPayTransaction() if ($response != null) { - if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) + if($response->getMessages()->getResultCode() == "Ok") { $tresponse = $response->getTransactionResponse(); diff --git a/MobileInAppTransactions/create-an-apple-pay-transaction.php b/MobileInAppTransactions/create-an-apple-pay-transaction.php index 1325942..4a8006a 100644 --- a/MobileInAppTransactions/create-an-apple-pay-transaction.php +++ b/MobileInAppTransactions/create-an-apple-pay-transaction.php @@ -1,6 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); @@ -40,7 +40,7 @@ function createAnApplePayTransaction() if ($response != null) { - if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) + if($response->getMessages()->getResultCode() == "Ok") { $tresponse = $response->getTransactionResponse(); diff --git a/PayPalExpressCheckout/authorization-and-capture-continued.php b/PayPalExpressCheckout/authorization-and-capture-continued.php index 9318235..6ef77cd 100644 --- a/PayPalExpressCheckout/authorization-and-capture-continued.php +++ b/PayPalExpressCheckout/authorization-and-capture-continued.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); @@ -36,7 +37,7 @@ function payPalAuthorizeCaptureContinued($refTransId, $payerID) $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); if ($response != null) { - if ($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { + if ($response->getMessages()->getResultCode() == "Ok") { $tresponse = $response->getTransactionResponse(); if ($tresponse != null && $tresponse->getMessages() != null) { diff --git a/PayPalExpressCheckout/authorization-and-capture.php b/PayPalExpressCheckout/authorization-and-capture.php index f064942..5252c27 100644 --- a/PayPalExpressCheckout/authorization-and-capture.php +++ b/PayPalExpressCheckout/authorization-and-capture.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); @@ -37,7 +38,7 @@ function payPalAuthorizeCapture($amount) if ($response != null) { - if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) + if($response->getMessages()->getResultCode() == "Ok") { $tresponse = $response->getTransactionResponse(); diff --git a/PayPalExpressCheckout/authorization-only-continued.php b/PayPalExpressCheckout/authorization-only-continued.php index d276772..20422d7 100644 --- a/PayPalExpressCheckout/authorization-only-continued.php +++ b/PayPalExpressCheckout/authorization-only-continued.php @@ -1,6 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); @@ -47,7 +47,7 @@ function payPalAuthorizeOnlyContinued($transactionId, $payerId) $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); if ($response != null) { - if ($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { + if ($response->getMessages()->getResultCode() == "Ok") { $tresponse = $response->getTransactionResponse(); if ($tresponse != null && $tresponse->getMessages() != null) { diff --git a/PayPalExpressCheckout/authorization-only.php b/PayPalExpressCheckout/authorization-only.php index 7436cd1..32fd18e 100644 --- a/PayPalExpressCheckout/authorization-only.php +++ b/PayPalExpressCheckout/authorization-only.php @@ -1,6 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); @@ -40,7 +40,7 @@ function payPalAuthorizeOnly($amount) if ($response != null) { - if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) + if($response->getMessages()->getResultCode() == "Ok") { $tresponse = $response->getTransactionResponse(); diff --git a/PayPalExpressCheckout/credit.php b/PayPalExpressCheckout/credit.php index 1277807..498eba8 100644 --- a/PayPalExpressCheckout/credit.php +++ b/PayPalExpressCheckout/credit.php @@ -1,6 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); @@ -45,7 +45,7 @@ function payPalCredit($transactionId) if ($response != null) { - if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) + if($response->getMessages()->getResultCode() == "Ok") { $tresponse = $response->getTransactionResponse(); diff --git a/PayPalExpressCheckout/get-details.php b/PayPalExpressCheckout/get-details.php index 98fefab..4a81b70 100644 --- a/PayPalExpressCheckout/get-details.php +++ b/PayPalExpressCheckout/get-details.php @@ -1,6 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); @@ -49,7 +49,7 @@ function payPalGetDetails($transactionId) if ($response != null) { - if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) + if($response->getMessages()->getResultCode() == "Ok") { $tresponse = $response->getTransactionResponse(); diff --git a/PayPalExpressCheckout/prior-authorization-capture.php b/PayPalExpressCheckout/prior-authorization-capture.php index be4dc43..432d0fe 100644 --- a/PayPalExpressCheckout/prior-authorization-capture.php +++ b/PayPalExpressCheckout/prior-authorization-capture.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); @@ -40,7 +41,7 @@ function payPalPriorAuthorizationCapture($transactionId) if ($response != null) { - if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) + if($response->getMessages()->getResultCode() == "Ok") { $tresponse = $response->getTransactionResponse(); diff --git a/PayPalExpressCheckout/void.php b/PayPalExpressCheckout/void.php index c6d7e3f..bb6e242 100644 --- a/PayPalExpressCheckout/void.php +++ b/PayPalExpressCheckout/void.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); @@ -39,7 +40,7 @@ function payPalVoid($transactionId) if ($response != null) { - if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) + if($response->getMessages()->getResultCode() == "Ok") { $tresponse = $response->getTransactionResponse(); diff --git a/PaymentTransactions/authorize-credit-card.php b/PaymentTransactions/authorize-credit-card.php index d7cc566..10c8198 100644 --- a/PaymentTransactions/authorize-credit-card.php +++ b/PaymentTransactions/authorize-credit-card.php @@ -1,6 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); @@ -89,7 +89,7 @@ function authorizeCreditCard($amount) if ($response != null) { // Check to see if the API request was successfully received and acted upon - if ($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { + if ($response->getMessages()->getResultCode() == "Ok") { // Since the API request was successful, look for a transaction response // and parse it to display the results of authorizing the card $tresponse = $response->getTransactionResponse(); @@ -128,6 +128,6 @@ function authorizeCreditCard($amount) } if (!defined('DONT_RUN_SAMPLES')) { - authorizeCreditCard(\SampleCode\Constants::SAMPLE_AMOUNT); + authorizeCreditCard("2.23"); } ?> \ No newline at end of file diff --git a/PaymentTransactions/capture-funds-authorized-through-another-channel.php b/PaymentTransactions/capture-funds-authorized-through-another-channel.php index 607cc3e..8879a05 100644 --- a/PaymentTransactions/capture-funds-authorized-through-another-channel.php +++ b/PaymentTransactions/capture-funds-authorized-through-another-channel.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); @@ -40,7 +41,7 @@ function captureFundsAuthorizedThroughAnotherChannel($amount) if ($response != null) { - if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) + if($response->getMessages()->getResultCode() == "Ok") { $tresponse = $response->getTransactionResponse(); diff --git a/PaymentTransactions/capture-previously-authorized-amount.php b/PaymentTransactions/capture-previously-authorized-amount.php index bb311dd..de19ffd 100644 --- a/PaymentTransactions/capture-previously-authorized-amount.php +++ b/PaymentTransactions/capture-previously-authorized-amount.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); @@ -32,7 +33,7 @@ function capturePreviouslyAuthorizedAmount($transactionid) if ($response != null) { - if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) + if($response->getMessages()->getResultCode() == "Ok") { $tresponse = $response->getTransactionResponse(); diff --git a/PaymentTransactions/charge-credit-card.php b/PaymentTransactions/charge-credit-card.php index c401d81..c05df53 100644 --- a/PaymentTransactions/charge-credit-card.php +++ b/PaymentTransactions/charge-credit-card.php @@ -1,6 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); @@ -89,7 +89,7 @@ function chargeCreditCard($amount) if ($response != null) { // Check to see if the API request was successfully received and acted upon - if ($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { + if ($response->getMessages()->getResultCode() == "Ok") { // Since the API request was successful, look for a transaction response // and parse it to display the results of authorizing the card $tresponse = $response->getTransactionResponse(); @@ -128,5 +128,5 @@ function chargeCreditCard($amount) } if (!defined('DONT_RUN_SAMPLES')) { - chargeCreditCard(\SampleCode\Constants::SAMPLE_AMOUNT); + chargeCreditCard("2.23"); } diff --git a/PaymentTransactions/charge-customer-profile.php b/PaymentTransactions/charge-customer-profile.php index 12a91ef..7482001 100644 --- a/PaymentTransactions/charge-customer-profile.php +++ b/PaymentTransactions/charge-customer-profile.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); @@ -36,7 +37,7 @@ function chargeCustomerProfile($profileid, $paymentprofileid, $amount) if ($response != null) { - if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) + if($response->getMessages()->getResultCode() == "Ok") { $tresponse = $response->getTransactionResponse(); diff --git a/PaymentTransactions/charge-tokenized-credit-card.php b/PaymentTransactions/charge-tokenized-credit-card.php index fd6dafd..7b11b1d 100644 --- a/PaymentTransactions/charge-tokenized-credit-card.php +++ b/PaymentTransactions/charge-tokenized-credit-card.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); @@ -43,7 +44,7 @@ function chargeTokenizedCreditCard($amount) if ($response != null) { - if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) + if($response->getMessages()->getResultCode() == "Ok") { $tresponse = $response->getTransactionResponse(); diff --git a/PaymentTransactions/create-an-accept-payment-transaction.php b/PaymentTransactions/create-an-accept-payment-transaction.php index caa2fb2..c38cc1c 100644 --- a/PaymentTransactions/create-an-accept-payment-transaction.php +++ b/PaymentTransactions/create-an-accept-payment-transaction.php @@ -1,6 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); @@ -89,7 +89,7 @@ function createAnAcceptPaymentTransaction($amount) if ($response != null) { // Check to see if the API request was successfully received and acted upon - if ($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { + if ($response->getMessages()->getResultCode() == "Ok") { // Since the API request was successful, look for a transaction response // and parse it to display the results of authorizing the card $tresponse = $response->getTransactionResponse(); @@ -128,6 +128,6 @@ function createAnAcceptPaymentTransaction($amount) } if (!defined('DONT_RUN_SAMPLES')) { - CreateAnAcceptTransaction(\SampleCode\Constants::SAMPLE_AMOUNT); + CreateAnAcceptTransaction("2.23"); } ?> \ No newline at end of file diff --git a/PaymentTransactions/credit-bank-account.php b/PaymentTransactions/credit-bank-account.php index a7c861c..bab21f6 100644 --- a/PaymentTransactions/credit-bank-account.php +++ b/PaymentTransactions/credit-bank-account.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); @@ -49,7 +50,7 @@ function creditBankAccount($amount) $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); if ($response != null) { - if ($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { + if ($response->getMessages()->getResultCode() == "Ok") { $tresponse = $response->getTransactionResponse(); if ($tresponse != null && $tresponse->getMessages() != null) { diff --git a/PaymentTransactions/debit-bank-account.php b/PaymentTransactions/debit-bank-account.php index 2b91678..c3da2b2 100644 --- a/PaymentTransactions/debit-bank-account.php +++ b/PaymentTransactions/debit-bank-account.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); @@ -49,7 +50,7 @@ function debitBankAccount($amount) $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); if ($response != null) { - if ($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { + if ($response->getMessages()->getResultCode() == "Ok") { $tresponse = $response->getTransactionResponse(); if ($tresponse != null && $tresponse->getMessages() != null) { diff --git a/PaymentTransactions/get-an-accept-payment-page.php b/PaymentTransactions/get-an-accept-payment-page.php index 6d600be..30fe57e 100644 --- a/PaymentTransactions/get-an-accept-payment-page.php +++ b/PaymentTransactions/get-an-accept-payment-page.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); diff --git a/PaymentTransactions/refund-transaction.php b/PaymentTransactions/refund-transaction.php index 5ea21d0..7171066 100644 --- a/PaymentTransactions/refund-transaction.php +++ b/PaymentTransactions/refund-transaction.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); @@ -39,7 +40,7 @@ function refundTransaction($refTransId, $amount) if ($response != null) { - if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) + if($response->getMessages()->getResultCode() == "Ok") { $tresponse = $response->getTransactionResponse(); @@ -84,5 +85,5 @@ function refundTransaction($refTransId, $amount) return $response; } if(!defined('DONT_RUN_SAMPLES')) - refundTransaction( \SampleCode\Constants::SAMPLE_AMOUNT_REFUND); + refundTransaction( "2.23"); ?> diff --git a/PaymentTransactions/update-split-tender-group.php b/PaymentTransactions/update-split-tender-group.php index 1e1b1fd..c09310b 100644 --- a/PaymentTransactions/update-split-tender-group.php +++ b/PaymentTransactions/update-split-tender-group.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); diff --git a/PaymentTransactions/void-transaction.php b/PaymentTransactions/void-transaction.php index 29ea2e4..c2a4d3b 100644 --- a/PaymentTransactions/void-transaction.php +++ b/PaymentTransactions/void-transaction.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); @@ -30,7 +31,7 @@ function voidTransaction($transactionid) if ($response != null) { - if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) + if($response->getMessages()->getResultCode() == "Ok") { $tresponse = $response->getTransactionResponse(); diff --git a/RecurringBilling/cancel-subscription.php b/RecurringBilling/cancel-subscription.php index 378345b..e4cbe9e 100644 --- a/RecurringBilling/cancel-subscription.php +++ b/RecurringBilling/cancel-subscription.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); diff --git a/RecurringBilling/create-subscription-from-customer-profile.php b/RecurringBilling/create-subscription-from-customer-profile.php index 9a53131..ce69254 100644 --- a/RecurringBilling/create-subscription-from-customer-profile.php +++ b/RecurringBilling/create-subscription-from-customer-profile.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); diff --git a/RecurringBilling/create-subscription.php b/RecurringBilling/create-subscription.php index fa6b675..66f539a 100644 --- a/RecurringBilling/create-subscription.php +++ b/RecurringBilling/create-subscription.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); diff --git a/RecurringBilling/get-list-of-subscriptions.php b/RecurringBilling/get-list-of-subscriptions.php index 444c9f5..44049d7 100644 --- a/RecurringBilling/get-list-of-subscriptions.php +++ b/RecurringBilling/get-list-of-subscriptions.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); diff --git a/RecurringBilling/get-subscription-status.php b/RecurringBilling/get-subscription-status.php index fd5af2f..52796b0 100644 --- a/RecurringBilling/get-subscription-status.php +++ b/RecurringBilling/get-subscription-status.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); diff --git a/RecurringBilling/get-subscription.php b/RecurringBilling/get-subscription.php index fa9be72..23b0409 100644 --- a/RecurringBilling/get-subscription.php +++ b/RecurringBilling/get-subscription.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); diff --git a/RecurringBilling/update-subscription.php b/RecurringBilling/update-subscription.php index e8e05d9..6729445 100644 --- a/RecurringBilling/update-subscription.php +++ b/RecurringBilling/update-subscription.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); diff --git a/TransactionReporting/get-account-updater-job-details.php b/TransactionReporting/get-account-updater-job-details.php index 12f9d81..0d26eb5 100644 --- a/TransactionReporting/get-account-updater-job-details.php +++ b/TransactionReporting/get-account-updater-job-details.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the request's refId $refId = 'ref' . time(); diff --git a/TransactionReporting/get-account-updater-job-summary.php b/TransactionReporting/get-account-updater-job-summary.php index cca6160..444e894 100644 --- a/TransactionReporting/get-account-updater-job-summary.php +++ b/TransactionReporting/get-account-updater-job-summary.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the request's refId $refId = 'ref' . time(); diff --git a/TransactionReporting/get-batch-statistics.php b/TransactionReporting/get-batch-statistics.php index 4038762..9a161c6 100644 --- a/TransactionReporting/get-batch-statistics.php +++ b/TransactionReporting/get-batch-statistics.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); diff --git a/TransactionReporting/get-customer-profile-transaction-list.php b/TransactionReporting/get-customer-profile-transaction-list.php index 1f209a6..69eb20c 100644 --- a/TransactionReporting/get-customer-profile-transaction-list.php +++ b/TransactionReporting/get-customer-profile-transaction-list.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); diff --git a/TransactionReporting/get-merchant-details.php b/TransactionReporting/get-merchant-details.php index 542ae6c..1b20655 100644 --- a/TransactionReporting/get-merchant-details.php +++ b/TransactionReporting/get-merchant-details.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); diff --git a/TransactionReporting/get-settled-batch-list.php b/TransactionReporting/get-settled-batch-list.php index 3fe7902..89292af 100644 --- a/TransactionReporting/get-settled-batch-list.php +++ b/TransactionReporting/get-settled-batch-list.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); diff --git a/TransactionReporting/get-transaction-details.php b/TransactionReporting/get-transaction-details.php index 25cdcb1..d54def5 100644 --- a/TransactionReporting/get-transaction-details.php +++ b/TransactionReporting/get-transaction-details.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); diff --git a/TransactionReporting/get-transaction-list.php b/TransactionReporting/get-transaction-list.php index 3ca299d..bfad6f0 100644 --- a/TransactionReporting/get-transaction-list.php +++ b/TransactionReporting/get-transaction-list.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the request's refId $refId = 'ref' . time(); diff --git a/TransactionReporting/get-unsettled-transaction-list.php b/TransactionReporting/get-unsettled-transaction-list.php index e472349..45e9db8 100644 --- a/TransactionReporting/get-unsettled-transaction-list.php +++ b/TransactionReporting/get-unsettled-transaction-list.php @@ -1,5 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); diff --git a/VisaCheckout/create-visa-checkout-transaction.php b/VisaCheckout/create-visa-checkout-transaction.php index e39795f..8ec941c 100644 --- a/VisaCheckout/create-visa-checkout-transaction.php +++ b/VisaCheckout/create-visa-checkout-transaction.php @@ -1,6 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); @@ -42,7 +42,7 @@ function createVisaCheckoutTransaction() if ($response != null) { - if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) + if($response->getMessages()->getResultCode() == "Ok") { $tresponse = $response->getTransactionResponse(); if ($tresponse != null && $tresponse->getMessages() != null) diff --git a/VisaCheckout/decrypt-visa-checkout-data.php b/VisaCheckout/decrypt-visa-checkout-data.php index 21f8e94..48c8de4 100644 --- a/VisaCheckout/decrypt-visa-checkout-data.php +++ b/VisaCheckout/decrypt-visa-checkout-data.php @@ -1,6 +1,6 @@ setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); diff --git a/constants/Constants.php b/constants/Constants.php deleted file mode 100644 index d1ce2da..0000000 --- a/constants/Constants.php +++ /dev/null @@ -1,21 +0,0 @@ - - diff --git a/constants/SampleCodeConstants.php b/constants/SampleCodeConstants.php new file mode 100644 index 0000000..0cd03fd --- /dev/null +++ b/constants/SampleCodeConstants.php @@ -0,0 +1,9 @@ + + diff --git a/test-runner.php b/test-runner.php index e381c5b..ab4363a 100644 --- a/test-runner.php +++ b/test-runner.php @@ -2,7 +2,7 @@ define("DONT_RUN_SAMPLES", "true"); define("SAMPLE_CODE_NAME_HEADING", "SampleCodeName"); require 'vendor/autoload.php'; -require_once 'constants/Constants.php'; +require_once 'constants/SampleCodeConstants.php'; if ($_SERVER['argc'] != 3) { die('\n Usage: phpunit test-runner.php '); From 1e60d38f56ebe065f2f378ba35acf36e1169fb08 Mon Sep 17 00:00:00 2001 From: Basu Date: Fri, 20 Jul 2018 15:11:13 +0530 Subject: [PATCH 105/149] Removed_constants_folder_from_composer.json --- composer.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 1ffb837..0008661 100644 --- a/composer.json +++ b/composer.json @@ -3,9 +3,6 @@ "php": ">=5.6", "ext-curl": "*", "phpunit/phpunit": "~4.8||~6.0", - "authorizenet/authorizenet": ">=1.9.7 || <2.0" - }, - "autoload": { - "classmap": ["constants"] + "authorizenet/authorizenet": ">=1.9.7 || <2.0" } } From 0fddad0207d6fd5ef4334ec9bb1ad068aa192d5d Mon Sep 17 00:00:00 2001 From: Kaushik Date: Fri, 20 Jul 2018 17:55:36 +0530 Subject: [PATCH 106/149] Enhance Testrunner --- test-runner.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test-runner.php b/test-runner.php index e381c5b..6c43654 100644 --- a/test-runner.php +++ b/test-runner.php @@ -42,7 +42,7 @@ class TestRunner extends PHPUnit\Framework\TestCase //random amount for transactions/subscriptions public static function getAmount() { - return 12 + (rand(1, 900000)/12); + return 12 + (rand(1, 9000)/10); } //random email for a new customer profile public static function getEmail() @@ -70,12 +70,14 @@ public function testAllSampleCodes() list($apiName, $isDependent, $shouldRun)=explode(",", $line); $apiName = trim($apiName); echo "\nApi name: " . $apiName."\n"; + fwrite(STDOUT, print_r("\nStarting Test: " . $apiName."\n", TRUE)); } if ($apiName && (false === strpos($apiName, SAMPLE_CODE_NAME_HEADING))) { echo "should run:".$shouldRun."\n"; if ("0" === $shouldRun) { - echo ":Skipping " . $sampleMethodName . "\n"; + echo ":Skipping " . $apiName . "\n"; } else { + //Try the request twice for ($i=0; $i<=1; $i++) { if ("0" === $isDependent) { echo "not dependent\n"; @@ -89,7 +91,9 @@ public function testAllSampleCodes() //request the api echo "Running sample: " . $sampleMethodName . "\n"; + fwrite(STDOUT, print_r($apiName . "Start Time: " . date("H:i:s."). gettimeofday()['usec'] . "\n", TRUE)); $response = call_user_func($sampleMethodName); + fwrite(STDOUT, print_r($apiName . "Finish Time: " . date("H:i:s."). gettimeofday()['usec'] . "\n", TRUE)); if (($response != null) && ($response->getMessages()->getResultCode() == "Ok")) { break; @@ -99,6 +103,7 @@ public function testAllSampleCodes() //response must be successful $this->assertNotNull($response); $this->assertEquals($response->getMessages()->getResultCode(), "Ok"); + echo $sampleMethodName . " - OK \n"; $runTests++; } } From c15c27b798ba6107b1fbd8b6ead4b099dd5268c6 Mon Sep 17 00:00:00 2001 From: Kaushik Date: Thu, 2 Aug 2018 17:29:09 +0530 Subject: [PATCH 107/149] Randomize Bank account numbers --- PaymentTransactions/credit-bank-account.php | 5 ++++- PaymentTransactions/debit-bank-account.php | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/PaymentTransactions/credit-bank-account.php b/PaymentTransactions/credit-bank-account.php index bab21f6..b68f771 100644 --- a/PaymentTransactions/credit-bank-account.php +++ b/PaymentTransactions/credit-bank-account.php @@ -17,13 +17,16 @@ function creditBankAccount($amount) // Set the transaction's refId $refId = 'ref' . time(); + //Generate random bank account number + $randomAccountNumber= rand(100000000,9999999999); + // Create the payment data for a Bank Account $bankAccount = new AnetAPI\BankAccountType(); $bankAccount->setAccountType('checking'); // see eCheck documentation for proper echeck type to use for each situation //$bankAccount->setEcheckType('WEB'); $bankAccount->setRoutingNumber('122000661'); //('122235821'); //('125008547'); - $bankAccount->setAccountNumber('1234567890'); + $bankAccount->setAccountNumber($randomAccountNumber); $bankAccount->setNameOnAccount('John Doe'); $bankAccount->setBankName('Wells Fargo Bank NA'); diff --git a/PaymentTransactions/debit-bank-account.php b/PaymentTransactions/debit-bank-account.php index c3da2b2..26d6b93 100644 --- a/PaymentTransactions/debit-bank-account.php +++ b/PaymentTransactions/debit-bank-account.php @@ -17,13 +17,16 @@ function debitBankAccount($amount) // Set the transaction's refId $refId = 'ref' . time(); + //Generate random bank account number + $randomAccountNumber= rand(100000000,9999999999); + // Create the payment data for a Bank Account $bankAccount = new AnetAPI\BankAccountType(); $bankAccount->setAccountType('checking'); // see eCheck documentation for proper echeck type to use for each situation $bankAccount->setEcheckType('WEB'); $bankAccount->setRoutingNumber('122000661'); - $bankAccount->setAccountNumber('1234567890'); + $bankAccount->setAccountNumber($randomAccountNumber); $bankAccount->setNameOnAccount('John Doe'); $bankAccount->setBankName('Wells Fargo Bank NA'); From 79aa06acfb6f5760f68c05d1990d59f30c78a634 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Fri, 10 Aug 2018 16:54:15 +0530 Subject: [PATCH 108/149] + Adding files to Accept Suite --- .../create-an-accept-payment-transaction.php | 0 .../create-an-accept-transaction.php | 0 .../get-accept-customer-profile-page.php | 0 .../get-an-accept-payment-page.php | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename {PaymentTransactions => AcceptSuite}/create-an-accept-payment-transaction.php (100%) rename {MobileInAppTransactions => AcceptSuite}/create-an-accept-transaction.php (100%) rename {CustomerProfiles => AcceptSuite}/get-accept-customer-profile-page.php (100%) rename {PaymentTransactions => AcceptSuite}/get-an-accept-payment-page.php (100%) diff --git a/PaymentTransactions/create-an-accept-payment-transaction.php b/AcceptSuite/create-an-accept-payment-transaction.php similarity index 100% rename from PaymentTransactions/create-an-accept-payment-transaction.php rename to AcceptSuite/create-an-accept-payment-transaction.php diff --git a/MobileInAppTransactions/create-an-accept-transaction.php b/AcceptSuite/create-an-accept-transaction.php similarity index 100% rename from MobileInAppTransactions/create-an-accept-transaction.php rename to AcceptSuite/create-an-accept-transaction.php diff --git a/CustomerProfiles/get-accept-customer-profile-page.php b/AcceptSuite/get-accept-customer-profile-page.php similarity index 100% rename from CustomerProfiles/get-accept-customer-profile-page.php rename to AcceptSuite/get-accept-customer-profile-page.php diff --git a/PaymentTransactions/get-an-accept-payment-page.php b/AcceptSuite/get-an-accept-payment-page.php similarity index 100% rename from PaymentTransactions/get-an-accept-payment-page.php rename to AcceptSuite/get-an-accept-payment-page.php From 8dd58e3cde60b3630945b2da415a021b8ca049f2 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Fri, 10 Aug 2018 17:04:15 +0530 Subject: [PATCH 109/149] + Fixing test-runner.php --- test-runner.php | 1 + 1 file changed, 1 insertion(+) diff --git a/test-runner.php b/test-runner.php index d974414..e4ac837 100644 --- a/test-runner.php +++ b/test-runner.php @@ -14,6 +14,7 @@ } $directories = array( + 'AcceptSuite/', 'CustomerProfiles/', 'RecurringBilling/', 'PayPalExpressCheckout/', From d1604b77d8f9c6d4c0f5086e6fff3715cc3f17a6 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Fri, 10 Aug 2018 23:51:28 +0530 Subject: [PATCH 110/149] Revert "+ Fixing test-runner.php" This reverts commit 8dd58e3cde60b3630945b2da415a021b8ca049f2. Reverting changes --- test-runner.php | 1 - 1 file changed, 1 deletion(-) diff --git a/test-runner.php b/test-runner.php index e4ac837..d974414 100644 --- a/test-runner.php +++ b/test-runner.php @@ -14,7 +14,6 @@ } $directories = array( - 'AcceptSuite/', 'CustomerProfiles/', 'RecurringBilling/', 'PayPalExpressCheckout/', From d155e1f73451f2d629f1f061ea7f38e58a9cd9af Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Fri, 10 Aug 2018 23:52:07 +0530 Subject: [PATCH 111/149] Revert "+ Adding files to Accept Suite" This reverts commit 79aa06acfb6f5760f68c05d1990d59f30c78a634. Reverting changes --- .../get-accept-customer-profile-page.php | 0 .../create-an-accept-transaction.php | 0 .../create-an-accept-payment-transaction.php | 0 .../get-an-accept-payment-page.php | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename {AcceptSuite => CustomerProfiles}/get-accept-customer-profile-page.php (100%) rename {AcceptSuite => MobileInAppTransactions}/create-an-accept-transaction.php (100%) rename {AcceptSuite => PaymentTransactions}/create-an-accept-payment-transaction.php (100%) rename {AcceptSuite => PaymentTransactions}/get-an-accept-payment-page.php (100%) diff --git a/AcceptSuite/get-accept-customer-profile-page.php b/CustomerProfiles/get-accept-customer-profile-page.php similarity index 100% rename from AcceptSuite/get-accept-customer-profile-page.php rename to CustomerProfiles/get-accept-customer-profile-page.php diff --git a/AcceptSuite/create-an-accept-transaction.php b/MobileInAppTransactions/create-an-accept-transaction.php similarity index 100% rename from AcceptSuite/create-an-accept-transaction.php rename to MobileInAppTransactions/create-an-accept-transaction.php diff --git a/AcceptSuite/create-an-accept-payment-transaction.php b/PaymentTransactions/create-an-accept-payment-transaction.php similarity index 100% rename from AcceptSuite/create-an-accept-payment-transaction.php rename to PaymentTransactions/create-an-accept-payment-transaction.php diff --git a/AcceptSuite/get-an-accept-payment-page.php b/PaymentTransactions/get-an-accept-payment-page.php similarity index 100% rename from AcceptSuite/get-an-accept-payment-page.php rename to PaymentTransactions/get-an-accept-payment-page.php From e0514f3cce814423d183014cc945e30a7d68a7b3 Mon Sep 17 00:00:00 2001 From: saikatbasu01 Date: Mon, 13 Aug 2018 17:22:55 +0530 Subject: [PATCH 112/149] Added randomization for account number in debit-bank-account sample code --- PaymentTransactions/debit-bank-account.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PaymentTransactions/debit-bank-account.php b/PaymentTransactions/debit-bank-account.php index c3da2b2..18d762e 100644 --- a/PaymentTransactions/debit-bank-account.php +++ b/PaymentTransactions/debit-bank-account.php @@ -22,8 +22,8 @@ function debitBankAccount($amount) $bankAccount->setAccountType('checking'); // see eCheck documentation for proper echeck type to use for each situation $bankAccount->setEcheckType('WEB'); - $bankAccount->setRoutingNumber('122000661'); - $bankAccount->setAccountNumber('1234567890'); + $bankAccount->setRoutingNumber('125008547'); + $bankAccount->setAccountNumber(rand(10000,999999999999)); $bankAccount->setNameOnAccount('John Doe'); $bankAccount->setBankName('Wells Fargo Bank NA'); From b06e8e0241fb8baa268e13732d6f123abb0ec102 Mon Sep 17 00:00:00 2001 From: saikatbasu01 Date: Mon, 13 Aug 2018 17:30:24 +0530 Subject: [PATCH 113/149] Added randomization for account number in debit-bank-account sample code --- PaymentTransactions/debit-bank-account.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PaymentTransactions/debit-bank-account.php b/PaymentTransactions/debit-bank-account.php index 18d762e..ad9ba20 100644 --- a/PaymentTransactions/debit-bank-account.php +++ b/PaymentTransactions/debit-bank-account.php @@ -22,7 +22,7 @@ function debitBankAccount($amount) $bankAccount->setAccountType('checking'); // see eCheck documentation for proper echeck type to use for each situation $bankAccount->setEcheckType('WEB'); - $bankAccount->setRoutingNumber('125008547'); + $bankAccount->setRoutingNumber('122000661'); $bankAccount->setAccountNumber(rand(10000,999999999999)); $bankAccount->setNameOnAccount('John Doe'); $bankAccount->setBankName('Wells Fargo Bank NA'); From e99a9ad536fc902f74e41a77b22862947d7e7432 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Thu, 11 Oct 2018 15:25:51 +0530 Subject: [PATCH 114/149] Update for SDK v1.9.8 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 0008661..34fe3c3 100644 --- a/composer.json +++ b/composer.json @@ -3,6 +3,6 @@ "php": ">=5.6", "ext-curl": "*", "phpunit/phpunit": "~4.8||~6.0", - "authorizenet/authorizenet": ">=1.9.7 || <2.0" + "authorizenet/authorizenet": ">=1.9.8 || <2.0" } } From 7bea3435f127fc6a2ea8b5392df2f5eac7ba7e29 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Tue, 16 Oct 2018 10:35:11 +0530 Subject: [PATCH 115/149] October 18 Release of API Reference --- .../create-an-accept-payment-transaction.php | 0 .../get-accept-customer-profile-page.php | 0 .../get-an-accept-payment-page.php | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename {PaymentTransactions => AcceptSuite}/create-an-accept-payment-transaction.php (100%) rename {CustomerProfiles => AcceptSuite}/get-accept-customer-profile-page.php (100%) rename {PaymentTransactions => AcceptSuite}/get-an-accept-payment-page.php (100%) diff --git a/PaymentTransactions/create-an-accept-payment-transaction.php b/AcceptSuite/create-an-accept-payment-transaction.php similarity index 100% rename from PaymentTransactions/create-an-accept-payment-transaction.php rename to AcceptSuite/create-an-accept-payment-transaction.php diff --git a/CustomerProfiles/get-accept-customer-profile-page.php b/AcceptSuite/get-accept-customer-profile-page.php similarity index 100% rename from CustomerProfiles/get-accept-customer-profile-page.php rename to AcceptSuite/get-accept-customer-profile-page.php diff --git a/PaymentTransactions/get-an-accept-payment-page.php b/AcceptSuite/get-an-accept-payment-page.php similarity index 100% rename from PaymentTransactions/get-an-accept-payment-page.php rename to AcceptSuite/get-an-accept-payment-page.php From 4432ac4fad62e9aa5796dec4b2a9c70677c4a861 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Wed, 24 Oct 2018 12:51:35 +0530 Subject: [PATCH 116/149] Fixing AcceptSuite changes --- test-runner.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test-runner.php b/test-runner.php index d974414..61c981c 100644 --- a/test-runner.php +++ b/test-runner.php @@ -20,7 +20,8 @@ 'PaymentTransactions/', 'TransactionReporting/', 'MobileInappTransactions/', - 'VisaCheckout/' + 'VisaCheckout/', + 'AcceptSuite/' ); $errorlevel=error_reporting(); From c7e3401277db1bd763518af8001438dd2a169f18 Mon Sep 17 00:00:00 2001 From: Sharath Date: Thu, 25 Oct 2018 14:22:28 +0530 Subject: [PATCH 117/149] Changes made to call createAnAcceptPaymentTransaction method --- AcceptSuite/create-an-accept-payment-transaction.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AcceptSuite/create-an-accept-payment-transaction.php b/AcceptSuite/create-an-accept-payment-transaction.php index c38cc1c..562d514 100644 --- a/AcceptSuite/create-an-accept-payment-transaction.php +++ b/AcceptSuite/create-an-accept-payment-transaction.php @@ -128,6 +128,6 @@ function createAnAcceptPaymentTransaction($amount) } if (!defined('DONT_RUN_SAMPLES')) { - CreateAnAcceptTransaction("2.23"); + createAnAcceptPaymentTransaction("2.23"); } ?> \ No newline at end of file From 40ff2e59c86e1369af49f4b420dd39d8b5bca5e5 Mon Sep 17 00:00:00 2001 From: Anjali Nauhwar Date: Fri, 16 Nov 2018 10:54:16 +0530 Subject: [PATCH 118/149] + Correcting UpdateCustomerPaymentProfile --- .../update-customer-payment-profile.php | 150 ++++++++---------- 1 file changed, 70 insertions(+), 80 deletions(-) diff --git a/CustomerProfiles/update-customer-payment-profile.php b/CustomerProfiles/update-customer-payment-profile.php index 38b504c..6093087 100644 --- a/CustomerProfiles/update-customer-payment-profile.php +++ b/CustomerProfiles/update-customer-payment-profile.php @@ -6,9 +6,9 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); -function updateCustomerPaymentProfile($customerProfileId = "36731856", - $customerPaymentProfileId = "33211899" -) { +function updateCustomerPaymentProfile($customerProfileId = "1916322670", + $customerPaymentProfileId = "1829639667") +{ /* Create a merchantAuthenticationType object with authentication details retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); @@ -18,87 +18,77 @@ function updateCustomerPaymentProfile($customerProfileId = "36731856", // Set the transaction's refId $refId = 'ref' . time(); - //Set profile ids of profile to be updated - $request = new AnetAPI\UpdateCustomerPaymentProfileRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setCustomerProfileId($customerProfileId); - $controller = new AnetController\GetCustomerProfileController($request); - - - // We're updating the billing address but everything has to be passed in an update - // For card information you can pass exactly what comes back from an GetCustomerPaymentProfile - // if you don't need to update that info - $creditCard = new AnetAPI\CreditCardType(); - $creditCard->setCardNumber( "4111111111111111" ); - $creditCard->setExpirationDate("2038-12"); - $paymentCreditCard = new AnetAPI\PaymentType(); - $paymentCreditCard->setCreditCard($creditCard); - - // Create the Bill To info for new payment type - $billto = new AnetAPI\CustomerAddressType(); - $billto->setFirstName("Mrs Mary"); - $billto->setLastName("Doe"); - $billto->setAddress("1 New St."); - $billto->setCity("Brand New City"); - $billto->setState("WA"); - $billto->setZip("98004"); - $billto->setPhoneNumber("000-000-0000"); - $billto->setfaxNumber("999-999-9999"); - $billto->setCountry("USA"); + $request = new AnetAPI\GetCustomerPaymentProfileRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setRefId( $refId); + $request->setCustomerProfileId($customerProfileId); + $request->setCustomerPaymentProfileId($customerPaymentProfileId); + $controller = new AnetController\GetCustomerPaymentProfileController($request); + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok")) + { + $billto = new AnetAPI\CustomerAddressType(); + $billto = $response->getPaymentProfile()->getbillTo(); + + $creditCard = new AnetAPI\CreditCardType(); + $creditCard->setCardNumber( "4111111111111111" ); + $creditCard->setExpirationDate("2038-12"); + + $paymentCreditCard = new AnetAPI\PaymentType(); + $paymentCreditCard->setCreditCard($creditCard); + $paymentprofile = new AnetAPI\CustomerPaymentProfileExType(); + $paymentprofile->setBillTo($billto); + $paymentprofile->setCustomerPaymentProfileId($customerPaymentProfileId); + $paymentprofile->setPayment($paymentCreditCard); - // Create the Customer Payment Profile object - $paymentprofile = new AnetAPI\CustomerPaymentProfileExType(); - $paymentprofile->setCustomerPaymentProfileId($customerPaymentProfileId); - $paymentprofile->setBillTo($billto); - $paymentprofile->setPayment($paymentCreditCard); + // We're updating the billing address but everything has to be passed in an update + // For card information you can pass exactly what comes back from an GetCustomerPaymentProfile + // if you don't need to update that info + + // Update the Bill To info for new payment type + $billto->setFirstName("Mrs Mary"); + $billto->setLastName("Doe"); + $billto->setAddress("9 New St."); + $billto->setCity("Brand New City"); + $billto->setState("WA"); + $billto->setZip("98004"); + $billto->setPhoneNumber("000-000-0000"); + $billto->setfaxNumber("999-999-9999"); + $billto->setCountry("USA"); + + // Update the Customer Payment Profile object + $paymentprofile->setBillTo($billto); - // Submit a UpdatePaymentProfileRequest - $request->setPaymentProfile( $paymentprofile ); + // Submit a UpdatePaymentProfileRequest + $request = new AnetAPI\UpdateCustomerPaymentProfileRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setCustomerProfileId($customerProfileId); + $request->setPaymentProfile( $paymentprofile ); - $controller = new AnetController\UpdateCustomerPaymentProfileController($request); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) - { - echo "Update Customer Payment Profile SUCCESS: " . "\n"; - - // Update only returns success or fail, if success - // confirm the update by doing a GetCustomerPaymentProfile - $getRequest = new AnetAPI\GetCustomerPaymentProfileRequest(); - $getRequest->setMerchantAuthentication($merchantAuthentication); - $getRequest->setRefId( $refId); - $getRequest->setCustomerProfileId($customerProfileId); - $getRequest->setCustomerPaymentProfileId($customerPaymentProfileId); + $controller = new AnetController\UpdateCustomerPaymentProfileController($request); + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) + { + $Message = $response->getMessages()->getMessage(); + print_r($response); + echo "Update Customer Payment Profile SUCCESS: " . $Message[0]->getCode() . " " .$Message[0]->getText() . "\n"; + } + else + { + echo "Failed to Update Customer Payment Profile : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; + } + + return $response; + } + else + { + echo "Failed to Get Customer Payment Profile : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; + } - $controller = new AnetController\GetCustomerPaymentProfileController($getRequest); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - if(($response != null)){ - if ($response->getMessages()->getResultCode() == "Ok") - { - echo "GetCustomerPaymentProfile SUCCESS: " . "\n"; - echo "Customer Payment Profile Id: " . $response->getPaymentProfile()->getCustomerPaymentProfileId() . "\n"; - echo "Customer Payment Profile Billing Address: " . $response->getPaymentProfile()->getbillTo()->getAddress(). "\n"; - } - else - { - echo "GetCustomerPaymentProfile ERROR : Invalid response\n"; - $errorMessages = $response->getMessages()->getMessage(); - echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; - } - } - else{ - echo "NULL Response Error"; - } + return $response; +} - } - else - { - echo "Update Customer Payment Profile: ERROR Invalid response\n"; - $errorMessages = $response->getMessages()->getMessage(); - echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; - } - return $response; - } - if(!defined('DONT_RUN_SAMPLES')) - updateCustomerPaymentProfile(); +if(!defined('DONT_RUN_SAMPLES')) + updateCustomerPaymentProfile(); ?> From ebab0ec91f5ee4be52ad66db67a8d544dcfbd63c Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Thu, 29 Nov 2018 18:19:34 +0530 Subject: [PATCH 119/149] Changed version to v.1.9.9 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 34fe3c3..bd7d261 100644 --- a/composer.json +++ b/composer.json @@ -3,6 +3,6 @@ "php": ">=5.6", "ext-curl": "*", "phpunit/phpunit": "~4.8||~6.0", - "authorizenet/authorizenet": ">=1.9.8 || <2.0" + "authorizenet/authorizenet": ">=1.9.9 || <2.0" } } From e0a86ed7ebb007c35c3c3a8a7a5080681cbef3f7 Mon Sep 17 00:00:00 2001 From: Sharath Date: Mon, 10 Dec 2018 17:58:57 +0530 Subject: [PATCH 120/149] Sample-Code for Chase Pay --- .../create-chasepay-transaction.php | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 PaymentTransactions/create-chasepay-transaction.php diff --git a/PaymentTransactions/create-chasepay-transaction.php b/PaymentTransactions/create-chasepay-transaction.php new file mode 100644 index 0000000..c5634e4 --- /dev/null +++ b/PaymentTransactions/create-chasepay-transaction.php @@ -0,0 +1,98 @@ +setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId + $refId = 'ref' . time(); + + // Create the payment data for a credit card + $creditCard = new AnetAPI\CreditCardType(); + $creditCard->setCardNumber("4111111111111111"); + $creditCard->setExpirationDate("2038-12"); + $creditCard->setCardCode("999"); + // Set the token specific info + $creditCard->setIsPaymentToken(true); + $creditCard->setCryptogram("EjRWeJASNFZ4kBI0VniQEjRWeJA="); + $creditCard->setTokenRequestorName("CHASE_PAY"); + $creditCard->setTokenRequestorId("12345678901"); + $creditCard->setTokenRequestorEci("07"); + + $paymentOne = new AnetAPI\PaymentType(); + $paymentOne->setCreditCard($creditCard); + + //create a transaction + $transactionRequestType = new AnetAPI\TransactionRequestType(); + $transactionRequestType->setTransactionType("authCaptureTransaction"); + $transactionRequestType->setAmount($amount); + $transactionRequestType->setPayment($paymentOne); + + + $request = new AnetAPI\CreateTransactionRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setRefId( $refId); + $request->setTransactionRequest( $transactionRequestType); + $controller = new AnetController\CreateTransactionController($request); + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + + if ($response != null) + { + if($response->getMessages()->getResultCode() == "Ok") + { + $tresponse = $response->getTransactionResponse(); + + if ($tresponse != null && $tresponse->getMessages() != null) + { + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + echo "Charge Tokenized Credit Card AUTH CODE : " . $tresponse->getAuthCode() . "\n"; + echo "Charge Tokenized Credit Card TRANS ID : " . $tresponse->getTransId() . "\n"; + echo " Code : " . $tresponse->getMessages()[0]->getCode() . "\n"; + echo " Description : " . $tresponse->getMessages()[0]->getDescription() . "\n"; + } + else + { + echo "Transaction Failed \n"; + if($tresponse->getErrors() != null) + { + echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; + echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; + } + } + } + else + { + echo "Transaction Failed \n"; + $tresponse = $response->getTransactionResponse(); + if($tresponse != null && $tresponse->getErrors() != null) + { + echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; + echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; + } + else + { + echo " Error code : " . $response->getMessages()->getMessage()[0]->getCode() . "\n"; + echo " Error message : " . $response->getMessages()->getMessage()[0]->getText() . "\n"; + } + } + } + else + { + echo "No response returned \n"; + } + + return $response; + } + if(!defined('DONT_RUN_SAMPLES')) + createChasepayTransaction(12.23); +?> From 44fc49348f0d143c620ee76e984c93d74e97645a Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Thu, 13 Dec 2018 13:50:22 +0530 Subject: [PATCH 121/149] + Fixing the name of the file --- ...sepay-transaction.php => create-chase-pay-transaction.php} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename PaymentTransactions/{create-chasepay-transaction.php => create-chase-pay-transaction.php} (97%) diff --git a/PaymentTransactions/create-chasepay-transaction.php b/PaymentTransactions/create-chase-pay-transaction.php similarity index 97% rename from PaymentTransactions/create-chasepay-transaction.php rename to PaymentTransactions/create-chase-pay-transaction.php index c5634e4..ccf1b02 100644 --- a/PaymentTransactions/create-chasepay-transaction.php +++ b/PaymentTransactions/create-chase-pay-transaction.php @@ -6,7 +6,7 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); -function createChasepayTransaction($amount) +function createChasePayTransaction($amount) { /* Create a merchantAuthenticationType object with authentication details retrieved from the constants file */ @@ -94,5 +94,5 @@ function createChasepayTransaction($amount) return $response; } if(!defined('DONT_RUN_SAMPLES')) - createChasepayTransaction(12.23); + createChasePayTransaction(12.23); ?> From 039ccc95e3c74c8e58abede4fd28f5c69b61d1cf Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Wed, 19 Dec 2018 19:43:18 +0530 Subject: [PATCH 122/149] Adding comment on refId field --- TransactionReporting/get-transaction-details.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/TransactionReporting/get-transaction-details.php b/TransactionReporting/get-transaction-details.php index d54def5..1822d78 100644 --- a/TransactionReporting/get-transaction-details.php +++ b/TransactionReporting/get-transaction-details.php @@ -15,6 +15,9 @@ function getTransactionDetails($transactionId) $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId + // The refId is a Merchant-assigned reference ID for the request. + // If included in the request, this value is included in the response. + // This feature might be especially useful for multi-threaded applications. $refId = 'ref' . time(); $request = new AnetAPI\GetTransactionDetailsRequest(); @@ -43,4 +46,4 @@ function getTransactionDetails($transactionId) if(!defined('DONT_RUN_SAMPLES')) getTransactionDetails("2238968786"); -?> \ No newline at end of file +?> From 4d914c4ac2ea354101ec189367a22a959d11f301 Mon Sep 17 00:00:00 2001 From: Kaushik Mahato Date: Mon, 7 Jan 2019 15:45:25 +0530 Subject: [PATCH 123/149] Removed unwanted ] --- CustomerProfiles/delete-customer-payment-profile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CustomerProfiles/delete-customer-payment-profile.php b/CustomerProfiles/delete-customer-payment-profile.php index 2ddf876..64383d9 100644 --- a/CustomerProfiles/delete-customer-payment-profile.php +++ b/CustomerProfiles/delete-customer-payment-profile.php @@ -1,4 +1,4 @@ -] Date: Mon, 7 Jan 2019 15:56:54 +0530 Subject: [PATCH 124/149] Update create-customer-profile-with-accept-nonce.php --- CustomerProfiles/create-customer-profile-with-accept-nonce.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CustomerProfiles/create-customer-profile-with-accept-nonce.php b/CustomerProfiles/create-customer-profile-with-accept-nonce.php index d9d0375..abce577 100644 --- a/CustomerProfiles/create-customer-profile-with-accept-nonce.php +++ b/CustomerProfiles/create-customer-profile-with-accept-nonce.php @@ -42,7 +42,7 @@ function createCustomerProfileWithAcceptNonce($email) $billto->setState("TX"); $billto->setZip("44628"); $billto->setCountry("USA"); - $billto->setPhoneNumber($phoneNumber); + $billto->setPhoneNumber(123-123-1234); $billto->setfaxNumber("999-999-9999"); // Create a new Customer Payment Profile object From 87314cda6dd3867e44625f2a71b79d6c888ace33 Mon Sep 17 00:00:00 2001 From: KarthikeyanKumar Date: Thu, 14 Feb 2019 10:36:02 +0530 Subject: [PATCH 125/149] Create compute_trans_hashSHA2.php This is the code to verify anet payments integrity using sha hmac512 algorithm --- Sha512/compute_trans_hashSHA2.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Sha512/compute_trans_hashSHA2.php diff --git a/Sha512/compute_trans_hashSHA2.php b/Sha512/compute_trans_hashSHA2.php new file mode 100644 index 0000000..fbf6e75 --- /dev/null +++ b/Sha512/compute_trans_hashSHA2.php @@ -0,0 +1,20 @@ + From 3d4ef81948f86820bf3f1237204e812262b6db36 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Mon, 18 Mar 2019 11:37:22 +0530 Subject: [PATCH 126/149] Transaction Hash Upgrade Guide --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 99bb4ff..16df4c1 100644 --- a/README.md +++ b/README.md @@ -48,3 +48,7 @@ We provide a custom `SPL` autoloader. Just [download the SDK](https://github.com ```php require 'path/to/anet_php_sdk/autoload.php'; ``` + + +### Transaction Hash Upgrade +Authorize.Net is phasing out the MD5 based `transHash` element in favor of the SHA-512 based `transHashSHA2`. The setting in the Merchant Interface which controlled the MD5 Hash option is no longer available, and the `transHash` element will stop returning values at a later date to be determined. For information on how to use `transHashSHA2`, see the [Transaction Hash Upgrade Guide] (https://developer.authorize.net/support/hash_upgrade/). From 3b8fc7c1462e240c4b4c497984c45e680f6a94de Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Mon, 18 Mar 2019 11:38:34 +0530 Subject: [PATCH 127/149] Reverting change --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index 16df4c1..99bb4ff 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,3 @@ We provide a custom `SPL` autoloader. Just [download the SDK](https://github.com ```php require 'path/to/anet_php_sdk/autoload.php'; ``` - - -### Transaction Hash Upgrade -Authorize.Net is phasing out the MD5 based `transHash` element in favor of the SHA-512 based `transHashSHA2`. The setting in the Merchant Interface which controlled the MD5 Hash option is no longer available, and the `transHash` element will stop returning values at a later date to be determined. For information on how to use `transHashSHA2`, see the [Transaction Hash Upgrade Guide] (https://developer.authorize.net/support/hash_upgrade/). From 6e1dcf6d2d86950b5973946b2507c70d8ec83381 Mon Sep 17 00:00:00 2001 From: Kaushik Mahato Date: Fri, 21 Jun 2019 13:53:17 +0530 Subject: [PATCH 128/149] Update create-customer-profile.php removing $paymentProfile->setDefaultpaymentProfile(true); as its not valid for this sample code --- CustomerProfiles/create-customer-profile.php | 1 - 1 file changed, 1 deletion(-) diff --git a/CustomerProfiles/create-customer-profile.php b/CustomerProfiles/create-customer-profile.php index 91390da..49fb43f 100644 --- a/CustomerProfiles/create-customer-profile.php +++ b/CustomerProfiles/create-customer-profile.php @@ -67,7 +67,6 @@ function createCustomerProfile($email) $paymentProfile->setCustomerType('individual'); $paymentProfile->setBillTo($billTo); $paymentProfile->setPayment($paymentCreditCard); - $paymentProfile->setDefaultpaymentProfile(true); $paymentProfiles[] = $paymentProfile; From a642526ff20068d05685303f8e42b7bbefd79dd4 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Wed, 31 Jul 2019 22:10:50 +0530 Subject: [PATCH 129/149] Update update-customer-payment-profile.php --- CustomerProfiles/update-customer-payment-profile.php | 1 + 1 file changed, 1 insertion(+) diff --git a/CustomerProfiles/update-customer-payment-profile.php b/CustomerProfiles/update-customer-payment-profile.php index 6093087..834c18f 100644 --- a/CustomerProfiles/update-customer-payment-profile.php +++ b/CustomerProfiles/update-customer-payment-profile.php @@ -76,6 +76,7 @@ function updateCustomerPaymentProfile($customerProfileId = "1916322670", } else { + $errorMessages = $response->getMessages()->getMessage(); echo "Failed to Update Customer Payment Profile : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } From 5de62af3679d3e0e6a69177ff6ff938d77f5d46f Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Wed, 31 Jul 2019 22:12:41 +0530 Subject: [PATCH 130/149] Update update-customer-payment-profile.php --- CustomerProfiles/update-customer-payment-profile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CustomerProfiles/update-customer-payment-profile.php b/CustomerProfiles/update-customer-payment-profile.php index 834c18f..484d5e5 100644 --- a/CustomerProfiles/update-customer-payment-profile.php +++ b/CustomerProfiles/update-customer-payment-profile.php @@ -74,7 +74,7 @@ function updateCustomerPaymentProfile($customerProfileId = "1916322670", print_r($response); echo "Update Customer Payment Profile SUCCESS: " . $Message[0]->getCode() . " " .$Message[0]->getText() . "\n"; } - else + else if ($response != null) { $errorMessages = $response->getMessages()->getMessage(); echo "Failed to Update Customer Payment Profile : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; From b66cc4033af0730a58827dfe5808549e3e19e42e Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Wed, 31 Jul 2019 22:13:27 +0530 Subject: [PATCH 131/149] Update .travis.yml --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 0d096c4..efd338d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,7 @@ language: php +dist: trusty + php: - 5.6 - 7.0 From c68826ea454f83b02afcd1598a4e73a2f00687d6 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Wed, 4 Mar 2020 13:56:51 +0530 Subject: [PATCH 132/149] + Renamed Visa Checkout to Visa SRC + Blocking GetCustomerProfileIds call as response exceeds log limit --- SampleCodeList.txt | 6 +++--- ...kout-transaction.php => create-visa-src-transaction.php} | 4 ++-- ...ypt-visa-checkout-data.php => decrypt-visa-src-data.php} | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) rename VisaCheckout/{create-visa-checkout-transaction.php => create-visa-src-transaction.php} (98%) rename VisaCheckout/{decrypt-visa-checkout-data.php => decrypt-visa-src-data.php} (98%) diff --git a/SampleCodeList.txt b/SampleCodeList.txt index 621aa28..a41fd6f 100644 --- a/SampleCodeList.txt +++ b/SampleCodeList.txt @@ -7,8 +7,8 @@ GetTransactionList,0,1 CreateAnApplePayTransaction,0,0 CreateAnAcceptTransaction,0,0 CreateAnAndroidPayTransaction,0,0 -DecryptVisaCheckoutData,0,1 -CreateVisaCheckoutTransaction,0,0 +decryptVisaSrcData,0,1 +createVisaSrcTransaction,0,0 CaptureFundsAuthorizedThroughAnotherChannel,1,1 AuthorizeCreditCard,1,1 DebitBankAccount,1,1 @@ -23,7 +23,7 @@ UpdateCustomerShippingAddress,1,1 UpdateCustomerProfile,0,1 UpdateCustomerPaymentProfile,1,1 GetCustomerShippingAddress,1,1 -GetCustomerProfileIds,0,1 +GetCustomerProfileIds,0,0 GetCustomerProfile,1,1 GetAcceptCustomerProfilePage,1,1 GetCustomerPaymentProfile,1,1 diff --git a/VisaCheckout/create-visa-checkout-transaction.php b/VisaCheckout/create-visa-src-transaction.php similarity index 98% rename from VisaCheckout/create-visa-checkout-transaction.php rename to VisaCheckout/create-visa-src-transaction.php index 8ec941c..1edcf11 100644 --- a/VisaCheckout/create-visa-checkout-transaction.php +++ b/VisaCheckout/create-visa-src-transaction.php @@ -6,7 +6,7 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); -function createVisaCheckoutTransaction() +function createVisaSrcTransaction() { /* Create a merchantAuthenticationType object with authentication details retrieved from the constants file */ @@ -88,6 +88,6 @@ function createVisaCheckoutTransaction() } if(!defined('DONT_RUN_SAMPLES')) - createVisaCheckoutTransaction(); + createVisaSrcTransaction(); ?> diff --git a/VisaCheckout/decrypt-visa-checkout-data.php b/VisaCheckout/decrypt-visa-src-data.php similarity index 98% rename from VisaCheckout/decrypt-visa-checkout-data.php rename to VisaCheckout/decrypt-visa-src-data.php index 48c8de4..2b2b791 100644 --- a/VisaCheckout/decrypt-visa-checkout-data.php +++ b/VisaCheckout/decrypt-visa-src-data.php @@ -6,7 +6,7 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); -function decryptVisaCheckoutData() +function decryptVisaSrcData() { /* Create a merchantAuthenticationType object with authentication details retrieved from the constants file */ @@ -46,6 +46,6 @@ function decryptVisaCheckoutData() } if(!defined('DONT_RUN_SAMPLES')) - decryptVisaCheckoutData(); + decryptVisaSrcData(); ?> From 064ae813384b352d80f8281f13b566ba0b5e281c Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Thu, 4 Feb 2021 23:35:56 +0530 Subject: [PATCH 133/149] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index bd7d261..7d41385 100644 --- a/composer.json +++ b/composer.json @@ -3,6 +3,6 @@ "php": ">=5.6", "ext-curl": "*", "phpunit/phpunit": "~4.8||~6.0", - "authorizenet/authorizenet": ">=1.9.9 || <2.0" + "authorizenet/authorizenet": ">=1.9.9 || <2.1" } } From a9415419647e05e35aa226b328f469383c337119 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Mon, 8 Mar 2021 15:29:54 +0530 Subject: [PATCH 134/149] Testing on PHP v8.0 --- .travis.yml | 5 +++- .../create-customer-payment-profile.php | 2 +- .../create-customer-shipping-address.php | 2 +- .../delete-customer-payment-profile.php | 4 +-- CustomerProfiles/delete-customer-profile.php | 2 +- .../delete-customer-shipping-address.php | 2 +- .../get-customer-payment-profile.php | 4 +-- .../update-customer-shipping-address.php | 2 +- .../validate-customer-payment-profile.php | 4 +-- RecurringBilling/cancel-subscription.php | 2 +- RecurringBilling/create-subscription.php | 2 +- test-runner.php => TestRunner.php | 0 TransactionReporting/get-transaction-list.php | 26 +++++++++---------- 13 files changed, 30 insertions(+), 27 deletions(-) rename test-runner.php => TestRunner.php (100%) diff --git a/.travis.yml b/.travis.yml index efd338d..8c7ae89 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,9 @@ php: - 5.6 - 7.0 - 7.1 + - 7.3 + - 7.4 + - 8.0 sudo: false @@ -13,5 +16,5 @@ before_script: - composer install --prefer-dist script: - - phpunit test-runner.php . + - phpunit TestRunner.php . diff --git a/CustomerProfiles/create-customer-payment-profile.php b/CustomerProfiles/create-customer-payment-profile.php index 1acb10c..3c3812f 100644 --- a/CustomerProfiles/create-customer-payment-profile.php +++ b/CustomerProfiles/create-customer-payment-profile.php @@ -79,6 +79,6 @@ function createCustomerPaymentProfile($existingcustomerprofileid, $phoneNumber) } if (!defined('DONT_RUN_SAMPLES')) { - createCustomerPaymentProfile("1807545561", "000-000-0009"); + createCustomerPaymentProfile("1929905607", "000-000-0009"); } ?> diff --git a/CustomerProfiles/create-customer-shipping-address.php b/CustomerProfiles/create-customer-shipping-address.php index 22ce6fb..3044353 100644 --- a/CustomerProfiles/create-customer-shipping-address.php +++ b/CustomerProfiles/create-customer-shipping-address.php @@ -6,7 +6,7 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); -function createCustomerShippingAddress($existingcustomerprofileid = "36152127", +function createCustomerShippingAddress($existingcustomerprofileid = "1929905607", $phoneNumber="000-000-0000" ) { /* Create a merchantAuthenticationType object with authentication details diff --git a/CustomerProfiles/delete-customer-payment-profile.php b/CustomerProfiles/delete-customer-payment-profile.php index 64383d9..ce3e6ca 100644 --- a/CustomerProfiles/delete-customer-payment-profile.php +++ b/CustomerProfiles/delete-customer-payment-profile.php @@ -6,8 +6,8 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); -function deleteCustomerPaymentProfile($customerProfileId= "36152127", - $customerpaymentprofileid = "32689274" +function deleteCustomerPaymentProfile($customerProfileId= "1929905607", + $customerpaymentprofileid = "1842074814" ) { /* Create a merchantAuthenticationType object with authentication details retrieved from the constants file */ diff --git a/CustomerProfiles/delete-customer-profile.php b/CustomerProfiles/delete-customer-profile.php index 9044d0c..ee918cc 100644 --- a/CustomerProfiles/delete-customer-profile.php +++ b/CustomerProfiles/delete-customer-profile.php @@ -39,5 +39,5 @@ function deleteCustomerProfile($customerProfileId) } if(!defined('DONT_RUN_SAMPLES')) - deleteCustomerProfile("38958129"); + deleteCustomerProfile("1929905651"); ?> diff --git a/CustomerProfiles/delete-customer-shipping-address.php b/CustomerProfiles/delete-customer-shipping-address.php index 9d3cb2f..d3f2ccc 100644 --- a/CustomerProfiles/delete-customer-shipping-address.php +++ b/CustomerProfiles/delete-customer-shipping-address.php @@ -6,7 +6,7 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); -function deleteCustomerShippingAddress($customerprofileid = "36731856", $customeraddressid = "36976434") +function deleteCustomerShippingAddress($customerprofileid = "1929905607", $customeraddressid = "901116911") { /* Create a merchantAuthenticationType object with authentication details retrieved from the constants file */ diff --git a/CustomerProfiles/get-customer-payment-profile.php b/CustomerProfiles/get-customer-payment-profile.php index c059bc5..6e056a5 100644 --- a/CustomerProfiles/get-customer-payment-profile.php +++ b/CustomerProfiles/get-customer-payment-profile.php @@ -7,8 +7,8 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); -function getCustomerPaymentProfile($customerProfileId="36731856", - $customerPaymentProfileId= "33211899" +function getCustomerPaymentProfile($customerProfileId="1929905607", + $customerPaymentProfileId= "1842074814" ) { /* Create a merchantAuthenticationType object with authentication details retrieved from the constants file */ diff --git a/CustomerProfiles/update-customer-shipping-address.php b/CustomerProfiles/update-customer-shipping-address.php index 3c7cb7f..36ad6ad 100644 --- a/CustomerProfiles/update-customer-shipping-address.php +++ b/CustomerProfiles/update-customer-shipping-address.php @@ -54,5 +54,5 @@ function updateCustomerShippingAddress($customerprofileid, $customeraddressid) return $response; } if(!defined('DONT_RUN_SAMPLES')) - updateCustomerShippingAddress( "36152127","36976566"); + updateCustomerShippingAddress( "1929905607","901116911"); ?> diff --git a/CustomerProfiles/validate-customer-payment-profile.php b/CustomerProfiles/validate-customer-payment-profile.php index b262186..ca57209 100644 --- a/CustomerProfiles/validate-customer-payment-profile.php +++ b/CustomerProfiles/validate-customer-payment-profile.php @@ -6,8 +6,8 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); -function validateCustomerPaymentProfile($customerProfileId= "36731856", - $customerPaymentProfileId= "33211899" +function validateCustomerPaymentProfile($customerProfileId= "1929905607", + $customerPaymentProfileId= "1842074814" ) { /* Create a merchantAuthenticationType object with authentication details retrieved from the constants file */ diff --git a/RecurringBilling/cancel-subscription.php b/RecurringBilling/cancel-subscription.php index e4cbe9e..59f8553 100644 --- a/RecurringBilling/cancel-subscription.php +++ b/RecurringBilling/cancel-subscription.php @@ -45,6 +45,6 @@ function cancelSubscription($subscriptionId) } if(!defined('DONT_RUN_SAMPLES')) - cancelSubscription("3056945"); + cancelSubscription("7087965"); ?> diff --git a/RecurringBilling/create-subscription.php b/RecurringBilling/create-subscription.php index 66f539a..1bf6fba 100644 --- a/RecurringBilling/create-subscription.php +++ b/RecurringBilling/create-subscription.php @@ -28,7 +28,7 @@ function createSubscription($intervalLength) $paymentSchedule = new AnetAPI\PaymentScheduleType(); $paymentSchedule->setInterval($interval); - $paymentSchedule->setStartDate(new DateTime('2020-08-30')); + $paymentSchedule->setStartDate(new DateTime('2035-12-30')); $paymentSchedule->setTotalOccurrences("12"); $paymentSchedule->setTrialOccurrences("1"); diff --git a/test-runner.php b/TestRunner.php similarity index 100% rename from test-runner.php rename to TestRunner.php diff --git a/TransactionReporting/get-transaction-list.php b/TransactionReporting/get-transaction-list.php index bfad6f0..ccf86c1 100644 --- a/TransactionReporting/get-transaction-list.php +++ b/TransactionReporting/get-transaction-list.php @@ -30,19 +30,19 @@ function getTransactionList() if (($response != null) && ($response->getMessages()->getResultCode() == "Ok")) { - echo "SUCCESS: Get Transaction List for BatchID : " . $batchId . "\n\n"; - if ($response->getTransactions() == null) { - echo "No Transaction to display in this Batch."; - return ; - } - //Displaying the details of each transaction in the list - foreach ($response->getTransactions() as $transaction) { - echo " ->Transaction Id : " . $transaction->getTransId() . "\n"; - echo " Submitted on (Local) : " . date_format($transaction->getSubmitTimeLocal(), 'Y-m-d H:i:s') . "\n"; - echo " Status : " . $transaction->getTransactionStatus() . "\n"; - echo " Settle amount : " . number_format($transaction->getSettleAmount(), 2, '.', '') . "\n"; - } - } + echo "SUCCESS: Get Transaction List for BatchID : " . $batchId . "\n\n"; + if ($response->getTransactions() == null) { + echo "No Transaction to display in this Batch."; + return $response; + } + //Displaying the details of each transaction in the list + foreach ($response->getTransactions() as $transaction) { + echo " ->Transaction Id : " . $transaction->getTransId() . "\n"; + echo " Submitted on (Local) : " . date_format($transaction->getSubmitTimeLocal(), 'Y-m-d H:i:s') . "\n"; + echo " Status : " . $transaction->getTransactionStatus() . "\n"; + echo " Settle amount : " . number_format($transaction->getSettleAmount(), 2, '.', '') . "\n"; + } + } else { echo "ERROR : Invalid response\n"; From fc1b992e618c453edfc7fb8c8369f6421e5a421a Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Mon, 8 Mar 2021 15:31:19 +0530 Subject: [PATCH 135/149] Updating to latest version --- composer.json | 4 ++-- composer.json.sdk-dev | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index bd7d261..a33436e 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "require": { "php": ">=5.6", "ext-curl": "*", - "phpunit/phpunit": "~4.8||~6.0", - "authorizenet/authorizenet": ">=1.9.9 || <2.0" + "phpunit/phpunit": "~9.0||~9.5", + "authorizenet/authorizenet": ">=2.0 || <2.1" } } diff --git a/composer.json.sdk-dev b/composer.json.sdk-dev index 12fdd53..9caf00c 100644 --- a/composer.json.sdk-dev +++ b/composer.json.sdk-dev @@ -2,8 +2,8 @@ "require": { "php": ">=5.6", "ext-curl": "*", - "phpunit/phpunit": "~4.8||~6.0", - "authorizenet/authorizenet": ">=1.9.6 || <2.0" + "phpunit/phpunit": "~9.0||~9.5", + "authorizenet/authorizenet": ">=2.0 || <2.1" }, "autoload": { "classmap": ["constants", "lib"] From 45e4119274568006b12d77861219e105a83566d4 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Mon, 8 Mar 2021 15:38:08 +0530 Subject: [PATCH 136/149] Changed composer to update --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8c7ae89..26a04b3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ php: sudo: false before_script: - - composer install --prefer-dist + - composer update --prefer-dist script: - phpunit TestRunner.php . From 33a17976bbfdbd9f40e6d1e9aa4211f862407936 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Mon, 8 Mar 2021 15:45:05 +0530 Subject: [PATCH 137/149] Downgraded version of phpunit --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index a33436e..b4a3a6b 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "require": { "php": ">=5.6", "ext-curl": "*", - "phpunit/phpunit": "~9.0||~9.5", + "phpunit/phpunit": "~4.8||~6.0", "authorizenet/authorizenet": ">=2.0 || <2.1" } } From 51a436d0b882bb0daf150ed095fbc7db7b2ab48f Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Mon, 8 Mar 2021 15:52:38 +0530 Subject: [PATCH 138/149] Testing without trusty image --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 26a04b3..af82246 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: php -dist: trusty +# dist: trusty php: - 5.6 From cb43517fe605cebe1193970196251c0b6518af74 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Mon, 8 Mar 2021 16:37:06 +0530 Subject: [PATCH 139/149] Testing multiple versions of PhpUnit --- .travis.yml | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index af82246..896ef42 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,13 +6,35 @@ php: - 5.6 - 7.0 - 7.1 + - 7.2 - 7.3 - 7.4 - 8.0 - + +env: + - PHPUNIT_VERSION=5.6.* + +matrix: + include: + - php: 5.6 + env: PHPUNIT_VERSION=5.6.* + - php: 7.0 + env: PHPUNIT_VERSION=6.5.* + - php: 7.1 + env: PHPUNIT_VERSION=7.5.* + - php: 7.2 + env: PHPUNIT_VERSION=8.5.* + - php: 7.3 + env: PHPUNIT_VERSION=9.5.* + - php: 7.4 + env: PHPUNIT_VERSION=9.5.* + - php: 8.0 + env: PHPUNIT_VERSION=9.5.* + sudo: false before_script: + - composer require "phpunit/phpunit:${PHPUNIT_VERSION}" --no-update - composer update --prefer-dist script: From 13d437891bfd90668fef1d06a5b7bd67ae4b7e9e Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Mon, 8 Mar 2021 16:39:28 +0530 Subject: [PATCH 140/149] Removed base version of PhpUnit --- .travis.yml | 4 ++-- composer.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 896ef42..4263ae5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,8 +11,8 @@ php: - 7.4 - 8.0 -env: - - PHPUNIT_VERSION=5.6.* +# env: +# - PHPUNIT_VERSION=5.6.* matrix: include: diff --git a/composer.json b/composer.json index b4a3a6b..c9bf403 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "require": { "php": ">=5.6", "ext-curl": "*", - "phpunit/phpunit": "~4.8||~6.0", + "phpunit/phpunit": "9.3.5", "authorizenet/authorizenet": ">=2.0 || <2.1" } } From e2ac0c16a4fdd06d3a557494b3b08183af5a80de Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Mon, 8 Mar 2021 16:41:06 +0530 Subject: [PATCH 141/149] Removed dependency to phpunit from composer --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index c9bf403..08f03a6 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,6 @@ "require": { "php": ">=5.6", "ext-curl": "*", - "phpunit/phpunit": "9.3.5", "authorizenet/authorizenet": ">=2.0 || <2.1" } } From 8a9d912c92015fea5127de47b9a3b9b2ca405ee0 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Mon, 8 Mar 2021 16:42:31 +0530 Subject: [PATCH 142/149] Comment out php versions without env variables --- .travis.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4263ae5..d0845ee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,14 +2,14 @@ language: php # dist: trusty -php: - - 5.6 - - 7.0 - - 7.1 - - 7.2 - - 7.3 - - 7.4 - - 8.0 +# php: +# - 5.6 +# - 7.0 +# - 7.1 +# - 7.2 +# - 7.3 +# - 7.4 +# - 8.0 # env: # - PHPUNIT_VERSION=5.6.* From 13f9e73de7ed04e62937cadfbdc42625b43c5a40 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Mon, 8 Mar 2021 16:55:27 +0530 Subject: [PATCH 143/149] Corrected version of phpunit --- .travis.yml | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index d0845ee..3992743 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,27 +1,13 @@ language: php -# dist: trusty - -# php: -# - 5.6 -# - 7.0 -# - 7.1 -# - 7.2 -# - 7.3 -# - 7.4 -# - 8.0 - -# env: -# - PHPUNIT_VERSION=5.6.* - matrix: include: - php: 5.6 env: PHPUNIT_VERSION=5.6.* - php: 7.0 - env: PHPUNIT_VERSION=6.5.* + env: PHPUNIT_VERSION=5.7.* - php: 7.1 - env: PHPUNIT_VERSION=7.5.* + env: PHPUNIT_VERSION=6.5.* - php: 7.2 env: PHPUNIT_VERSION=8.5.* - php: 7.3 From fd0177ba90ba2d156c3cd6ca3193e0a2cf11ef78 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Mon, 8 Mar 2021 17:01:01 +0530 Subject: [PATCH 144/149] Corrected version of phpunit --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3992743..363cc6b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,9 +5,9 @@ matrix: - php: 5.6 env: PHPUNIT_VERSION=5.6.* - php: 7.0 - env: PHPUNIT_VERSION=5.7.* + env: PHPUNIT_VERSION=5.6.* - php: 7.1 - env: PHPUNIT_VERSION=6.5.* + env: PHPUNIT_VERSION=5.7.* - php: 7.2 env: PHPUNIT_VERSION=8.5.* - php: 7.3 From a1450dcf94a22f3be1ab9f3281bd387f5bcda7ef Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Mon, 8 Mar 2021 17:06:56 +0530 Subject: [PATCH 145/149] Specify dist per PHP version --- .travis.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.travis.yml b/.travis.yml index 363cc6b..45de70f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,18 +4,25 @@ matrix: include: - php: 5.6 env: PHPUNIT_VERSION=5.6.* + dist: trusty - php: 7.0 env: PHPUNIT_VERSION=5.6.* + dist: trusty - php: 7.1 env: PHPUNIT_VERSION=5.7.* + dist: trusty - php: 7.2 env: PHPUNIT_VERSION=8.5.* + dist: bionic - php: 7.3 env: PHPUNIT_VERSION=9.5.* + dist: bionic - php: 7.4 env: PHPUNIT_VERSION=9.5.* + dist: bionic - php: 8.0 env: PHPUNIT_VERSION=9.5.* + dist: bionic sudo: false From 76879828d7a985064504f04a0af334d482257f62 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Date: Wed, 19 Jul 2023 21:15:12 +0530 Subject: [PATCH 146/149] Added CreateGooglePayTransaction --- .../create-google-pay-transaction.php | 113 ++++++++++++++++++ .../update-split-tender-group.php | 2 +- 2 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 MobileInAppTransactions/create-google-pay-transaction.php diff --git a/MobileInAppTransactions/create-google-pay-transaction.php b/MobileInAppTransactions/create-google-pay-transaction.php new file mode 100644 index 0000000..75ecc36 --- /dev/null +++ b/MobileInAppTransactions/create-google-pay-transaction.php @@ -0,0 +1,113 @@ +setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); + + $refId = 'ref' . time(); + + $opaqueData = new AnetAPI\OpaqueDataType(); + $opaqueData->setDataDescriptor("COMMON.GOOGLE.INAPP.PAYMENT"); + $opaqueData->setDataValue("1234567890ABCDEF1111AAAA2222BBBB3333CCCC4444DDDD5555EEEE6666FFFF7777888899990000"); + $paymentType = new AnetAPI\PaymentType(); + $paymentType->setOpaqueData($opaqueData); + + $lineItem = new AnetAPI\LineItemType(); + $lineItem->setItemId("1"); + $lineItem->setName("vase"); + $lineItem->setDescription("Cannes logo"); + $lineItem->setQuantity(18); + $lineItem->setUnitPrice(45.00); + + $lineItemsArray = array(); + $lineItemsArray[0] = $lineItem; + + $tax = new AnetAPI\ExtendedAmountType(); + $tax->setAmount(5.00); + $tax->setName("level2 tax name"); + $tax->setDescription("level2 tax"); + + $userField = new AnetAPI\UserFieldType(); + $userFields = array(); + + $userField->setName("UserDefinedFieldName1"); + $userField->setValue("UserDefinedFieldValue1"); + $userFields[0] = $userField; + + $userField->setName("UserDefinedFieldName2"); + $userField->setValue("UserDefinedFieldValue2"); + $userFields[1] = $userField; + + $transactionRequestType = new AnetAPI\TransactionRequestType(); + $transactionRequestType->setTransactionType("authCaptureTransaction"); + $transactionRequestType->setAmount(151); + $transactionRequestType->setPayment($paymentType); + + $request = new AnetAPI\CreateTransactionRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setRefId($refId); + $request->setTransactionRequest( $transactionRequestType); + + $controller = new AnetController\CreateTransactionController($request); + $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); + + + if ($response != null) + { + if($response->getMessages()->getResultCode() == "Ok") + { + $tresponse = $response->getTransactionResponse(); + + if ($tresponse != null && $tresponse->getMessages() != null) + { + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + echo " AUTH CODE : " . $tresponse->getAuthCode() . "\n"; + echo " TRANS ID : " . $tresponse->getTransId() . "\n"; + echo " Code : " . $tresponse->getMessages()[0]->getCode() . "\n"; + echo " Description : " . $tresponse->getMessages()[0]->getDescription() . "\n"; + } + else + { + echo "Transaction Failed \n"; + if($tresponse->getErrors() != null) + { + echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; + echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; + } + } + } + else + { + echo "Transaction Failed \n"; + $tresponse = $response->getTransactionResponse(); + if($tresponse != null && $tresponse->getErrors() != null) + { + echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; + echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; + } + else + { + echo " Error code : " . $response->getMessages()->getMessage()[0]->getCode() . "\n"; + echo " Error message : " . $response->getMessages()->getMessage()[0]->getText() . "\n"; + } + } + } + else + { + echo "No response returned \n"; + } + + return $response; +} + +if(!defined('DONT_RUN_SAMPLES')) + createGooglePayTransaction(); +?> diff --git a/PaymentTransactions/update-split-tender-group.php b/PaymentTransactions/update-split-tender-group.php index c09310b..e386750 100644 --- a/PaymentTransactions/update-split-tender-group.php +++ b/PaymentTransactions/update-split-tender-group.php @@ -19,7 +19,7 @@ function updateSplitTenderGroup() $request = new AnetAPI\UpdateSplitTenderGroupRequest(); $request->setMerchantAuthentication($merchantAuthentication); - $request->setRefId($refId); + $request->setRefId($refId); $request->setSplitTenderId("115901"); $request->setSplitTenderStatus("voided"); From 1760330886e7945a9f21b1ecdf97123980ab8530 Mon Sep 17 00:00:00 2001 From: Gaidin Daishan Date: Thu, 22 Feb 2024 18:32:12 +0530 Subject: [PATCH 147/149] Updated dates used in requests --- RecurringBilling/create-subscription-from-customer-profile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RecurringBilling/create-subscription-from-customer-profile.php b/RecurringBilling/create-subscription-from-customer-profile.php index ce69254..8681182 100644 --- a/RecurringBilling/create-subscription-from-customer-profile.php +++ b/RecurringBilling/create-subscription-from-customer-profile.php @@ -29,7 +29,7 @@ function createSubscriptionFromCustomerProfile($intervalLength, $customerProfile $paymentSchedule = new AnetAPI\PaymentScheduleType(); $paymentSchedule->setInterval($interval); - $paymentSchedule->setStartDate(new DateTime('2020-08-30')); + $paymentSchedule->setStartDate(new DateTime('2035-08-30')); $paymentSchedule->setTotalOccurrences("12"); $paymentSchedule->setTrialOccurrences("1"); From 97a99c42c1eda1d887b0bd54ec6d0945dbfa1a35 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Thu, 22 Feb 2024 19:40:00 +0530 Subject: [PATCH 148/149] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 99bb4ff..e929b5c 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ You can also run each sample directly from the command line. ``` e.g. ``` - $ php PaymentTransactions/charge-credit-card.php + $ php PaymentTransactions/authorize-credit-card.php ``` ### Installation Notes From 1c3610e348e410cc36dd56a0a7418080ef037a16 Mon Sep 17 00:00:00 2001 From: gnongsie Date: Thu, 25 Jul 2024 12:24:05 +0530 Subject: [PATCH 149/149] Modifications to keep up to date --- .gitignore | 3 +++ RecurringBilling/get-list-of-subscriptions.php | 10 ++++++---- SampleCodeList.txt | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 1ed26d5..5e1ed6a 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,6 @@ # Operating system files .DS_Store +/lib +/*.cache +/testslog diff --git a/RecurringBilling/get-list-of-subscriptions.php b/RecurringBilling/get-list-of-subscriptions.php index 44049d7..72330e8 100644 --- a/RecurringBilling/get-list-of-subscriptions.php +++ b/RecurringBilling/get-list-of-subscriptions.php @@ -22,7 +22,7 @@ function getListOfSubscriptions() $sorting->setOrderDescending(false); $paging = new AnetAPI\PagingType(); - $paging->setLimit("1000"); + $paging->setLimit("10"); $paging->setOffset("1"); $request = new AnetAPI\ARBGetSubscriptionListRequest(); @@ -39,10 +39,12 @@ function getListOfSubscriptions() if (($response != null) && ($response->getMessages()->getResultCode() == "Ok")) { echo "SUCCESS: Subscription Details:" . "\n"; - foreach ($response->getSubscriptionDetails() as $subscriptionDetails) { - echo "Subscription ID: " . $subscriptionDetails->getId() . "\n"; - } echo "Total Number In Results:" . $response->getTotalNumInResultSet() . "\n"; + if ($response->getTotalNumInResultSet() > 0) { + foreach ($response->getSubscriptionDetails() as $subscriptionDetails) { + echo "Subscription ID: " . $subscriptionDetails->getId() . "\n"; + } + } } else { echo "ERROR : Invalid response\n"; $errorMessages = $response->getMessages()->getMessage(); diff --git a/SampleCodeList.txt b/SampleCodeList.txt index a41fd6f..5119f91 100644 --- a/SampleCodeList.txt +++ b/SampleCodeList.txt @@ -7,7 +7,7 @@ GetTransactionList,0,1 CreateAnApplePayTransaction,0,0 CreateAnAcceptTransaction,0,0 CreateAnAndroidPayTransaction,0,0 -decryptVisaSrcData,0,1 +decryptVisaSrcData,0,0 createVisaSrcTransaction,0,0 CaptureFundsAuthorizedThroughAnotherChannel,1,1 AuthorizeCreditCard,1,1