From 0bd3cb3a327a5085a93629525253889074bc250e Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Mon, 28 Dec 2015 07:41:29 -0800 Subject: [PATCH 001/287] Delete capture-only.php --- PaymentTransactions/capture-only.php | 65 ---------------------------- 1 file changed, 65 deletions(-) delete mode 100644 PaymentTransactions/capture-only.php diff --git a/PaymentTransactions/capture-only.php b/PaymentTransactions/capture-only.php deleted file mode 100644 index 79ed408..0000000 --- a/PaymentTransactions/capture-only.php +++ /dev/null @@ -1,65 +0,0 @@ -setName("556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); - $refId = "123456"; - - //=================================================================== - // This transaction type is used when you have an auth code that was - // obtained from a system other than authorize.net for example a - // verbal authorization over the telephone - //==================================================================== - - // Create the payment data for a credit card - $creditCard = new AnetAPI\CreditCardType(); - $creditCard->setCardNumber( "4111111111111111"); - $creditCard->setExpirationDate( "2038-12"); - - //$creditCard->setCardCode("999"); - $paymentOne = new AnetAPI\PaymentType(); - $paymentOne->setCreditCard($creditCard); - // Order info - $order = new AnetAPI\OrderType(); - $order->setInvoiceNumber("INV-12345"); - $order->setDescription("Product Description"); - - //create a captureOnly transaction - $transactionRequestType = new AnetAPI\TransactionRequestType(); - $transactionRequestType->setTransactionType( "captureOnlyTransaction"); - $transactionRequestType->setAmount(151); - // This is the Auth Code from another payment channel - $transactionRequestType->setAuthCode("ABC123"); - $transactionRequestType->setPayment($paymentOne); - $transactionRequestType->setOrder($order); - - $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) - { - $tresponse = $response->getTransactionResponse(); - if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) - { - echo "Capture Funds TRANS ID : " . $tresponse->getTransId() . "\n"; - } - else - { - echo " Capture Funds Authorized Through Another Channel: Invalid response\n"; - } - } - else - { - echo "Capture Funds Authorized Through Another Channel NULL response Error\n"; - } -?> From 4d70fe00771593a42ab3051d0662cb8bbb5b727e Mon Sep 17 00:00:00 2001 From: brianmc Date: Mon, 28 Dec 2015 15:16:53 -0800 Subject: [PATCH 002/287] Updated sample to correct taxable example --- 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 764f551..99f4757 100644 --- a/PaymentTransactions/charge-credit-card.php +++ b/PaymentTransactions/charge-credit-card.php @@ -30,7 +30,7 @@ $lineitem->setDescription("golf shirt"); $lineitem->setQuantity("1"); $lineitem->setUnitPrice(20.95); - $lineitem->setTaxable("Y"); + $lineitem->setTaxable(false); // Tax info $tax = new AnetAPI\ExtendedAmountType(); From 4bdd0c6125e3dd0545b64f24babe69c6f3d83b04 Mon Sep 17 00:00:00 2001 From: ashtru Date: Tue, 29 Dec 2015 11:53:21 +0530 Subject: [PATCH 003/287] Rename file to CustomerProfiles/create-customer-profile-from-a-transaction.php to match with API reference http://developer.authorize.net/api/reference/index.html#customer-profiles-create-a-customer-profile-from-a-transaction --- ...saction.php => create-customer-profile-from-a-transaction.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename CustomerProfiles/{create-profile-from-transaction.php => create-customer-profile-from-a-transaction.php} (100%) diff --git a/CustomerProfiles/create-profile-from-transaction.php b/CustomerProfiles/create-customer-profile-from-a-transaction.php similarity index 100% rename from CustomerProfiles/create-profile-from-transaction.php rename to CustomerProfiles/create-customer-profile-from-a-transaction.php From bc74ef0d76da3550a83dc4c8bf6d5d59b0c9a4e8 Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Mon, 28 Dec 2015 23:30:14 -0800 Subject: [PATCH 004/287] Rename create-profile-from-transaction.php to create-customer-profile-from-transaction.php --- ...ansaction.php => create-customer-profile-from-transaction.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename CustomerProfiles/{create-profile-from-transaction.php => create-customer-profile-from-transaction.php} (100%) diff --git a/CustomerProfiles/create-profile-from-transaction.php b/CustomerProfiles/create-customer-profile-from-transaction.php similarity index 100% rename from CustomerProfiles/create-profile-from-transaction.php rename to CustomerProfiles/create-customer-profile-from-transaction.php From 53785a510792f16c22750055d841717eaa1b0b3f Mon Sep 17 00:00:00 2001 From: brianmc Date: Mon, 11 Jan 2016 09:12:22 -0800 Subject: [PATCH 005/287] Updated Customer Payment Profile samples to illustrate updates more clearly. --- .../get-customer-payment-profile.php | 3 + .../update-customer-payment-profile.php | 90 +++++++++++-------- 2 files changed, 54 insertions(+), 39 deletions(-) diff --git a/CustomerProfiles/get-customer-payment-profile.php b/CustomerProfiles/get-customer-payment-profile.php index fecc48a..e4d6ff0 100644 --- a/CustomerProfiles/get-customer-payment-profile.php +++ b/CustomerProfiles/get-customer-payment-profile.php @@ -28,6 +28,9 @@ { echo "GetCustomerPaymentProfile SUCCESS: " . "\n"; echo "Customer Payment Profile Id: " . $response->getPaymentProfile()->getCustomerPaymentProfileId() . "\n"; + echo "Customer Payment Profile Billing Address: " . $response->getPaymentProfile()->getbillTo()->getAddress(). "\n"; + echo "Customer Payment Profile Card Last 4 " . $response->getPaymentProfile()->getPayment()->getCreditCard()->getCardNumber(). "\n"; + } else { diff --git a/CustomerProfiles/update-customer-payment-profile.php b/CustomerProfiles/update-customer-payment-profile.php index da3095e..9f87d04 100644 --- a/CustomerProfiles/update-customer-payment-profile.php +++ b/CustomerProfiles/update-customer-payment-profile.php @@ -5,69 +5,81 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + $merchantAuthentication->setName("5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); $refId = 'ref' . time(); - //Use an existing profile id - $existingcustomerprofileid = "35858366"; - // Retrieve an existing customer profile id along with all the associated payment profiles and shipping addresses - $request = new AnetAPI\GetCustomerProfileRequest(); + //Set profile ids of profile to be updated + $request = new AnetAPI\UpdateCustomerPaymentProfileRequest(); $request->setMerchantAuthentication($merchantAuthentication); - $request->setCustomerProfileId( $existingcustomerprofileid ); + $request->setCustomerProfileId("36731856"); $controller = new AnetController\GetCustomerProfileController($request); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) - { - // echo "SUCCESS: PROFILE RETRIEVED : " . $response->getProfile() . "\n"; - $getcustomerprofileid = $response->getProfile(); - } - else - { - echo "GetCustomerProfileRequest ERROR : Invalid response\n"; - } - // Create the payment data for a credit card + + // 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( "4012888818888" ); - $creditCard->setExpirationDate( "2038-11"); + $creditCard->setCardNumber( "XXXX1111" ); + $creditCard->setExpirationDate( "XXXX"); $paymentCreditCard = new AnetAPI\PaymentType(); $paymentCreditCard->setCreditCard($creditCard); // Create the Bill To info for new payment type $billto = new AnetAPI\CustomerAddressType(); - $billto->setFirstName("Jane"); + $billto->setFirstName("Mrs Mary"); $billto->setLastName("Doe"); - $billto->setCompany("My company"); - $billto->setAddress("588 Willis Ct"); - $billto->setCity("Vacaville"); - $billto->setState("CA"); - $billto->setZip("95688"); - $billto->setPhoneNumber("555-555-1212"); + $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"); + - // Create a new Customer Payment Profile + // Create the Customer Payment Profile object $paymentprofile = new AnetAPI\CustomerPaymentProfileExType(); - $paymentprofile->setCustomerType('individual'); + $paymentprofile->setCustomerPaymentProfileId("33211899"); $paymentprofile->setBillTo($billto); $paymentprofile->setPayment($paymentCreditCard); - $paymentprofile->setCustomerPaymentProfileId( $getcustomerprofileid); - $paymentprofiles[] = $paymentprofile; - // Submit a UpdatePaymentProfileRequest to update an existing create a new Customer Payment Profile - $paymentprofilerequest = new AnetAPI\UpdateCustomerPaymentProfileRequest(); - $paymentprofilerequest->setMerchantAuthentication($merchantAuthentication); - $paymentprofilerequest->setCustomerProfileId( $getcustomerprofileid ); - $paymentprofilerequest->setPaymentProfile( $paymentprofile ); - $paymentprofilerequest->setRefId($refId); - $paymentprofilerequest->setValidationMode("liveMode"); + // Submit a UpdatePaymentProfileRequest + $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"; - $retrievedcustomerprofile = $response->getProfile(); + + // 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("36731856"); + $getRequest->setCustomerPaymentProfileId("33211899"); + + $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"; + echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + } + } + else{ + echo "NULL Response Error"; + } + } else { From 5918d901199dd4b7c7d2b1313e1ed08d06f38d5c Mon Sep 17 00:00:00 2001 From: ashtru Date: Wed, 13 Jan 2016 18:16:21 +0530 Subject: [PATCH 006/287] Adding phpunit. --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index c849bec..f69329b 100644 --- a/composer.json +++ b/composer.json @@ -2,6 +2,7 @@ "require": { "php": ">=5.2.0", + "phpunit/phpunit": "~4.0", "ext-curl": "*", "authorizenet/authorizenet": "1.8.6.2", "jms/serializer": "xsd2php-dev as 0.18.0" From ea5cffe3fe52369e576100dad30a813e980fc0de Mon Sep 17 00:00:00 2001 From: ashtru Date: Wed, 13 Jan 2016 18:33:53 +0530 Subject: [PATCH 007/287] Create .travis.yml --- .travis.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..b77e4af --- /dev/null +++ b/.travis.yml @@ -0,0 +1,12 @@ +language: php + +php: + - 5.6 + +sudo: false + +before_script: + - composer install --prefer-dist --dev + +script: + - vendor/phpunit/phpunit/phpunit --coverage-clover=coverage.clover From 3ec62ea4413bd49bfc4c6a6aa3e1d825917682fd Mon Sep 17 00:00:00 2001 From: ashtru Date: Wed, 13 Jan 2016 18:37:25 +0530 Subject: [PATCH 008/287] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f69329b..495f874 100644 --- a/composer.json +++ b/composer.json @@ -2,12 +2,12 @@ "require": { "php": ">=5.2.0", - "phpunit/phpunit": "~4.0", "ext-curl": "*", "authorizenet/authorizenet": "1.8.6.2", "jms/serializer": "xsd2php-dev as 0.18.0" }, "require-dev": { + "phpunit/phpunit": "~4.0", "goetas/xsd2php": "2.*@dev", "goetas/xsd-reader": "2.*@dev" }, From c9587dd686d6065f5b36e1399187302d2d82b932 Mon Sep 17 00:00:00 2001 From: ashtru Date: Wed, 13 Jan 2016 19:01:23 +0530 Subject: [PATCH 009/287] trying to run phpunit in travis --- phpunit.xml.dist | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 phpunit.xml.dist diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..55a62e5 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,43 @@ + + + + + + . + + + + + + ./lib + + ./vendor + ./tests + ./build + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 9d6060fdc1e8959bad0e70d9e77e0e928e572e2e Mon Sep 17 00:00:00 2001 From: ashtru Date: Wed, 13 Jan 2016 19:10:51 +0530 Subject: [PATCH 010/287] removed bootstrap attribute from phpunit tag --- phpunit.xml.dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 55a62e5..d985ab5 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,7 +1,7 @@ From 78592c24de97291aaebbebca1b877a9e6655d752 Mon Sep 17 00:00:00 2001 From: ashtru Date: Wed, 13 Jan 2016 19:21:50 +0530 Subject: [PATCH 011/287] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b77e4af..3458716 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,4 +9,4 @@ before_script: - composer install --prefer-dist --dev script: - - vendor/phpunit/phpunit/phpunit --coverage-clover=coverage.clover + - vendor/phpunit/phpunit/phpunit From 7c7ae12255fc8496ded97ffd7a1e72f823b02db6 Mon Sep 17 00:00:00 2001 From: ashtru Date: Wed, 13 Jan 2016 19:24:04 +0530 Subject: [PATCH 012/287] Update composer.json --- composer.json | 50 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/composer.json b/composer.json index 495f874..bb1c884 100644 --- a/composer.json +++ b/composer.json @@ -1,19 +1,35 @@ { - - "require": { - "php": ">=5.2.0", - "ext-curl": "*", - "authorizenet/authorizenet": "1.8.6.2", - "jms/serializer": "xsd2php-dev as 0.18.0" -}, -"require-dev": { - "phpunit/phpunit": "~4.0", - "goetas/xsd2php": "2.*@dev", - "goetas/xsd-reader": "2.*@dev" -}, -"repositories": [{ - "type": "vcs", - "url": "https://github.com/goetas/serializer.git" - }] - + "name": "authorizenet/authorizenet", + "type": "library", + "description": "Official PHP SDK for Authorize.Net", + "keywords": ["authorizenet", "authorize.net", "payment", "ecommerce"], + "license": "proprietary", + "homepage": "http://developer.authorize.net", + "require": { + "php": "~5.3", + "ext-curl": "*", + "ext-json": "*", + "ext-simplexml": "*", + "ext-xmlwriter": "*", + "jms/serializer": "xsd2php-dev as 0.18.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0", + "phpmd/phpmd": "~2.0", + "goetas/xsd2php":"2.*@dev", + "goetas/xsd-reader":"2.*@dev" + }, + "suggest": { + "phpdocumentor/phpdocumentor": "For generating API documentation" + }, + "autoload": { + "classmap": ["lib"] + }, + "autoload-dev": { + "classmap": ["tests"] + }, + "repositories": [{ + "type": "vcs", + "url": "https://github.com/goetas/serializer.git" + }] } From 2139d793c2b31c35aa8fa20c01b52908efe5e98a Mon Sep 17 00:00:00 2001 From: ashtru Date: Wed, 13 Jan 2016 19:29:42 +0530 Subject: [PATCH 013/287] Update composer.json --- composer.json | 47 +++++++++++++++++++---------------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/composer.json b/composer.json index bb1c884..179bb50 100644 --- a/composer.json +++ b/composer.json @@ -1,35 +1,26 @@ { - "name": "authorizenet/authorizenet", - "type": "library", - "description": "Official PHP SDK for Authorize.Net", - "keywords": ["authorizenet", "authorize.net", "payment", "ecommerce"], - "license": "proprietary", - "homepage": "http://developer.authorize.net", - "require": { - "php": "~5.3", - "ext-curl": "*", - "ext-json": "*", - "ext-simplexml": "*", - "ext-xmlwriter": "*", - "jms/serializer": "xsd2php-dev as 0.18.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.0", - "phpmd/phpmd": "~2.0", - "goetas/xsd2php":"2.*@dev", - "goetas/xsd-reader":"2.*@dev" - }, - "suggest": { - "phpdocumentor/phpdocumentor": "For generating API documentation" - }, - "autoload": { + + "require": { + "php": ">=5.2.0", + "ext-curl": "*", + "authorizenet/authorizenet": "1.8.6.2", + "jms/serializer": "xsd2php-dev as 0.18.0" +}, +"require-dev": { + "phpunit/phpunit": "~4.0", + "phpmd/phpmd": "~2.0", + "goetas/xsd2php":"2.*@dev", + "goetas/xsd-reader":"2.*@dev" +}, +"autoload": { "classmap": ["lib"] }, "autoload-dev": { "classmap": ["tests"] }, - "repositories": [{ - "type": "vcs", - "url": "https://github.com/goetas/serializer.git" - }] +"repositories": [{ + "type": "vcs", + "url": "https://github.com/goetas/serializer.git" + }] + } From 41cfb33475a2d35910259cb809b244157e091c08 Mon Sep 17 00:00:00 2001 From: ashtru Date: Wed, 13 Jan 2016 19:29:50 +0530 Subject: [PATCH 014/287] Update .travis.yml --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 3458716..2a9cd0d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ php: sudo: false before_script: + - pecl install xmldiff - composer install --prefer-dist --dev script: From 4515721e17327bdad0bf8b5fa841f2783fcd6183 Mon Sep 17 00:00:00 2001 From: ashtru Date: Wed, 13 Jan 2016 19:32:37 +0530 Subject: [PATCH 015/287] Update composer.json --- composer.json | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 179bb50..f5a176c 100644 --- a/composer.json +++ b/composer.json @@ -12,12 +12,7 @@ "goetas/xsd2php":"2.*@dev", "goetas/xsd-reader":"2.*@dev" }, -"autoload": { - "classmap": ["lib"] - }, - "autoload-dev": { - "classmap": ["tests"] - }, + "repositories": [{ "type": "vcs", "url": "https://github.com/goetas/serializer.git" From b40d1e9f87b1b501de901815bf166316ff56c959 Mon Sep 17 00:00:00 2001 From: ashtru Date: Thu, 14 Jan 2016 11:39:04 +0530 Subject: [PATCH 016/287] Test Runner initial commit. Two samples : create-customer-profile create-customer-payment-profile runner files: test-runner.php & SamplesCodeList.txt --- .../create-customer-payment-profile.php | 101 ++++++------ ...eate-customer-profile-from-transaction.php | 41 +++-- CustomerProfiles/create-customer-profile.php | 116 +++++++------- .../create-customer-shipping-address.php | 71 ++++---- .../delete-customer-payment-profile.php | 50 +++--- CustomerProfiles/delete-customer-profile.php | 138 ++++++++-------- .../delete-customer-shipping-address.php | 49 +++--- .../get-customer-payment-profile-list.php | 8 +- .../get-customer-payment-profile.php | 10 +- CustomerProfiles/get-customer-profile-ids.php | 6 + CustomerProfiles/get-customer-profile.php | 9 ++ .../get-customer-shipping-address.php | 76 +++++---- CustomerProfiles/get-hosted-profile-page.php | 74 +++++---- .../update-customer-payment-profile.php | 151 +++++++++--------- .../update-customer-shipping-address.php | 6 + .../validate-customer-payment-profile.php | 12 +- SampleCodeList.txt | 15 ++ test-runner.php | 98 ++++++++++++ 18 files changed, 618 insertions(+), 413 deletions(-) create mode 100644 SampleCodeList.txt create mode 100644 test-runner.php diff --git a/CustomerProfiles/create-customer-payment-profile.php b/CustomerProfiles/create-customer-payment-profile.php index 501b524..96ec372 100644 --- a/CustomerProfiles/create-customer-payment-profile.php +++ b/CustomerProfiles/create-customer-payment-profile.php @@ -3,58 +3,63 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); - $refId = 'ref' . time(); - //Use an existing profile id - $existingcustomerprofileid = "35858366"; + + function createCustomerPaymentProfile($existingcustomerprofileid, $phoneNumber){ + // Common setup for API credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName("556KThWQ6vf2"); + $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + $refId = 'ref' . time(); - $creditCard = new AnetAPI\CreditCardType(); - $creditCard->setCardNumber( "4012888818888" ); - $creditCard->setExpirationDate( "2038-11"); - $creditCard->setCardCode( "123"); - $paymentCreditCard = new AnetAPI\PaymentType(); - $paymentCreditCard->setCreditCard($creditCard); + $creditCard = new AnetAPI\CreditCardType(); + $creditCard->setCardNumber( "4242424242424242" ); + $creditCard->setExpirationDate( "2038-11"); + $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("Mrs Mary"); - $billto->setLastName("Doe"); - $billto->setCompany("My company"); - $billto->setAddress("123 Main St."); - $billto->setCity("Bellevue"); - $billto->setState("WA"); - $billto->setZip("98004"); - $billto->setPhoneNumber("000-000-0000"); - $billto->setfaxNumber("999-999-9999"); - $billto->setCountry("USA"); + // Create the Bill To info for new payment type + $billto = new AnetAPI\CustomerAddressType(); + $billto->setFirstName("Mrs Mary"); + $billto->setLastName("Doe"); + $billto->setCompany("My company"); + $billto->setAddress("123 Main St."); + $billto->setCity("Bellevue"); + $billto->setState("WA"); + $billto->setZip("98004"); + $billto->setPhoneNumber("000-000-0000"); + $billto->setfaxNumber("999-999-9999"); + $billto->setCountry("USA"); - // Create a new Customer Payment Profile - $paymentprofile = new AnetAPI\CustomerPaymentProfileType(); - $paymentprofile->setCustomerType('individual'); - $paymentprofile->setBillTo($billto); - $paymentprofile->setPayment($paymentCreditCard); + // Create a new Customer Payment Profile + $paymentprofile = new AnetAPI\CustomerPaymentProfileType(); + $paymentprofile->setCustomerType('individual'); + $paymentprofile->setBillTo($billto); + $paymentprofile->setPayment($paymentCreditCard); - $paymentprofiles[] = $paymentprofile; + $paymentprofiles[] = $paymentprofile; - // Submit a CreateCustomerPaymentProfileRequest to create a new Customer Payment Profile - $paymentprofilerequest = new AnetAPI\CreateCustomerPaymentProfileRequest(); - $paymentprofilerequest->setMerchantAuthentication($merchantAuthentication); - $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"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; - + // 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"; + echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + + } + return $response; } + if(!defined(DONT_RUN_SAMPLES)) + createCustomerPaymentProfile("35858366","000-000-0009"); ?> diff --git a/CustomerProfiles/create-customer-profile-from-transaction.php b/CustomerProfiles/create-customer-profile-from-transaction.php index 8490804..22a651f 100644 --- a/CustomerProfiles/create-customer-profile-from-transaction.php +++ b/CustomerProfiles/create-customer-profile-from-transaction.php @@ -3,28 +3,35 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + + function createCustomerProfileFromTransaction() + { + // Common setup for API credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName("556KThWQ6vf2"); + $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); - $request = new AnetAPI\CreateCustomerProfileFromTransactionRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setTransId("2235382051"); + $request = new AnetAPI\CreateCustomerProfileFromTransactionRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setTransId("2238251168"); - $controller = new AnetController\CreateCustomerProfileFromTransactionController($request); + $controller = new AnetController\CreateCustomerProfileFromTransactionController($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: PROFILE ID : " . $response->getCustomerProfileId() . "\n"; - } - else - { - echo "ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) + { + echo "SUCCESS: PROFILE ID : " . $response->getCustomerProfileId() . "\n"; + } + else + { + echo "ERROR : Invalid response\n"; + echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + } + return $response; } + if(!defined(DONT_RUN_SAMPLES)) + createCustomerProfileFromTransaction(); ?> diff --git a/CustomerProfiles/create-customer-profile.php b/CustomerProfiles/create-customer-profile.php index 0ced164..01d0aaa 100644 --- a/CustomerProfiles/create-customer-profile.php +++ b/CustomerProfiles/create-customer-profile.php @@ -3,64 +3,72 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); - $refId = 'ref' . time(); + + function createCustomerProfile($merchantCustomerId=-1){ + + // Common setup for API credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName("556KThWQ6vf2"); + $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + $refId = 'ref' . time(); - // 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); + // 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); - // 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 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 - $paymentprofile = new AnetAPI\CustomerPaymentProfileType(); + $paymentprofile = new AnetAPI\CustomerPaymentProfileType(); - $paymentprofile->setCustomerType('individual'); - $paymentprofile->setBillTo($billto); - $paymentprofile->setPayment($paymentCreditCard); - $paymentprofiles[] = $paymentprofile; - $customerprofile = new AnetAPI\CustomerProfileType(); - $customerprofile->setDescription("Customer 2 Test PHP"); - $merchantCustomerId = time().rand(1,150); - $customerprofile->setMerchantCustomerId($merchantCustomerId); - $customerprofile->setEmail("test2@domain.com"); - $customerprofile->setPaymentProfiles($paymentprofiles); + $paymentprofile->setCustomerType('individual'); + $paymentprofile->setBillTo($billto); + $paymentprofile->setPayment($paymentCreditCard); + $paymentprofiles[] = $paymentprofile; + $customerprofile = new AnetAPI\CustomerProfileType(); + $customerprofile->setDescription("Customer 2 Test PHP"); + if(-1 == $merchantCustomerId) + $merchantCustomerId=time().rand(1,150); + $customerprofile->setMerchantCustomerId($merchantCustomerId); + $customerprofile->setEmail("test2@domain.com"); + $customerprofile->setPaymentProfiles($paymentprofiles); - $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 "SUCCESS: PROFILE ID : " . $response->getCustomerProfileId() . "\n"; - echo "SUCCESS: PAYMENT PROFILE ID : " . $response->getCustomerPaymentProfileIdList()[0] . "\n"; - } - else - { - echo "ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; - + $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"; + echo "SUCCESS: PAYMENT PROFILE ID : " . $response->getCustomerPaymentProfileIdList()[0] . "\n"; + } + else + { + echo "ERROR : Invalid response\n"; + echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + + } + return $response; } + if(!defined(DONT_RUN_SAMPLES)) + createCustomerProfile(); ?> diff --git a/CustomerProfiles/create-customer-shipping-address.php b/CustomerProfiles/create-customer-shipping-address.php index a33c725..90bf638 100644 --- a/CustomerProfiles/create-customer-shipping-address.php +++ b/CustomerProfiles/create-customer-shipping-address.php @@ -3,42 +3,47 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + function createCustomerShippingAddress($existingcustomerprofileid = "35872074") + { + // Common setup for API credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName("556KThWQ6vf2"); + $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); - // An existing customer profile id for this merchant name and transaction key - $existingcustomerprofileid = "35872074"; + // 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("000-000-0000"); - $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("000-000-0000"); + $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"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + $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"; + echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + } + return $response; } + if(!defined(DONT_RUN_SAMPLES)) + createCustomerShippingAddress(); ?> diff --git a/CustomerProfiles/delete-customer-payment-profile.php b/CustomerProfiles/delete-customer-payment-profile.php index 352f466..5cbf010 100644 --- a/CustomerProfiles/delete-customer-payment-profile.php +++ b/CustomerProfiles/delete-customer-payment-profile.php @@ -3,29 +3,33 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); - - // An existing payment profile ID for this Merchant name and Transaction key - // - $customerprofileid = "10000"; - $customerpaymentprofileid = "20000"; - - $request = new AnetAPI\DeleteCustomerPaymentProfileRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setCustomerProfileId($customerprofileid); - $request->setCustomerPaymentProfileId($customerpaymentprofileid); - $controller = new AnetController\DeleteCustomerPaymentProfileController($request); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) + + function deleteCustomerPaymentProfile($customerProfileId="38900575", $customerpaymentprofileid = "35366197") { - echo "SUCCESS: Delete Customer Payment Profile SUCCESS :" . "\n"; - } - else - { - echo "ERROR : Delete Customer Payment Profile: Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + // Common setup for API credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName("556KThWQ6vf2"); + $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + + // Use an existing payment profile ID for this Merchant name and Transaction key + + $request = new AnetAPI\DeleteCustomerPaymentProfileRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setCustomerProfileId($customerProfileId); + $request->setCustomerPaymentProfileId($customerpaymentprofileid); + $controller = new AnetController\DeleteCustomerPaymentProfileController($request); + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) + { + echo "SUCCESS: Delete Customer Payment Profile SUCCESS :" . "\n"; + } + else + { + echo "ERROR : Delete Customer Payment Profile: Invalid response\n"; + echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + } + return $response; } + if(!defined(DONT_RUN_SAMPLES)) + deleteCustomerPaymentProfile(); ?> diff --git a/CustomerProfiles/delete-customer-profile.php b/CustomerProfiles/delete-customer-profile.php index 4bd07fc..d68e2e7 100644 --- a/CustomerProfiles/delete-customer-profile.php +++ b/CustomerProfiles/delete-customer-profile.php @@ -3,79 +3,85 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); - $refId = 'ref' . time(); + + function deleteCustomerProfile() + { + // Common setup for API credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName("556KThWQ6vf2"); + $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + $refId = 'ref' . time(); - // 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); + // 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); - // 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 + // 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 - $paymentprofile = new AnetAPI\CustomerPaymentProfileType(); + $paymentprofile = new AnetAPI\CustomerPaymentProfileType(); - $paymentprofile->setCustomerType('individual'); - $paymentprofile->setBillTo($billto); - $paymentprofile->setPayment($paymentCreditCard); - $paymentprofiles[] = $paymentprofile; - $customerprofile = new AnetAPI\CustomerProfileType(); - $customerprofile->setDescription("Create Customer Profile Request Test for PHP"); - $merchantCustomerId = time().rand(1,150); - $customerprofile->setMerchantCustomerId($merchantCustomerId); - $customerprofile->setEmail("customerprofile@domain.com"); - $customerprofile->setPaymentProfiles($paymentprofiles); + $paymentprofile->setCustomerType('individual'); + $paymentprofile->setBillTo($billto); + $paymentprofile->setPayment($paymentCreditCard); + $paymentprofiles[] = $paymentprofile; + $customerprofile = new AnetAPI\CustomerProfileType(); + $customerprofile->setDescription("Create Customer Profile Request Test for PHP"); + $merchantCustomerId = time().rand(1,150); + $customerprofile->setMerchantCustomerId($merchantCustomerId); + $customerprofile->setEmail("customerprofile@domain.com"); + $customerprofile->setPaymentProfiles($paymentprofiles); - $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 "SUCCESS: CreateCustomerProfile PROFILE ID : " . $response->getCustomerProfileId() . "\n"; + $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 "SUCCESS: CreateCustomerProfile PROFILE ID : " . $response->getCustomerProfileId() . "\n"; - $profileidcreated = $response->getCustomerProfileId(); - } - else - { - echo "ERROR : CreateCustomerProfile: Invalid response\n"; - } - // Delete an existing customer profile - $request = new AnetAPI\DeleteCustomerProfileRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setCustomerProfileId( $profileidcreated ); + $profileidcreated = $response->getCustomerProfileId(); + } + else + { + echo "ERROR : CreateCustomerProfile: Invalid response\n"; + } + // Delete an existing customer profile + $request = new AnetAPI\DeleteCustomerProfileRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setCustomerProfileId( $profileidcreated ); - $controller = new AnetController\DeleteCustomerProfileController($request); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) - { - echo "DeleteCustomerProfile SUCCESS : " . "\n"; - } - else - { - echo "ERROR : DeleteCustomerProfile: Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + $controller = new AnetController\DeleteCustomerProfileController($request); + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) + { + echo "DeleteCustomerProfile SUCCESS : " . "\n"; + } + else + { + echo "ERROR : DeleteCustomerProfile: Invalid response\n"; + echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + } } + if(!defined(DONT_RUN_SAMPLES)) + deleteCustomerProfile(); ?> diff --git a/CustomerProfiles/delete-customer-shipping-address.php b/CustomerProfiles/delete-customer-shipping-address.php index ae85c7d..7294ce0 100644 --- a/CustomerProfiles/delete-customer-shipping-address.php +++ b/CustomerProfiles/delete-customer-shipping-address.php @@ -3,30 +3,33 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); - - // Use an existing customer profile and address id for this merchant name and transaction key - $customerprofileid = "35894174"; - $customeraddressid = "32445389"; + function deleteCustomerShippingAddress($customerprofileid = "35872074", $customeraddressid = "36931511") + { + // Common setup for API credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName("556KThWQ6vf2"); + $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); - // Delete an existing customer shipping address for an existing customer profile - $request = new AnetAPI\DeleteCustomerShippingAddressRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setCustomerProfileId($customerprofileid); - $request->setCustomerAddressId($customeraddressid); + // 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 + $request = new AnetAPI\DeleteCustomerShippingAddressRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setCustomerProfileId($customerprofileid); + $request->setCustomerAddressId($customeraddressid); - $controller = new AnetController\DeleteCustomerShippingAddressController($request); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) - { - echo "Delete Customer Shipping Address SUCCESS:" . "\n"; - } - else - { - echo "Delete Customer Shipping Address ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + $controller = new AnetController\DeleteCustomerShippingAddressController($request); + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) + { + echo "Delete Customer Shipping Address SUCCESS:" . "\n"; + } + else + { + echo "Delete Customer Shipping Address ERROR : Invalid response\n"; + echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + } + return $response; } + if(!defined(DONT_RUN_SAMPLES)) + deleteCustomerShippingAddress(); ?> diff --git a/CustomerProfiles/get-customer-payment-profile-list.php b/CustomerProfiles/get-customer-payment-profile-list.php index e42b7cc..3c97953 100644 --- a/CustomerProfiles/get-customer-payment-profile-list.php +++ b/CustomerProfiles/get-customer-payment-profile-list.php @@ -8,6 +8,8 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); + function getCustomerPaymentProfileList() + { // Common setup for API credentials (merchant) $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName("5KP3u95bQpv"); @@ -20,7 +22,7 @@ $paging->setOffset("1"); //Setting the sorting - $sorting = new AnetApi\CustomerPaymentProfileSortingType(); + $sorting = new AnetAPI\CustomerPaymentProfileSortingType(); $sorting->setOrderBy("id"); $sorting->setOrderDescending("false"); @@ -69,4 +71,8 @@ // Failed to get the response echo "NULL Response Error"; } + return $response; + } + if(!defined(DONT_RUN_SAMPLES)) + getCustomerPaymentProfileList(); ?> diff --git a/CustomerProfiles/get-customer-payment-profile.php b/CustomerProfiles/get-customer-payment-profile.php index e4d6ff0..8453865 100644 --- a/CustomerProfiles/get-customer-payment-profile.php +++ b/CustomerProfiles/get-customer-payment-profile.php @@ -8,6 +8,8 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); +function getCustomerPaymentProfile($customerProfileId="36731856", $customerPaymentProfileId="33211899") +{ // Common setup for API credentials (merchant) $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName("5KP3u95bQpv"); @@ -18,8 +20,8 @@ $request = new AnetAPI\GetCustomerPaymentProfileRequest(); $request->setMerchantAuthentication($merchantAuthentication); $request->setRefId( $refId); -$request->setCustomerProfileId("36731856"); -$request->setCustomerPaymentProfileId("33211899"); +$request->setCustomerProfileId($customerProfileId); +$request->setCustomerPaymentProfileId($customerPaymentProfileId); $controller = new AnetController\GetCustomerPaymentProfileController($request); $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); @@ -41,4 +43,8 @@ else{ echo "NULL Response Error"; } +return $response; +} +if(!defined(DONT_RUN_SAMPLES)) + getCustomerPaymentProfile(); ?> diff --git a/CustomerProfiles/get-customer-profile-ids.php b/CustomerProfiles/get-customer-profile-ids.php index 0851f9f..f42f127 100644 --- a/CustomerProfiles/get-customer-profile-ids.php +++ b/CustomerProfiles/get-customer-profile-ids.php @@ -3,6 +3,8 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); + function getCustomerProfileIds() + { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName("556KThWQ6vf2"); @@ -25,4 +27,8 @@ echo "GetCustomerProfileId's ERROR : Invalid response\n"; echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; } + return $response; + } + if(!defined(DONT_RUN_SAMPLES)) + getCustomerProfileIds(); ?> diff --git a/CustomerProfiles/get-customer-profile.php b/CustomerProfiles/get-customer-profile.php index b450add..5f3d53a 100644 --- a/CustomerProfiles/get-customer-profile.php +++ b/CustomerProfiles/get-customer-profile.php @@ -4,6 +4,9 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); // Common setup for API credentials + + function getCustomerProfile(){ + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName("556KThWQ6vf2"); $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); @@ -83,4 +86,10 @@ echo "ERROR : GetCustomerProfile: Invalid response\n"; echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; } + return $response; + } + if(!defined('DONT_RUN_SAMPLES')) + { + getCustomerProfile(); + } ?> diff --git a/CustomerProfiles/get-customer-shipping-address.php b/CustomerProfiles/get-customer-shipping-address.php index d06fa04..68d3bab 100644 --- a/CustomerProfiles/get-customer-shipping-address.php +++ b/CustomerProfiles/get-customer-shipping-address.php @@ -3,42 +3,48 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + function getCustomerShippingAddress() + { + // Common setup for API credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName("5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); - // An existing customer profile id and shipping address id for this merchant name and transaction key - $customerProfileId = "36731856"; - $customerAddressId = "35850995"; + // An existing customer profile id and shipping address id for this merchant name and transaction key + $customerProfileId = "36731856"; + $customerAddressId = "35850995"; - $request = new AnetAPI\GetCustomerShippingAddressRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setCustomerProfileId($customerProfileId); - $request->setCustomerAddressId($customerAddressId); - - $controller = new AnetController\GetCustomerShippingAddressController($request); - - //Retrieving existing customer shipping address - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) - { - echo "Get Customer Shipping Address SUCCESS" . "\n"; - echo " FirstName : " . $response->getAddress()->getFirstName() . "\n"; - echo " LastName : " . $response->getAddress()->getLastName() . "\n"; - echo " Company : " . $response->getAddress()->getCompany() . "\n"; - echo " Address : " . $response->getAddress()->getAddress() . "\n"; - echo " City : " . $response->getAddress()->getCity() . "\n"; - echo " State : " . $response->getAddress()->getState() . "\n"; - echo " Zip : " . $response->getAddress()->getZip() . "\n"; - echo " Country : " . $response->getAddress()->getCountry() . "\n"; - echo " Phone Number : " . $response->getAddress()->getPhoneNumber() . "\n"; - echo " FAX Number : " . $response->getAddress()->getFaxNumber() . "\n"; - echo "Customer AddressId : " . $response->getAddress()->getCustomerAddressId() . "\n"; - } - else - { - echo "Get Customer Shipping Address ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + $request = new AnetAPI\GetCustomerShippingAddressRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setCustomerProfileId($customerProfileId); + $request->setCustomerAddressId($customerAddressId); + + $controller = new AnetController\GetCustomerShippingAddressController($request); + + //Retrieving existing customer shipping address + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) + { + echo "Get Customer Shipping Address SUCCESS" . "\n"; + echo " FirstName : " . $response->getAddress()->getFirstName() . "\n"; + echo " LastName : " . $response->getAddress()->getLastName() . "\n"; + echo " Company : " . $response->getAddress()->getCompany() . "\n"; + echo " Address : " . $response->getAddress()->getAddress() . "\n"; + echo " City : " . $response->getAddress()->getCity() . "\n"; + echo " State : " . $response->getAddress()->getState() . "\n"; + echo " Zip : " . $response->getAddress()->getZip() . "\n"; + echo " Country : " . $response->getAddress()->getCountry() . "\n"; + echo " Phone Number : " . $response->getAddress()->getPhoneNumber() . "\n"; + echo " FAX Number : " . $response->getAddress()->getFaxNumber() . "\n"; + echo "Customer AddressId : " . $response->getAddress()->getCustomerAddressId() . "\n"; + } + else + { + echo "Get Customer Shipping Address ERROR : Invalid response\n"; + echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + } + return $response; } + if(!defined(DONT_RUN_SAMPLES)) + getCustomerShippingAddress(); ?> diff --git a/CustomerProfiles/get-hosted-profile-page.php b/CustomerProfiles/get-hosted-profile-page.php index 81441af..a22c567 100644 --- a/CustomerProfiles/get-hosted-profile-page.php +++ b/CustomerProfiles/get-hosted-profile-page.php @@ -4,41 +4,47 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("3Zw3Ru9nx"); - $merchantAuthentication->setTransactionKey("7Tbj6T3a9cPq4A5d"); - - // An existing payment profile ID for this Merchant name and Transaction key - // - $customerprofileid = "37680862"; - $customerpaymentprofileid = "34249159"; - - $setting = new AnetAPI\SettingType(); - $setting->setSettingName("hostedProfileReturnUrl"); - $setting->setSettingValue("https://returnurl.com/return/"); - - //$alist = new AnetAPI\ArrayOfSettingType(); - //$alist->addToSetting($setting); - - $request = new AnetAPI\GetHostedProfilePageRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setCustomerProfileId($customerprofileid); - $request->addToHostedProfileSettings($setting); - - $controller = new AnetController\GetHostedProfilePageController($request); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - - if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) + function getHostedProfielPage() { - echo $response->getMessages()->getMessage()[0]->getCode()."\n"; - echo $response->getMessages()->getMessage()[0]->getText()."\n"; + // Common setup for API credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName("3Zw3Ru9nx"); + $merchantAuthentication->setTransactionKey("7Tbj6T3a9cPq4A5d"); + + // An existing payment profile ID for this Merchant name and Transaction key + // + $customerprofileid = "37680862"; + $customerpaymentprofileid = "34249159"; - echo $response->getToken()."\n"; - } - else - { - echo "ERROR : Failed to get hosted profile page\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + $setting = new AnetAPI\SettingType(); + $setting->setSettingName("hostedProfileReturnUrl"); + $setting->setSettingValue("https://returnurl.com/return/"); + + //$alist = new AnetAPI\ArrayOfSettingType(); + //$alist->addToSetting($setting); + + $request = new AnetAPI\GetHostedProfilePageRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setCustomerProfileId($customerprofileid); + $request->addToHostedProfileSettings($setting); + + $controller = new AnetController\GetHostedProfilePageController($request); + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) + { + echo $response->getMessages()->getMessage()[0]->getCode()."\n"; + echo $response->getMessages()->getMessage()[0]->getText()."\n"; + + echo $response->getToken()."\n"; + } + else + { + echo "ERROR : Failed to get hosted profile page\n"; + echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + } + return $response; } + if(!defined(DONT_RUN_SAMPLES)) + getHostedProfielPage(); ?> \ No newline at end of file diff --git a/CustomerProfiles/update-customer-payment-profile.php b/CustomerProfiles/update-customer-payment-profile.php index 9f87d04..b749d09 100644 --- a/CustomerProfiles/update-customer-payment-profile.php +++ b/CustomerProfiles/update-customer-payment-profile.php @@ -3,87 +3,92 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); - $refId = 'ref' . time(); + function updateCustomerPaymentProfile($customerProfileId="36731856", $customerPaymentProfileId="33211899") + { + // Common setup for API credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName("5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $refId = 'ref' . time(); - //Set profile ids of profile to be updated - $request = new AnetAPI\UpdateCustomerPaymentProfileRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setCustomerProfileId("36731856"); - $controller = new AnetController\GetCustomerProfileController($request); + //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( "XXXX1111" ); - $creditCard->setExpirationDate( "XXXX"); - $paymentCreditCard = new AnetAPI\PaymentType(); - $paymentCreditCard->setCreditCard($creditCard); + // 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( "XXXX1111" ); + $creditCard->setExpirationDate( "XXXX"); + $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"); - + // 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"); + - // Create the Customer Payment Profile object - $paymentprofile = new AnetAPI\CustomerPaymentProfileExType(); - $paymentprofile->setCustomerPaymentProfileId("33211899"); - $paymentprofile->setBillTo($billto); - $paymentprofile->setPayment($paymentCreditCard); + // Create the Customer Payment Profile object + $paymentprofile = new AnetAPI\CustomerPaymentProfileExType(); + $paymentprofile->setCustomerPaymentProfileId($customerPaymentProfileId); + $paymentprofile->setBillTo($billto); + $paymentprofile->setPayment($paymentCreditCard); - // Submit a UpdatePaymentProfileRequest - $request->setPaymentProfile( $paymentprofile ); + // Submit a UpdatePaymentProfileRequest + $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("36731856"); - $getRequest->setCustomerPaymentProfileId("33211899"); + $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\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"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; - } - } - else{ - echo "NULL Response Error"; - } + $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"; + echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + } + } + else{ + echo "NULL Response Error"; + } - } - else - { - echo "Update Customer Payment Profile: ERROR Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + } + else + { + echo "Update Customer Payment Profile: ERROR Invalid response\n"; + echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + } } + if(!defined(DONT_RUN_SAMPLES)) + updateCustomerPaymentProfile(); ?> diff --git a/CustomerProfiles/update-customer-shipping-address.php b/CustomerProfiles/update-customer-shipping-address.php index 98c6422..49f0966 100644 --- a/CustomerProfiles/update-customer-shipping-address.php +++ b/CustomerProfiles/update-customer-shipping-address.php @@ -3,6 +3,8 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); + function updateCustomerShippingAddress() + { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName("556KThWQ6vf2"); @@ -40,4 +42,8 @@ echo "Update Customer Shipping Address ERROR : Invalid response\n"; echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; } + return $response; + } + if(!defined(DONT_RUN_SAMPLES)) + updateCustomerShippingAddress(); ?> diff --git a/CustomerProfiles/validate-customer-payment-profile.php b/CustomerProfiles/validate-customer-payment-profile.php index 4e8cd27..d4d6e4e 100644 --- a/CustomerProfiles/validate-customer-payment-profile.php +++ b/CustomerProfiles/validate-customer-payment-profile.php @@ -4,15 +4,15 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); + function validateCustomerPaymentProfile($customerprofileid = "37680862", $customerpaymentprofileid = "34249159") + { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName("3Zw3Ru9nx"); $merchantAuthentication->setTransactionKey("7Tbj6T3a9cPq4A5d"); - // An existing payment profile ID for this Merchant name and Transaction key - // - $customerprofileid = "37680862"; - $customerpaymentprofileid = "34249159"; + // Use an existing payment profile ID for this Merchant name and Transaction key + //validationmode tests , does not send an email receipt $validationmode = "testMode"; $request = new AnetAPI\ValidateCustomerPaymentProfileRequest(); @@ -33,4 +33,8 @@ echo "ERROR : Validate Customer Payment Profile: Invalid response\n"; echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; } + return $response; + } + if(!defined(DONT_RUN_SAMPLES)) + validateCustomerPaymentProfile(); ?> diff --git a/SampleCodeList.txt b/SampleCodeList.txt new file mode 100644 index 0000000..35f5fad --- /dev/null +++ b/SampleCodeList.txt @@ -0,0 +1,15 @@ +SampleCodeName,IsDependent,ShouldRun +CreateCustomerProfile,0,1 +GetCustomerProfile,0,0 +GetCustomerProfileIds,0,0 +UpdateCustomerProfile,0,0 +DeleteCustomerProfile,0,0 +CreateCustomerPaymentProfile,1,1 +GetCustomerPaymentProfile,0,0 +GetCustomerPaymentProfileList,0,0 +ValidateCustomerPaymentProfile,0,0 +UpdateCustomerPaymentProfile,0,0 +DeleteCustomerPaymentProfile,0,0 +CreateCustomerShippingAddress,0,0 +DeleteCustomerShippingAddress,0,0 +CreateCustomerProfileFromTransaction,0,0 diff --git a/test-runner.php b/test-runner.php new file mode 100644 index 0000000..8f982ec --- /dev/null +++ b/test-runner.php @@ -0,0 +1,98 @@ +assertNotNull($response); + $this->assertEquals($response->getMessages()->getResultCode(), "Ok"); + $runTests++; + } + } + } + echo "Number of sample codes run: ". $runTests; + } + public static function runCreateCustomerPaymentProfile(){ + $responseCustomerProfile = createCustomerProfile(); + $existingCustomerProfileId = $responseCustomerProfile->getCustomerProfileId(); + return createCustomerPaymentProfile($existingCustomerProfileId, self::randPhoneNumber()); + } + private static function toPhoneNumber($num) + { + $zeroPadded = sprintf("%10d", $num); + return substr($zeroPadded,0,3)."-".substr($zeroPadded,3,3)."-".substr(6,4); + + } +} \ No newline at end of file From e80fb39091b995a506c083d64487b8e84c131b96 Mon Sep 17 00:00:00 2001 From: srathod Date: Thu, 14 Jan 2016 11:48:59 +0530 Subject: [PATCH 017/287] - Added full SampleCodeList. --- SampleCodeList.txt | 62 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 49 insertions(+), 13 deletions(-) diff --git a/SampleCodeList.txt b/SampleCodeList.txt index 35f5fad..3535b85 100644 --- a/SampleCodeList.txt +++ b/SampleCodeList.txt @@ -1,15 +1,51 @@ SampleCodeName,IsDependent,ShouldRun -CreateCustomerProfile,0,1 -GetCustomerProfile,0,0 -GetCustomerProfileIds,0,0 -UpdateCustomerProfile,0,0 -DeleteCustomerProfile,0,0 +CreateSubscription,1,1 +GetCustomerPaymentProfileList,0,1 +GetTransactionList,0,1 +CreateAnApplePayTransaction,0,0 +DecryptVisaCheckoutData,0,1 +CreateVisaCheckoutTransaction,0,0 +CaptureFundsAuthorizedThroughAnotherChannel,0,1 +AuthorizeCreditCard,1,1 +DebitBankAccount,0,1 +ChargeTokenizedCreditCard,0,0 +PayPalAuthorizeOnly,0,1 +GetListOfSubscriptions,0,1 +GetUnsettledTransactionList,0,1 +GetBatchStatistics,0,1 +GetSettledBatchList,0,1 +UpdateSplitTenderGroup,0,1 +ValidateCustomerPaymentProfile,1,1 +UpdateCustomerShippingAddress,1,1 +UpdateCustomerProfile,1,1 +UpdateCustomerPaymentProfile,1,1 +GetCustomerShippingAddress,1,1 +GetCustomerProfileIds,1,1 +GetCustomerProfile,1,1 +GetHostedProfilePage,1,1 +GetCustomerPaymentProfile,1,1 +DeleteCustomerShippingAddress,1,1 +DeleteCustomerProfile,1,1 +DeleteCustomerPaymentProfile,1,1 +CreateCustomerShippingAddress,1,1 +CreateCustomerProfileFromTransaction,1,0 +GetTransactionDetails,1,1 +ChargeCreditCard,1,1 +CapturePreviouslyAuthorizedgetAmount,1,0 +Refund,1,0 +Void,1,1 +CreditBankAccount,1,0 +ChargeCustomerProfile,1,1 +PayPalVoid,1,0 +PayPalAuthorizeCapture,1,1 +PayPalAuthorizeCaptureContinue,1,1 +PayPalAuthorizeOnlyContinue,1,0 +PayPalCredit,1,0 +PayPalGetDetails,1,1 +PayPalPriorAuthorizationCapture,1,0 +CancelSubscription,1,1 +GetSubscriptionStatus,1,1 +GetSubscription,1,1 +UpdateSubscription,1,1 +CreateCustomerProfile,1,1 CreateCustomerPaymentProfile,1,1 -GetCustomerPaymentProfile,0,0 -GetCustomerPaymentProfileList,0,0 -ValidateCustomerPaymentProfile,0,0 -UpdateCustomerPaymentProfile,0,0 -DeleteCustomerPaymentProfile,0,0 -CreateCustomerShippingAddress,0,0 -DeleteCustomerShippingAddress,0,0 -CreateCustomerProfileFromTransaction,0,0 From c0f7e0f7d28a72e6a56a9092c96e3ede249d2126 Mon Sep 17 00:00:00 2001 From: akankari Date: Thu, 14 Jan 2016 12:16:46 +0530 Subject: [PATCH 018/287] Move the ARB and Transaction details sample codes to function --- RecurringBilling/cancel-subscription.php | 62 +++++---- RecurringBilling/create-subscription.php | 100 ++++++++------- .../get-list-of-subscriptions.php | 84 +++++++------ RecurringBilling/get-subscription-status.php | 61 +++++---- RecurringBilling/get-subscription.php | 82 ++++++------ RecurringBilling/update-subscription.php | 66 +++++----- TransactionReporting/get-batch-statistics.php | 95 +++++++------- .../get-settled-batch-list.php | 118 ++++++++++-------- .../get-transaction-details.php | 50 ++++---- TransactionReporting/get-transaction-list.php | 75 ++++++----- .../get-unsettled-transaction-list.php | 54 ++++---- 11 files changed, 469 insertions(+), 378 deletions(-) diff --git a/RecurringBilling/cancel-subscription.php b/RecurringBilling/cancel-subscription.php index ef08ad9..9184740 100644 --- a/RecurringBilling/cancel-subscription.php +++ b/RecurringBilling/cancel-subscription.php @@ -4,30 +4,40 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - // Common Set Up for API Credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName( "556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); - - $refId = 'ref' . time(); - - $request = new AnetAPI\ARBCancelSubscriptionRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setRefId($refId); - $request->setSubscriptionId("100748"); - - $controller = new AnetController\ARBCancelSubscriptionController($request); - - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - - if (($response != null) && ($response->getMessages()->getResultCode() == "Ok")) - { - echo "SUCCESS" . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; - } - else - { - echo "ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; - + function cancelSubscription($subscriptionId) { + + // Common Set Up for API Credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName( "556KThWQ6vf2"); + $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + + $refId = 'ref' . time(); + + $request = new AnetAPI\ARBCancelSubscriptionRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setRefId($refId); + $request->setSubscriptionId($subscriptionId); + + $controller = new AnetController\ARBCancelSubscriptionController($request); + + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok")) + { + echo "SUCCESS" . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + } + else + { + echo "ERROR : Invalid response\n"; + echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + + } + + return $response; + } - ?> + + if(!defined(DONT_RUN_SAMPLES)) + cancelSubscription("100748"); + +?> diff --git a/RecurringBilling/create-subscription.php b/RecurringBilling/create-subscription.php index 01925d7..a762024 100644 --- a/RecurringBilling/create-subscription.php +++ b/RecurringBilling/create-subscription.php @@ -4,61 +4,71 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); date_default_timezone_set('America/Los_Angeles'); - // Common Set Up for API Credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName( "556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + + function createSubscription($intervalLength) { - $refId = 'ref' . time(); + // Common Set Up for API Credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName( "556KThWQ6vf2"); + $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); - // Subscription Type Info - $subscription = new AnetAPI\ARBSubscriptionType(); - $subscription->setName("Sample Subscription"); + $refId = 'ref' . time(); - $interval = new AnetAPI\PaymentScheduleType\IntervalAType(); - $interval->setLength("1"); - $interval->setUnit("months"); + // Subscription Type Info + $subscription = new AnetAPI\ARBSubscriptionType(); + $subscription->setName("Sample Subscription"); - $paymentSchedule = new AnetAPI\PaymentScheduleType(); - $paymentSchedule->setInterval($interval); - $paymentSchedule->setStartDate(new DateTime('2020-08-30')); - $paymentSchedule->setTotalOccurrences("12"); - $paymentSchedule->setTrialOccurrences("1"); + $interval = new AnetAPI\PaymentScheduleType\IntervalAType(); + $interval->setLength($intervalLength); + $interval->setUnit("days"); - $subscription->setPaymentSchedule($paymentSchedule); - $subscription->setAmount("10.29"); - $subscription->setTrialAmount("0.00"); - - $creditCard = new AnetAPI\CreditCardType(); - $creditCard->setCardNumber("4111111111111111"); - $creditCard->setExpirationDate("2020-12"); + $paymentSchedule = new AnetAPI\PaymentScheduleType(); + $paymentSchedule->setInterval($interval); + $paymentSchedule->setStartDate(new DateTime('2020-08-30')); + $paymentSchedule->setTotalOccurrences("12"); + $paymentSchedule->setTrialOccurrences("1"); - $payment = new AnetAPI\PaymentType(); - $payment->setCreditCard($creditCard); + $subscription->setPaymentSchedule($paymentSchedule); + $subscription->setAmount("10.29"); + $subscription->setTrialAmount("0.00"); + + $creditCard = new AnetAPI\CreditCardType(); + $creditCard->setCardNumber("4111111111111111"); + $creditCard->setExpirationDate("2020-12"); - $subscription->setPayment($payment); + $payment = new AnetAPI\PaymentType(); + $payment->setCreditCard($creditCard); - $billTo = new AnetAPI\NameAndAddressType(); - $billTo->setFirstName("John"); - $billTo->setLastName("Smith"); + $subscription->setPayment($payment); - $subscription->setBillTo($billTo); + $billTo = new AnetAPI\NameAndAddressType(); + $billTo->setFirstName("John"); + $billTo->setLastName("Smith"); - $request = new AnetAPI\ARBCreateSubscriptionRequest(); - $request->setmerchantAuthentication($merchantAuthentication); - $request->setRefId($refId); - $request->setSubscription($subscription); - $controller = new AnetController\ARBCreateSubscriptionController($request); + $subscription->setBillTo($billTo); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - - if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) - { - echo "SUCCESS: Subscription ID : " . $response->getSubscriptionId() . "\n"; - } - else - { - echo "ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + $request = new AnetAPI\ARBCreateSubscriptionRequest(); + $request->setmerchantAuthentication($merchantAuthentication); + $request->setRefId($refId); + $request->setSubscription($subscription); + $controller = new AnetController\ARBCreateSubscriptionController($request); + + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) + { + echo "SUCCESS: Subscription ID : " . $response->getSubscriptionId() . "\n"; + } + else + { + echo "ERROR : Invalid response\n"; + echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + } + + return $response; } + + if(!defined(DONT_RUN_SAMPLES)) + createSubscription(23); + ?> diff --git a/RecurringBilling/get-list-of-subscriptions.php b/RecurringBilling/get-list-of-subscriptions.php index 17ce681..45262af 100644 --- a/RecurringBilling/get-list-of-subscriptions.php +++ b/RecurringBilling/get-list-of-subscriptions.php @@ -4,42 +4,50 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - // Common Set Up for API Credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName( "556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); - - $refId = 'ref' . time(); - - $sorting = new AnetAPI\ARBGetSubscriptionListSortingType(); - $sorting->setOrderBy("id"); - $sorting->setOrderDescending("false"); - - $paging = new AnetAPI\PagingType(); - $paging->setLimit("1000"); - $paging->setOffset("1"); - - $request = new AnetAPI\ARBGetSubscriptionListRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setRefId($refId); - $request->setSearchType("subscriptionInactive"); - $request->setSorting($sorting); - $request->setPaging($paging); - - - $controller = new AnetController\ARBGetSubscriptionListController($request); - - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - - if (($response != null) && ($response->getMessages()->getResultCode() == "Ok")) - { - echo "SUCCESS: Subscription Details:" . $response->getSubscriptionDetails() . "\n"; - echo "Total Number In Results:" . $response->getTotalNumInResultSet() . "\n"; - } - else - { - echo "ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; - + function getListOfSubscriptions() { + + // Common Set Up for API Credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName( "556KThWQ6vf2"); + $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + + $refId = 'ref' . time(); + + $sorting = new AnetAPI\ARBGetSubscriptionListSortingType(); + $sorting->setOrderBy("id"); + $sorting->setOrderDescending("false"); + + $paging = new AnetAPI\PagingType(); + $paging->setLimit("1000"); + $paging->setOffset("1"); + + $request = new AnetAPI\ARBGetSubscriptionListRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setRefId($refId); + $request->setSearchType("subscriptionInactive"); + $request->setSorting($sorting); + $request->setPaging($paging); + + + $controller = new AnetController\ARBGetSubscriptionListController($request); + + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok")) + { + echo "SUCCESS: Subscription Details:" . $response->getSubscriptionDetails() . "\n"; + echo "Total Number In Results:" . $response->getTotalNumInResultSet() . "\n"; + } + else + { + echo "ERROR : Invalid response\n"; + echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + + } + + return $response; } - ?> + + if(!defined(DONT_RUN_SAMPLES)) + getListOfSubscriptions(); +?> diff --git a/RecurringBilling/get-subscription-status.php b/RecurringBilling/get-subscription-status.php index 4754eb6..399df87 100644 --- a/RecurringBilling/get-subscription-status.php +++ b/RecurringBilling/get-subscription-status.php @@ -4,30 +4,39 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - // Common Set Up for API Credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName( "556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); - - $refId = 'ref' . time(); - - $request = new AnetAPI\ARBGetSubscriptionStatusRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setRefId($refId); - $request->setSubscriptionId("100748"); - - $controller = new AnetController\ARBGetSubscriptionStatusController($request); - - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - - if (($response != null) && ($response->getMessages()->getResultCode() == "Ok")) - { - echo "SUCCESS: Subscription Status : " . $response->getStatus() . "\n"; - } - else - { - echo "ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; - + function getSubscriptionStatus($subscriptionId) { + + // Common Set Up for API Credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName( "556KThWQ6vf2"); + $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + + $refId = 'ref' . time(); + + $request = new AnetAPI\ARBGetSubscriptionStatusRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setRefId($refId); + $request->setSubscriptionId($subscriptionId); + + $controller = new AnetController\ARBGetSubscriptionStatusController($request); + + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok")) + { + echo "SUCCESS: Subscription Status : " . $response->getStatus() . "\n"; + } + else + { + echo "ERROR : Invalid response\n"; + echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + + } + + return $response; } - ?> + + if(!defined(DONT_RUN_SAMPLES)) + getSubscriptionStatus("100748"); + +?> diff --git a/RecurringBilling/get-subscription.php b/RecurringBilling/get-subscription.php index 91e7dea..a515576 100644 --- a/RecurringBilling/get-subscription.php +++ b/RecurringBilling/get-subscription.php @@ -5,49 +5,57 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - // Common Set Up for API Credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName( "556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + function getSubscription($subscriptionId) { - $refId = 'ref' . time(); - - // Creating the API Request with required parameters - $request = new AnetAPI\ARBGetSubscriptionRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setRefId($refId); - $request->setSubscriptionId("2930242"); - - // Controller - $controller = new AnetController\ARBGetSubscriptionController($request); - - // Getting the response - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + // Common Set Up for API Credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName( "556KThWQ6vf2"); + $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + + $refId = 'ref' . time(); + + // 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); + + // Getting the response + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - if ($response != null) - { - if($response->getMessages()->getResultCode() == "Ok") + if ($response != null) { - // 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"; + 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"; + } + else + { + // Error + echo "ERROR : Invalid response\n"; + echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + + } } else { - // Error - echo "ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; - + // Failed to get response + echo "Null Response Error"; } + + return $response; } - else - { - // Failed to get response - echo "Null Response Error"; - } + + if(!defined(DONT_RUN_SAMPLES)) + getSubscription("2930242"); ?> diff --git a/RecurringBilling/update-subscription.php b/RecurringBilling/update-subscription.php index fba101e..d0f48b6 100644 --- a/RecurringBilling/update-subscription.php +++ b/RecurringBilling/update-subscription.php @@ -4,41 +4,49 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - // Common Set Up for API Credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName( "556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + function updateSubscription($subscriptionId) { - $refId = 'ref' . time(); + // Common Set Up for API Credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName( "556KThWQ6vf2"); + $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); - $subscription = new AnetAPI\ARBSubscriptionType(); + $refId = 'ref' . time(); - $creditCard = new AnetAPI\CreditCardType(); - $creditCard->setCardNumber("4111111111111111"); - $creditCard->setExpirationDate("2020-12"); + $subscription = new AnetAPI\ARBSubscriptionType(); - $payment = new AnetAPI\PaymentType(); - $payment->setCreditCard($creditCard); + $creditCard = new AnetAPI\CreditCardType(); + $creditCard->setCardNumber("4111111111111111"); + $creditCard->setExpirationDate("2020-12"); - $subscription->setPayment($payment); + $payment = new AnetAPI\PaymentType(); + $payment->setCreditCard($creditCard); - $request = new AnetAPI\ARBUpdateSubscriptionRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setRefId($refId); - $request->setSubscriptionId("100748"); - $request->setSubscription($subscription); + $subscription->setPayment($payment); - $controller = new AnetController\ARBUpdateSubscriptionController($request); + $request = new AnetAPI\ARBUpdateSubscriptionRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setRefId($refId); + $request->setSubscriptionId($subscriptionId); + $request->setSubscription($subscription); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - - if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) - { - echo "SUCCESS" . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; - } - else - { - echo "ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + $controller = new AnetController\ARBUpdateSubscriptionController($request); + + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) + { + echo "SUCCESS" . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + } + else + { + echo "ERROR : Invalid response\n"; + echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + } + + return $response; } - ?> + + if(!defined(DONT_RUN_SAMPLES)) + updateSubscription("100748"); +?> diff --git a/TransactionReporting/get-batch-statistics.php b/TransactionReporting/get-batch-statistics.php index 4f9caad..a765dcb 100644 --- a/TransactionReporting/get-batch-statistics.php +++ b/TransactionReporting/get-batch-statistics.php @@ -4,51 +4,60 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - // Common Set Up for API Credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName( "5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); - $refId = 'ref' . time(); + function getBatchStatistics() { - //Setting a valid batch Id for the Merchant - $batchId = "4532808"; - - // Creating a request - $request = new AnetAPI\GetBatchStatisticsRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setBatchId($batchId); + // Common Set Up for API Credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName( "5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $refId = 'ref' . time(); + + //Setting a valid batch Id for the Merchant + $batchId = "4532808"; - //Creating the controller - $controller = new AnetController\GetBatchStatisticsController($request); + // Creating a request + $request = new AnetAPI\GetBatchStatisticsRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setBatchId($batchId); + + //Creating the controller + $controller = new AnetController\GetBatchStatisticsController($request); - //Retrieving response - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + //Retrieving response + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - if (($response != null) && ($response->getMessages()->getResultCode() == "Ok")) - { - echo "SUCCESS: Successfully got the list of subscriptions : \n\n"; - echo "Batch ID : " . $response->getBatch()->getBatchId() . "\n"; - echo "Settlement Time : " . date_format($response->getBatch()->getSettlementTimeUTC(),"Y/m/d H:i:s") . "\n"; - echo "Settlement state : " . $response->getBatch()->getSettlementState() . "\n"; - echo "Payment Method : " . $response->getBatch()->getPaymentMethod() . "\n"; - echo "Statistic Details:"; - //Displaying the details of each transaction in the list - foreach ($response->getBatch()->getStatistics() as $statistics) - { - echo " Account Type : " . $statistics->getAccountType() . "\n"; - echo " Charge Amount : " . $statistics->getChargeAmount() . "\n"; - echo " Charge Count : " . $statistics->getChargeCount() . "\n"; - echo " Refund Amount : " . $statistics->getRefundAmount() . "\n"; - echo " Refund Count : " . $statistics->getRefundCount() . "\n"; - echo " Void Count : " . $statistics->getRefundCount() . "\n"; - echo " Decline Count : " . $statistics->getRefundCount() . "\n"; - echo " Error Count : " . $statistics->getRefundCount() . "\n"; - } - } - else - { - echo "ERROR : Failed to get the batch statistics\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; - + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok")) + { + echo "SUCCESS: Successfully got the list of subscriptions : \n\n"; + echo "Batch ID : " . $response->getBatch()->getBatchId() . "\n"; + echo "Settlement Time : " . date_format($response->getBatch()->getSettlementTimeUTC(),"Y/m/d H:i:s") . "\n"; + echo "Settlement state : " . $response->getBatch()->getSettlementState() . "\n"; + echo "Payment Method : " . $response->getBatch()->getPaymentMethod() . "\n"; + echo "Statistic Details:"; + //Displaying the details of each transaction in the list + foreach ($response->getBatch()->getStatistics() as $statistics) + { + echo " Account Type : " . $statistics->getAccountType() . "\n"; + echo " Charge Amount : " . $statistics->getChargeAmount() . "\n"; + echo " Charge Count : " . $statistics->getChargeCount() . "\n"; + echo " Refund Amount : " . $statistics->getRefundAmount() . "\n"; + echo " Refund Count : " . $statistics->getRefundCount() . "\n"; + echo " Void Count : " . $statistics->getRefundCount() . "\n"; + echo " Decline Count : " . $statistics->getRefundCount() . "\n"; + echo " Error Count : " . $statistics->getRefundCount() . "\n"; + } + } + else + { + echo "ERROR : Failed to get the batch statistics\n"; + echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + + } + + return $response; } - ?> \ No newline at end of file + + if(!defined(DONT_RUN_SAMPLES)) + getBatchStatistics(); + +?> \ No newline at end of file diff --git a/TransactionReporting/get-settled-batch-list.php b/TransactionReporting/get-settled-batch-list.php index b241992..489a464 100644 --- a/TransactionReporting/get-settled-batch-list.php +++ b/TransactionReporting/get-settled-batch-list.php @@ -4,59 +4,67 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - // Common Set Up for API Credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName( "5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); - - $request = new AnetAPI\GetSettledBatchListRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $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); - - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - - if (($response != null) && ($response->getMessages()->getResultCode() == "Ok")) - { - foreach($response->getBatchList() as $batch) - { - 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 settlement state: " . $batch->getSettlementState() . "\n"; - echo "Batch market type: " . $batch->getMarketType() . "\n"; - echo "Batch product: " . $batch->getProduct() . "\n"; - foreach($batch->getStatistics() as $statistics) - { - echo "Account type: ".$statistics->getAccountType()."\n"; - echo "Total charge amount: ".$statistics->getChargeAmount()."\n"; - echo "Charge count: ".$statistics->getChargeCount()."\n"; - echo "Refund amount: ".$statistics->getRefundAmount()."\n"; - echo "Refund count: ".$statistics->getRefundCount()."\n"; - echo "Void count: ".$statistics->getVoidCount()."\n"; - echo "Decline count: ".$statistics->getDeclineCount()."\n"; - echo "Error amount: ".$statistics->getErrorCount()."\n"; - } - } - } - else - { - echo "ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; - + function getSettledBatchList() { + + // Common Set Up for API Credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName( "5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + + $request = new AnetAPI\GetSettledBatchListRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $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); + + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok")) + { + foreach($response->getBatchList() as $batch) + { + 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 settlement state: " . $batch->getSettlementState() . "\n"; + echo "Batch market type: " . $batch->getMarketType() . "\n"; + echo "Batch product: " . $batch->getProduct() . "\n"; + foreach($batch->getStatistics() as $statistics) + { + echo "Account type: ".$statistics->getAccountType()."\n"; + echo "Total charge amount: ".$statistics->getChargeAmount()."\n"; + echo "Charge count: ".$statistics->getChargeCount()."\n"; + echo "Refund amount: ".$statistics->getRefundAmount()."\n"; + echo "Refund count: ".$statistics->getRefundCount()."\n"; + echo "Void count: ".$statistics->getVoidCount()."\n"; + echo "Decline count: ".$statistics->getDeclineCount()."\n"; + echo "Error amount: ".$statistics->getErrorCount()."\n"; + } + } + } + else + { + echo "ERROR : Invalid response\n"; + echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + } + + return $response; } - ?> + + if(!defined(DONT_RUN_SAMPLES)) + getSettledBatchList(); + +?> diff --git a/TransactionReporting/get-transaction-details.php b/TransactionReporting/get-transaction-details.php index b48de44..de7363b 100644 --- a/TransactionReporting/get-transaction-details.php +++ b/TransactionReporting/get-transaction-details.php @@ -4,33 +4,39 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - // Common Set Up for API Credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName( "5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + function getTransactionDetails($transactionId) { - $refId = 'ref' . time(); + // Common Set Up for API Credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName( "5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $refId = 'ref' . time(); - $request = new AnetAPI\GetTransactionDetailsRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setTransId("2238968786"); + $request = new AnetAPI\GetTransactionDetailsRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setTransId($transactionId); + $controller = new AnetController\GetTransactionDetailsController($request); - $controller = new AnetController\GetTransactionDetailsController($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: Transaction Status:" . $response->getTransaction()->getTransactionStatus() . "\n"; + echo " Auth Amount:" . $response->getTransaction()->getAuthAmount() . "\n"; + echo " Trans ID:" . $response->getTransaction()->getTransId() . "\n"; + } + else + { + echo "ERROR : Invalid response\n"; + echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + + } - if (($response != null) && ($response->getMessages()->getResultCode() == "Ok")) - { - echo "SUCCESS: Transaction Status:" . $response->getTransaction()->getTransactionStatus() . "\n"; - echo " Auth Amount:" . $response->getTransaction()->getAuthAmount() . "\n"; - echo " Trans ID:" . $response->getTransaction()->getTransId() . "\n"; - } - else - { - echo "ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; - + return $response; } - ?> + + if(!defined(DONT_RUN_SAMPLES)) + getTransactionDetails("2238968786"); +?> \ No newline at end of file diff --git a/TransactionReporting/get-transaction-list.php b/TransactionReporting/get-transaction-list.php index 3e63fe6..b10a4ae 100644 --- a/TransactionReporting/get-transaction-list.php +++ b/TransactionReporting/get-transaction-list.php @@ -4,43 +4,50 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - // Common Set Up for API Credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName( "5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + function getTransactionList() { + // Common Set Up for API Credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName( "5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); - $refId = 'ref' . time(); + $refId = 'ref' . time(); - //Setting a valid batch Id for the Merchant - $batchId = "4606008"; - $request = new AnetAPI\GetTransactionListRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setBatchId($batchId); + //Setting a valid batch Id for the Merchant + $batchId = "4606008"; + $request = new AnetAPI\GetTransactionListRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setBatchId($batchId); - $controller = new AnetController\GetTransactionListController($request); + $controller = new AnetController\GetTransactionListController($request); - //Retrieving transaction list for the given Batch Id - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + //Retrieving transaction list for the given Batch Id + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - 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 dispaly 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"; - } - } - else - { - echo "ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; - + 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 dispaly 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"; + } + } + else + { + echo "ERROR : Invalid response\n"; + echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + + } + + return $response; } - ?> \ No newline at end of file + + if(!defined(DONT_RUN_SAMPLES)) + getTransactionList(); +?> \ No newline at end of file diff --git a/TransactionReporting/get-unsettled-transaction-list.php b/TransactionReporting/get-unsettled-transaction-list.php index 2592470..3c24c18 100644 --- a/TransactionReporting/get-unsettled-transaction-list.php +++ b/TransactionReporting/get-unsettled-transaction-list.php @@ -4,34 +4,42 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - // Common Set Up for API Credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName( "5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + function getUnsettledTransactionList() { + // Common Set Up for API Credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName( "5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); - $refId = 'ref' . time(); + $refId = 'ref' . time(); - $request = new AnetAPI\GetUnsettledTransactionListRequest(); - $request->setMerchantAuthentication($merchantAuthentication); + $request = new AnetAPI\GetUnsettledTransactionListRequest(); + $request->setMerchantAuthentication($merchantAuthentication); - $controller = new AnetController\GetUnsettledTransactionListController($request); + $controller = new AnetController\GetUnsettledTransactionListController($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")) - { - foreach($response->getTransactions() as $tx) - { - echo "SUCCESS: TransactionID: " . $tx->getTransId() . "\n"; - } - - } - else - { - echo "ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; - + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok")) + { + foreach($response->getTransactions() as $tx) + { + echo "SUCCESS: TransactionID: " . $tx->getTransId() . "\n"; + } + + } + else + { + echo "ERROR : Invalid response\n"; + echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + + } + + return $response; } - ?> + + if(!defined(DONT_RUN_SAMPLES)) + getUnsettledTransactionList(); + +?> From dc4b977d2c865fe3d4a0b59da2830790703f03d1 Mon Sep 17 00:00:00 2001 From: srathod Date: Thu, 14 Jan 2016 12:25:17 +0530 Subject: [PATCH 019/287] - Updated sample codes in PaymentTransactions, VisaCheckout and ApplePayTransactions for testrunner. - Encapsulated the sample codes in function and added return response statement. --- .../create-an-apple-pay-transaction.php | 83 ++++---- PaymentTransactions/authorize-credit-card.php | 86 ++++---- ...nds-authorized-through-another-channel.php | 72 +++---- .../capture-previously-authorized-amount.php | 132 ++++++------ PaymentTransactions/charge-credit-card.php | 188 +++++++++--------- .../charge-customer-profile.php | 80 ++++---- .../charge-tokenized-credit-card.php | 81 ++++---- PaymentTransactions/credit-bank-account.php | 100 +++++----- PaymentTransactions/debit-bank-account.php | 101 +++++----- PaymentTransactions/refund-transaction.php | 72 ++++--- .../update-split-tender-group.php | 46 +++-- PaymentTransactions/void-transaction.php | 73 ++++--- .../create-visa-checkout-transaction.php | 89 +++++---- VisaCheckout/decrypt-visa-checkout-data.php | 62 +++--- 14 files changed, 670 insertions(+), 595 deletions(-) diff --git a/ApplePayTransactions/create-an-apple-pay-transaction.php b/ApplePayTransactions/create-an-apple-pay-transaction.php index 3d2581d..5704383 100644 --- a/ApplePayTransactions/create-an-apple-pay-transaction.php +++ b/ApplePayTransactions/create-an-apple-pay-transaction.php @@ -5,48 +5,55 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); -$merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); -$merchantAuthentication->setName("5KP3u95bQpv"); -$merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); -$refId = 'ref' . time(); - -$op = new AnetAPI\OpaqueDataType(); -$op->setDataDescriptor("COMMON.APPLE.INAPP.PAYMENT"); -$op->setDataValue("eyJkYXRhIjoiQkRQTldTdE1tR2V3UVVXR2c0bzdFXC9qKzFjcTFUNzhxeVU4NGI2N2l0amNZSTh3UFlBT2hzaGpoWlBycWRVcjRYd1BNYmo0emNHTWR5KysxSDJWa1BPWStCT01GMjV1YjE5Y1g0bkN2a1hVVU9UakRsbEIxVGdTcjhKSFp4Z3A5ckNnc1NVZ2JCZ0tmNjBYS3V0WGY2YWpcL284WkliS25yS1E4U2gwb3VMQUtsb1VNbit2UHU0K0E3V0tycXJhdXo5SnZPUXA2dmhJcStIS2pVY1VOQ0lUUHlGaG1PRXRxK0grdzB2UmExQ0U2V2hGQk5uQ0hxenpXS2NrQlwvMG5xTFpSVFliRjBwK3Z5QmlWYVdIZWdoRVJmSHhSdGJ6cGVjelJQUHVGc2ZwSFZzNDhvUExDXC9rXC8xTU5kNDdrelwvcEhEY1JcL0R5NmFVTStsTmZvaWx5XC9RSk4rdFMzbTBIZk90SVNBUHFPbVhlbXZyNnhKQ2pDWmxDdXcwQzltWHpcL29iSHBvZnVJRVM4cjljcUdHc1VBUERwdzdnNjQybTRQendLRitIQnVZVW5lV0RCTlNEMnU2amJBRzMiLCJ2ZXJzaW9uIjoiRUNfdjEiLCJoZWFkZXIiOnsiYXBwbGljYXRpb25EYXRhIjoiOTRlZTA1OTMzNWU1ODdlNTAxY2M0YmY5MDYxM2UwODE0ZjAwYTdiMDhiYzdjNjQ4ZmQ4NjVhMmFmNmEyMmNjMiIsInRyYW5zYWN0aW9uSWQiOiJjMWNhZjVhZTcyZjAwMzlhODJiYWQ5MmI4MjgzNjM3MzRmODViZjJmOWNhZGYxOTNkMWJhZDlkZGNiNjBhNzk1IiwiZXBoZW1lcmFsUHVibGljS2V5IjoiTUlJQlN6Q0NBUU1HQnlxR1NNNDlBZ0V3Z2ZjQ0FRRXdMQVlIS29aSXpqMEJBUUloQVBcL1wvXC9cLzhBQUFBQkFBQUFBQUFBQUFBQUFBQUFcL1wvXC9cL1wvXC9cL1wvXC9cL1wvXC9cL1wvXC9cL01Gc0VJUFwvXC9cL1wvOEFBQUFCQUFBQUFBQUFBQUFBQUFBQVwvXC9cL1wvXC9cL1wvXC9cL1wvXC9cL1wvXC9cLzhCQ0JheGpYWXFqcVQ1N1BydlZWMm1JYThaUjBHc014VHNQWTd6ancrSjlKZ1N3TVZBTVNkTmdpRzV3U1RhbVo0NFJPZEpyZUJuMzZRQkVFRWF4ZlI4dUVzUWtmNHZPYmxZNlJBOG5jRGZZRXQ2ek9nOUtFNVJkaVl3cFpQNDBMaVwvaHBcL200N242MHA4RDU0V0s4NHpWMnN4WHM3THRrQm9ONzlSOVFJaEFQXC9cL1wvXC84QUFBQUFcL1wvXC9cL1wvXC9cL1wvXC9cLys4NXZxdHB4ZWVoUE81eXNMOFl5VlJBZ0VCQTBJQUJHbStnc2wwUFpGVFwva0RkVVNreHd5Zm84SnB3VFFRekJtOWxKSm5tVGw0REdVdkFENEdzZUdqXC9wc2hCWjBLM1RldXFEdFwvdERMYkUrOFwvbTB5Q21veHc9IiwicHVibGljS2V5SGFzaCI6IlwvYmI5Q05DMzZ1QmhlSEZQYm1vaEI3T28xT3NYMkora0pxdjQ4ek9WVmlRPSJ9LCJzaWduYXR1cmUiOiJNSUlEUWdZSktvWklodmNOQVFjQ29JSURNekNDQXk4Q0FRRXhDekFKQmdVckRnTUNHZ1VBTUFzR0NTcUdTSWIzRFFFSEFhQ0NBaXN3Z2dJbk1JSUJsS0FEQWdFQ0FoQmNsK1BmMytVNHBrMTNuVkQ5bndRUU1Ba0dCU3NPQXdJZEJRQXdKekVsTUNNR0ExVUVBeDRjQUdNQWFBQnRBR0VBYVFCQUFIWUFhUUJ6QUdFQUxnQmpBRzhBYlRBZUZ3MHhOREF4TURFd05qQXdNREJhRncweU5EQXhNREV3TmpBd01EQmFNQ2N4SlRBakJnTlZCQU1lSEFCakFHZ0FiUUJoQUdrQVFBQjJBR2tBY3dCaEFDNEFZd0J2QUcwd2daOHdEUVlKS29aSWh2Y05BUUVCQlFBRGdZMEFNSUdKQW9HQkFOQzgra2d0Z212V0YxT3pqZ0ROcmpURUJSdW9cLzVNS3ZsTTE0NnBBZjdHeDQxYmxFOXc0ZklYSkFEN0ZmTzdRS2pJWFlOdDM5ckx5eTd4RHdiXC81SWtaTTYwVFoyaUkxcGo1NVVjOGZkNGZ6T3BrM2Z0WmFRR1hOTFlwdEcxZDlWN0lTODJPdXA5TU1vMUJQVnJYVFBITmNzTTk5RVBVblBxZGJlR2M4N20wckFnTUJBQUdqWERCYU1GZ0dBMVVkQVFSUk1FK0FFSFpXUHJXdEpkN1laNDMxaENnN1lGU2hLVEFuTVNVd0l3WURWUVFESGh3QVl3Qm9BRzBBWVFCcEFFQUFkZ0JwQUhNQVlRQXVBR01BYndCdGdoQmNsK1BmMytVNHBrMTNuVkQ5bndRUU1Ba0dCU3NPQXdJZEJRQURnWUVBYlVLWUNrdUlLUzlRUTJtRmNNWVJFSW0ybCtYZzhcL0pYditHQlZRSmtPS29zY1k0aU5ERkFcL2JRbG9nZjlMTFU4NFRId05SbnN2VjNQcnY3UlRZODFncTBkdEM4elljQWFBa0NISUkzeXFNbko0QU91NkVPVzlrSmsyMzJnU0U3V2xDdEhiZkxTS2Z1U2dRWDhLWFFZdVpMazJScjYzTjhBcFhzWHdCTDNjSjB4Z2VBd2dkMENBUUV3T3pBbk1TVXdJd1lEVlFRREhod0FZd0JvQUcwQVlRQnBBRUFBZGdCcEFITUFZUUF1QUdNQWJ3QnRBaEJjbCtQZjMrVTRwazEzblZEOW53UVFNQWtHQlNzT0F3SWFCUUF3RFFZSktvWklodmNOQVFFQkJRQUVnWUJhSzNFbE9zdGJIOFdvb3NlREFCZitKZ1wvMTI5SmNJYXdtN2M2VnhuN1phc05iQXEzdEF0OFB0eSt1UUNnc3NYcVprTEE3a3oyR3pNb2xOdHY5d1ltdTlVandhcjFQSFlTK0JcL29Hbm96NTkxd2phZ1hXUnowbk1vNXkzTzFLelgwZDhDUkhBVmE4OFNyVjFhNUpJaVJldjNvU3RJcXd2NXh1WmxkYWc2VHI4dz09In0="); -$paymentOne = new AnetAPI\PaymentType(); -$paymentOne->setOpaqueData($op); - -//create a transaction -$transactionRequestType = new AnetAPI\TransactionRequestType(); -$transactionRequestType->setTransactionType( "authCaptureTransaction"); -$transactionRequestType->setAmount(151); -$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) -{ - $tresponse = $response->getTransactionResponse(); - - if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + +function createAnApplePayTransaction(){ + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName("5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $refId = 'ref' . time(); + + $op = new AnetAPI\OpaqueDataType(); + $op->setDataDescriptor("COMMON.APPLE.INAPP.PAYMENT"); + $op->setDataValue("eyJkYXRhIjoiQkRQTldTdE1tR2V3UVVXR2c0bzdFXC9qKzFjcTFUNzhxeVU4NGI2N2l0amNZSTh3UFlBT2hzaGpoWlBycWRVcjRYd1BNYmo0emNHTWR5KysxSDJWa1BPWStCT01GMjV1YjE5Y1g0bkN2a1hVVU9UakRsbEIxVGdTcjhKSFp4Z3A5ckNnc1NVZ2JCZ0tmNjBYS3V0WGY2YWpcL284WkliS25yS1E4U2gwb3VMQUtsb1VNbit2UHU0K0E3V0tycXJhdXo5SnZPUXA2dmhJcStIS2pVY1VOQ0lUUHlGaG1PRXRxK0grdzB2UmExQ0U2V2hGQk5uQ0hxenpXS2NrQlwvMG5xTFpSVFliRjBwK3Z5QmlWYVdIZWdoRVJmSHhSdGJ6cGVjelJQUHVGc2ZwSFZzNDhvUExDXC9rXC8xTU5kNDdrelwvcEhEY1JcL0R5NmFVTStsTmZvaWx5XC9RSk4rdFMzbTBIZk90SVNBUHFPbVhlbXZyNnhKQ2pDWmxDdXcwQzltWHpcL29iSHBvZnVJRVM4cjljcUdHc1VBUERwdzdnNjQybTRQendLRitIQnVZVW5lV0RCTlNEMnU2amJBRzMiLCJ2ZXJzaW9uIjoiRUNfdjEiLCJoZWFkZXIiOnsiYXBwbGljYXRpb25EYXRhIjoiOTRlZTA1OTMzNWU1ODdlNTAxY2M0YmY5MDYxM2UwODE0ZjAwYTdiMDhiYzdjNjQ4ZmQ4NjVhMmFmNmEyMmNjMiIsInRyYW5zYWN0aW9uSWQiOiJjMWNhZjVhZTcyZjAwMzlhODJiYWQ5MmI4MjgzNjM3MzRmODViZjJmOWNhZGYxOTNkMWJhZDlkZGNiNjBhNzk1IiwiZXBoZW1lcmFsUHVibGljS2V5IjoiTUlJQlN6Q0NBUU1HQnlxR1NNNDlBZ0V3Z2ZjQ0FRRXdMQVlIS29aSXpqMEJBUUloQVBcL1wvXC9cLzhBQUFBQkFBQUFBQUFBQUFBQUFBQUFcL1wvXC9cL1wvXC9cL1wvXC9cL1wvXC9cL1wvXC9cL01Gc0VJUFwvXC9cL1wvOEFBQUFCQUFBQUFBQUFBQUFBQUFBQVwvXC9cL1wvXC9cL1wvXC9cL1wvXC9cL1wvXC9cLzhCQ0JheGpYWXFqcVQ1N1BydlZWMm1JYThaUjBHc014VHNQWTd6ancrSjlKZ1N3TVZBTVNkTmdpRzV3U1RhbVo0NFJPZEpyZUJuMzZRQkVFRWF4ZlI4dUVzUWtmNHZPYmxZNlJBOG5jRGZZRXQ2ek9nOUtFNVJkaVl3cFpQNDBMaVwvaHBcL200N242MHA4RDU0V0s4NHpWMnN4WHM3THRrQm9ONzlSOVFJaEFQXC9cL1wvXC84QUFBQUFcL1wvXC9cL1wvXC9cL1wvXC9cLys4NXZxdHB4ZWVoUE81eXNMOFl5VlJBZ0VCQTBJQUJHbStnc2wwUFpGVFwva0RkVVNreHd5Zm84SnB3VFFRekJtOWxKSm5tVGw0REdVdkFENEdzZUdqXC9wc2hCWjBLM1RldXFEdFwvdERMYkUrOFwvbTB5Q21veHc9IiwicHVibGljS2V5SGFzaCI6IlwvYmI5Q05DMzZ1QmhlSEZQYm1vaEI3T28xT3NYMkora0pxdjQ4ek9WVmlRPSJ9LCJzaWduYXR1cmUiOiJNSUlEUWdZSktvWklodmNOQVFjQ29JSURNekNDQXk4Q0FRRXhDekFKQmdVckRnTUNHZ1VBTUFzR0NTcUdTSWIzRFFFSEFhQ0NBaXN3Z2dJbk1JSUJsS0FEQWdFQ0FoQmNsK1BmMytVNHBrMTNuVkQ5bndRUU1Ba0dCU3NPQXdJZEJRQXdKekVsTUNNR0ExVUVBeDRjQUdNQWFBQnRBR0VBYVFCQUFIWUFhUUJ6QUdFQUxnQmpBRzhBYlRBZUZ3MHhOREF4TURFd05qQXdNREJhRncweU5EQXhNREV3TmpBd01EQmFNQ2N4SlRBakJnTlZCQU1lSEFCakFHZ0FiUUJoQUdrQVFBQjJBR2tBY3dCaEFDNEFZd0J2QUcwd2daOHdEUVlKS29aSWh2Y05BUUVCQlFBRGdZMEFNSUdKQW9HQkFOQzgra2d0Z212V0YxT3pqZ0ROcmpURUJSdW9cLzVNS3ZsTTE0NnBBZjdHeDQxYmxFOXc0ZklYSkFEN0ZmTzdRS2pJWFlOdDM5ckx5eTd4RHdiXC81SWtaTTYwVFoyaUkxcGo1NVVjOGZkNGZ6T3BrM2Z0WmFRR1hOTFlwdEcxZDlWN0lTODJPdXA5TU1vMUJQVnJYVFBITmNzTTk5RVBVblBxZGJlR2M4N20wckFnTUJBQUdqWERCYU1GZ0dBMVVkQVFSUk1FK0FFSFpXUHJXdEpkN1laNDMxaENnN1lGU2hLVEFuTVNVd0l3WURWUVFESGh3QVl3Qm9BRzBBWVFCcEFFQUFkZ0JwQUhNQVlRQXVBR01BYndCdGdoQmNsK1BmMytVNHBrMTNuVkQ5bndRUU1Ba0dCU3NPQXdJZEJRQURnWUVBYlVLWUNrdUlLUzlRUTJtRmNNWVJFSW0ybCtYZzhcL0pYditHQlZRSmtPS29zY1k0aU5ERkFcL2JRbG9nZjlMTFU4NFRId05SbnN2VjNQcnY3UlRZODFncTBkdEM4elljQWFBa0NISUkzeXFNbko0QU91NkVPVzlrSmsyMzJnU0U3V2xDdEhiZkxTS2Z1U2dRWDhLWFFZdVpMazJScjYzTjhBcFhzWHdCTDNjSjB4Z2VBd2dkMENBUUV3T3pBbk1TVXdJd1lEVlFRREhod0FZd0JvQUcwQVlRQnBBRUFBZGdCcEFITUFZUUF1QUdNQWJ3QnRBaEJjbCtQZjMrVTRwazEzblZEOW53UVFNQWtHQlNzT0F3SWFCUUF3RFFZSktvWklodmNOQVFFQkJRQUVnWUJhSzNFbE9zdGJIOFdvb3NlREFCZitKZ1wvMTI5SmNJYXdtN2M2VnhuN1phc05iQXEzdEF0OFB0eSt1UUNnc3NYcVprTEE3a3oyR3pNb2xOdHY5d1ltdTlVandhcjFQSFlTK0JcL29Hbm96NTkxd2phZ1hXUnowbk1vNXkzTzFLelgwZDhDUkhBVmE4OFNyVjFhNUpJaVJldjNvU3RJcXd2NXh1WmxkYWc2VHI4dz09In0="); + $paymentOne = new AnetAPI\PaymentType(); + $paymentOne->setOpaqueData($op); + + //create a transaction + $transactionRequestType = new AnetAPI\TransactionRequestType(); + $transactionRequestType->setTransactionType( "authCaptureTransaction"); + $transactionRequestType->setAmount(151); + $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) { - echo " AUTH CODE : " . $tresponse->getAuthCode() . "\n"; - echo " TRANS ID : " . $tresponse->getTransId() . "\n"; + $tresponse = $response->getTransactionResponse(); + + if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + { + echo " AUTH CODE : " . $tresponse->getAuthCode() . "\n"; + echo " TRANS ID : " . $tresponse->getTransId() . "\n"; + } + else + { + echo "ERROR : Invalid response\n"; + echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + } } else { - echo "ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + echo "Null response"; } + return $response; } -else -{ - echo "Null response"; -} + +if(!defined(DONT_RUN_SAMPLES)) + createAnApplePayTransaction(); ?> diff --git a/PaymentTransactions/authorize-credit-card.php b/PaymentTransactions/authorize-credit-card.php index 90c55bb..001c250 100644 --- a/PaymentTransactions/authorize-credit-card.php +++ b/PaymentTransactions/authorize-credit-card.php @@ -6,51 +6,55 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); - $refId = 'ref' . time(); - - // Create the payment data for a credit card - $creditCard = new AnetAPI\CreditCardType(); - $creditCard->setCardNumber( "4111111111111111" ); - $creditCard->setExpirationDate( "2038-12"); - $paymentOne = new AnetAPI\PaymentType(); - $paymentOne->setCreditCard($creditCard); - - //create a transaction - $transactionRequestType = new AnetAPI\TransactionRequestType(); - $transactionRequestType->setTransactionType( "authOnlyTransaction"); - $transactionRequestType->setAmount(151); - $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) - { - $tresponse = $response->getTransactionResponse(); - - if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + function authorizeCreditCard(){ + // Common setup for API credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName("5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $refId = 'ref' . time(); + + // Create the payment data for a credit card + $creditCard = new AnetAPI\CreditCardType(); + $creditCard->setCardNumber( "4111111111111111" ); + $creditCard->setExpirationDate( "2038-12"); + $paymentOne = new AnetAPI\PaymentType(); + $paymentOne->setCreditCard($creditCard); + + //create a transaction + $transactionRequestType = new AnetAPI\TransactionRequestType(); + $transactionRequestType->setTransactionType( "authOnlyTransaction"); + $transactionRequestType->setAmount(151); + $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) { - echo " AUTH CODE : " . $tresponse->getAuthCode() . "\n"; - echo " TRANS ID : " . $tresponse->getTransId() . "\n"; + $tresponse = $response->getTransactionResponse(); + + if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + { + echo " AUTH CODE : " . $tresponse->getAuthCode() . "\n"; + echo " TRANS ID : " . $tresponse->getTransId() . "\n"; + } + else + { + echo "ERROR : " . $tresponse->getResponseCode() . "\n"; + } + } else { - echo "ERROR : " . $tresponse->getResponseCode() . "\n"; + echo "No response returned"; } - + return $response; } - else - { - echo "No response returned"; - } - + if(!defined(DONT_RUN_SAMPLES)) + authorizeCreditCard(); ?> \ 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 1e00a81..73747ff 100644 --- a/PaymentTransactions/capture-funds-authorized-through-another-channel.php +++ b/PaymentTransactions/capture-funds-authorized-through-another-channel.php @@ -4,52 +4,56 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); +function captureFundsAuthorizedThroughAnotherChannel(){ + // Common setup for API credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName("556KThWQ6vf2"); + $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + $refId = "123456"; -// Common setup for API credentials -$merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); -$merchantAuthentication->setName("556KThWQ6vf2"); -$merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); -$refId = "123456"; + $creditCard = new AnetAPI\CreditCardType(); + $creditCard->setCardNumber( "4111111111111111"); + $creditCard->setExpirationDate( "2038-12"); -$creditCard = new AnetAPI\CreditCardType(); -$creditCard->setCardNumber( "4111111111111111"); -$creditCard->setExpirationDate( "2038-12"); + $paymentOne = new AnetAPI\PaymentType(); + $paymentOne->setCreditCard($creditCard); -$paymentOne = new AnetAPI\PaymentType(); -$paymentOne->setCreditCard($creditCard); + $transactionRequestType = new AnetAPI\TransactionRequestType(); + $transactionRequestType->setTransactionType("captureOnlyTransaction"); + $transactionRequestType->setAmount(5.00); + $transactionRequestType->setPayment($paymentOne); -$transactionRequestType = new AnetAPI\TransactionRequestType(); -$transactionRequestType->setTransactionType("captureOnlyTransaction"); -$transactionRequestType->setAmount(5.00); -$transactionRequestType->setPayment($paymentOne); + //Auth code of the previously authorized amount + $transactionRequestType->setAuthCode("ROHNFQ"); -//Auth code of the previously authorized amount -$transactionRequestType->setAuthCode("ROHNFQ"); + $request = new AnetAPI\CreateTransactionRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setTransactionRequest( $transactionRequestType); -$request = new AnetAPI\CreateTransactionRequest(); -$request->setMerchantAuthentication($merchantAuthentication); -$request->setTransactionRequest( $transactionRequestType); + $controller = new AnetController\CreateTransactionController($request); + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); -$controller = new AnetController\CreateTransactionController($request); -$response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - -if ($response != null) -{ - $tresponse = $response->getTransactionResponse(); - if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + if ($response != null) { - echo "Successful." . "\n"; - echo "Capture funds authorized through another channel TRANS ID : " . $tresponse->getTransId() . "\n"; + $tresponse = $response->getTransactionResponse(); + if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + { + echo "Successful." . "\n"; + echo "Capture funds authorized through another channel TRANS ID : " . $tresponse->getTransId() . "\n"; + } + else + { + echo "Capture funds authorized through another channel ERROR: Invalid response\n"; + echo "Response Code: " . $response->getMessages()->getMessage()[0]->getCode() . " Response Text: " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + } } else { - echo "Capture funds authorized through another channel ERROR: Invalid response\n"; - echo "Response Code: " . $response->getMessages()->getMessage()[0]->getCode() . " Response Text: " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + echo "Capture funds authorized through another channel NULL Response Error\n"; } + return $response; } -else -{ - echo "Capture funds authorized through another channel NULL Response Error\n"; -} +if(!defined(DONT_RUN_SAMPLES)) + captureFundsAuthorizedThroughAnotherChannel(); ?> diff --git a/PaymentTransactions/capture-previously-authorized-amount.php b/PaymentTransactions/capture-previously-authorized-amount.php index ec6db61..fc310cf 100644 --- a/PaymentTransactions/capture-previously-authorized-amount.php +++ b/PaymentTransactions/capture-previously-authorized-amount.php @@ -4,88 +4,92 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); + function capturePreviouslyAuthorizedAmount(){ + // Common setup for API credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName("556KThWQ6vf2"); + $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + $refId = "123456"; - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); - $refId = "123456"; + // Create the payment data for a credit card + $creditCard = new AnetAPI\CreditCardType(); + $creditCard->setCardNumber( "4111111111111111"); + $creditCard->setExpirationDate( "2038-12"); - // Create the payment data for a credit card - $creditCard = new AnetAPI\CreditCardType(); - $creditCard->setCardNumber( "4111111111111111"); - $creditCard->setExpirationDate( "2038-12"); + //$creditCard->setCardCode("999"); + $paymentOne = new AnetAPI\PaymentType(); + $paymentOne->setCreditCard($creditCard); - //$creditCard->setCardCode("999"); - $paymentOne = new AnetAPI\PaymentType(); - $paymentOne->setCreditCard($creditCard); + // First Authorize the amount + $transactionRequestType = new AnetAPI\TransactionRequestType(); + $transactionRequestType->setTransactionType("priorAuthCaptureTransaction"); + $transactionRequestType->setAmount(5.00); + $transactionRequestType->setPayment($paymentOne); - // First Authorize the amount - $transactionRequestType = new AnetAPI\TransactionRequestType(); - $transactionRequestType->setTransactionType("priorAuthCaptureTransaction"); - $transactionRequestType->setAmount(5.00); - $transactionRequestType->setPayment($paymentOne); + + $request = new AnetAPI\CreateTransactionRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setTransactionRequest( $transactionRequestType); - - $request = new AnetAPI\CreateTransactionRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setTransactionRequest( $transactionRequestType); + $controller = new AnetController\CreateTransactionController($request); + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + + $authTransId = "0"; - $controller = new AnetController\CreateTransactionController($request); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - - $authTransId = "0"; - - if ($response != null) - { - $tresponse = $response->getTransactionResponse(); - $authTransId = $tresponse->getTransId(); - - if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + if ($response != null) { - echo "AUTH CODE : " . $tresponse->getAuthCode() . "\n"; - echo "TRANS ID : " . $authTransId . "\n"; + $tresponse = $response->getTransactionResponse(); + $authTransId = $tresponse->getTransId(); + + if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + { + echo "AUTH CODE : " . $tresponse->getAuthCode() . "\n"; + echo "TRANS ID : " . $authTransId . "\n"; + } + else + { + echo "Authorization : Invalid response\n"; + } } else { - echo "Authorization : Invalid response\n"; + echo "Authorization NULL Response Error\n"; } - } - else - { - echo "Authorization NULL Response Error\n"; - } - // Now capture the previously authorized amount - echo "Capturing the Authorization with transaction ID : " . $authTransId . "\n"; - $transactionRequestType = new AnetAPI\TransactionRequestType(); - $transactionRequestType->setTransactionType("priorAuthCaptureTransaction"); - $transactionRequestType->setAmount(5.00); - $transactionRequestType->setRefTransId($authTransId); + // Now capture the previously authorized amount + echo "Capturing the Authorization with transaction ID : " . $authTransId . "\n"; + $transactionRequestType = new AnetAPI\TransactionRequestType(); + $transactionRequestType->setTransactionType("priorAuthCaptureTransaction"); + $transactionRequestType->setAmount(5.00); + $transactionRequestType->setRefTransId($authTransId); - - $request = new AnetAPI\CreateTransactionRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setTransactionRequest( $transactionRequestType); + + $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) - { - $tresponse = $response->getTransactionResponse(); - if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + $controller = new AnetController\CreateTransactionController($request); + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + + if ($response != null) { - echo "Successful." . "\n"; - echo "Capture Previously Authorized Amount TRANS ID : " . $tresponse->getTransId() . "\n"; + $tresponse = $response->getTransactionResponse(); + if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + { + echo "Successful." . "\n"; + echo "Capture Previously Authorized Amount TRANS ID : " . $tresponse->getTransId() . "\n"; + } + else + { + echo " Capture Previously Authorized Amount: Invalid response\n"; + } } else { - echo " Capture Previously Authorized Amount: Invalid response\n"; + echo "Capture Previously Authorized Amount NULL Response Error\n"; } + return $response; } - else - { - echo "Capture Previously Authorized Amount NULL Response Error\n"; - } + if(!defined(DONT_RUN_SAMPLES)) + capturePreviouslyAuthorizedAmount(); ?> diff --git a/PaymentTransactions/charge-credit-card.php b/PaymentTransactions/charge-credit-card.php index 99f4757..b349dce 100644 --- a/PaymentTransactions/charge-credit-card.php +++ b/PaymentTransactions/charge-credit-card.php @@ -4,106 +4,110 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); + function chargeCreditCard(){ + // Common setup for API credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName("556KThWQ6vf2"); + $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + $refId = 'ref' . time(); - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); - $refId = 'ref' . time(); + // Create the payment data for a credit card + $creditCard = new AnetAPI\CreditCardType(); + $creditCard->setCardNumber( "4111111111111111" ); + $creditCard->setExpirationDate( "2038-12"); + $paymentOne = new AnetAPI\PaymentType(); + $paymentOne->setCreditCard($creditCard); - // Create the payment data for a credit card - $creditCard = new AnetAPI\CreditCardType(); - $creditCard->setCardNumber( "4111111111111111" ); - $creditCard->setExpirationDate( "2038-12"); - $paymentOne = new AnetAPI\PaymentType(); - $paymentOne->setCreditCard($creditCard); + // Order info + $order = new AnetAPI\OrderType(); + $order->setInvoiceNumber("101"); + $order->setDescription("Golf Shirts"); - // Order info - $order = new AnetAPI\OrderType(); - $order->setInvoiceNumber("101"); - $order->setDescription("Golf Shirts"); + // Line Item Info + $lineitem = new AnetAPI\LineItemType(); + $lineitem->setItemId("Shirts"); + $lineitem->setName("item1"); + $lineitem->setDescription("golf shirt"); + $lineitem->setQuantity("1"); + $lineitem->setUnitPrice(20.95); + $lineitem->setTaxable(false); - // Line Item Info - $lineitem = new AnetAPI\LineItemType(); - $lineitem->setItemId("Shirts"); - $lineitem->setName("item1"); - $lineitem->setDescription("golf shirt"); - $lineitem->setQuantity("1"); - $lineitem->setUnitPrice(20.95); - $lineitem->setTaxable(false); + // Tax info + $tax = new AnetAPI\ExtendedAmountType(); + $tax->setName("level 2 tax name"); + $tax->setAmount(4.50); + $tax->setDescription("level 2 tax"); - // Tax info - $tax = new AnetAPI\ExtendedAmountType(); - $tax->setName("level 2 tax name"); - $tax->setAmount(4.50); - $tax->setDescription("level 2 tax"); + // Customer info + $customer = new AnetAPI\CustomerDataType(); + $customer->setId("15"); + $customer->setEmail("foo@example.com"); - // Customer info - $customer = new AnetAPI\CustomerDataType(); - $customer->setId("15"); - $customer->setEmail("foo@example.com"); + // PO Number + $ponumber = "15"; + //Ship To Info + $shipto = new AnetAPI\NameAndAddressType(); + $shipto->setFirstName("Bayles"); + $shipto->setLastName("China"); + $shipto->setCompany("Thyme for Tea"); + $shipto->setAddress("12 Main Street"); + $shipto->setCity("Pecan Springs"); + $shipto->setState("TX"); + $shipto->setZip("44628"); + $shipto->setCountry("USA"); - // PO Number - $ponumber = "15"; - //Ship To Info - $shipto = new AnetAPI\NameAndAddressType(); - $shipto->setFirstName("Bayles"); - $shipto->setLastName("China"); - $shipto->setCompany("Thyme for Tea"); - $shipto->setAddress("12 Main Street"); - $shipto->setCity("Pecan Springs"); - $shipto->setState("TX"); - $shipto->setZip("44628"); - $shipto->setCountry("USA"); + // Bill To + $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 transaction + $transactionRequestType = new AnetAPI\TransactionRequestType(); + $transactionRequestType->setTransactionType( "authCaptureTransaction"); + $transactionRequestType->setAmount(151.51); + $transactionRequestType->setPayment($paymentOne); + $transactionRequestType->setOrder($order); + $transactionRequestType->addToLineItems($lineitem); + $transactionRequestType->setTax($tax); + $transactionRequestType->setPoNumber($ponumber); + $transactionRequestType->setCustomer($customer); + $transactionRequestType->setBillTo($billto); + $transactionRequestType->setShipTo($shipto); - // Bill To - $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 transaction - $transactionRequestType = new AnetAPI\TransactionRequestType(); - $transactionRequestType->setTransactionType( "authCaptureTransaction"); - $transactionRequestType->setAmount(151.51); - $transactionRequestType->setPayment($paymentOne); - $transactionRequestType->setOrder($order); - $transactionRequestType->addToLineItems($lineitem); - $transactionRequestType->setTax($tax); - $transactionRequestType->setPoNumber($ponumber); - $transactionRequestType->setCustomer($customer); - $transactionRequestType->setBillTo($billto); - $transactionRequestType->setShipTo($shipto); + $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) + { + $tresponse = $response->getTransactionResponse(); - $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) - { - $tresponse = $response->getTransactionResponse(); - - if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) - { - echo "Charge Credit Card AUTH CODE : " . $tresponse->getAuthCode() . "\n"; - echo "Charge Credit Card TRANS ID : " . $tresponse->getTransId() . "\n"; - } - else - { - echo "Charge Credit Card ERROR : Invalid response\n"; - } - - } - else - { - echo "Charge Credit card Null response returned"; + if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + { + echo "Charge Credit Card AUTH CODE : " . $tresponse->getAuthCode() . "\n"; + echo "Charge Credit Card TRANS ID : " . $tresponse->getTransId() . "\n"; + } + else + { + echo "Charge Credit Card ERROR : Invalid response\n"; + } + + } + else + { + echo "Charge Credit card Null response returned"; + } + return $response; } + if(!defined(DONT_RUN_SAMPLES)) + chargeCreditCard(); ?> diff --git a/PaymentTransactions/charge-customer-profile.php b/PaymentTransactions/charge-customer-profile.php index 594459e..d8c8966 100644 --- a/PaymentTransactions/charge-customer-profile.php +++ b/PaymentTransactions/charge-customer-profile.php @@ -3,50 +3,56 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); - $refId = 'ref' . time(); - $profileToCharge = new AnetAPI\CustomerProfilePaymentType(); - $profileToCharge->setCustomerProfileId("36731856"); - $paymentProfile = new AnetAPI\PaymentProfileType(); - $paymentProfile->setPaymentProfileId("33211899"); - $profileToCharge->setPaymentProfile($paymentProfile); + function chargeCustomerProfile(){ + // Common setup for API credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName("5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $refId = 'ref' . time(); + $profileToCharge = new AnetAPI\CustomerProfilePaymentType(); + $profileToCharge->setCustomerProfileId("36731856"); + $paymentProfile = new AnetAPI\PaymentProfileType(); + $paymentProfile->setPaymentProfileId("33211899"); + $profileToCharge->setPaymentProfile($paymentProfile); - $transactionRequestType = new AnetAPI\TransactionRequestType(); - $transactionRequestType->setTransactionType( "authCaptureTransaction"); - $transactionRequestType->setAmount(100.50); - $transactionRequestType->setProfile($profileToCharge); - $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) - { - $tresponse = $response->getTransactionResponse(); - if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) - { - echo "Charge Customer Profile APPROVED :" . "\n"; - echo " Charge Customer Profile AUTH CODE : " . $tresponse->getAuthCode() . "\n"; - echo " Charge Customer Profile TRANS ID : " . $tresponse->getTransId() . "\n"; - } - elseif (($tresponse != null) && ($tresponse->getResponseCode()=="2") ) + $transactionRequestType = new AnetAPI\TransactionRequestType(); + $transactionRequestType->setTransactionType( "authCaptureTransaction"); + $transactionRequestType->setAmount(100.50); + $transactionRequestType->setProfile($profileToCharge); + + $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) { - echo "ERROR" . "\n"; + $tresponse = $response->getTransactionResponse(); + if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + { + echo "Charge Customer Profile APPROVED :" . "\n"; + echo " Charge Customer Profile AUTH CODE : " . $tresponse->getAuthCode() . "\n"; + echo " Charge Customer Profile TRANS ID : " . $tresponse->getTransId() . "\n"; + } + elseif (($tresponse != null) && ($tresponse->getResponseCode()=="2") ) + { + echo "ERROR" . "\n"; + } + elseif (($tresponse != null) && ($tresponse->getResponseCode()=="4") ) + { + echo "ERROR: HELD FOR REVIEW:" . "\n"; + } } - elseif (($tresponse != null) && ($tresponse->getResponseCode()=="4") ) + else { - echo "ERROR: HELD FOR REVIEW:" . "\n"; + echo "no response returned"; } + return $response; } - else - { - echo "no response returned"; - } + if(!defined(DONT_RUN_SAMPLES)) + chargeCustomerProfile(); ?> diff --git a/PaymentTransactions/charge-tokenized-credit-card.php b/PaymentTransactions/charge-tokenized-credit-card.php index 6995709..a271dbe 100644 --- a/PaymentTransactions/charge-tokenized-credit-card.php +++ b/PaymentTransactions/charge-tokenized-credit-card.php @@ -4,51 +4,56 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); - $refId = 'ref' . time(); + function chargeTokenizedCreditCard(){ + // Common setup for API credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName("556KThWQ6vf2"); + $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + $refId = 'ref' . time(); - // Create the payment data for a credit card - $creditCard = new AnetAPI\CreditCardType(); - $creditCard->setCardNumber( "4111111111111111" ); - $creditCard->setExpirationDate( "2038-12"); - //Set the cryptogram - $creditCard->setCryptogram("EjRWeJASNFZ4kBI0VniQEjRWeJA="); - - $paymentOne = new AnetAPI\PaymentType(); - $paymentOne->setCreditCard($creditCard); - - //create a transaction - $transactionRequestType = new AnetAPI\TransactionRequestType(); - $transactionRequestType->setTransactionType("authCaptureTransaction"); - $transactionRequestType->setAmount(151.22); - $transactionRequestType->setPayment($paymentOne); + // Create the payment data for a credit card + $creditCard = new AnetAPI\CreditCardType(); + $creditCard->setCardNumber( "4111111111111111" ); + $creditCard->setExpirationDate( "2038-12"); + //Set the cryptogram + $creditCard->setCryptogram("EjRWeJASNFZ4kBI0VniQEjRWeJA="); + + $paymentOne = new AnetAPI\PaymentType(); + $paymentOne->setCreditCard($creditCard); + + //create a transaction + $transactionRequestType = new AnetAPI\TransactionRequestType(); + $transactionRequestType->setTransactionType("authCaptureTransaction"); + $transactionRequestType->setAmount(151.22); + $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) - { - $tresponse = $response->getTransactionResponse(); - if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + $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) { - echo "Charge Tokenized Credit Card AUTH CODE : " . $tresponse->getAuthCode() . "\n"; - echo "Charge Tokenized Credit Card TRANS ID : " . $tresponse->getTransId() . "\n"; + $tresponse = $response->getTransactionResponse(); + if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + { + echo "Charge Tokenized Credit Card AUTH CODE : " . $tresponse->getAuthCode() . "\n"; + echo "Charge Tokenized Credit Card TRANS ID : " . $tresponse->getTransId() . "\n"; + } + else + { + echo "Charge Tokenized Credit Card ERROR : Invalid response\n"; + } } else { - echo "Charge Tokenized Credit Card ERROR : Invalid response\n"; + echo "Charge Tokenized Credit Card Null response returned"; } + return $response; } - else - { - echo "Charge Tokenized Credit Card Null response returned"; - } + if(!defined(DONT_RUN_SAMPLES)) + chargeTokenizedCreditCard(); ?> diff --git a/PaymentTransactions/credit-bank-account.php b/PaymentTransactions/credit-bank-account.php index 80305d3..fa41cf9 100644 --- a/PaymentTransactions/credit-bank-account.php +++ b/PaymentTransactions/credit-bank-account.php @@ -3,58 +3,64 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); - $refId = 'ref' . time(); - // Create the payment data for a Bank Account - $bankAccount = new AnetAPI\BankAccountType(); - $bankAccount->setRoutingNumber('125000024'); - $bankAccount->setAccountNumber('12345678'); - $bankAccount->setNameOnAccount('John Doe'); - - $paymentBank= new AnetAPI\PaymentType(); - $paymentBank->setBankAccount($bankAccount); -// Order info - $order = new AnetAPI\OrderType(); - $order->setInvoiceNumber("101"); - $order->setDescription("Golf Shirts"); + function creditBankAccount(){ + // Common setup for API credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName("556KThWQ6vf2"); + $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + $refId = 'ref' . time(); + // Create the payment data for a Bank Account + $bankAccount = new AnetAPI\BankAccountType(); + $bankAccount->setRoutingNumber('125000024'); + $bankAccount->setAccountNumber('12345678'); + $bankAccount->setNameOnAccount('John Doe'); + + $paymentBank= new AnetAPI\PaymentType(); + $paymentBank->setBankAccount($bankAccount); - //create a debit card Bank transaction - - $transactionRequestType = new AnetAPI\TransactionRequestType(); - $transactionRequestType->setTransactionType( "refundTransaction"); - $transactionRequestType->setAmount(250.75); - $transactionRequestType->setPayment($paymentBank); - $transactionRequestType->setOrder($order); - $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) - { - $tresponse = $response->getTransactionResponse(); - if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) - { - echo "Credit Bank Account APPROVED :" . "\n"; - echo "Credit Bank Account AUTH CODE : " . $tresponse->getAuthCode() . "\n"; - echo "Credit Bank Account TRANS ID : " . $tresponse->getTransId() . "\n"; - } - elseif (($tresponse != null) && ($tresponse->getResponseCode()=="2") ) + // Order info + $order = new AnetAPI\OrderType(); + $order->setInvoiceNumber("101"); + $order->setDescription("Golf Shirts"); + + //create a debit card Bank transaction + + $transactionRequestType = new AnetAPI\TransactionRequestType(); + $transactionRequestType->setTransactionType( "refundTransaction"); + $transactionRequestType->setAmount(250.75); + $transactionRequestType->setPayment($paymentBank); + $transactionRequestType->setOrder($order); + $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) { - echo "Credit Bank Account ERROR : DECLINED" . "\n"; + $tresponse = $response->getTransactionResponse(); + if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + { + echo "Credit Bank Account APPROVED :" . "\n"; + echo "Credit Bank Account AUTH CODE : " . $tresponse->getAuthCode() . "\n"; + echo "Credit Bank Account TRANS ID : " . $tresponse->getTransId() . "\n"; + } + elseif (($tresponse != null) && ($tresponse->getResponseCode()=="2") ) + { + echo "Credit Bank Account ERROR : DECLINED" . "\n"; + } + elseif (($tresponse != null) && ($tresponse->getResponseCode()=="4") ) + { + echo "Credit Bank Account ERROR: HELD FOR REVIEW:" . "\n"; + } } - elseif (($tresponse != null) && ($tresponse->getResponseCode()=="4") ) + else { - echo "Credit Bank Account ERROR: HELD FOR REVIEW:" . "\n"; + echo "Credit Bank Account No response returned"; } + return $response; } - else - { - echo "Credit Bank Account No response returned"; - } + if(!defined(DONT_RUN_SAMPLES)) + creditBankAccount(); ?> diff --git a/PaymentTransactions/debit-bank-account.php b/PaymentTransactions/debit-bank-account.php index d6930da..5939a5d 100644 --- a/PaymentTransactions/debit-bank-account.php +++ b/PaymentTransactions/debit-bank-account.php @@ -4,63 +4,68 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); - $refId = 'ref' . time(); + function debitBankAccount(){ + // Common setup for API credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName("556KThWQ6vf2"); + $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + $refId = 'ref' . time(); - // Create the payment data for a Bank Account - $bankAccount = new AnetAPI\BankAccountType(); - //$bankAccount->setAccountType('CHECKING'); - $bankAccount->setEcheckType('WEB'); - $bankAccount->setRoutingNumber('121042882'); - $bankAccount->setAccountNumber('123456789123'); - $bankAccount->setNameOnAccount('Jane Doe'); - $bankAccount->setBankName('Bank of the Earth'); + // Create the payment data for a Bank Account + $bankAccount = new AnetAPI\BankAccountType(); + //$bankAccount->setAccountType('CHECKING'); + $bankAccount->setEcheckType('WEB'); + $bankAccount->setRoutingNumber('121042882'); + $bankAccount->setAccountNumber('123456789123'); + $bankAccount->setNameOnAccount('Jane Doe'); + $bankAccount->setBankName('Bank of the Earth'); - $paymentBank= new AnetAPI\PaymentType(); - $paymentBank->setBankAccount($bankAccount); + $paymentBank= new AnetAPI\PaymentType(); + $paymentBank->setBankAccount($bankAccount); - //create a debit card Bank transaction - - $transactionRequestType = new AnetAPI\TransactionRequestType(); - $transactionRequestType->setTransactionType( "authCaptureTransaction"); - $transactionRequestType->setAmount(250.75); - $transactionRequestType->setPayment($paymentBank); + //create a debit card Bank transaction + + $transactionRequestType = new AnetAPI\TransactionRequestType(); + $transactionRequestType->setTransactionType( "authCaptureTransaction"); + $transactionRequestType->setAmount(250.75); + $transactionRequestType->setPayment($paymentBank); - $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) - { - $tresponse = $response->getTransactionResponse(); - if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + $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) { - echo "Debit Bank Account APPROVED :" . "\n"; - echo " Debit Bank Account AUTH CODE : " . $tresponse->getAuthCode() . "\n"; - echo " Debit Banlk Account TRANS ID : " . $tresponse->getTransId() . "\n"; - } - elseif (($tresponse != null) && ($tresponse->getResponseCode()=="2") ) - { - echo "Debit Bank Account ERROR : DECLINED" . "\n"; - echo "Error : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; - } - elseif (($tresponse != null) && ($tresponse->getResponseCode()=="4") ) - { - echo "Debit Bank Account ERROR: HELD FOR REVIEW:" . "\n"; + $tresponse = $response->getTransactionResponse(); + if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + { + echo "Debit Bank Account APPROVED :" . "\n"; + echo " Debit Bank Account AUTH CODE : " . $tresponse->getAuthCode() . "\n"; + echo " Debit Banlk Account TRANS ID : " . $tresponse->getTransId() . "\n"; + } + elseif (($tresponse != null) && ($tresponse->getResponseCode()=="2") ) + { + echo "Debit Bank Account ERROR : DECLINED" . "\n"; + echo "Error : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; + } + elseif (($tresponse != null) && ($tresponse->getResponseCode()=="4") ) + { + echo "Debit Bank Account ERROR: HELD FOR REVIEW:" . "\n"; + } + else + { + echo "Debit Bank Account 3 response returned"; + } } else { - echo "Debit Bank Account 3 response returned"; + echo "Debit Bank Account Null response returned"; } + return $response; } - else - { - echo "Debit Bank Account Null response returned"; - } + if(!defined(DONT_RUN_SAMPLES)) + debitBankAccount(); ?> diff --git a/PaymentTransactions/refund-transaction.php b/PaymentTransactions/refund-transaction.php index 02078ff..31fef59 100644 --- a/PaymentTransactions/refund-transaction.php +++ b/PaymentTransactions/refund-transaction.php @@ -3,43 +3,49 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); - $refId = 'ref' . time(); - // Create the payment data for a credit card - $creditCard = new AnetAPI\CreditCardType(); - $creditCard->setCardNumber( "4111111111111111" ); - $creditCard->setExpirationDate( "2038-12"); - $paymentOne = new AnetAPI\PaymentType(); - $paymentOne->setCreditCard($creditCard); - //create a transaction - $transactionRequestType = new AnetAPI\TransactionRequestType(); - $transactionRequestType->setTransactionType( "refundTransaction"); - $transactionRequestType->setAmount(151.21); - $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) - { - $tresponse = $response->getTransactionResponse(); - if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + + function refundTransaction(){ + // Common setup for API credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName("556KThWQ6vf2"); + $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + $refId = 'ref' . time(); + // Create the payment data for a credit card + $creditCard = new AnetAPI\CreditCardType(); + $creditCard->setCardNumber( "4111111111111111" ); + $creditCard->setExpirationDate( "2038-12"); + $paymentOne = new AnetAPI\PaymentType(); + $paymentOne->setCreditCard($creditCard); + //create a transaction + $transactionRequestType = new AnetAPI\TransactionRequestType(); + $transactionRequestType->setTransactionType( "refundTransaction"); + $transactionRequestType->setAmount(151.21); + $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) { - echo "Refund SUCCESS: " . $tresponse->getTransId() . "\n"; + $tresponse = $response->getTransactionResponse(); + if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + { + echo "Refund SUCCESS: " . $tresponse->getTransId() . "\n"; + } + else + { + echo "Refund ERROR : " . $tresponse->getResponseCode() . "\n"; + } + } else { - echo "Refund ERROR : " . $tresponse->getResponseCode() . "\n"; + echo "Refund Null response returned"; } - - } - else - { - echo "Refund Null response returned"; + return $response; } + if(!defined(DONT_RUN_SAMPLES)) + refundTransaction(); ?> diff --git a/PaymentTransactions/update-split-tender-group.php b/PaymentTransactions/update-split-tender-group.php index 5f9d78b..0747201 100644 --- a/PaymentTransactions/update-split-tender-group.php +++ b/PaymentTransactions/update-split-tender-group.php @@ -3,28 +3,34 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - - // Common Set Up for API Credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName( "8V4xFm3z"); - $merchantAuthentication->setTransactionKey("655AS4Ek7TJ42snq"); - $request = new AnetAPI\UpdateSplitTenderGroupRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setSplitTenderId("116468"); - $request->setSplitTenderStatus("voided"); + function updateSplitTenderGroup(){ + // Common Set Up for API Credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName( "8V4xFm3z"); + $merchantAuthentication->setTransactionKey("655AS4Ek7TJ42snq"); - $controller = new AnetController\UpdateSplitTenderGroupController($request); + $request = new AnetAPI\UpdateSplitTenderGroupRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setSplitTenderId("116468"); + $request->setSplitTenderStatus("voided"); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - - if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) - { - echo "SUCCESS : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; - } - else - { - echo "ERROR : Invalid response\n"; - echo "Response Code : " . $response->getMessages()->getMessage()[0]->getCode() . " Resposne text: " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + $controller = new AnetController\UpdateSplitTenderGroupController($request); + + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) + { + echo "SUCCESS : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + } + else + { + echo "ERROR : Invalid response\n"; + echo "Response Code : " . $response->getMessages()->getMessage()[0]->getCode() . " Resposne text: " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + } + return $response; } + + if(!defined(DONT_RUN_SAMPLES)) + updateSplitTenderGroup(); ?> \ No newline at end of file diff --git a/PaymentTransactions/void-transaction.php b/PaymentTransactions/void-transaction.php index 0e9b60b..2fcf8eb 100644 --- a/PaymentTransactions/void-transaction.php +++ b/PaymentTransactions/void-transaction.php @@ -3,43 +3,50 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); - $refId = 'ref' . time(); - // Create the payment data for a credit card - $creditCard = new AnetAPI\CreditCardType(); - $creditCard->setCardNumber( "4111111111111111" ); - $creditCard->setExpirationDate( "2038-12"); - $paymentOne = new AnetAPI\PaymentType(); - $paymentOne->setCreditCard($creditCard); - //create a transaction - $transactionRequestType = new AnetAPI\TransactionRequestType(); - $transactionRequestType->setTransactionType( "voidTransaction"); - $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) - { - $tresponse = $response->getTransactionResponse(); - if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + + function voidTransaction(){ + // Common setup for API credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName("556KThWQ6vf2"); + $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + $refId = 'ref' . time(); + // Create the payment data for a credit card + $creditCard = new AnetAPI\CreditCardType(); + $creditCard->setCardNumber( "4111111111111111" ); + $creditCard->setExpirationDate( "2038-12"); + $paymentOne = new AnetAPI\PaymentType(); + $paymentOne->setCreditCard($creditCard); + //create a transaction + $transactionRequestType = new AnetAPI\TransactionRequestType(); + $transactionRequestType->setTransactionType( "voidTransaction"); + $transaction + RequestType->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) { - echo "Void transaction SUCCESS AUTH CODE: " . $tresponse->getAuthCode() . "\n"; - echo "Void transaction SUCCESS TRANS ID : " . $tresponse->getTransId() . "\n"; + $tresponse = $response->getTransactionResponse(); + if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + { + echo "Void transaction SUCCESS AUTH CODE: " . $tresponse->getAuthCode() . "\n"; + echo "Void transaction SUCCESS TRANS ID : " . $tresponse->getTransId() . "\n"; + } + else + { + echo "void transaction ERROR : " . $tresponse->getResponseCode() . "\n"; + } + } else { - echo "void transaction ERROR : " . $tresponse->getResponseCode() . "\n"; + echo "Void transaction Null esponse returned"; } - - } - else - { - echo "Void transaction Null esponse returned"; + return $response; } + if(!defined(DONT_RUN_SAMPLES)) + voidTransaction(); ?> diff --git a/VisaCheckout/create-visa-checkout-transaction.php b/VisaCheckout/create-visa-checkout-transaction.php index 5727bb1..5a75969 100644 --- a/VisaCheckout/create-visa-checkout-transaction.php +++ b/VisaCheckout/create-visa-checkout-transaction.php @@ -6,53 +6,58 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); - $refId = 'ref' . time(); - - // Create the payment data from a Visa Checkout blob - $op = new AnetAPI\OpaqueDataType(); - $op->setDataDescriptor("COMMON.VCO.ONLINE.PAYMENT"); - $op->setDataValue("4Ng5pzJ6DXfAvLSzVauN9KTufx5lTHhFlnuIr248N3fjtyHrHqMuhOkB1BLiSjKWeTM9+BNj3+9nY56d7CsUfIuvVSTaJRhQQSex1dS2Y2Y+/cA5U+3D1pg5YtTmDVUGlsu1simAd3huwPnwD+CG6O8Ml0AmXvYHntmL3vFaJomadMQBy27k8Dbh5eplPBwyawKUVJ7GqTyKLe8aOYkBUHT5ANWkq2hlGps44BOoDHZ26JWjHdorBZtVIqMK1SIyW4Dih5c/Y//w2toA8WBTPILIvt4h6HPPvWZMZCHCqom9D2k4WGH5+BCEY2jHI7gfYV6xRx54i5vitsYTKm3CyA0C5+l0FNDkfUFHDvVUG9FVzRWVd0TXYhDwfa2pcfI68eYvkEfeT+ZNJ24ZXKPrJo6KZ3x6eZAhzgAMFiC+tPsiygb2zQy5PVoYoBIGj/NGNRqmhZTOEajcO3ZjWxfAnLZAmvMi+pEwJCMmuIY4qRU3RfcaXhAoaUPpDxqrSxR1m+CUKYVdt3nnnQeVaVqf+RaeV9cyFJvILeBPXTBVC50AckVLS37UuBWgWaWcchjRPk9mriDu2KlHQwdR4zu0jnLh4i3tbxV416QBcYLO6AF2Ixlm3GzqGE6QcVssgFCUAhklBWGNLP62O1jtyV4NgTD36QhvHEHby7o4XBB+mjlY6xSEXR+IW9u64AzfDCsTxWiAOE65le6cSk4NDV8DrtYeIozILivWu6wFSpy1gMfiDot4Ndv3C9xCFvH0Bzlky7NoZrvSolKTVNTs8W8UqMFV19qGl6SRaNUEhCqgso/FkdO0eGXFMdQPuP11wQzK/9F3yB9gS2rpXi9sy8DrCqnJ9EXMmliSstKuQl5+yfGc8K3Urot3t+BmNoOvzM9Aha/PzmbLnuKBN6/DUbIw5mhNMCvIA1ByispKpjeV682jl4uslkRsitGLcIOBREFXvGaLxRb37HJkXCHk+jorpDz7LUQhVkClN+hW0vXtgdHQFCIOL7uREdbvk6BZbQlFsuVEKGZxPbKPEJfqMbH54B4a4P5XNQHm4Yt4haH4T0JuYgzoSo76uuXD3g5IuUvy7x8Ykuja1rwW/k//SZAiGaZraRIIAEnzHiUP8dcufb/RonHGnJcYXIEWeIF1lX980bDA+H4vlO8/nN/Mj+EL6tT95MfRDiQHUW69qkqotQd7FJ5uWT+NtetzqDsN5s3sIhwkLKIn9EDLIav5v4SXKxkG+ycMJmGFcfhs7Td9O6hl+Om/JD3he3rgfClaFi/ZR7AVY6fWbAAm9QftKijQ6rskPDYL9Y3gVSA9rdduSg97fUHC+FdfyQXGH552cDLs2ZgzYw6KluXHEuwhACgNotxToPYTTdZxxNr1vPoqYCqHDL2dL8dkuO59/sbZE1m4ektKvUC2wz0UdTDVbHN8HSrLPn2hf/xQp5bKeDDjYkWvNKuwy+aug9H+Uu/m1LuPK/YdogVv9l25y/c2Qbj3dAJ9xTuKjmiJLKlRh4SUI9+05HjDF+i84AoUZ8LuC7LGtrN8ReYIktLhaXq9+XDh5fv4NYhnuYgWkUioKtx1dmfOMHjpLm4aE8Ra1gpJQcZAgwnqYubQvnYy0nY4VaykNix7m3vZwItpKOLqxDYxa3q0qUw25X9zafAM61kPW6EP+4idPzHNww6r1FD4Ihq644dCnCXwoSQ531DW6oAPot8iLZ/xXwoWwrW05k9t2RHjjLbw1L5r1CKgShJQfX7nkJxfGyuw1RmqoQDuNt/tj9M/dHOnoPnOYZZN0JX+Al8PI5zs+LLajw1imu9YcSpwMz3ZlfQqTfI0fjSCc8Is6qVYDMvKD0TweY4hiIxkzs+RyQmPgIeIWqf7Su5+RcnXitb3OuFibBGCjdDeG0ESG8qeiBQKZ3wEyZG09eDAfhuUR5kfZCG4Q01u2YDoRzObxLd8Ruf7HNvtefucFLubciWvOSzbDUisoz0wwOSgJGHucC3IR+1mb/4gz/dI2wvWFInhKcQz4ivkuHaFj8XwvZMcpkwPKtg3pRGTleX/gfjbHcx2VcWRcMPdlDMgTgst9ouN763TZUHHLxjECyB9pkLrR1nhG0cS/aig8Bq1+AH7tvl1wLVxm1Z77DVX4aUIxBH2YUcOgpe6mrWFi6LK3im4/grZECsL/XC4tsTEHjO/U3SazUuhP+6LiCYqp50+3zZf3RpWlxZoYjm5SJ9VIWabocO/Ef26G38lKottW1XsSQUan7myYFFyeyon2hnufzMuxpyXTJ7TLekXCi2gLYbGjldgiRmGShPXzSar+hC2"); - $op->setDataKey("JxAB39A9yUsf6wMD0jwGKCuY7mmzWaeEj85MH02AfKGUxOkJ00JK+o8vGG55cUF9voYU4QQ1Jec4p6nKmsxXmTREEaJwmQErotD4fpcFOyoqWTLMZfslrkHgiqbwru/V"); - $paymentOne = new AnetAPI\PaymentType(); - $paymentOne->setOpaqueData($op); - - //create a transaction - $transactionRequestType = new AnetAPI\TransactionRequestType(); - $transactionRequestType->setTransactionType( "authCaptureTransaction"); - $transactionRequestType->setAmount(151); - $transactionRequestType->setCallId("9004180129978687101"); - $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) - { - $tresponse = $response->getTransactionResponse(); - - if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + function createVisaCheckoutTransaction(){ + // Common setup for API credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName("5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $refId = 'ref' . time(); + + // Create the payment data from a Visa Checkout blob + $op = new AnetAPI\OpaqueDataType(); + $op->setDataDescriptor("COMMON.VCO.ONLINE.PAYMENT"); + $op->setDataValue("4Ng5pzJ6DXfAvLSzVauN9KTufx5lTHhFlnuIr248N3fjtyHrHqMuhOkB1BLiSjKWeTM9+BNj3+9nY56d7CsUfIuvVSTaJRhQQSex1dS2Y2Y+/cA5U+3D1pg5YtTmDVUGlsu1simAd3huwPnwD+CG6O8Ml0AmXvYHntmL3vFaJomadMQBy27k8Dbh5eplPBwyawKUVJ7GqTyKLe8aOYkBUHT5ANWkq2hlGps44BOoDHZ26JWjHdorBZtVIqMK1SIyW4Dih5c/Y//w2toA8WBTPILIvt4h6HPPvWZMZCHCqom9D2k4WGH5+BCEY2jHI7gfYV6xRx54i5vitsYTKm3CyA0C5+l0FNDkfUFHDvVUG9FVzRWVd0TXYhDwfa2pcfI68eYvkEfeT+ZNJ24ZXKPrJo6KZ3x6eZAhzgAMFiC+tPsiygb2zQy5PVoYoBIGj/NGNRqmhZTOEajcO3ZjWxfAnLZAmvMi+pEwJCMmuIY4qRU3RfcaXhAoaUPpDxqrSxR1m+CUKYVdt3nnnQeVaVqf+RaeV9cyFJvILeBPXTBVC50AckVLS37UuBWgWaWcchjRPk9mriDu2KlHQwdR4zu0jnLh4i3tbxV416QBcYLO6AF2Ixlm3GzqGE6QcVssgFCUAhklBWGNLP62O1jtyV4NgTD36QhvHEHby7o4XBB+mjlY6xSEXR+IW9u64AzfDCsTxWiAOE65le6cSk4NDV8DrtYeIozILivWu6wFSpy1gMfiDot4Ndv3C9xCFvH0Bzlky7NoZrvSolKTVNTs8W8UqMFV19qGl6SRaNUEhCqgso/FkdO0eGXFMdQPuP11wQzK/9F3yB9gS2rpXi9sy8DrCqnJ9EXMmliSstKuQl5+yfGc8K3Urot3t+BmNoOvzM9Aha/PzmbLnuKBN6/DUbIw5mhNMCvIA1ByispKpjeV682jl4uslkRsitGLcIOBREFXvGaLxRb37HJkXCHk+jorpDz7LUQhVkClN+hW0vXtgdHQFCIOL7uREdbvk6BZbQlFsuVEKGZxPbKPEJfqMbH54B4a4P5XNQHm4Yt4haH4T0JuYgzoSo76uuXD3g5IuUvy7x8Ykuja1rwW/k//SZAiGaZraRIIAEnzHiUP8dcufb/RonHGnJcYXIEWeIF1lX980bDA+H4vlO8/nN/Mj+EL6tT95MfRDiQHUW69qkqotQd7FJ5uWT+NtetzqDsN5s3sIhwkLKIn9EDLIav5v4SXKxkG+ycMJmGFcfhs7Td9O6hl+Om/JD3he3rgfClaFi/ZR7AVY6fWbAAm9QftKijQ6rskPDYL9Y3gVSA9rdduSg97fUHC+FdfyQXGH552cDLs2ZgzYw6KluXHEuwhACgNotxToPYTTdZxxNr1vPoqYCqHDL2dL8dkuO59/sbZE1m4ektKvUC2wz0UdTDVbHN8HSrLPn2hf/xQp5bKeDDjYkWvNKuwy+aug9H+Uu/m1LuPK/YdogVv9l25y/c2Qbj3dAJ9xTuKjmiJLKlRh4SUI9+05HjDF+i84AoUZ8LuC7LGtrN8ReYIktLhaXq9+XDh5fv4NYhnuYgWkUioKtx1dmfOMHjpLm4aE8Ra1gpJQcZAgwnqYubQvnYy0nY4VaykNix7m3vZwItpKOLqxDYxa3q0qUw25X9zafAM61kPW6EP+4idPzHNww6r1FD4Ihq644dCnCXwoSQ531DW6oAPot8iLZ/xXwoWwrW05k9t2RHjjLbw1L5r1CKgShJQfX7nkJxfGyuw1RmqoQDuNt/tj9M/dHOnoPnOYZZN0JX+Al8PI5zs+LLajw1imu9YcSpwMz3ZlfQqTfI0fjSCc8Is6qVYDMvKD0TweY4hiIxkzs+RyQmPgIeIWqf7Su5+RcnXitb3OuFibBGCjdDeG0ESG8qeiBQKZ3wEyZG09eDAfhuUR5kfZCG4Q01u2YDoRzObxLd8Ruf7HNvtefucFLubciWvOSzbDUisoz0wwOSgJGHucC3IR+1mb/4gz/dI2wvWFInhKcQz4ivkuHaFj8XwvZMcpkwPKtg3pRGTleX/gfjbHcx2VcWRcMPdlDMgTgst9ouN763TZUHHLxjECyB9pkLrR1nhG0cS/aig8Bq1+AH7tvl1wLVxm1Z77DVX4aUIxBH2YUcOgpe6mrWFi6LK3im4/grZECsL/XC4tsTEHjO/U3SazUuhP+6LiCYqp50+3zZf3RpWlxZoYjm5SJ9VIWabocO/Ef26G38lKottW1XsSQUan7myYFFyeyon2hnufzMuxpyXTJ7TLekXCi2gLYbGjldgiRmGShPXzSar+hC2"); + $op->setDataKey("JxAB39A9yUsf6wMD0jwGKCuY7mmzWaeEj85MH02AfKGUxOkJ00JK+o8vGG55cUF9voYU4QQ1Jec4p6nKmsxXmTREEaJwmQErotD4fpcFOyoqWTLMZfslrkHgiqbwru/V"); + $paymentOne = new AnetAPI\PaymentType(); + $paymentOne->setOpaqueData($op); + + //create a transaction + $transactionRequestType = new AnetAPI\TransactionRequestType(); + $transactionRequestType->setTransactionType( "authCaptureTransaction"); + $transactionRequestType->setAmount(151); + $transactionRequestType->setCallId("9004180129978687101"); + $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) { - echo " AUTH CODE : " . $tresponse->getAuthCode() . "\n"; - echo " TRANS ID : " . $tresponse->getTransId() . "\n"; + $tresponse = $response->getTransactionResponse(); + + if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + { + echo " AUTH CODE : " . $tresponse->getAuthCode() . "\n"; + echo " TRANS ID : " . $tresponse->getTransId() . "\n"; + } + else + { + echo "BAD NEWS : " . $tresponse->getResponseCode() . "\n"; + } } else { - echo "BAD NEWS : " . $tresponse->getResponseCode() . "\n"; + echo "REALLY BAD NEWS : "; } - - } - else - { - echo "REALLY BAD NEWS : "; + return $response; } + + if(!defined(DONT_RUN_SAMPLES)) + createVisaCheckoutTransaction(); ?> diff --git a/VisaCheckout/decrypt-visa-checkout-data.php b/VisaCheckout/decrypt-visa-checkout-data.php index fbc0a38..47a5943 100644 --- a/VisaCheckout/decrypt-visa-checkout-data.php +++ b/VisaCheckout/decrypt-visa-checkout-data.php @@ -6,36 +6,42 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); - $refId = 'ref' . time(); - - // Create the payment data from a Visa Checkout blob - $op = new AnetAPI\OpaqueDataType(); - $op->setDataDescriptor("COMMON.VCO.ONLINE.PAYMENT"); - $op->setDataValue("4Ng5pzJ6DXfAvLSzVauN9KTufx5lTHhFlnuIr248N3fjtyHrHqMuhOkB1BLiSjKWeTM9+BNj3+9nY56d7CsUfIuvVSTaJRhQQSex1dS2Y2Y+/cA5U+3D1pg5YtTmDVUGlsu1simAd3huwPnwD+CG6O8Ml0AmXvYHntmL3vFaJomadMQBy27k8Dbh5eplPBwyawKUVJ7GqTyKLe8aOYkBUHT5ANWkq2hlGps44BOoDHZ26JWjHdorBZtVIqMK1SIyW4Dih5c/Y//w2toA8WBTPILIvt4h6HPPvWZMZCHCqom9D2k4WGH5+BCEY2jHI7gfYV6xRx54i5vitsYTKm3CyA0C5+l0FNDkfUFHDvVUG9FVzRWVd0TXYhDwfa2pcfI68eYvkEfeT+ZNJ24ZXKPrJo6KZ3x6eZAhzgAMFiC+tPsiygb2zQy5PVoYoBIGj/NGNRqmhZTOEajcO3ZjWxfAnLZAmvMi+pEwJCMmuIY4qRU3RfcaXhAoaUPpDxqrSxR1m+CUKYVdt3nnnQeVaVqf+RaeV9cyFJvILeBPXTBVC50AckVLS37UuBWgWaWcchjRPk9mriDu2KlHQwdR4zu0jnLh4i3tbxV416QBcYLO6AF2Ixlm3GzqGE6QcVssgFCUAhklBWGNLP62O1jtyV4NgTD36QhvHEHby7o4XBB+mjlY6xSEXR+IW9u64AzfDCsTxWiAOE65le6cSk4NDV8DrtYeIozILivWu6wFSpy1gMfiDot4Ndv3C9xCFvH0Bzlky7NoZrvSolKTVNTs8W8UqMFV19qGl6SRaNUEhCqgso/FkdO0eGXFMdQPuP11wQzK/9F3yB9gS2rpXi9sy8DrCqnJ9EXMmliSstKuQl5+yfGc8K3Urot3t+BmNoOvzM9Aha/PzmbLnuKBN6/DUbIw5mhNMCvIA1ByispKpjeV682jl4uslkRsitGLcIOBREFXvGaLxRb37HJkXCHk+jorpDz7LUQhVkClN+hW0vXtgdHQFCIOL7uREdbvk6BZbQlFsuVEKGZxPbKPEJfqMbH54B4a4P5XNQHm4Yt4haH4T0JuYgzoSo76uuXD3g5IuUvy7x8Ykuja1rwW/k//SZAiGaZraRIIAEnzHiUP8dcufb/RonHGnJcYXIEWeIF1lX980bDA+H4vlO8/nN/Mj+EL6tT95MfRDiQHUW69qkqotQd7FJ5uWT+NtetzqDsN5s3sIhwkLKIn9EDLIav5v4SXKxkG+ycMJmGFcfhs7Td9O6hl+Om/JD3he3rgfClaFi/ZR7AVY6fWbAAm9QftKijQ6rskPDYL9Y3gVSA9rdduSg97fUHC+FdfyQXGH552cDLs2ZgzYw6KluXHEuwhACgNotxToPYTTdZxxNr1vPoqYCqHDL2dL8dkuO59/sbZE1m4ektKvUC2wz0UdTDVbHN8HSrLPn2hf/xQp5bKeDDjYkWvNKuwy+aug9H+Uu/m1LuPK/YdogVv9l25y/c2Qbj3dAJ9xTuKjmiJLKlRh4SUI9+05HjDF+i84AoUZ8LuC7LGtrN8ReYIktLhaXq9+XDh5fv4NYhnuYgWkUioKtx1dmfOMHjpLm4aE8Ra1gpJQcZAgwnqYubQvnYy0nY4VaykNix7m3vZwItpKOLqxDYxa3q0qUw25X9zafAM61kPW6EP+4idPzHNww6r1FD4Ihq644dCnCXwoSQ531DW6oAPot8iLZ/xXwoWwrW05k9t2RHjjLbw1L5r1CKgShJQfX7nkJxfGyuw1RmqoQDuNt/tj9M/dHOnoPnOYZZN0JX+Al8PI5zs+LLajw1imu9YcSpwMz3ZlfQqTfI0fjSCc8Is6qVYDMvKD0TweY4hiIxkzs+RyQmPgIeIWqf7Su5+RcnXitb3OuFibBGCjdDeG0ESG8qeiBQKZ3wEyZG09eDAfhuUR5kfZCG4Q01u2YDoRzObxLd8Ruf7HNvtefucFLubciWvOSzbDUisoz0wwOSgJGHucC3IR+1mb/4gz/dI2wvWFInhKcQz4ivkuHaFj8XwvZMcpkwPKtg3pRGTleX/gfjbHcx2VcWRcMPdlDMgTgst9ouN763TZUHHLxjECyB9pkLrR1nhG0cS/aig8Bq1+AH7tvl1wLVxm1Z77DVX4aUIxBH2YUcOgpe6mrWFi6LK3im4/grZECsL/XC4tsTEHjO/U3SazUuhP+6LiCYqp50+3zZf3RpWlxZoYjm5SJ9VIWabocO/Ef26G38lKottW1XsSQUan7myYFFyeyon2hnufzMuxpyXTJ7TLekXCi2gLYbGjldgiRmGShPXzSar+hC2"); - $op->setDataKey("JxAB39A9yUsf6wMD0jwGKCuY7mmzWaeEj85MH02AfKGUxOkJ00JK+o8vGG55cUF9voYU4QQ1Jec4p6nKmsxXmTREEaJwmQErotD4fpcFOyoqWTLMZfslrkHgiqbwru/V"); - - //create a decrypt request - $decryptRequest = new AnetAPI\DecryptPaymentDataRequest(); - $decryptRequest->setRefId( $refId); - $decryptRequest->setMerchantAuthentication($merchantAuthentication); - $decryptRequest->setOpaqueData($op); - $decryptRequest->setCallId("9004180129978687101"); - - - $controller = new AnetController\DecryptPaymentDataController($decryptRequest); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - - if ($response != null) - { - if ($response->getMessages()->getResultCode() == "Ok") + function decryptVisaCheckoutData(){ + // Common setup for API credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName("5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $refId = 'ref' . time(); + + // Create the payment data from a Visa Checkout blob + $op = new AnetAPI\OpaqueDataType(); + $op->setDataDescriptor("COMMON.VCO.ONLINE.PAYMENT"); + $op->setDataValue("4Ng5pzJ6DXfAvLSzVauN9KTufx5lTHhFlnuIr248N3fjtyHrHqMuhOkB1BLiSjKWeTM9+BNj3+9nY56d7CsUfIuvVSTaJRhQQSex1dS2Y2Y+/cA5U+3D1pg5YtTmDVUGlsu1simAd3huwPnwD+CG6O8Ml0AmXvYHntmL3vFaJomadMQBy27k8Dbh5eplPBwyawKUVJ7GqTyKLe8aOYkBUHT5ANWkq2hlGps44BOoDHZ26JWjHdorBZtVIqMK1SIyW4Dih5c/Y//w2toA8WBTPILIvt4h6HPPvWZMZCHCqom9D2k4WGH5+BCEY2jHI7gfYV6xRx54i5vitsYTKm3CyA0C5+l0FNDkfUFHDvVUG9FVzRWVd0TXYhDwfa2pcfI68eYvkEfeT+ZNJ24ZXKPrJo6KZ3x6eZAhzgAMFiC+tPsiygb2zQy5PVoYoBIGj/NGNRqmhZTOEajcO3ZjWxfAnLZAmvMi+pEwJCMmuIY4qRU3RfcaXhAoaUPpDxqrSxR1m+CUKYVdt3nnnQeVaVqf+RaeV9cyFJvILeBPXTBVC50AckVLS37UuBWgWaWcchjRPk9mriDu2KlHQwdR4zu0jnLh4i3tbxV416QBcYLO6AF2Ixlm3GzqGE6QcVssgFCUAhklBWGNLP62O1jtyV4NgTD36QhvHEHby7o4XBB+mjlY6xSEXR+IW9u64AzfDCsTxWiAOE65le6cSk4NDV8DrtYeIozILivWu6wFSpy1gMfiDot4Ndv3C9xCFvH0Bzlky7NoZrvSolKTVNTs8W8UqMFV19qGl6SRaNUEhCqgso/FkdO0eGXFMdQPuP11wQzK/9F3yB9gS2rpXi9sy8DrCqnJ9EXMmliSstKuQl5+yfGc8K3Urot3t+BmNoOvzM9Aha/PzmbLnuKBN6/DUbIw5mhNMCvIA1ByispKpjeV682jl4uslkRsitGLcIOBREFXvGaLxRb37HJkXCHk+jorpDz7LUQhVkClN+hW0vXtgdHQFCIOL7uREdbvk6BZbQlFsuVEKGZxPbKPEJfqMbH54B4a4P5XNQHm4Yt4haH4T0JuYgzoSo76uuXD3g5IuUvy7x8Ykuja1rwW/k//SZAiGaZraRIIAEnzHiUP8dcufb/RonHGnJcYXIEWeIF1lX980bDA+H4vlO8/nN/Mj+EL6tT95MfRDiQHUW69qkqotQd7FJ5uWT+NtetzqDsN5s3sIhwkLKIn9EDLIav5v4SXKxkG+ycMJmGFcfhs7Td9O6hl+Om/JD3he3rgfClaFi/ZR7AVY6fWbAAm9QftKijQ6rskPDYL9Y3gVSA9rdduSg97fUHC+FdfyQXGH552cDLs2ZgzYw6KluXHEuwhACgNotxToPYTTdZxxNr1vPoqYCqHDL2dL8dkuO59/sbZE1m4ektKvUC2wz0UdTDVbHN8HSrLPn2hf/xQp5bKeDDjYkWvNKuwy+aug9H+Uu/m1LuPK/YdogVv9l25y/c2Qbj3dAJ9xTuKjmiJLKlRh4SUI9+05HjDF+i84AoUZ8LuC7LGtrN8ReYIktLhaXq9+XDh5fv4NYhnuYgWkUioKtx1dmfOMHjpLm4aE8Ra1gpJQcZAgwnqYubQvnYy0nY4VaykNix7m3vZwItpKOLqxDYxa3q0qUw25X9zafAM61kPW6EP+4idPzHNww6r1FD4Ihq644dCnCXwoSQ531DW6oAPot8iLZ/xXwoWwrW05k9t2RHjjLbw1L5r1CKgShJQfX7nkJxfGyuw1RmqoQDuNt/tj9M/dHOnoPnOYZZN0JX+Al8PI5zs+LLajw1imu9YcSpwMz3ZlfQqTfI0fjSCc8Is6qVYDMvKD0TweY4hiIxkzs+RyQmPgIeIWqf7Su5+RcnXitb3OuFibBGCjdDeG0ESG8qeiBQKZ3wEyZG09eDAfhuUR5kfZCG4Q01u2YDoRzObxLd8Ruf7HNvtefucFLubciWvOSzbDUisoz0wwOSgJGHucC3IR+1mb/4gz/dI2wvWFInhKcQz4ivkuHaFj8XwvZMcpkwPKtg3pRGTleX/gfjbHcx2VcWRcMPdlDMgTgst9ouN763TZUHHLxjECyB9pkLrR1nhG0cS/aig8Bq1+AH7tvl1wLVxm1Z77DVX4aUIxBH2YUcOgpe6mrWFi6LK3im4/grZECsL/XC4tsTEHjO/U3SazUuhP+6LiCYqp50+3zZf3RpWlxZoYjm5SJ9VIWabocO/Ef26G38lKottW1XsSQUan7myYFFyeyon2hnufzMuxpyXTJ7TLekXCi2gLYbGjldgiRmGShPXzSar+hC2"); + $op->setDataKey("JxAB39A9yUsf6wMD0jwGKCuY7mmzWaeEj85MH02AfKGUxOkJ00JK+o8vGG55cUF9voYU4QQ1Jec4p6nKmsxXmTREEaJwmQErotD4fpcFOyoqWTLMZfslrkHgiqbwru/V"); + + //create a decrypt request + $decryptRequest = new AnetAPI\DecryptPaymentDataRequest(); + $decryptRequest->setRefId( $refId); + $decryptRequest->setMerchantAuthentication($merchantAuthentication); + $decryptRequest->setOpaqueData($op); + $decryptRequest->setCallId("9004180129978687101"); + + + $controller = new AnetController\DecryptPaymentDataController($decryptRequest); + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + + if ($response != null) { - echo "Card Number : " . $response->getCardInfo()->getCardNumber() . "\n"; - echo "Amount : " . $response->getPaymentDetails()->getAmount() . "\n"; + if ($response->getMessages()->getResultCode() == "Ok") + { + echo "Card Number : " . $response->getCardInfo()->getCardNumber() . "\n"; + echo "Amount : " . $response->getPaymentDetails()->getAmount() . "\n"; + } } + return $response; } + if(!defined(DONT_RUN_SAMPLES)) + decryptVisaCheckoutData(); + ?> From b8bc80dcd0d059bfa7ae6eced04020f4e5ce78da Mon Sep 17 00:00:00 2001 From: akankari Date: Thu, 14 Jan 2016 12:36:38 +0530 Subject: [PATCH 020/287] Move the Paypal sample codes to function --- .../authorization-and-capture-continue.php | 104 +++++++++--------- .../authorization-and-capture.php | 78 +++++++------ .../authorization-only-continued.php | 91 ++++++++------- PaypalExpressCheckout/authorization-only.php | 86 ++++++++------- PaypalExpressCheckout/credit.php | 99 +++++++++-------- PaypalExpressCheckout/get-details.php | 100 +++++++++-------- .../prior-authorization-capture.php | 84 +++++++------- PaypalExpressCheckout/void.php | 85 +++++++------- 8 files changed, 394 insertions(+), 333 deletions(-) diff --git a/PaypalExpressCheckout/authorization-and-capture-continue.php b/PaypalExpressCheckout/authorization-and-capture-continue.php index 5341865..43ffbf5 100644 --- a/PaypalExpressCheckout/authorization-and-capture-continue.php +++ b/PaypalExpressCheckout/authorization-and-capture-continue.php @@ -4,58 +4,62 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - // Put the values of the Payer ID and Ref. Transaction ID generated in Authorization and Capture - $payerID="6ZSCSYG33VP8Q"; - $refTransId="2241708986"; - - // Common setup for API credentials (with PayPal compatible merchant credentials) - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); - - $payPalType=new AnetAPI\PayPalType(); - $payPalType->setPayerID($payerID); - - $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); - - $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) - { - $tresponse = $response->getTransactionResponse(); - if (($tresponse != null)) - { - echo "Transaction Response...\n"; - echo "Received 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"; - } - else - echo "NULL transactionResponse Error\n"; - $messages=$response->getMessages(); - if (($messages != null)) + function payPalAuthorizeCaptureContinue($refTransId, $payerID) { + + // Common setup for API credentials (with PayPal compatible merchant credentials) + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName("5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + + $payPalType=new AnetAPI\PayPalType(); + $payPalType->setPayerID($payerID); + + $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); + + $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) { - echo "Messages...\n"; - echo "Result code: ".$messages->getResultCode()."\n"; - $message0=$messages->getMessage()[0]; - if($message0!=null) - echo "Message: ".$message0->getCode().", ".$message0->getText()."\n"; + $tresponse = $response->getTransactionResponse(); + if (($tresponse != null)) + { + echo "Transaction Response...\n"; + echo "Received 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"; + } + else + echo "NULL transactionResponse Error\n"; + $messages=$response->getMessages(); + if (($messages != null)) + { + echo "Messages...\n"; + echo "Result code: ".$messages->getResultCode()."\n"; + $message0=$messages->getMessage()[0]; + if($message0!=null) + echo "Message: ".$message0->getCode().", ".$message0->getText()."\n"; + } + else + echo "NULL messages Error\n"; } else - echo "NULL messages Error\n"; + echo "NULL response Error\n"; + + return $response; } - else - echo "NULL response Error\n"; + + if(!defined(DONT_RUN_SAMPLES)) + payPalAuthorizeCaptureContinue("2241708986","6ZSCSYG33VP8Q"); ?> diff --git a/PaypalExpressCheckout/authorization-and-capture.php b/PaypalExpressCheckout/authorization-and-capture.php index 59cdaaa..0b4318a 100644 --- a/PaypalExpressCheckout/authorization-and-capture.php +++ b/PaypalExpressCheckout/authorization-and-capture.php @@ -4,43 +4,51 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - // Common setup for API credentials (with PayPal compatible merchant credentials) - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); - - $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); - - // Create an authorize and capture transaction - $transactionRequestType = new AnetAPI\TransactionRequestType(); - $transactionRequestType->setTransactionType( "authCaptureTransaction"); - $transactionRequestType->setPayment($paymentOne); - $transactionRequestType->setAmount(151); - - $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) - { - $tresponse = $response->getTransactionResponse(); - if (($tresponse != null)) + function payPalAuthorizeCapture($amount) { + + // Common setup for API credentials (with PayPal compatible merchant credentials) + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName("5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + + $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); + + // Create an authorize and capture transaction + $transactionRequestType = new AnetAPI\TransactionRequestType(); + $transactionRequestType->setTransactionType( "authCaptureTransaction"); + $transactionRequestType->setPayment($paymentOne); + $transactionRequestType->setAmount($amount); + + $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) { - echo "Received 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"; + $tresponse = $response->getTransactionResponse(); + if (($tresponse != null)) + { + echo "Received 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"; + } + else + echo "NULL transactionResponse Error\n"; } else - echo "NULL transactionResponse Error\n"; + echo "NULL response Error\n"; + + return $response; } - else - echo "NULL response Error\n"; + + if(!defined(DONT_RUN_SAMPLES)) + payPalAuthorizeCapture(12.12); ?> diff --git a/PaypalExpressCheckout/authorization-only-continued.php b/PaypalExpressCheckout/authorization-only-continued.php index f490050..7d52a11 100644 --- a/PaypalExpressCheckout/authorization-only-continued.php +++ b/PaypalExpressCheckout/authorization-only-continued.php @@ -6,58 +6,65 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - echo "PayPal Authorize Only Continue Transaction\n"; - - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); - $refId = 'ref' . time(); - - $paypal_type = new AnetAPI\PayPalType(); - $paypal_type->setPayerID("JJLRRB29QC7RU"); - $paypal_type->setSuccessUrl("http://www.merchanteCommerceSite.com/Success/TC25262"); - $paypal_type->setCancelUrl("http://www.merchanteCommerceSite.com/Success/TC25262"); - - $payment_type = new AnetAPI\PaymentType(); - $payment_type->setPayPal($paypal_type); + function payPalAuthorizeOnlyContinue($transactionId, $payerId) { + echo "PayPal Authorize Only Continue Transaction\n"; + + // Common setup for API credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName("5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $refId = 'ref' . time(); - //create a transaction - $transactionRequestType = new AnetAPI\TransactionRequestType(); - $transactionRequestType->setTransactionType( "authOnlyContinueTransaction"); - $transactionRequestType->setRefTransId("2241711631"); - $transactionRequestType->setAmount(125.34); - $transactionRequestType->setPayment($payment_type); + $paypal_type = new AnetAPI\PayPalType(); + $paypal_type->setPayerID($payerId); + $paypal_type->setSuccessUrl("http://www.merchanteCommerceSite.com/Success/TC25262"); + $paypal_type->setCancelUrl("http://www.merchanteCommerceSite.com/Success/TC25262"); + + $payment_type = new AnetAPI\PaymentType(); + $payment_type->setPayPal($paypal_type); - $request = new AnetAPI\CreateTransactionRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setRefId( $refId); - $request->setTransactionRequest( $transactionRequestType); + //create a transaction + $transactionRequestType = new AnetAPI\TransactionRequestType(); + $transactionRequestType->setTransactionType( "authOnlyContinueTransaction"); + $transactionRequestType->setRefTransId($transactionId); + $transactionRequestType->setAmount(125.34); + $transactionRequestType->setPayment($payment_type); - $controller = new AnetController\CreateTransactionController($request); + $request = new AnetAPI\CreateTransactionRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setRefId( $refId); + $request->setTransactionRequest( $transactionRequestType); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + $controller = new AnetController\CreateTransactionController($request); - if ($response != null) - { - $tresponse = $response->getTransactionResponse(); - - if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + + if ($response != null) { - //echo " RESULT CODE : " . $response->getResultCode() . "\n"; - echo " TRANS ID : " . $tresponse->getTransId() . "\n"; - echo "Payer ID : " . $tresponse->getSecureAcceptance()->getPayerID(); + $tresponse = $response->getTransactionResponse(); + + if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + { + //echo " RESULT CODE : " . $response->getResultCode() . "\n"; + echo " TRANS ID : " . $tresponse->getTransId() . "\n"; + echo "Payer ID : " . $tresponse->getSecureAcceptance()->getPayerID(); + } + else + { + //print_r($tresponse); + echo "ERROR : " . $tresponse->getResponseCode() . "\n"; + } + } else { - //print_r($tresponse); - echo "ERROR : " . $tresponse->getResponseCode() . "\n"; + echo "No response returned"; } - - } - else - { - echo "No response returned"; + + return $response; } + + if(!defined(DONT_RUN_SAMPLES)) + payPalAuthorizeOnlyContinue("2241711631", "JJLRRB29QC7RU"); ?> diff --git a/PaypalExpressCheckout/authorization-only.php b/PaypalExpressCheckout/authorization-only.php index 94c0d9d..d6a127c 100644 --- a/PaypalExpressCheckout/authorization-only.php +++ b/PaypalExpressCheckout/authorization-only.php @@ -6,46 +6,54 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); -// Common setup for API credentials (Paypal compatible merchant) -$merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); -$merchantAuthentication->setName("5KP3u95bQpv"); -$merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); -$refId = 'ref' . time(); - -// Create the payment data for a paypal account -$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); - -//create a auth-only transaction -$transactionRequestType = new AnetAPI\TransactionRequestType(); -$transactionRequestType->setTransactionType( "authOnlyTransaction"); -$transactionRequestType->setAmount(921); -$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)) -{ - $tresponse = $response->getTransactionResponse(); - if (($tresponse != null)&& ($response->getMessages()->getResultCode()=="Ok")) +function payPalAuthorizeOnly() { + // Common setup for API credentials (Paypal compatible merchant) + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName("5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $refId = 'ref' . time(); + + // Create the payment data for a paypal account + $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); + + //create a auth-only transaction + $transactionRequestType = new AnetAPI\TransactionRequestType(); + $transactionRequestType->setTransactionType( "authOnlyTransaction"); + $transactionRequestType->setAmount(921); + $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)) { - echo "Received response code: ".$tresponse->getResponseCode()."\n"; - //Valid response codes: 1=Approved, 2=Declined, 3=Error, 5=Need Payer Consent\n"; - echo "Secure acceptance URL: ".$tresponse->getSecureAcceptance()->getSecureAcceptanceUrl()."\n"; - } - else{ - echo "ERROR : " . $tresponse->getResponseCode() . "\n"; + $tresponse = $response->getTransactionResponse(); + if (($tresponse != null)&& ($response->getMessages()->getResultCode()=="Ok")) + { + echo "Received response code: ".$tresponse->getResponseCode()."\n"; + //Valid response codes: 1=Approved, 2=Declined, 3=Error, 5=Need Payer Consent\n"; + echo "Secure acceptance URL: ".$tresponse->getSecureAcceptance()->getSecureAcceptanceUrl()."\n"; + } + else{ + echo "ERROR : " . $tresponse->getResponseCode() . "\n"; + } } + else + echo "NULL response Error\n"; + + return $response; } -else - echo "NULL response Error\n"; + +if(!defined(DONT_RUN_SAMPLES)) + payPalAuthorizeOnly(); + ?> diff --git a/PaypalExpressCheckout/credit.php b/PaypalExpressCheckout/credit.php index 9894449..6893f89 100644 --- a/PaypalExpressCheckout/credit.php +++ b/PaypalExpressCheckout/credit.php @@ -6,55 +6,64 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); -// Common setup for API credentials (Paypal compatible merchant) -$merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); -// $merchantAuthentication->setName("mbld_api_-g9yGXH6"); -// $merchantAuthentication->setTransactionKey("8b948Sk5Tk5jBB6w"); -$merchantAuthentication->setName("5KP3u95bQpv"); -$merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); - -$refId = 'ref' . time(); -$refTransId = "2241762126"; - -// Create the payment data for a paypal account -$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); - -//create a refund transaction -$transactionRequestType = new AnetAPI\TransactionRequestType(); -$transactionRequestType->setTransactionType( "refundTransaction"); -$transactionRequestType->setAmount(181); -$transactionRequestType->setPayment($paymentOne); -///refTransId of successfully settled transaction -$transactionRequestType->setRefTransId($refTransId); - -$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) -{ - $tresponse = $response->getTransactionResponse(); - - if (($tresponse != null)&& ($response->getMessages()->getResultCode()=="Ok")) +function payPalCredit($transactionId) { + + // Common setup for API credentials (Paypal compatible merchant) + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + // $merchantAuthentication->setName("mbld_api_-g9yGXH6"); + // $merchantAuthentication->setTransactionKey("8b948Sk5Tk5jBB6w"); + $merchantAuthentication->setName("5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + + $refId = 'ref' . time(); + $refTransId = $transactionId; + + // Create the payment data for a paypal account + $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); + + //create a refund transaction + $transactionRequestType = new AnetAPI\TransactionRequestType(); + $transactionRequestType->setTransactionType( "refundTransaction"); + $transactionRequestType->setAmount(181); + $transactionRequestType->setPayment($paymentOne); + ///refTransId of successfully settled transaction + $transactionRequestType->setRefTransId($refTransId); + + $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) { - echo "Credit SUCCESS AUTH CODE : " . $tresponse->getAuthCode() . "\n"; - echo "Credit TRANS ID : " . $tresponse->getTransId() . "\n"; + $tresponse = $response->getTransactionResponse(); + + if (($tresponse != null)&& ($response->getMessages()->getResultCode()=="Ok")) + { + echo "Credit SUCCESS AUTH CODE : " . $tresponse->getAuthCode() . "\n"; + echo "Credit TRANS ID : " . $tresponse->getTransId() . "\n"; + } + else + { + echo "Credit ERROR : " . $tresponse->getResponseCode() . "\n"; + } } else { - echo "Credit ERROR : " . $tresponse->getResponseCode() . "\n"; + echo "No response returned"; } + + return $response; } -else -{ - echo "No response returned"; -} + +if(!defined(DONT_RUN_SAMPLES)) + payPalCredit("2241762126"); + ?> diff --git a/PaypalExpressCheckout/get-details.php b/PaypalExpressCheckout/get-details.php index 4893a9f..37d437a 100644 --- a/PaypalExpressCheckout/get-details.php +++ b/PaypalExpressCheckout/get-details.php @@ -6,61 +6,69 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - echo "PayPal Get Details Transaction\n"; - - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); - - $refId = 'ref' . time(); + function payPalGetDetails($transactionId) { - //create a transaction of type get details - $transactionRequestType = new AnetAPI\TransactionRequestType(); - $transactionRequestType->setTransactionType( "getDetailsTransaction"); - - //replace following transaction ID with your transaction ID for which the details are required - $transactionRequestType->setRefTransId("2241687090"); + echo "PayPal Get Details Transaction\n"; + + // Common setup for API credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName("5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + + $refId = 'ref' . time(); - //create a transaction request - $request = new AnetAPI\CreateTransactionRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setRefId( $refId); - $request->setTransactionRequest( $transactionRequestType); + //create a transaction of type get details + $transactionRequestType = new AnetAPI\TransactionRequestType(); + $transactionRequestType->setTransactionType( "getDetailsTransaction"); + + //replace following transaction ID with your transaction ID for which the details are required + $transactionRequestType->setRefTransId($transactionId); - $controller = new AnetController\CreateTransactionController($request); + //create a transaction request + $request = new AnetAPI\CreateTransactionRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setRefId( $refId); + $request->setTransactionRequest( $transactionRequestType); - //execute the api call to get transaction details - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + $controller = new AnetController\CreateTransactionController($request); - if ($response != null) - { - $tresponse = $response->getTransactionResponse(); - - if($tresponse != null) + //execute the api call to get transaction details + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + + if ($response != null) { - if ($tresponse->getResponseCode()=="1") - { - //parse the shipping information from response - $shipping_response = $tresponse->getShipTo(); - echo "Shipping address : " . $shipping_response->getAddress() . ", " . $shipping_response->getCity() - . ", " . $shipping_response->getState() . ", " . $shipping_response->getCountry() . "\n"; - - echo "Payer ID : " . $tresponse->getSecureAcceptance()->getPayerID(); - } - else - { - echo "ERROR : " . $tresponse->getResponseCode() . "\n"; - } + $tresponse = $response->getTransactionResponse(); + + if($tresponse != null) + { + if ($tresponse->getResponseCode()=="1") + { + //parse the shipping information from response + $shipping_response = $tresponse->getShipTo(); + echo "Shipping address : " . $shipping_response->getAddress() . ", " . $shipping_response->getCity() + . ", " . $shipping_response->getState() . ", " . $shipping_response->getCountry() . "\n"; + + echo "Payer ID : " . $tresponse->getSecureAcceptance()->getPayerID(); + } + else + { + echo "ERROR : " . $tresponse->getResponseCode() . "\n"; + } + } + else + { + echo "No response returned"; + } } else { - echo "No response returned"; - } - } - else - { - echo "No response returned"; + echo "No response returned"; + } + + return $response; } +if(!defined(DONT_RUN_SAMPLES)) + payPalGetDetails("2241687090"); + ?> \ No newline at end of file diff --git a/PaypalExpressCheckout/prior-authorization-capture.php b/PaypalExpressCheckout/prior-authorization-capture.php index 63653c0..5da3963 100644 --- a/PaypalExpressCheckout/prior-authorization-capture.php +++ b/PaypalExpressCheckout/prior-authorization-capture.php @@ -3,49 +3,57 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); - $refId = 'ref' . time(); - - $payPalType = new AnetAPI\PayPalType(); - $payPalType->setSuccessUrl("http://www.merchanteCommerceSite.com/Success/TC25262"); - $payPalType->setCancelUrl("http://www.merchanteCommerceSite.com/Success/TC25262"); - - $paymentType = new AnetAPI\PaymentType(); - $paymentType->setPayPal($payPalType); - - $transactionRequest = new AnetAPI\TransactionRequestType(); - $transactionRequest->setTransactionType("priorAuthCaptureTransaction"); - $transactionRequest->setPayment($paymentType); - $transactionRequest->setAmount(floatval(19.45)); - $transactionRequest->setRefTransId(2241687191); - - $request = new AnetAPI\CreateTransactionRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setRefId( $refId); - $request->setTransactionRequest($transactionRequest); - - $controller = new AnetController\CreateTransactionController($request); - - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - - if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) - { - $tresponse = $response->getTransactionResponse(); - if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + + function payPalPriorAuthorizationCapture($transactionId) { + + // Common setup for API credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName("5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $refId = 'ref' . time(); + + $payPalType = new AnetAPI\PayPalType(); + $payPalType->setSuccessUrl("http://www.merchanteCommerceSite.com/Success/TC25262"); + $payPalType->setCancelUrl("http://www.merchanteCommerceSite.com/Success/TC25262"); + + $paymentType = new AnetAPI\PaymentType(); + $paymentType->setPayPal($payPalType); + + $transactionRequest = new AnetAPI\TransactionRequestType(); + $transactionRequest->setTransactionType("priorAuthCaptureTransaction"); + $transactionRequest->setPayment($paymentType); + $transactionRequest->setAmount(floatval(19.45)); + $transactionRequest->setRefTransId($transactionId); + + $request = new AnetAPI\CreateTransactionRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setRefId( $refId); + $request->setTransactionRequest($transactionRequest); + + $controller = new AnetController\CreateTransactionController($request); + + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) { - echo "Prior Authorization capture AUTH CODE : " . $tresponse->getAuthCode() . "\n"; + $tresponse = $response->getTransactionResponse(); + if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + { + echo "Prior Authorization capture AUTH CODE : " . $tresponse->getAuthCode() . "\n"; + } + else + { + echo "Prior Authorization capture ERROR : Invalid response\n"; + } } else { - echo "Prior Authorization capture ERROR : Invalid response\n"; + echo "PriorAuthorizationCapture ERROR : Invalid response\n"; } - } - else - { - echo "PriorAuthorizationCapture ERROR : Invalid response\n"; + + return $response; } + if(!defined(DONT_RUN_SAMPLES)) + payPalPriorAuthorizationCapture("2241687191"); ?> \ No newline at end of file diff --git a/PaypalExpressCheckout/void.php b/PaypalExpressCheckout/void.php index 48f5b8e..49fb761 100644 --- a/PaypalExpressCheckout/void.php +++ b/PaypalExpressCheckout/void.php @@ -3,48 +3,57 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); - $refId = 'ref' . time(); - - $payPalType = new AnetAPI\PayPalType(); - $payPalType->setSuccessUrl(""); - $payPalType->setCancelUrl(""); - - $paymentType = new AnetAPI\PaymentType(); - $paymentType->setPayPal($payPalType); - - $transactionRequest = new AnetAPI\TransactionRequestType(); - $transactionRequest->setTransactionType("voidTransaction"); - $transactionRequest->setPayment($paymentType); - $transactionRequest->setRefTransId(2241706281); - - $request = new AnetAPI\CreateTransactionRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setRefId( $refId); - $request->setTransactionRequest($transactionRequest); - - $controller = new AnetController\CreateTransactionController($request); - - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - - if ($response != null) - { - $tresponse = $response->getTransactionResponse(); - if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + + function payPalVoid($transactionId) { + + // Common setup for API credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName("5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $refId = 'ref' . time(); + + $payPalType = new AnetAPI\PayPalType(); + $payPalType->setSuccessUrl(""); + $payPalType->setCancelUrl(""); + + $paymentType = new AnetAPI\PaymentType(); + $paymentType->setPayPal($payPalType); + + $transactionRequest = new AnetAPI\TransactionRequestType(); + $transactionRequest->setTransactionType("voidTransaction"); + $transactionRequest->setPayment($paymentType); + $transactionRequest->setRefTransId($transactionId); + + $request = new AnetAPI\CreateTransactionRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setRefId( $refId); + $request->setTransactionRequest($transactionRequest); + + $controller = new AnetController\CreateTransactionController($request); + + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + + if ($response != null) { - echo "Void transaction SUCCESS TRANS ID : " . $tresponse->getTransId() . "\n"; + $tresponse = $response->getTransactionResponse(); + if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + { + echo "Void transaction SUCCESS TRANS ID : " . $tresponse->getTransId() . "\n"; + } + else + { + echo "Void transaction ERROR : " . $tresponse->getResponseCode() . "\n"; + } } else { - echo "Void transaction ERROR : " . $tresponse->getResponseCode() . "\n"; - } - } - else - { - echo "Void transaction Null esponse returned"; + echo "Void transaction Null esponse returned"; + } + + return $response; } + if(!defined(DONT_RUN_SAMPLES)) + payPalVoid("2241706281"); + ?> \ No newline at end of file From 2a4ce32cb8f37d639f080c636870356dc8fc0ccb Mon Sep 17 00:00:00 2001 From: srathod Date: Thu, 14 Jan 2016 14:48:10 +0530 Subject: [PATCH 021/287] - Added dependent methods in test runner class. --- CustomerProfiles/create-customer-profile.php | 6 +- PaymentTransactions/authorize-credit-card.php | 4 +- .../capture-previously-authorized-amount.php | 52 +--------- PaymentTransactions/charge-credit-card.php | 8 +- .../charge-customer-profile.php | 8 +- .../charge-tokenized-credit-card.php | 4 +- PaymentTransactions/credit-bank-account.php | 6 +- PaymentTransactions/debit-bank-account.php | 4 +- PaymentTransactions/refund-transaction.php | 8 +- PaymentTransactions/void-transaction.php | 6 +- test-runner.php | 98 ++++++++++++++++++- 11 files changed, 125 insertions(+), 79 deletions(-) diff --git a/CustomerProfiles/create-customer-profile.php b/CustomerProfiles/create-customer-profile.php index 01d0aaa..954ac5c 100644 --- a/CustomerProfiles/create-customer-profile.php +++ b/CustomerProfiles/create-customer-profile.php @@ -4,7 +4,7 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - function createCustomerProfile($merchantCustomerId=-1){ + function createCustomerProfile($email){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); @@ -46,8 +46,8 @@ function createCustomerProfile($merchantCustomerId=-1){ $customerprofile->setDescription("Customer 2 Test PHP"); if(-1 == $merchantCustomerId) $merchantCustomerId=time().rand(1,150); - $customerprofile->setMerchantCustomerId($merchantCustomerId); - $customerprofile->setEmail("test2@domain.com"); + $customerprofile->setMerchantCustomerId("M_".$email); + $customerprofile->setEmail($email); $customerprofile->setPaymentProfiles($paymentprofiles); $request = new AnetAPI\CreateCustomerProfileRequest(); diff --git a/PaymentTransactions/authorize-credit-card.php b/PaymentTransactions/authorize-credit-card.php index 001c250..7d9af0a 100644 --- a/PaymentTransactions/authorize-credit-card.php +++ b/PaymentTransactions/authorize-credit-card.php @@ -6,7 +6,7 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function authorizeCreditCard(){ + function authorizeCreditCard($amount){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName("5KP3u95bQpv"); @@ -23,7 +23,7 @@ function authorizeCreditCard(){ //create a transaction $transactionRequestType = new AnetAPI\TransactionRequestType(); $transactionRequestType->setTransactionType( "authOnlyTransaction"); - $transactionRequestType->setAmount(151); + $transactionRequestType->setAmount($amount); $transactionRequestType->setPayment($paymentOne); $request = new AnetAPI\CreateTransactionRequest(); diff --git a/PaymentTransactions/capture-previously-authorized-amount.php b/PaymentTransactions/capture-previously-authorized-amount.php index fc310cf..5ec062a 100644 --- a/PaymentTransactions/capture-previously-authorized-amount.php +++ b/PaymentTransactions/capture-previously-authorized-amount.php @@ -4,64 +4,18 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - function capturePreviouslyAuthorizedAmount(){ + function capturePreviouslyAuthorizedAmount($transactionid){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName("556KThWQ6vf2"); $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); $refId = "123456"; - // Create the payment data for a credit card - $creditCard = new AnetAPI\CreditCardType(); - $creditCard->setCardNumber( "4111111111111111"); - $creditCard->setExpirationDate( "2038-12"); - - //$creditCard->setCardCode("999"); - $paymentOne = new AnetAPI\PaymentType(); - $paymentOne->setCreditCard($creditCard); - - // First Authorize the amount - $transactionRequestType = new AnetAPI\TransactionRequestType(); - $transactionRequestType->setTransactionType("priorAuthCaptureTransaction"); - $transactionRequestType->setAmount(5.00); - $transactionRequestType->setPayment($paymentOne); - - - $request = new AnetAPI\CreateTransactionRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setTransactionRequest( $transactionRequestType); - - $controller = new AnetController\CreateTransactionController($request); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - - $authTransId = "0"; - - if ($response != null) - { - $tresponse = $response->getTransactionResponse(); - $authTransId = $tresponse->getTransId(); - - if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) - { - echo "AUTH CODE : " . $tresponse->getAuthCode() . "\n"; - echo "TRANS ID : " . $authTransId . "\n"; - } - else - { - echo "Authorization : Invalid response\n"; - } - } - else - { - echo "Authorization NULL Response Error\n"; - } - // Now capture the previously authorized amount - echo "Capturing the Authorization with transaction ID : " . $authTransId . "\n"; + echo "Capturing the Authorization with transaction ID : " . $transactionid . "\n"; $transactionRequestType = new AnetAPI\TransactionRequestType(); $transactionRequestType->setTransactionType("priorAuthCaptureTransaction"); - $transactionRequestType->setAmount(5.00); - $transactionRequestType->setRefTransId($authTransId); + $transactionRequestType->setRefTransId($transactionid); $request = new AnetAPI\CreateTransactionRequest(); diff --git a/PaymentTransactions/charge-credit-card.php b/PaymentTransactions/charge-credit-card.php index b349dce..44f6945 100644 --- a/PaymentTransactions/charge-credit-card.php +++ b/PaymentTransactions/charge-credit-card.php @@ -4,7 +4,7 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - function chargeCreditCard(){ + function chargeCreditCard($amount){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName("556KThWQ6vf2"); @@ -29,13 +29,13 @@ function chargeCreditCard(){ $lineitem->setName("item1"); $lineitem->setDescription("golf shirt"); $lineitem->setQuantity("1"); - $lineitem->setUnitPrice(20.95); + $lineitem->setUnitPrice($amount); $lineitem->setTaxable(false); // Tax info $tax = new AnetAPI\ExtendedAmountType(); $tax->setName("level 2 tax name"); - $tax->setAmount(4.50); + $tax->setAmount($amount); $tax->setDescription("level 2 tax"); // Customer info @@ -70,7 +70,7 @@ function chargeCreditCard(){ //create a transaction $transactionRequestType = new AnetAPI\TransactionRequestType(); $transactionRequestType->setTransactionType( "authCaptureTransaction"); - $transactionRequestType->setAmount(151.51); + $transactionRequestType->setAmount($amount); $transactionRequestType->setPayment($paymentOne); $transactionRequestType->setOrder($order); $transactionRequestType->addToLineItems($lineitem); diff --git a/PaymentTransactions/charge-customer-profile.php b/PaymentTransactions/charge-customer-profile.php index d8c8966..8ea16b7 100644 --- a/PaymentTransactions/charge-customer-profile.php +++ b/PaymentTransactions/charge-customer-profile.php @@ -4,7 +4,7 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - function chargeCustomerProfile(){ + function chargeCustomerProfile($profileid, $paymentprofileid, $amount){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName("5KP3u95bQpv"); @@ -12,15 +12,15 @@ function chargeCustomerProfile(){ $refId = 'ref' . time(); $profileToCharge = new AnetAPI\CustomerProfilePaymentType(); - $profileToCharge->setCustomerProfileId("36731856"); + $profileToCharge->setCustomerProfileId($profileid); $paymentProfile = new AnetAPI\PaymentProfileType(); - $paymentProfile->setPaymentProfileId("33211899"); + $paymentProfile->setPaymentProfileId($paymentprofileid); $profileToCharge->setPaymentProfile($paymentProfile); $transactionRequestType = new AnetAPI\TransactionRequestType(); $transactionRequestType->setTransactionType( "authCaptureTransaction"); - $transactionRequestType->setAmount(100.50); + $transactionRequestType->setAmount($amount); $transactionRequestType->setProfile($profileToCharge); $request = new AnetAPI\CreateTransactionRequest(); diff --git a/PaymentTransactions/charge-tokenized-credit-card.php b/PaymentTransactions/charge-tokenized-credit-card.php index a271dbe..589a8f0 100644 --- a/PaymentTransactions/charge-tokenized-credit-card.php +++ b/PaymentTransactions/charge-tokenized-credit-card.php @@ -4,7 +4,7 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - function chargeTokenizedCreditCard(){ + function chargeTokenizedCreditCard($amount){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName("556KThWQ6vf2"); @@ -24,7 +24,7 @@ function chargeTokenizedCreditCard(){ //create a transaction $transactionRequestType = new AnetAPI\TransactionRequestType(); $transactionRequestType->setTransactionType("authCaptureTransaction"); - $transactionRequestType->setAmount(151.22); + $transactionRequestType->setAmount($amount); $transactionRequestType->setPayment($paymentOne); diff --git a/PaymentTransactions/credit-bank-account.php b/PaymentTransactions/credit-bank-account.php index fa41cf9..fc61386 100644 --- a/PaymentTransactions/credit-bank-account.php +++ b/PaymentTransactions/credit-bank-account.php @@ -4,12 +4,12 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - function creditBankAccount(){ + function creditBankAccount($transactionid, $amount){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName("556KThWQ6vf2"); $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); - $refId = 'ref' . time(); + $refId = $transactionid; // Create the payment data for a Bank Account $bankAccount = new AnetAPI\BankAccountType(); $bankAccount->setRoutingNumber('125000024'); @@ -28,7 +28,7 @@ function creditBankAccount(){ $transactionRequestType = new AnetAPI\TransactionRequestType(); $transactionRequestType->setTransactionType( "refundTransaction"); - $transactionRequestType->setAmount(250.75); + $transactionRequestType->setAmount($amount); $transactionRequestType->setPayment($paymentBank); $transactionRequestType->setOrder($order); $request = new AnetAPI\CreateTransactionRequest(); diff --git a/PaymentTransactions/debit-bank-account.php b/PaymentTransactions/debit-bank-account.php index 5939a5d..edc6cb8 100644 --- a/PaymentTransactions/debit-bank-account.php +++ b/PaymentTransactions/debit-bank-account.php @@ -4,7 +4,7 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - function debitBankAccount(){ + function debitBankAccount($amount){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName("556KThWQ6vf2"); @@ -28,7 +28,7 @@ function debitBankAccount(){ $transactionRequestType = new AnetAPI\TransactionRequestType(); $transactionRequestType->setTransactionType( "authCaptureTransaction"); - $transactionRequestType->setAmount(250.75); + $transactionRequestType->setAmount($amount); $transactionRequestType->setPayment($paymentBank); $request = new AnetAPI\CreateTransactionRequest(); diff --git a/PaymentTransactions/refund-transaction.php b/PaymentTransactions/refund-transaction.php index 31fef59..4ea096c 100644 --- a/PaymentTransactions/refund-transaction.php +++ b/PaymentTransactions/refund-transaction.php @@ -4,12 +4,12 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - function refundTransaction(){ + function refundTransaction($amount, $transactionid){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName("556KThWQ6vf2"); $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); - $refId = 'ref' . time(); + // Create the payment data for a credit card $creditCard = new AnetAPI\CreditCardType(); $creditCard->setCardNumber( "4111111111111111" ); @@ -19,11 +19,11 @@ function refundTransaction(){ //create a transaction $transactionRequestType = new AnetAPI\TransactionRequestType(); $transactionRequestType->setTransactionType( "refundTransaction"); - $transactionRequestType->setAmount(151.21); + $transactionRequestType->setAmount($amount); $transactionRequestType->setPayment($paymentOne); $request = new AnetAPI\CreateTransactionRequest(); $request->setMerchantAuthentication($merchantAuthentication); - $request->setRefId( $refId); + $request->setRefId($transactionid); $request->setTransactionRequest( $transactionRequestType); $controller = new AnetController\CreateTransactionController($request); $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); diff --git a/PaymentTransactions/void-transaction.php b/PaymentTransactions/void-transaction.php index 2fcf8eb..2f5f979 100644 --- a/PaymentTransactions/void-transaction.php +++ b/PaymentTransactions/void-transaction.php @@ -4,12 +4,12 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - function voidTransaction(){ + function voidTransaction($transactionid){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName("556KThWQ6vf2"); $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); - $refId = 'ref' . time(); + // Create the payment data for a credit card $creditCard = new AnetAPI\CreditCardType(); $creditCard->setCardNumber( "4111111111111111" ); @@ -23,7 +23,7 @@ function voidTransaction(){ RequestType->setPayment($paymentOne); $request = new AnetAPI\CreateTransactionRequest(); $request->setMerchantAuthentication($merchantAuthentication); - $request->setRefId( $refId); + $request->setRefId($transactionid); $request->setTransactionRequest( $transactionRequestType); $controller = new AnetController\CreateTransactionController($request); $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); diff --git a/test-runner.php b/test-runner.php index 8f982ec..9020742 100644 --- a/test-runner.php +++ b/test-runner.php @@ -20,7 +20,7 @@ class TestRunner extends PHPUnit_Framework_TestCase public static $payerID = "LM6NCLZ5RAKBY"; //random amount for transactions/subscriptions public static function randAmount(){ - return rand(0, 10000); + return 12 + (rand(1, 10000)/12); } //random email for a new customer profile public static function randEmail(){ @@ -84,7 +84,9 @@ public function testAllSampleCodes(){ } echo "Number of sample codes run: ". $runTests; } - public static function runCreateCustomerPaymentProfile(){ + + public static function runCreateCustomerPaymentProfile() + { $responseCustomerProfile = createCustomerProfile(); $existingCustomerProfileId = $responseCustomerProfile->getCustomerProfileId(); return createCustomerPaymentProfile($existingCustomerProfileId, self::randPhoneNumber()); @@ -93,6 +95,96 @@ 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::randAmount()); + } + + public static function runDebitBankAccount() + { + return debitBankAccount(self::randAmount()); + } + + public static function runChargeTokenizedCreditCard() + { + return chargeTokenizedCreditCard(self::randAmount()); + } + + public static function runChargeCreditCard() + { + return chargeCreditCard(self::randAmount()); + } + + public static function runCapturePreviouslyAuthorizedAmount() + { + $response = authorizeCreditCard(self::randAmount()); + return capturePreviouslyAuthorizedAmount(response->getTransactionResponse()->getTransId()); + } + + public static function runRefundTransaction() + { + $response = authorizeCreditCard.run(self::randAmount()); + $response = capturePreviouslyAuthorizedAmount($response->getTransactionResponse()->getTransId()); + return refundTransaction(self::randAmount(), response->getTransactionResponse()->getTransId()); + } + + public static function runVoidTransaction() + { + $response = authorizeCreditCard(self::randAmount()); + return voidTransaction($response->getTransactionResponse()->getTransId()); + } + + public static function runCreditBankAccount() + { + return creditBankAccount(self::$transactionID, self::randAmount()); + } + + public static function runChargeCustomerProfile() + { + $response = createCustomerProfile(self::randEmail()); + $paymentProfileResponse = createCustomerPaymentProfile(response->getCustomerProfileId()); + $chargeResponse = chargeCustomerProfile(response->getCustomerProfileId(), paymentProfileResponse->getCustomerPaymentProfileId(), self::randAmount()); + deleteCustomerProfile(response->getCustomerProfileId()); + + return $chargeResponse; + } + + private static function runPayPalVoid() { + $response = payPalAuthorizeCapture(self::randAmount()); + return payPalVoid($response->getTransactionResponse()->getTransId()); + } + + private static function runPayPalAuthorizeCapture() + { + return payPalAuthorizeCapture(self::randAmount()); + } + + private static function runPayPalAuthorizeCaptureContinue() + { + $response = payPalAuthorizeCapture(self::randAmount()); + return payPalAuthorizeCaptureContinue($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 runPayPalGetDetails() + { + $response = payPalAuthorizeCapture(self::randAmount()); + return payPalGetDetails($response->getTransactionResponse()->getTransId()); + } + + public static function runPayPalPriorAuthorizationCapture() + { + $response = payPalAuthorizeCapture(self::randAmount()); + return payPalPriorAuthorizationCapture($response->getTransactionResponse()->getTransId()) + } } \ No newline at end of file From d5b7edd5a07152adf97417d84657e15d34828731 Mon Sep 17 00:00:00 2001 From: ashtru Date: Thu, 14 Jan 2016 15:08:28 +0530 Subject: [PATCH 022/287] customer profiles samples initial update for test runnner. --- ...eate-customer-profile-from-transaction.php | 6 +- CustomerProfiles/create-customer-profile.php | 9 +- .../create-customer-shipping-address.php | 4 +- .../delete-customer-payment-profile.php | 2 +- CustomerProfiles/delete-customer-profile.php | 55 +++-- .../delete-customer-shipping-address.php | 1 + CustomerProfiles/get-customer-profile.php | 160 ++++++++------- CustomerProfiles/get-hosted-profile-page.php | 7 +- .../update-customer-payment-profile.php | 1 + CustomerProfiles/update-customer-profile.php | 193 ++++++++++-------- .../update-customer-shipping-address.php | 71 +++---- .../validate-customer-payment-profile.php | 8 +- SampleCodeList.txt | 38 ++-- test-runner.php | 77 ++++++- 14 files changed, 375 insertions(+), 257 deletions(-) diff --git a/CustomerProfiles/create-customer-profile-from-transaction.php b/CustomerProfiles/create-customer-profile-from-transaction.php index 22a651f..e14c486 100644 --- a/CustomerProfiles/create-customer-profile-from-transaction.php +++ b/CustomerProfiles/create-customer-profile-from-transaction.php @@ -4,18 +4,16 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - function createCustomerProfileFromTransaction() + function createCustomerProfileFromTransaction($transId="2238251168") { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName("556KThWQ6vf2"); $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); - - $request = new AnetAPI\CreateCustomerProfileFromTransactionRequest(); $request->setMerchantAuthentication($merchantAuthentication); - $request->setTransId("2238251168"); + $request->setTransId($transId); $controller = new AnetController\CreateCustomerProfileFromTransactionController($request); diff --git a/CustomerProfiles/create-customer-profile.php b/CustomerProfiles/create-customer-profile.php index 01d0aaa..e7d9831 100644 --- a/CustomerProfiles/create-customer-profile.php +++ b/CustomerProfiles/create-customer-profile.php @@ -4,7 +4,7 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - function createCustomerProfile($merchantCustomerId=-1){ + function createCustomerProfile($customerEmail){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); @@ -44,10 +44,9 @@ function createCustomerProfile($merchantCustomerId=-1){ $paymentprofiles[] = $paymentprofile; $customerprofile = new AnetAPI\CustomerProfileType(); $customerprofile->setDescription("Customer 2 Test PHP"); - if(-1 == $merchantCustomerId) - $merchantCustomerId=time().rand(1,150); + $merchantCustomerId=time().rand(1,150); $customerprofile->setMerchantCustomerId($merchantCustomerId); - $customerprofile->setEmail("test2@domain.com"); + $customerprofile->setEmail($customerEmail); $customerprofile->setPaymentProfiles($paymentprofiles); $request = new AnetAPI\CreateCustomerProfileRequest(); @@ -70,5 +69,5 @@ function createCustomerProfile($merchantCustomerId=-1){ return $response; } if(!defined(DONT_RUN_SAMPLES)) - createCustomerProfile(); + createCustomerProfile("john2@test.com"); ?> diff --git a/CustomerProfiles/create-customer-shipping-address.php b/CustomerProfiles/create-customer-shipping-address.php index 90bf638..3579bfb 100644 --- a/CustomerProfiles/create-customer-shipping-address.php +++ b/CustomerProfiles/create-customer-shipping-address.php @@ -3,7 +3,7 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - function createCustomerShippingAddress($existingcustomerprofileid = "35872074") + function createCustomerShippingAddress($existingcustomerprofileid = "35872074", $phoneNumber="000-000-0000") { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); @@ -22,7 +22,7 @@ function createCustomerShippingAddress($existingcustomerprofileid = "35872074") $customershippingaddress->setState("NJ"); $customershippingaddress->setZip("08753"); $customershippingaddress->setCountry("USA"); - $customershippingaddress->setPhoneNumber("000-000-0000"); + $customershippingaddress->setPhoneNumber($phoneNumber); $customershippingaddress->setFaxNumber("999-999-9999"); // Create a new customer shipping address for an existing customer profile diff --git a/CustomerProfiles/delete-customer-payment-profile.php b/CustomerProfiles/delete-customer-payment-profile.php index 5cbf010..0070042 100644 --- a/CustomerProfiles/delete-customer-payment-profile.php +++ b/CustomerProfiles/delete-customer-payment-profile.php @@ -1,4 +1,4 @@ -setName("556KThWQ6vf2"); $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + return $merchantAuthentication; + } + + function deleteCustomerProfileWithId($customerProfileId) + { + $refId = 'ref' . time(); + + $request = new AnetAPI\DeleteCustomerProfileRequest(); + $request->setMerchantAuthentication(deleteCustomerMerchantAuthentication()); + $request->setCustomerProfileId( $customerProfileId ); + + $controller = new AnetController\DeleteCustomerProfileController($request); + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) + { + echo "DeleteCustomerProfile SUCCESS : " . "\n"; + } + else + { + echo "ERROR : DeleteCustomerProfile: Invalid response\n"; + echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + + } + return $response; + } + function deleteCustomerProfile() + { + //merchantAuthentication set globally separately this sample $refId = 'ref' . time(); + + $request = new AnetAPI\DeleteCustomerProfileRequest(); + $request->setMerchantAuthentication(deleteCustomerMerchantAuthentication()); - // Create the payment data for a credit card + // Create the payment data for a credit card $creditCard = new AnetAPI\CreditCardType(); $creditCard->setCardNumber( "4111111111111111" ); $creditCard->setExpirationDate( "2038-12"); @@ -49,7 +80,7 @@ function deleteCustomerProfile() $customerprofile->setPaymentProfiles($paymentprofiles); $request = new AnetAPI\CreateCustomerProfileRequest(); - $request->setMerchantAuthentication($merchantAuthentication); + $request->setMerchantAuthentication(deleteCustomerMerchantAuthentication()); $request->setRefId( $refId); $request->setProfile($customerprofile); $controller = new AnetController\CreateCustomerProfileController($request); @@ -65,23 +96,9 @@ function deleteCustomerProfile() echo "ERROR : CreateCustomerProfile: Invalid response\n"; } // Delete an existing customer profile - $request = new AnetAPI\DeleteCustomerProfileRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setCustomerProfileId( $profileidcreated ); - - $controller = new AnetController\DeleteCustomerProfileController($request); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) - { - echo "DeleteCustomerProfile SUCCESS : " . "\n"; - } - else - { - echo "ERROR : DeleteCustomerProfile: Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; - - } + return deleteCustomerProfileWithId($profileidcreated); } + if(!defined(DONT_RUN_SAMPLES)) deleteCustomerProfile(); ?> diff --git a/CustomerProfiles/delete-customer-shipping-address.php b/CustomerProfiles/delete-customer-shipping-address.php index 7294ce0..fc006ed 100644 --- a/CustomerProfiles/delete-customer-shipping-address.php +++ b/CustomerProfiles/delete-customer-shipping-address.php @@ -3,6 +3,7 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); + function deleteCustomerShippingAddress($customerprofileid = "35872074", $customeraddressid = "36931511") { // Common setup for API credentials diff --git a/CustomerProfiles/get-customer-profile.php b/CustomerProfiles/get-customer-profile.php index 5f3d53a..19e91cb 100644 --- a/CustomerProfiles/get-customer-profile.php +++ b/CustomerProfiles/get-customer-profile.php @@ -3,90 +3,98 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - // Common setup for API credentials - function getCustomerProfile(){ - - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); - $refId = 'ref' . time(); - - // 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); + function getCustomerMerchantAuthentication() + { + // Common setup for API credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName("556KThWQ6vf2"); + $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + return $merchantAuthentication; + } + function getCustomerProfileWithId($profileIdRequested) + { + $request = new AnetAPI\GetCustomerProfileRequest(); + $request->setMerchantAuthentication(getCustomerMerchantAuthentication()); + $request->setCustomerProfileId($profileIdRequested); + $controller = new AnetController\GetCustomerProfileController($request); + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) + { + echo "GetCustomerProfile SUCCESS : " . "\n"; + $profileSelected = $response->getProfile(); + $paymentProfilesSelected = $profileSelected->getPaymentProfiles(); + echo "Profile Has " . count($paymentProfilesSelected). " Payment Profiles" . "\n"; - // 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 + } + else + { + echo "ERROR : GetCustomerProfile: Invalid response\n"; + echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + } + return $response; + } + function getCustomerProfile($customerProfileId){ + //merchant authentication is done in separate function + $refId = 'ref' . time(); + + // 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); - $paymentprofile = new AnetAPI\CustomerPaymentProfileType(); + // 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 - $paymentprofile->setCustomerType('individual'); - $paymentprofile->setBillTo($billto); - $paymentprofile->setPayment($paymentCreditCard); - $paymentprofiles[] = $paymentprofile; - $customerprofile = new AnetAPI\CustomerProfileType(); - $customerprofile->setDescription("Customer 2 Test PHP"); - $merchantCustomerId = time().rand(1,150); - $customerprofile->setMerchantCustomerId($merchantCustomerId); - $customerprofile->setEmail("test2@domain.com"); - $customerprofile->setPaymentProfiles($paymentprofiles); + $paymentprofile = new AnetAPI\CustomerPaymentProfileType(); - $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 "SUCCESS: CreateCustomerProfile PROFILE ID : " . $response->getCustomerProfileId() . "\n"; + $paymentprofile->setCustomerType('individual'); + $paymentprofile->setBillTo($billto); + $paymentprofile->setPayment($paymentCreditCard); + $paymentprofiles[] = $paymentprofile; + $customerprofile = new AnetAPI\CustomerProfileType(); + $customerprofile->setDescription("Customer 2 Test PHP"); + $merchantCustomerId = time().rand(1,150); + $customerprofile->setMerchantCustomerId($merchantCustomerId); + $customerprofile->setEmail("test2@domain.com"); + $customerprofile->setPaymentProfiles($paymentprofiles); - $profileIdRequested = $response->getCustomerProfileId(); - } - else - { - echo "ERROR : CreateCustomerProfile: Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; - } - // Retrieve an existing customer profile along with all the associated payment profiles and shipping addresses + $request = new AnetAPI\CreateCustomerProfileRequest(); + $request->setMerchantAuthentication(getCustomerMerchantAuthentication()); + $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 "SUCCESS: CreateCustomerProfile PROFILE ID : " . $response->getCustomerProfileId() . "\n"; - $request = new AnetAPI\GetCustomerProfileRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setCustomerProfileId($profileIdRequested); - $controller = new AnetController\GetCustomerProfileController($request); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) - { - echo "GetCustomerProfile SUCCESS : " . "\n"; - $profileSelected = $response->getProfile(); - $paymentProfilesSelected = $profileSelected->getPaymentProfiles(); - echo "Profile Has " . count($paymentProfilesSelected). " Payment Profiles" . "\n"; + $profileIdRequested = $response->getCustomerProfileId(); + } + else + { + echo "ERROR : CreateCustomerProfile: Invalid response\n"; + echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + } + // Retrieve an existing customer profile along with all the associated payment profiles and shipping addresses - } - else - { - echo "ERROR : GetCustomerProfile: Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; - } - return $response; + return getCustomerProfileWithId($profileIdRequested); } if(!defined('DONT_RUN_SAMPLES')) { diff --git a/CustomerProfiles/get-hosted-profile-page.php b/CustomerProfiles/get-hosted-profile-page.php index a22c567..344c48a 100644 --- a/CustomerProfiles/get-hosted-profile-page.php +++ b/CustomerProfiles/get-hosted-profile-page.php @@ -4,17 +4,14 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - function getHostedProfielPage() + function getHostedProfilePage($customerprofileid = "37680862") { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName("3Zw3Ru9nx"); $merchantAuthentication->setTransactionKey("7Tbj6T3a9cPq4A5d"); - // An existing payment profile ID for this Merchant name and Transaction key - // - $customerprofileid = "37680862"; - $customerpaymentprofileid = "34249159"; + // Use an existing payment profile ID for this Merchant name and Transaction key $setting = new AnetAPI\SettingType(); $setting->setSettingName("hostedProfileReturnUrl"); diff --git a/CustomerProfiles/update-customer-payment-profile.php b/CustomerProfiles/update-customer-payment-profile.php index b749d09..69f2d38 100644 --- a/CustomerProfiles/update-customer-payment-profile.php +++ b/CustomerProfiles/update-customer-payment-profile.php @@ -88,6 +88,7 @@ function updateCustomerPaymentProfile($customerProfileId="36731856", $customerPa echo "Update Customer Payment Profile: ERROR Invalid response\n"; echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; } + return $response; } if(!defined(DONT_RUN_SAMPLES)) updateCustomerPaymentProfile(); diff --git a/CustomerProfiles/update-customer-profile.php b/CustomerProfiles/update-customer-profile.php index a3ca29d..b60d415 100644 --- a/CustomerProfiles/update-customer-profile.php +++ b/CustomerProfiles/update-customer-profile.php @@ -3,103 +3,118 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); - $refId = 'ref' . time(); + + function updateCustomerProfileMerchantAuthentication() + { + // Common setup for API credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName("556KThWQ6vf2"); + $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + return $merchantAuthentication; + } + function updateCustomerProfileById($customerProfileId) + { + $updatecustomerprofile = new AnetAPI\CustomerProfileExType(); + $updatecustomerprofile->setCustomerProfileId($customerProfileId); + $updatecustomerprofile->setDescription("Updated existing Profile Request"); + $updatecustomerprofile->setEmail("updatecustomerprofile@domain.com"); - // 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); + $request = new AnetAPI\UpdateCustomerProfileRequest(); + $request->setMerchantAuthentication(updateCustomerProfileMerchantAuthentication()); + $request->setProfile($updatecustomerprofile); - // 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"); + $controller = new AnetController\UpdateCustomerProfileController($request); + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) + { + echo "UpdateCustomerProfile SUCCESS : " . "\n"; + // Validate the description and e-mail that was updated + $request = new AnetAPI\GetCustomerProfileRequest(); + $request->setMerchantAuthentication(updateCustomerProfileMerchantAuthentication()); + $request->setCustomerProfileId($customerProfileId ); + $controller = new AnetController\GetCustomerProfileController($request); + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) + { + echo "Get updated CustomerProfile SUCCESS : " . "\n"; + $profileselected = $response->getProfile(); + echo "Updated Customer Profile Customer description : " . $profileselected->getDescription() . "\n"; + echo "Updated Customer Profile EMail description : " . $profileselected->getEmail() . "\n"; + } + else + { + echo "ERROR : GetCustomerProfile: Invalid response\n"; + echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + } + } + else + { + echo "ERROR : UpdateCustomerProfile: Invalid response\n"; + echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + } + return $response; + } - // 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 + function updateCustomerProfile() + { + $refId = 'ref' . time(); - $paymentprofile = new AnetAPI\CustomerPaymentProfileType(); + // 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); - $paymentprofile->setCustomerType('individual'); - $paymentprofile->setBillTo($billto); - $paymentprofile->setPayment($paymentCreditCard); - $paymentprofiles[] = $paymentprofile; - $customerprofile = new AnetAPI\CustomerProfileType(); - $customerprofile->setDescription("Update Customer Profile Request Test for PHP"); - $merchantCustomerId = time().rand(1,150); - $customerprofile->setMerchantCustomerId($merchantCustomerId); - $customerprofile->setEmail("customerprofile@domain.com"); - $customerprofile->setPaymentProfiles($paymentprofiles); + // 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 - $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 "SUCCESS: CreateCustomerProfile PROFILE ID : " . $response->getCustomerProfileId() . "\n"; + $paymentprofile = new AnetAPI\CustomerPaymentProfileType(); - $profileidcreated = $response->getCustomerProfileId(); - } - else - { - echo "ERROR : CreateCustomerProfile: Invalid response\n"; - } - // Update an existing customer profile - - $updatecustomerprofile = new AnetAPI\CustomerProfileExType(); - $updatecustomerprofile->setCustomerProfileId($profileidcreated); - $updatecustomerprofile->setDescription("Updated existing Profile Request"); - $updatecustomerprofile->setEmail("updatecustomerprofile@domain.com"); + $paymentprofile->setCustomerType('individual'); + $paymentprofile->setBillTo($billto); + $paymentprofile->setPayment($paymentCreditCard); + $paymentprofiles[] = $paymentprofile; + $customerprofile = new AnetAPI\CustomerProfileType(); + $customerprofile->setDescription("Update Customer Profile Request Test for PHP"); + $merchantCustomerId = time().rand(1,150); + $customerprofile->setMerchantCustomerId($merchantCustomerId); + $customerprofile->setEmail("customerprofile@domain.com"); + $customerprofile->setPaymentProfiles($paymentprofiles); - $request = new AnetAPI\UpdateCustomerProfileRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setProfile($updatecustomerprofile); + $request = new AnetAPI\CreateCustomerProfileRequest(); + $request->setMerchantAuthentication(updateCustomerProfileMerchantAuthentication()); + $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 "SUCCESS: CreateCustomerProfile PROFILE ID : " . $response->getCustomerProfileId() . "\n"; - $controller = new AnetController\UpdateCustomerProfileController($request); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) - { - echo "UpdateCustomerProfile SUCCESS : " . "\n"; - // Validate the description and e-mail that was updated - $request = new AnetAPI\GetCustomerProfileRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setCustomerProfileId($profileidcreated ); - $controller = new AnetController\GetCustomerProfileController($request); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) - { - echo "Get updated CustomerProfile SUCCESS : " . "\n"; - $profileselected = $response->getProfile(); - echo "Updated Customer Profile Customer description : " . $profileselected->getDescription() . "\n"; - echo "Updated Customer Profile EMail description : " . $profileselected->getEmail() . "\n"; - } - else - { - echo "ERROR : GetCustomerProfile: Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; - } - } - else - { - echo "ERROR : UpdateCustomerProfile: Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + $profileidcreated = $response->getCustomerProfileId(); + } + else + { + echo "ERROR : CreateCustomerProfile: Invalid response\n"; + } + // Update an existing customer profile + return updateCustomerProfileById($profileidcreated); } + if(!defined(DONT_RUN_SAMPLES)) + updateCustomerProfile(); ?> diff --git a/CustomerProfiles/update-customer-shipping-address.php b/CustomerProfiles/update-customer-shipping-address.php index 49f0966..3a3634f 100644 --- a/CustomerProfiles/update-customer-shipping-address.php +++ b/CustomerProfiles/update-customer-shipping-address.php @@ -3,46 +3,47 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); + function updateCustomerShippingAddress() { - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + // Common setup for API credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName("556KThWQ6vf2"); + $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); - // An existing customer profile id for this merchant name and transaction key - $existingcustomerprofileid = "35843932"; + // An existing customer profile id for this merchant name and transaction key + $existingcustomerprofileid = "35843932"; - // Create the customer shipping address - $customershippingaddress = new AnetAPI\CustomerAddressExType(); - $customershippingaddress->setFirstName("Jane"); - $customershippingaddress->setLastName("White"); - $customershippingaddress->setCompany("Addresses R Us"); - $customershippingaddress->setAddress("14 North Spring Street Suite 240"); - $customershippingaddress->setCity("Toms River"); - $customershippingaddress->setState("NJ"); - $customershippingaddress->setZip("08753"); - $customershippingaddress->setCountry("USA"); - $customershippingaddress->setPhoneNumber("201-000-0000"); - $customershippingaddress->setFaxNumber("973-999-9999"); + // Create the customer shipping address + $customershippingaddress = new AnetAPI\CustomerAddressExType(); + $customershippingaddress->setFirstName("Jane"); + $customershippingaddress->setLastName("White"); + $customershippingaddress->setCompany("Addresses R Us"); + $customershippingaddress->setAddress("14 North Spring Street Suite 240"); + $customershippingaddress->setCity("Toms River"); + $customershippingaddress->setState("NJ"); + $customershippingaddress->setZip("08753"); + $customershippingaddress->setCountry("USA"); + $customershippingaddress->setPhoneNumber("201-000-0000"); + $customershippingaddress->setFaxNumber("973-999-9999"); - // Update an existing customer shipping address for an existing customer profile - $request = new AnetAPI\UpdateCustomerShippingAddressRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setCustomerProfileId($existingcustomerprofileid); - $request->setAddress($customershippingaddress); - $controller = new AnetController\UpdateCustomerShippingAddressController($request); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) - { - echo "Update Customer Shipping Address SUCCESS:" . "\n"; - } - else - { - echo "Update Customer Shipping Address ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; - } - return $response; + // Update an existing customer shipping address for an existing customer profile + $request = new AnetAPI\UpdateCustomerShippingAddressRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setCustomerProfileId($existingcustomerprofileid); + $request->setAddress($customershippingaddress); + $controller = new AnetController\UpdateCustomerShippingAddressController($request); + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) + { + echo "Update Customer Shipping Address SUCCESS:" . "\n"; + } + else + { + echo "Update Customer Shipping Address ERROR : Invalid response\n"; + echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + } + return $response; } if(!defined(DONT_RUN_SAMPLES)) updateCustomerShippingAddress(); diff --git a/CustomerProfiles/validate-customer-payment-profile.php b/CustomerProfiles/validate-customer-payment-profile.php index d4d6e4e..050316e 100644 --- a/CustomerProfiles/validate-customer-payment-profile.php +++ b/CustomerProfiles/validate-customer-payment-profile.php @@ -4,13 +4,13 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - function validateCustomerPaymentProfile($customerprofileid = "37680862", $customerpaymentprofileid = "34249159") + function validateCustomerPaymentProfile($customerProfileId="36731856", $customerPaymentProfileId="33211899") { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("3Zw3Ru9nx"); - $merchantAuthentication->setTransactionKey("7Tbj6T3a9cPq4A5d"); - + $merchantAuthentication->setName("5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + // Use an existing payment profile ID for this Merchant name and Transaction key //validationmode tests , does not send an email receipt $validationmode = "testMode"; diff --git a/SampleCodeList.txt b/SampleCodeList.txt index 35f5fad..86a9dcb 100644 --- a/SampleCodeList.txt +++ b/SampleCodeList.txt @@ -1,15 +1,27 @@ SampleCodeName,IsDependent,ShouldRun -CreateCustomerProfile,0,1 -GetCustomerProfile,0,0 -GetCustomerProfileIds,0,0 -UpdateCustomerProfile,0,0 -DeleteCustomerProfile,0,0 + +CreateCustomerProfile,1,1 +GetCustomerProfile,1,1 +GetCustomerProfileIds,0,1 +UpdateCustomerProfile,1,1 +DeleteCustomerProfile,0,1 + CreateCustomerPaymentProfile,1,1 -GetCustomerPaymentProfile,0,0 -GetCustomerPaymentProfileList,0,0 -ValidateCustomerPaymentProfile,0,0 -UpdateCustomerPaymentProfile,0,0 -DeleteCustomerPaymentProfile,0,0 -CreateCustomerShippingAddress,0,0 -DeleteCustomerShippingAddress,0,0 -CreateCustomerProfileFromTransaction,0,0 +GetCustomerPaymentProfile,1,1 +GetCustomerPaymentProfileList,0,1 +ValidateCustomerPaymentProfile,1,1 + +UpdateCustomerPaymentProfile,1,1 +DeleteCustomerPaymentProfile,1,1 + +CreateCustomerShippingAddress,1,1 +GetCustomerShippingAddress,0,1 +UpdateCustomerShippingAddress,0,1 +DeleteCustomerShippingAddress,1,1 + +GetHostedProfilePage,0,1 +CreateCustomerProfileFromTransaction,0,1 + + + + diff --git a/test-runner.php b/test-runner.php index 8f982ec..e3e25da 100644 --- a/test-runner.php +++ b/test-runner.php @@ -35,6 +35,7 @@ public function getDay(){ } public function testAllSampleCodes(){ $runTests = 0; + $skippedTests = 0; $file = 'SampleCodeList.txt'; $data = file($file) or die('\nCould not read SampleCodeList.'); foreach ($data as $line) @@ -53,7 +54,8 @@ public function testAllSampleCodes(){ echo "should run:".$shouldRun."\n"; if("0" === $shouldRun) { - echo ":Skipping " . $sampleMethodName . "\n"; + echo ":Skipping " . $apiName . "\n"; + $skippedTests++; } else { @@ -71,7 +73,7 @@ public function testAllSampleCodes(){ //request the api - echo "Running sample: " . $sampleMethodName; + echo "Running sample: " . $sampleMethodName . "\n"; $response = call_user_func($sampleMethodName); @@ -83,12 +85,79 @@ public function testAllSampleCodes(){ } } echo "Number of sample codes run: ". $runTests; + echo "Number of sample codes skipped: " . $skippedTests; } + //customer profiles methods + public static function runCreateCustomerProfile(){ + $response = createCustomerProfile(self::randEmail()); + $customerProfileId = $response->getCustomerProfileId(); + deleteCustomerProfileWithId($customerProfileId); + return $response; + } + public static function runGetCustomerProfile(){ + $responseCustomerProfile = createCustomerProfile(self::randEmail()); + $existingCustomerProfileId = $responseCustomerProfile->getCustomerProfileId(); + $response = getCustomerProfile($existingCustomerProfileId); + return $response; + } + public static function runUpdateCustomerProfile(){ + $responseCustomerProfile = createCustomerProfile(self::randEmail()); + $customerProfileId = $responseCustomerProfile->getCustomerProfileId(); + $response = updateCustomerProfileById($customerProfileId); + deleteCustomerProfileWithId($customerProfileId); + return $response; + } + //customer profiles - payment profiles methods public static function runCreateCustomerPaymentProfile(){ - $responseCustomerProfile = createCustomerProfile(); + $responseCustomerProfile = createCustomerProfile(self::randEmail()); $existingCustomerProfileId = $responseCustomerProfile->getCustomerProfileId(); - return createCustomerPaymentProfile($existingCustomerProfileId, self::randPhoneNumber()); + $response=createCustomerPaymentProfile($existingCustomerProfileId, self::randPhoneNumber()); + return $response; + } + public static function runGetCustomerPaymentProfile(){ + $customerProfileId = createCustomerProfile(self::randEmail())->getCustomerProfileId(); + $customerPaymentProfileId = createCustomerPaymentProfile($customerProfileId, self::randPhoneNumber()) + ->getCustomerPaymentProfileId(); + $response= getCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId); + deleteCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId); + return $response; + } + public static function runValidateCustomerPaymentProfile(){ + $customerProfileId = createCustomerProfile(self::randEmail())->getCustomerProfileId(); + $customerPaymentProfileId = createCustomerPaymentProfile($customerProfileId, self::randPhoneNumber()) + ->getCustomerPaymentProfileId(); + $response= getCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId); + validateCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId); + return $response; + } + public static function runUpdateCustomerPaymentProfile(){ + $customerProfileId = createCustomerProfile(self::randEmail())->getCustomerProfileId(); + $customerPaymentProfileId = createCustomerPaymentProfile($customerProfileId, self::randPhoneNumber()) + ->getCustomerPaymentProfileId(); + $response= getCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId); + updateCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId); + return $response; + } + public static function runDeleteCustomerPaymentProfile(){ + $customerProfileId = createCustomerProfile(self::randEmail())->getCustomerProfileId(); + $customerPaymentProfileId = createCustomerPaymentProfile($customerProfileId, self::randPhoneNumber()) + ->getCustomerPaymentProfileId(); + $response= getCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId); + deleteCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId); + return $response; + } + //customer profiles - shipping address + public static function runCreateCustomerShippingAddress(){ + $customerProfileId = createCustomerProfile(self::randEmail())->getCustomerProfileId(); + $response = createCustomerShippingAddress($customerProfileId, self::randPhoneNumber()) + deleteCustomerShippingAddress($customerProfileId, $response->getCustomerShippingAddressId()); + return $response; } + public static function runDeleteCustomerShippingAddress(){ + $customerProfileId = createCustomerProfile(self::randEmail())->getCustomerProfileId(); + $responseCreateShipping = createCustomerShippingAddress($customerProfileId, self::randPhoneNumber()) + return deleteCustomerShippingAddress($customerProfileId, $responsCreateShippinge->getCustomerShippingAddressId()); + } private static function toPhoneNumber($num) { $zeroPadded = sprintf("%10d", $num); From e4220e399cf9de3e6bd19ab2934e66065aa50695 Mon Sep 17 00:00:00 2001 From: srathod Date: Thu, 14 Jan 2016 16:11:52 +0530 Subject: [PATCH 023/287] - Updated sample codes for testrunner. --- .../create-customer-payment-profile.php | 4 +- ...eate-customer-profile-from-transaction.php | 4 +- CustomerProfiles/create-customer-profile.php | 4 +- .../create-customer-shipping-address.php | 4 +- .../delete-customer-payment-profile.php | 4 +- CustomerProfiles/delete-customer-profile.php | 4 +- .../delete-customer-shipping-address.php | 4 +- CustomerProfiles/get-customer-profile-ids.php | 4 +- CustomerProfiles/get-customer-profile.php | 4 +- CustomerProfiles/update-customer-profile.php | 4 +- .../update-customer-shipping-address.php | 4 +- ...nds-authorized-through-another-channel.php | 4 +- .../capture-previously-authorized-amount.php | 4 +- PaymentTransactions/charge-credit-card.php | 4 +- .../charge-tokenized-credit-card.php | 4 +- PaymentTransactions/credit-bank-account.php | 4 +- PaymentTransactions/debit-bank-account.php | 4 +- PaymentTransactions/refund-transaction.php | 4 +- PaymentTransactions/void-transaction.php | 7 +- RecurringBilling/cancel-subscription.php | 4 +- RecurringBilling/create-subscription.php | 4 +- .../get-list-of-subscriptions.php | 4 +- RecurringBilling/get-subscription-status.php | 4 +- RecurringBilling/get-subscription.php | 4 +- RecurringBilling/update-subscription.php | 4 +- test-runner.php | 181 +++++++++++++++--- 26 files changed, 202 insertions(+), 82 deletions(-) diff --git a/CustomerProfiles/create-customer-payment-profile.php b/CustomerProfiles/create-customer-payment-profile.php index 96ec372..e85726c 100644 --- a/CustomerProfiles/create-customer-payment-profile.php +++ b/CustomerProfiles/create-customer-payment-profile.php @@ -7,8 +7,8 @@ function createCustomerPaymentProfile($existingcustomerprofileid, $phoneNumber){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + $merchantAuthentication->setName("5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); $refId = 'ref' . time(); $creditCard = new AnetAPI\CreditCardType(); diff --git a/CustomerProfiles/create-customer-profile-from-transaction.php b/CustomerProfiles/create-customer-profile-from-transaction.php index 22a651f..be15eee 100644 --- a/CustomerProfiles/create-customer-profile-from-transaction.php +++ b/CustomerProfiles/create-customer-profile-from-transaction.php @@ -8,8 +8,8 @@ function createCustomerProfileFromTransaction() { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + $merchantAuthentication->setName("5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); diff --git a/CustomerProfiles/create-customer-profile.php b/CustomerProfiles/create-customer-profile.php index 954ac5c..7acdbd7 100644 --- a/CustomerProfiles/create-customer-profile.php +++ b/CustomerProfiles/create-customer-profile.php @@ -8,8 +8,8 @@ function createCustomerProfile($email){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + $merchantAuthentication->setName("5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); $refId = 'ref' . time(); // Create the payment data for a credit card diff --git a/CustomerProfiles/create-customer-shipping-address.php b/CustomerProfiles/create-customer-shipping-address.php index 90bf638..246c52b 100644 --- a/CustomerProfiles/create-customer-shipping-address.php +++ b/CustomerProfiles/create-customer-shipping-address.php @@ -7,8 +7,8 @@ function createCustomerShippingAddress($existingcustomerprofileid = "35872074") { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + $merchantAuthentication->setName("5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); // Use An existing customer profile id for this merchant name and transaction key diff --git a/CustomerProfiles/delete-customer-payment-profile.php b/CustomerProfiles/delete-customer-payment-profile.php index 5cbf010..2e81e6a 100644 --- a/CustomerProfiles/delete-customer-payment-profile.php +++ b/CustomerProfiles/delete-customer-payment-profile.php @@ -8,8 +8,8 @@ function deleteCustomerPaymentProfile($customerProfileId="38900575", $customerpa { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + $merchantAuthentication->setName("5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); // 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 d68e2e7..c5c3bfa 100644 --- a/CustomerProfiles/delete-customer-profile.php +++ b/CustomerProfiles/delete-customer-profile.php @@ -8,8 +8,8 @@ function deleteCustomerProfile() { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + $merchantAuthentication->setName("5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); $refId = 'ref' . time(); // Create the payment data for a credit card diff --git a/CustomerProfiles/delete-customer-shipping-address.php b/CustomerProfiles/delete-customer-shipping-address.php index 7294ce0..9ef58e3 100644 --- a/CustomerProfiles/delete-customer-shipping-address.php +++ b/CustomerProfiles/delete-customer-shipping-address.php @@ -7,8 +7,8 @@ function deleteCustomerShippingAddress($customerprofileid = "35872074", $custome { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + $merchantAuthentication->setName("5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); // 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-customer-profile-ids.php b/CustomerProfiles/get-customer-profile-ids.php index f42f127..0370ee3 100644 --- a/CustomerProfiles/get-customer-profile-ids.php +++ b/CustomerProfiles/get-customer-profile-ids.php @@ -7,8 +7,8 @@ function getCustomerProfileIds() { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + $merchantAuthentication->setName("5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); $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 5f3d53a..b769b90 100644 --- a/CustomerProfiles/get-customer-profile.php +++ b/CustomerProfiles/get-customer-profile.php @@ -8,8 +8,8 @@ function getCustomerProfile(){ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + $merchantAuthentication->setName("5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); $refId = 'ref' . time(); // Create the payment data for a credit card diff --git a/CustomerProfiles/update-customer-profile.php b/CustomerProfiles/update-customer-profile.php index a3ca29d..eb90d08 100644 --- a/CustomerProfiles/update-customer-profile.php +++ b/CustomerProfiles/update-customer-profile.php @@ -5,8 +5,8 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + $merchantAuthentication->setName("5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); $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 49f0966..66149ea 100644 --- a/CustomerProfiles/update-customer-shipping-address.php +++ b/CustomerProfiles/update-customer-shipping-address.php @@ -7,8 +7,8 @@ function updateCustomerShippingAddress() { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + $merchantAuthentication->setName("5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); // An existing customer profile id for this merchant name and transaction key $existingcustomerprofileid = "35843932"; diff --git a/PaymentTransactions/capture-funds-authorized-through-another-channel.php b/PaymentTransactions/capture-funds-authorized-through-another-channel.php index 73747ff..874a83a 100644 --- a/PaymentTransactions/capture-funds-authorized-through-another-channel.php +++ b/PaymentTransactions/capture-funds-authorized-through-another-channel.php @@ -7,8 +7,8 @@ function captureFundsAuthorizedThroughAnotherChannel(){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + $merchantAuthentication->setName("5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); $refId = "123456"; $creditCard = new AnetAPI\CreditCardType(); diff --git a/PaymentTransactions/capture-previously-authorized-amount.php b/PaymentTransactions/capture-previously-authorized-amount.php index 5ec062a..7907885 100644 --- a/PaymentTransactions/capture-previously-authorized-amount.php +++ b/PaymentTransactions/capture-previously-authorized-amount.php @@ -7,8 +7,8 @@ function capturePreviouslyAuthorizedAmount($transactionid){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + $merchantAuthentication->setName("5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); $refId = "123456"; // Now capture the previously authorized amount diff --git a/PaymentTransactions/charge-credit-card.php b/PaymentTransactions/charge-credit-card.php index 44f6945..a24b25f 100644 --- a/PaymentTransactions/charge-credit-card.php +++ b/PaymentTransactions/charge-credit-card.php @@ -7,8 +7,8 @@ function chargeCreditCard($amount){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + $merchantAuthentication->setName("5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); $refId = 'ref' . time(); // Create the payment data for a credit card diff --git a/PaymentTransactions/charge-tokenized-credit-card.php b/PaymentTransactions/charge-tokenized-credit-card.php index 589a8f0..241f403 100644 --- a/PaymentTransactions/charge-tokenized-credit-card.php +++ b/PaymentTransactions/charge-tokenized-credit-card.php @@ -7,8 +7,8 @@ function chargeTokenizedCreditCard($amount){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + $merchantAuthentication->setName("5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); $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 fc61386..cbbb897 100644 --- a/PaymentTransactions/credit-bank-account.php +++ b/PaymentTransactions/credit-bank-account.php @@ -7,8 +7,8 @@ function creditBankAccount($transactionid, $amount){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + $merchantAuthentication->setName("5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); $refId = $transactionid; // Create the payment data for a Bank Account $bankAccount = new AnetAPI\BankAccountType(); diff --git a/PaymentTransactions/debit-bank-account.php b/PaymentTransactions/debit-bank-account.php index edc6cb8..72297c2 100644 --- a/PaymentTransactions/debit-bank-account.php +++ b/PaymentTransactions/debit-bank-account.php @@ -7,8 +7,8 @@ function debitBankAccount($amount){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + $merchantAuthentication->setName("5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); $refId = 'ref' . time(); // Create the payment data for a Bank Account diff --git a/PaymentTransactions/refund-transaction.php b/PaymentTransactions/refund-transaction.php index 4ea096c..46ca639 100644 --- a/PaymentTransactions/refund-transaction.php +++ b/PaymentTransactions/refund-transaction.php @@ -7,8 +7,8 @@ function refundTransaction($amount, $transactionid){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + $merchantAuthentication->setName("5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); // Create the payment data for a credit card $creditCard = new AnetAPI\CreditCardType(); diff --git a/PaymentTransactions/void-transaction.php b/PaymentTransactions/void-transaction.php index 2f5f979..a7ec3f7 100644 --- a/PaymentTransactions/void-transaction.php +++ b/PaymentTransactions/void-transaction.php @@ -7,8 +7,8 @@ function voidTransaction($transactionid){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + $merchantAuthentication->setName("5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); // Create the payment data for a credit card $creditCard = new AnetAPI\CreditCardType(); @@ -19,8 +19,7 @@ function voidTransaction($transactionid){ //create a transaction $transactionRequestType = new AnetAPI\TransactionRequestType(); $transactionRequestType->setTransactionType( "voidTransaction"); - $transaction - RequestType->setPayment($paymentOne); + $transactionRequestType->setPayment($paymentOne); $request = new AnetAPI\CreateTransactionRequest(); $request->setMerchantAuthentication($merchantAuthentication); $request->setRefId($transactionid); diff --git a/RecurringBilling/cancel-subscription.php b/RecurringBilling/cancel-subscription.php index 9184740..0aa962c 100644 --- a/RecurringBilling/cancel-subscription.php +++ b/RecurringBilling/cancel-subscription.php @@ -8,8 +8,8 @@ function cancelSubscription($subscriptionId) { // Common Set Up for API Credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName( "556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + $merchantAuthentication->setName( "5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); $refId = 'ref' . time(); diff --git a/RecurringBilling/create-subscription.php b/RecurringBilling/create-subscription.php index a762024..df57678 100644 --- a/RecurringBilling/create-subscription.php +++ b/RecurringBilling/create-subscription.php @@ -9,8 +9,8 @@ function createSubscription($intervalLength) { // Common Set Up for API Credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName( "556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + $merchantAuthentication->setName( "5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); $refId = 'ref' . time(); diff --git a/RecurringBilling/get-list-of-subscriptions.php b/RecurringBilling/get-list-of-subscriptions.php index 45262af..2319047 100644 --- a/RecurringBilling/get-list-of-subscriptions.php +++ b/RecurringBilling/get-list-of-subscriptions.php @@ -8,8 +8,8 @@ function getListOfSubscriptions() { // Common Set Up for API Credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName( "556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + $merchantAuthentication->setName( "5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); $refId = 'ref' . time(); diff --git a/RecurringBilling/get-subscription-status.php b/RecurringBilling/get-subscription-status.php index 399df87..c8e7555 100644 --- a/RecurringBilling/get-subscription-status.php +++ b/RecurringBilling/get-subscription-status.php @@ -8,8 +8,8 @@ function getSubscriptionStatus($subscriptionId) { // Common Set Up for API Credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName( "556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + $merchantAuthentication->setName( "5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); $refId = 'ref' . time(); diff --git a/RecurringBilling/get-subscription.php b/RecurringBilling/get-subscription.php index a515576..aaa7085 100644 --- a/RecurringBilling/get-subscription.php +++ b/RecurringBilling/get-subscription.php @@ -9,8 +9,8 @@ function getSubscription($subscriptionId) { // Common Set Up for API Credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName( "556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + $merchantAuthentication->setName( "5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); $refId = 'ref' . time(); diff --git a/RecurringBilling/update-subscription.php b/RecurringBilling/update-subscription.php index d0f48b6..f90a303 100644 --- a/RecurringBilling/update-subscription.php +++ b/RecurringBilling/update-subscription.php @@ -8,8 +8,8 @@ function updateSubscription($subscriptionId) { // Common Set Up for API Credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName( "556KThWQ6vf2"); - $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); + $merchantAuthentication->setName( "5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); $refId = 'ref' . time(); diff --git a/test-runner.php b/test-runner.php index 9020742..de2be66 100644 --- a/test-runner.php +++ b/test-runner.php @@ -3,7 +3,13 @@ define("SAMPLE_CODE_NAME_HEADING", "SampleCodeName"); require 'vendor/autoload.php'; $directories = array( - 'CustomerProfiles/' + 'CustomerProfiles/', + 'RecurringBilling/', + 'PaypalExpressCheckout/', + 'PaymentTransactions/', + 'TransactionReporting/', + 'ApplePayTransactions/', + 'VisaCheckout/' ); foreach ($directories as $directory) { foreach(glob($directory . "*.php") as $sample) { @@ -19,15 +25,15 @@ class TestRunner extends PHPUnit_Framework_TestCase public static $transactionID = "2245440957"; public static $payerID = "LM6NCLZ5RAKBY"; //random amount for transactions/subscriptions - public static function randAmount(){ + public static function getAmount(){ return 12 + (rand(1, 10000)/12); } //random email for a new customer profile - public static function randEmail(){ + public static function getEmail(){ return rand(0,10000) . "@test.com"; } //random phonenumber for customer payment profile - public static function randPhoneNumber(){ + public static function getPhoneNumber(){ return self::toPhoneNumber(rand(0,9999999999)); } public function getDay(){ @@ -85,12 +91,6 @@ public function testAllSampleCodes(){ echo "Number of sample codes run: ". $runTests; } - public static function runCreateCustomerPaymentProfile() - { - $responseCustomerProfile = createCustomerProfile(); - $existingCustomerProfileId = $responseCustomerProfile->getCustomerProfileId(); - return createCustomerPaymentProfile($existingCustomerProfileId, self::randPhoneNumber()); - } private static function toPhoneNumber($num) { $zeroPadded = sprintf("%10d", $num); @@ -99,71 +99,71 @@ private static function toPhoneNumber($num) public static function runAuthorizeCreditCard() { - return authorizeCreditCard(self::randAmount()); + return authorizeCreditCard(self::getAmount()); } public static function runDebitBankAccount() { - return debitBankAccount(self::randAmount()); + return debitBankAccount(self::getAmount()); } public static function runChargeTokenizedCreditCard() { - return chargeTokenizedCreditCard(self::randAmount()); + return chargeTokenizedCreditCard(self::getAmount()); } public static function runChargeCreditCard() { - return chargeCreditCard(self::randAmount()); + return chargeCreditCard(self::getAmount()); } public static function runCapturePreviouslyAuthorizedAmount() { - $response = authorizeCreditCard(self::randAmount()); - return capturePreviouslyAuthorizedAmount(response->getTransactionResponse()->getTransId()); + $response = authorizeCreditCard(self::getAmount()); + return capturePreviouslyAuthorizedAmount($response->getTransactionResponse()->getTransId()); } public static function runRefundTransaction() { - $response = authorizeCreditCard.run(self::randAmount()); + $response = authorizeCreditCard.run(self::getAmount()); $response = capturePreviouslyAuthorizedAmount($response->getTransactionResponse()->getTransId()); - return refundTransaction(self::randAmount(), response->getTransactionResponse()->getTransId()); + return refundTransaction(self::getAmount(), $response->getTransactionResponse()->getTransId()); } public static function runVoidTransaction() { - $response = authorizeCreditCard(self::randAmount()); + $response = authorizeCreditCard(self::getAmount()); return voidTransaction($response->getTransactionResponse()->getTransId()); } public static function runCreditBankAccount() { - return creditBankAccount(self::$transactionID, self::randAmount()); + return creditBankAccount(self::$transactionID, self::getAmount()); } public static function runChargeCustomerProfile() { - $response = createCustomerProfile(self::randEmail()); - $paymentProfileResponse = createCustomerPaymentProfile(response->getCustomerProfileId()); - $chargeResponse = chargeCustomerProfile(response->getCustomerProfileId(), paymentProfileResponse->getCustomerPaymentProfileId(), self::randAmount()); - deleteCustomerProfile(response->getCustomerProfileId()); + $response = createCustomerProfile(self::getEmail()); + $paymentProfileResponse = createCustomerPaymentProfile($response->getCustomerProfileId()); + $chargeResponse = chargeCustomerProfile($response->getCustomerProfileId(), $paymentProfileResponse->getCustomerPaymentProfileId(), self::getAmount()); + deleteCustomerProfile($response->getCustomerProfileId()); return $chargeResponse; } private static function runPayPalVoid() { - $response = payPalAuthorizeCapture(self::randAmount()); + $response = payPalAuthorizeCapture(self::getAmount()); return payPalVoid($response->getTransactionResponse()->getTransId()); } private static function runPayPalAuthorizeCapture() { - return payPalAuthorizeCapture(self::randAmount()); + return payPalAuthorizeCapture(self::getAmount()); } private static function runPayPalAuthorizeCaptureContinue() { - $response = payPalAuthorizeCapture(self::randAmount()); + $response = payPalAuthorizeCapture(self::getAmount()); return payPalAuthorizeCaptureContinue($response->getTransactionResponse()->getTransId(), self::$payerID); } @@ -178,13 +178,134 @@ public static function runPayPalCredit() { public static function runPayPalGetDetails() { - $response = payPalAuthorizeCapture(self::randAmount()); + $response = payPalAuthorizeCapture(self::getAmount()); return payPalGetDetails($response->getTransactionResponse()->getTransId()); } public static function runPayPalPriorAuthorizationCapture() { - $response = payPalAuthorizeCapture(self::randAmount()); - return payPalPriorAuthorizationCapture($response->getTransactionResponse()->getTransId()) + $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 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::randEmail()); + $customerProfileId = $response->getCustomerProfileId(); + deleteCustomerProfileWithId($customerProfileId); + return $response; + } + public static function runGetCustomerProfile(){ + $responseCustomerProfile = createCustomerProfile(self::randEmail()); + $existingCustomerProfileId = $responseCustomerProfile->getCustomerProfileId(); + $response = getCustomerProfile($existingCustomerProfileId); + return $response; + } + public static function runUpdateCustomerProfile(){ + $responseCustomerProfile = createCustomerProfile(self::randEmail()); + $customerProfileId = $responseCustomerProfile->getCustomerProfileId(); + $response = updateCustomerProfileById($customerProfileId); + deleteCustomerProfileWithId($customerProfileId); + return $response; + } + //customer profiles - payment profiles methods + + public static function runCreateCustomerPaymentProfile() + { + $responseCustomerProfile = createCustomerProfile(self::randEmail()); + $existingCustomerProfileId = $responseCustomerProfile->getCustomerProfileId(); + $response=createCustomerPaymentProfile($existingCustomerProfileId, self::randPhoneNumber()); + return $response; + } + public static function runGetCustomerPaymentProfile(){ + $customerProfileId = createCustomerProfile(self::randEmail())->getCustomerProfileId(); + $customerPaymentProfileId = createCustomerPaymentProfile($customerProfileId, self::randPhoneNumber()) + ->getCustomerPaymentProfileId(); + $response= getCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId); + deleteCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId); + return $response; + } + public static function runValidateCustomerPaymentProfile(){ + $customerProfileId = createCustomerProfile(self::randEmail())->getCustomerProfileId(); + $customerPaymentProfileId = createCustomerPaymentProfile($customerProfileId, self::randPhoneNumber()) + ->getCustomerPaymentProfileId(); + $response= getCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId); + validateCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId); + return $response; + } + public static function runUpdateCustomerPaymentProfile(){ + $customerProfileId = createCustomerProfile(self::randEmail())->getCustomerProfileId(); + $customerPaymentProfileId = createCustomerPaymentProfile($customerProfileId, self::randPhoneNumber())->getCustomerPaymentProfileId(); + $response= getCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId); + updateCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId); + return $response; + } + public static function runDeleteCustomerPaymentProfile(){ + $customerProfileId = createCustomerProfile(self::randEmail())->getCustomerProfileId(); + $customerPaymentProfileId = createCustomerPaymentProfile($customerProfileId, self::randPhoneNumber()) + ->getCustomerPaymentProfileId(); + $response= getCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId); + deleteCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId); + return $response; + } + //customer profiles - shipping address + public static function runCreateCustomerShippingAddress(){ + $customerProfileId = createCustomerProfile(self::randEmail())->getCustomerProfileId(); + $response = createCustomerShippingAddress($customerProfileId, self::randPhoneNumber()); + deleteCustomerShippingAddress($customerProfileId, $response->getCustomerShippingAddressId()); + return $response; + } + public static function runDeleteCustomerShippingAddress(){ + $customerProfileId = createCustomerProfile(self::randEmail())->getCustomerProfileId(); + $responseCreateShipping = createCustomerShippingAddress($customerProfileId, self::randPhoneNumber()); + return deleteCustomerShippingAddress($customerProfileId, $responsCreateShippinge->getCustomerShippingAddressId()); + } } \ No newline at end of file From 162fc50a96e88498d6b28457c0931d92dd6be419 Mon Sep 17 00:00:00 2001 From: srathod Date: Thu, 14 Jan 2016 19:08:54 +0530 Subject: [PATCH 024/287] 38 samples running in test-runner.php --- CustomerProfiles/create-customer-profile.php | 3 +- CustomerProfiles/delete-customer-profile.php | 61 +----- CustomerProfiles/get-customer-profile-ids.php | 44 ++--- .../get-customer-shipping-address.php | 6 +- CustomerProfiles/get-hosted-profile-page.php | 6 +- .../update-customer-payment-profile.php | 4 +- CustomerProfiles/update-customer-profile.php | 184 +++++++++--------- .../update-customer-shipping-address.php | 5 +- ...nds-authorized-through-another-channel.php | 6 +- PaymentTransactions/charge-credit-card.php | 4 +- PaymentTransactions/debit-bank-account.php | 2 +- PaymentTransactions/void-transaction.php | 3 +- PaypalExpressCheckout/authorization-only.php | 6 +- PaypalExpressCheckout/get-details.php | 11 +- .../get-list-of-subscriptions.php | 2 +- SampleCodeList.txt | 20 +- test-runner.php | 170 +++++++++++----- 17 files changed, 284 insertions(+), 253 deletions(-) diff --git a/CustomerProfiles/create-customer-profile.php b/CustomerProfiles/create-customer-profile.php index 7acdbd7..d17e57d 100644 --- a/CustomerProfiles/create-customer-profile.php +++ b/CustomerProfiles/create-customer-profile.php @@ -44,8 +44,7 @@ function createCustomerProfile($email){ $paymentprofiles[] = $paymentprofile; $customerprofile = new AnetAPI\CustomerProfileType(); $customerprofile->setDescription("Customer 2 Test PHP"); - if(-1 == $merchantCustomerId) - $merchantCustomerId=time().rand(1,150); + $customerprofile->setMerchantCustomerId("M_".$email); $customerprofile->setEmail($email); $customerprofile->setPaymentProfiles($paymentprofiles); diff --git a/CustomerProfiles/delete-customer-profile.php b/CustomerProfiles/delete-customer-profile.php index c5c3bfa..815f960 100644 --- a/CustomerProfiles/delete-customer-profile.php +++ b/CustomerProfiles/delete-customer-profile.php @@ -4,7 +4,7 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - function deleteCustomerProfile() + function deleteCustomerProfile($customerProfileId) { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); @@ -12,62 +12,10 @@ function deleteCustomerProfile() $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); $refId = 'ref' . time(); - // 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); - - // 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 - - $paymentprofile = new AnetAPI\CustomerPaymentProfileType(); - - $paymentprofile->setCustomerType('individual'); - $paymentprofile->setBillTo($billto); - $paymentprofile->setPayment($paymentCreditCard); - $paymentprofiles[] = $paymentprofile; - $customerprofile = new AnetAPI\CustomerProfileType(); - $customerprofile->setDescription("Create Customer Profile Request Test for PHP"); - $merchantCustomerId = time().rand(1,150); - $customerprofile->setMerchantCustomerId($merchantCustomerId); - $customerprofile->setEmail("customerprofile@domain.com"); - $customerprofile->setPaymentProfiles($paymentprofiles); - - $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 "SUCCESS: CreateCustomerProfile PROFILE ID : " . $response->getCustomerProfileId() . "\n"; - - $profileidcreated = $response->getCustomerProfileId(); - } - else - { - echo "ERROR : CreateCustomerProfile: Invalid response\n"; - } // Delete an existing customer profile $request = new AnetAPI\DeleteCustomerProfileRequest(); $request->setMerchantAuthentication($merchantAuthentication); - $request->setCustomerProfileId( $profileidcreated ); + $request->setCustomerProfileId( $customerProfileId ); $controller = new AnetController\DeleteCustomerProfileController($request); $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); @@ -81,7 +29,10 @@ function deleteCustomerProfile() echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; } + + return $response; } + if(!defined(DONT_RUN_SAMPLES)) - deleteCustomerProfile(); + deleteCustomerProfile("2133432"); ?> diff --git a/CustomerProfiles/get-customer-profile-ids.php b/CustomerProfiles/get-customer-profile-ids.php index 0370ee3..4c5ae51 100644 --- a/CustomerProfiles/get-customer-profile-ids.php +++ b/CustomerProfiles/get-customer-profile-ids.php @@ -5,29 +5,29 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); function getCustomerProfileIds() { - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); - $refId = 'ref' . time(); + // Common setup for API credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName("5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $refId = 'ref' . time(); - // Get all existing customer profile ID's - $request = new AnetAPI\GetCustomerProfileIdsRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $controller = new AnetController\GetCustomerProfileIdsController($request); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) - { - echo "GetCustomerProfileId's SUCCESS: " . "\n"; - $profileIds[] = $response->getIds(); - echo "There are " . count($profileIds[0]) . " Customer Profile ID's for this Merchant Name and Transaction Key" . "\n"; - } - else - { - echo "GetCustomerProfileId's ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; - } - return $response; + // Get all existing customer profile ID's + $request = new AnetAPI\GetCustomerProfileIdsRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $controller = new AnetController\GetCustomerProfileIdsController($request); + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) + { + echo "GetCustomerProfileId's SUCCESS: " . "\n"; + $profileIds[] = $response->getIds(); + echo "There are " . count($profileIds[0]) . " Customer Profile ID's for this Merchant Name and Transaction Key" . "\n"; + } + else + { + echo "GetCustomerProfileId's ERROR : Invalid response\n"; + echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + } + return $response; } if(!defined(DONT_RUN_SAMPLES)) getCustomerProfileIds(); diff --git a/CustomerProfiles/get-customer-shipping-address.php b/CustomerProfiles/get-customer-shipping-address.php index 68d3bab..0ec0052 100644 --- a/CustomerProfiles/get-customer-shipping-address.php +++ b/CustomerProfiles/get-customer-shipping-address.php @@ -3,7 +3,7 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - function getCustomerShippingAddress() + function getCustomerShippingAddress($customerprofileid, $customeraddressid) { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); @@ -11,8 +11,8 @@ function getCustomerShippingAddress() $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); // An existing customer profile id and shipping address id for this merchant name and transaction key - $customerProfileId = "36731856"; - $customerAddressId = "35850995"; + $customerProfileId = $customerprofileid; + $customerAddressId = $customeraddressid; $request = new AnetAPI\GetCustomerShippingAddressRequest(); $request->setMerchantAuthentication($merchantAuthentication); diff --git a/CustomerProfiles/get-hosted-profile-page.php b/CustomerProfiles/get-hosted-profile-page.php index 344c48a..8e6d5cd 100644 --- a/CustomerProfiles/get-hosted-profile-page.php +++ b/CustomerProfiles/get-hosted-profile-page.php @@ -8,8 +8,8 @@ function getHostedProfilePage($customerprofileid = "37680862") { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("3Zw3Ru9nx"); - $merchantAuthentication->setTransactionKey("7Tbj6T3a9cPq4A5d"); + $merchantAuthentication->setName("5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); // Use an existing payment profile ID for this Merchant name and Transaction key @@ -43,5 +43,5 @@ function getHostedProfilePage($customerprofileid = "37680862") return $response; } if(!defined(DONT_RUN_SAMPLES)) - getHostedProfielPage(); + getHostedProfilePage(); ?> \ No newline at end of file diff --git a/CustomerProfiles/update-customer-payment-profile.php b/CustomerProfiles/update-customer-payment-profile.php index 69f2d38..012f2a8 100644 --- a/CustomerProfiles/update-customer-payment-profile.php +++ b/CustomerProfiles/update-customer-payment-profile.php @@ -22,8 +22,8 @@ function updateCustomerPaymentProfile($customerProfileId="36731856", $customerPa // 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( "XXXX1111" ); - $creditCard->setExpirationDate( "XXXX"); + $creditCard->setCardNumber( "4111111111111111" ); + $creditCard->setExpirationDate( "0718"); $paymentCreditCard = new AnetAPI\PaymentType(); $paymentCreditCard->setCreditCard($creditCard); diff --git a/CustomerProfiles/update-customer-profile.php b/CustomerProfiles/update-customer-profile.php index eb90d08..2ea83bd 100644 --- a/CustomerProfiles/update-customer-profile.php +++ b/CustomerProfiles/update-customer-profile.php @@ -3,103 +3,109 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); - $refId = 'ref' . time(); - // 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); + function updateCustomerProfile() { + // Common setup for API credentials + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName("5KP3u95bQpv"); + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $refId = 'ref' . time(); - // 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 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); - $paymentprofile = new AnetAPI\CustomerPaymentProfileType(); + // 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 - $paymentprofile->setCustomerType('individual'); - $paymentprofile->setBillTo($billto); - $paymentprofile->setPayment($paymentCreditCard); - $paymentprofiles[] = $paymentprofile; - $customerprofile = new AnetAPI\CustomerProfileType(); - $customerprofile->setDescription("Update Customer Profile Request Test for PHP"); - $merchantCustomerId = time().rand(1,150); - $customerprofile->setMerchantCustomerId($merchantCustomerId); - $customerprofile->setEmail("customerprofile@domain.com"); - $customerprofile->setPaymentProfiles($paymentprofiles); + $paymentprofile = new AnetAPI\CustomerPaymentProfileType(); - $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 "SUCCESS: CreateCustomerProfile PROFILE ID : " . $response->getCustomerProfileId() . "\n"; + $paymentprofile->setCustomerType('individual'); + $paymentprofile->setBillTo($billto); + $paymentprofile->setPayment($paymentCreditCard); + $paymentprofiles[] = $paymentprofile; + $customerprofile = new AnetAPI\CustomerProfileType(); + $customerprofile->setDescription("Update Customer Profile Request Test for PHP"); + $merchantCustomerId = time().rand(1,150); + $customerprofile->setMerchantCustomerId($merchantCustomerId); + $customerprofile->setEmail(rand(0,10000) . "@test.com"); + $customerprofile->setPaymentProfiles($paymentprofiles); - $profileidcreated = $response->getCustomerProfileId(); - } - else - { - echo "ERROR : CreateCustomerProfile: Invalid response\n"; - } - // Update an existing customer profile + $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 "SUCCESS: CreateCustomerProfile PROFILE ID : " . $response->getCustomerProfileId() . "\n"; - $updatecustomerprofile = new AnetAPI\CustomerProfileExType(); - $updatecustomerprofile->setCustomerProfileId($profileidcreated); - $updatecustomerprofile->setDescription("Updated existing Profile Request"); - $updatecustomerprofile->setEmail("updatecustomerprofile@domain.com"); + $profileidcreated = $response->getCustomerProfileId(); + } + else + { + echo "ERROR : CreateCustomerProfile: Invalid response\n"; + } + // Update an existing customer profile - $request = new AnetAPI\UpdateCustomerProfileRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setProfile($updatecustomerprofile); + $updatecustomerprofile = new AnetAPI\CustomerProfileExType(); + $updatecustomerprofile->setCustomerProfileId($profileidcreated); + $updatecustomerprofile->setDescription("Updated existing Profile Request"); + $updatecustomerprofile->setEmail("updated".rand(0,10000)."@test.com"); - $controller = new AnetController\UpdateCustomerProfileController($request); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) - { - echo "UpdateCustomerProfile SUCCESS : " . "\n"; - // Validate the description and e-mail that was updated - $request = new AnetAPI\GetCustomerProfileRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setCustomerProfileId($profileidcreated ); - $controller = new AnetController\GetCustomerProfileController($request); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) - { - echo "Get updated CustomerProfile SUCCESS : " . "\n"; - $profileselected = $response->getProfile(); - echo "Updated Customer Profile Customer description : " . $profileselected->getDescription() . "\n"; - echo "Updated Customer Profile EMail description : " . $profileselected->getEmail() . "\n"; - } - else - { - echo "ERROR : GetCustomerProfile: Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; - } - } - else - { - echo "ERROR : UpdateCustomerProfile: Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + $request = new AnetAPI\UpdateCustomerProfileRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setProfile($updatecustomerprofile); + + $controller = new AnetController\UpdateCustomerProfileController($request); + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) + { + echo "UpdateCustomerProfile SUCCESS : " . "\n"; + // Validate the description and e-mail that was updated + $request = new AnetAPI\GetCustomerProfileRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setCustomerProfileId($profileidcreated ); + $controller = new AnetController\GetCustomerProfileController($request); + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) + { + echo "Get updated CustomerProfile SUCCESS : " . "\n"; + $profileselected = $response->getProfile(); + echo "Updated Customer Profile Customer description : " . $profileselected->getDescription() . "\n"; + echo "Updated Customer Profile EMail description : " . $profileselected->getEmail() . "\n"; + } + else + { + echo "ERROR : GetCustomerProfile: Invalid response\n"; + echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + } + } + else + { + echo "ERROR : UpdateCustomerProfile: Invalid response\n"; + echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + } + return $response; } + if(!defined(DONT_RUN_SAMPLES)) + updateCustomerProfile(); ?> diff --git a/CustomerProfiles/update-customer-shipping-address.php b/CustomerProfiles/update-customer-shipping-address.php index 66149ea..241a718 100644 --- a/CustomerProfiles/update-customer-shipping-address.php +++ b/CustomerProfiles/update-customer-shipping-address.php @@ -3,7 +3,7 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - function updateCustomerShippingAddress() + function updateCustomerShippingAddress($customerprofileid, $customeraddressid) { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); @@ -11,7 +11,7 @@ function updateCustomerShippingAddress() $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); // An existing customer profile id for this merchant name and transaction key - $existingcustomerprofileid = "35843932"; + $existingcustomerprofileid = $customerprofileid; // Create the customer shipping address $customershippingaddress = new AnetAPI\CustomerAddressExType(); @@ -25,6 +25,7 @@ function updateCustomerShippingAddress() $customershippingaddress->setCountry("USA"); $customershippingaddress->setPhoneNumber("201-000-0000"); $customershippingaddress->setFaxNumber("973-999-9999"); + $customershippingaddress->setCustomerAddressId($customeraddressid); // Update an existing customer shipping address for an existing customer profile $request = new AnetAPI\UpdateCustomerShippingAddressRequest(); diff --git a/PaymentTransactions/capture-funds-authorized-through-another-channel.php b/PaymentTransactions/capture-funds-authorized-through-another-channel.php index 874a83a..b94ef37 100644 --- a/PaymentTransactions/capture-funds-authorized-through-another-channel.php +++ b/PaymentTransactions/capture-funds-authorized-through-another-channel.php @@ -4,7 +4,7 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); -function captureFundsAuthorizedThroughAnotherChannel(){ +function captureFundsAuthorizedThroughAnotherChannel($amount){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName("5KP3u95bQpv"); @@ -20,7 +20,7 @@ function captureFundsAuthorizedThroughAnotherChannel(){ $transactionRequestType = new AnetAPI\TransactionRequestType(); $transactionRequestType->setTransactionType("captureOnlyTransaction"); - $transactionRequestType->setAmount(5.00); + $transactionRequestType->setAmount($amount); $transactionRequestType->setPayment($paymentOne); //Auth code of the previously authorized amount @@ -55,5 +55,5 @@ function captureFundsAuthorizedThroughAnotherChannel(){ return $response; } if(!defined(DONT_RUN_SAMPLES)) - captureFundsAuthorizedThroughAnotherChannel(); + captureFundsAuthorizedThroughAnotherChannel(5.0); ?> diff --git a/PaymentTransactions/charge-credit-card.php b/PaymentTransactions/charge-credit-card.php index a24b25f..1619a3b 100644 --- a/PaymentTransactions/charge-credit-card.php +++ b/PaymentTransactions/charge-credit-card.php @@ -41,7 +41,7 @@ function chargeCreditCard($amount){ // Customer info $customer = new AnetAPI\CustomerDataType(); $customer->setId("15"); - $customer->setEmail("foo@example.com"); + $customer->setEmail(rand(0,10000) . "@test.com"); // PO Number $ponumber = "15"; @@ -91,7 +91,7 @@ function chargeCreditCard($amount){ { $tresponse = $response->getTransactionResponse(); - if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + if (($tresponse != null) && ($tresponse->getResponseCode()=="Ok") ) { echo "Charge Credit Card AUTH CODE : " . $tresponse->getAuthCode() . "\n"; echo "Charge Credit Card TRANS ID : " . $tresponse->getTransId() . "\n"; diff --git a/PaymentTransactions/debit-bank-account.php b/PaymentTransactions/debit-bank-account.php index 72297c2..53e81d7 100644 --- a/PaymentTransactions/debit-bank-account.php +++ b/PaymentTransactions/debit-bank-account.php @@ -67,5 +67,5 @@ function debitBankAccount($amount){ return $response; } if(!defined(DONT_RUN_SAMPLES)) - debitBankAccount(); + debitBankAccount(21.34); ?> diff --git a/PaymentTransactions/void-transaction.php b/PaymentTransactions/void-transaction.php index a7ec3f7..825b073 100644 --- a/PaymentTransactions/void-transaction.php +++ b/PaymentTransactions/void-transaction.php @@ -20,9 +20,10 @@ function voidTransaction($transactionid){ $transactionRequestType = new AnetAPI\TransactionRequestType(); $transactionRequestType->setTransactionType( "voidTransaction"); $transactionRequestType->setPayment($paymentOne); + $transactionRequestType->setRefTransId($transactionid); + $request = new AnetAPI\CreateTransactionRequest(); $request->setMerchantAuthentication($merchantAuthentication); - $request->setRefId($transactionid); $request->setTransactionRequest( $transactionRequestType); $controller = new AnetController\CreateTransactionController($request); $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); diff --git a/PaypalExpressCheckout/authorization-only.php b/PaypalExpressCheckout/authorization-only.php index d6a127c..8e59883 100644 --- a/PaypalExpressCheckout/authorization-only.php +++ b/PaypalExpressCheckout/authorization-only.php @@ -6,7 +6,7 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); -function payPalAuthorizeOnly() { +function payPalAuthorizeOnly($amount) { // Common setup for API credentials (Paypal compatible merchant) $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName("5KP3u95bQpv"); @@ -23,7 +23,7 @@ function payPalAuthorizeOnly() { //create a auth-only transaction $transactionRequestType = new AnetAPI\TransactionRequestType(); $transactionRequestType->setTransactionType( "authOnlyTransaction"); - $transactionRequestType->setAmount(921); + $transactionRequestType->setAmount($amount); $transactionRequestType->setPayment($paymentOne); $request = new AnetAPI\CreateTransactionRequest(); @@ -54,6 +54,6 @@ function payPalAuthorizeOnly() { } if(!defined(DONT_RUN_SAMPLES)) - payPalAuthorizeOnly(); + payPalAuthorizeOnly(23.34); ?> diff --git a/PaypalExpressCheckout/get-details.php b/PaypalExpressCheckout/get-details.php index 37d437a..3522121 100644 --- a/PaypalExpressCheckout/get-details.php +++ b/PaypalExpressCheckout/get-details.php @@ -24,6 +24,15 @@ function payPalGetDetails($transactionId) { //replace following transaction ID with your transaction ID for which the details are required $transactionRequestType->setRefTransId($transactionId); + // Create the payment data for a paypal account + $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); + + $transactionRequestType->setPayment($paymentOne); + //create a transaction request $request = new AnetAPI\CreateTransactionRequest(); $request->setMerchantAuthentication($merchantAuthentication); @@ -48,7 +57,7 @@ function payPalGetDetails($transactionId) { echo "Shipping address : " . $shipping_response->getAddress() . ", " . $shipping_response->getCity() . ", " . $shipping_response->getState() . ", " . $shipping_response->getCountry() . "\n"; - echo "Payer ID : " . $tresponse->getSecureAcceptance()->getPayerID(); + //echo "Payer ID : " . $tresponse->getSecureAcceptance()->getPayerID(); } else { diff --git a/RecurringBilling/get-list-of-subscriptions.php b/RecurringBilling/get-list-of-subscriptions.php index 2319047..8dbdf3b 100644 --- a/RecurringBilling/get-list-of-subscriptions.php +++ b/RecurringBilling/get-list-of-subscriptions.php @@ -35,7 +35,7 @@ function getListOfSubscriptions() { if (($response != null) && ($response->getMessages()->getResultCode() == "Ok")) { - echo "SUCCESS: Subscription Details:" . $response->getSubscriptionDetails() . "\n"; + //echo "SUCCESS: Subscription Details:" . $response->getSubscriptionDetails() . "\n"; echo "Total Number In Results:" . $response->getTotalNumInResultSet() . "\n"; } else diff --git a/SampleCodeList.txt b/SampleCodeList.txt index 3535b85..861a537 100644 --- a/SampleCodeList.txt +++ b/SampleCodeList.txt @@ -1,26 +1,26 @@ SampleCodeName,IsDependent,ShouldRun +ChargeCreditCard,1,1 CreateSubscription,1,1 GetCustomerPaymentProfileList,0,1 GetTransactionList,0,1 CreateAnApplePayTransaction,0,0 DecryptVisaCheckoutData,0,1 CreateVisaCheckoutTransaction,0,0 -CaptureFundsAuthorizedThroughAnotherChannel,0,1 +CaptureFundsAuthorizedThroughAnotherChannel,1,1 AuthorizeCreditCard,1,1 -DebitBankAccount,0,1 +DebitBankAccount,1,1 ChargeTokenizedCreditCard,0,0 -PayPalAuthorizeOnly,0,1 +PayPalAuthorizeOnly,1,1 GetListOfSubscriptions,0,1 GetUnsettledTransactionList,0,1 GetBatchStatistics,0,1 GetSettledBatchList,0,1 UpdateSplitTenderGroup,0,1 -ValidateCustomerPaymentProfile,1,1 UpdateCustomerShippingAddress,1,1 -UpdateCustomerProfile,1,1 +UpdateCustomerProfile,0,1 UpdateCustomerPaymentProfile,1,1 GetCustomerShippingAddress,1,1 -GetCustomerProfileIds,1,1 +GetCustomerProfileIds,0,1 GetCustomerProfile,1,1 GetHostedProfilePage,1,1 GetCustomerPaymentProfile,1,1 @@ -28,12 +28,11 @@ DeleteCustomerShippingAddress,1,1 DeleteCustomerProfile,1,1 DeleteCustomerPaymentProfile,1,1 CreateCustomerShippingAddress,1,1 -CreateCustomerProfileFromTransaction,1,0 +CreateCustomerProfileFromTransaction,0,0 GetTransactionDetails,1,1 -ChargeCreditCard,1,1 CapturePreviouslyAuthorizedgetAmount,1,0 -Refund,1,0 -Void,1,1 +RefundTransaction,1,0 +VoidTransaction,1,1 CreditBankAccount,1,0 ChargeCustomerProfile,1,1 PayPalVoid,1,0 @@ -49,3 +48,4 @@ GetSubscription,1,1 UpdateSubscription,1,1 CreateCustomerProfile,1,1 CreateCustomerPaymentProfile,1,1 +ValidateCustomerPaymentProfile,1,0 \ No newline at end of file diff --git a/test-runner.php b/test-runner.php index de2be66..69c5ca2 100644 --- a/test-runner.php +++ b/test-runner.php @@ -1,4 +1,7 @@ getCustomerProfileId()); + $paymentProfileResponse = createCustomerPaymentProfile($response->getCustomerProfileId(), self::getPhoneNumber()); $chargeResponse = chargeCustomerProfile($response->getCustomerProfileId(), $paymentProfileResponse->getCustomerPaymentProfileId(), self::getAmount()); deleteCustomerProfile($response->getCustomerProfileId()); @@ -176,6 +184,11 @@ public static function runPayPalCredit() { return payPalCredit(self::$transactionID); } + public static function runPayPalAuthorizeOnly() + { + return payPalAuthorizeOnly(self::getAmount()); + } + public static function runPayPalGetDetails() { $response = payPalAuthorizeCapture(self::getAmount()); @@ -191,7 +204,7 @@ public static function runPayPalPriorAuthorizationCapture() public static function runGetTransactionDetails() { $response = authorizeCreditCard(self::getAmount()); - return getTransactionDetails($response.getTransactionResponse().getTransId()); + return getTransactionDetails($response->getTransactionResponse()->getTransId()); } @@ -238,74 +251,125 @@ public static function runUpdateSubscription() //customer profiles methods public static function runCreateCustomerProfile(){ - $response = createCustomerProfile(self::randEmail()); - $customerProfileId = $response->getCustomerProfileId(); - deleteCustomerProfileWithId($customerProfileId); + + $response = createCustomerProfile(self::getEmail()); + deleteCustomerProfile($response->getCustomerProfileId()); return $response; } - public static function runGetCustomerProfile(){ - $responseCustomerProfile = createCustomerProfile(self::randEmail()); - $existingCustomerProfileId = $responseCustomerProfile->getCustomerProfileId(); - $response = getCustomerProfile($existingCustomerProfileId); - return $response; + + public static function runDeleteCustomerProfile(){ + + $responseCustomerProfile = createCustomerProfile(self::getEmail()); + return deleteCustomerProfile($responseCustomerProfile->getCustomerProfileId()); } - public static function runUpdateCustomerProfile(){ - $responseCustomerProfile = createCustomerProfile(self::randEmail()); - $customerProfileId = $responseCustomerProfile->getCustomerProfileId(); - $response = updateCustomerProfileById($customerProfileId); - deleteCustomerProfileWithId($customerProfileId); + + 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::randEmail()); - $existingCustomerProfileId = $responseCustomerProfile->getCustomerProfileId(); - $response=createCustomerPaymentProfile($existingCustomerProfileId, self::randPhoneNumber()); + $responseCustomerProfile = createCustomerProfile(self::getEmail()); + $response=createCustomerPaymentProfile($responseCustomerProfile->getCustomerProfileId(), self::getPhoneNumber()); + deleteCustomerProfile($responseCustomerProfile->getCustomerProfileId()); return $response; } - public static function runGetCustomerPaymentProfile(){ - $customerProfileId = createCustomerProfile(self::randEmail())->getCustomerProfileId(); - $customerPaymentProfileId = createCustomerPaymentProfile($customerProfileId, self::randPhoneNumber()) - ->getCustomerPaymentProfileId(); + + public static function runGetCustomerPaymentProfile() + { + $customerProfileId = createCustomerProfile(self::getEmail())->getCustomerProfileId(); + $customerPaymentProfileId = createCustomerPaymentProfile($customerProfileId, self::getPhoneNumber())->getCustomerPaymentProfileId(); $response= getCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId); - deleteCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId); + deleteCustomerProfile($customerProfileId); return $response; } - public static function runValidateCustomerPaymentProfile(){ - $customerProfileId = createCustomerProfile(self::randEmail())->getCustomerProfileId(); - $customerPaymentProfileId = createCustomerPaymentProfile($customerProfileId, self::randPhoneNumber()) - ->getCustomerPaymentProfileId(); - $response= getCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId); - validateCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId); + + 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::randEmail())->getCustomerProfileId(); - $customerPaymentProfileId = createCustomerPaymentProfile($customerProfileId, self::randPhoneNumber())->getCustomerPaymentProfileId(); - $response= getCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId); - updateCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId); + + 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::randEmail())->getCustomerProfileId(); - $customerPaymentProfileId = createCustomerPaymentProfile($customerProfileId, self::randPhoneNumber()) - ->getCustomerPaymentProfileId(); - $response= getCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId); - deleteCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId); + + 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::randEmail())->getCustomerProfileId(); - $response = createCustomerShippingAddress($customerProfileId, self::randPhoneNumber()); - deleteCustomerShippingAddress($customerProfileId, $response->getCustomerShippingAddressId()); + 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 runDeleteCustomerShippingAddress(){ - $customerProfileId = createCustomerProfile(self::randEmail())->getCustomerProfileId(); - $responseCreateShipping = createCustomerShippingAddress($customerProfileId, self::randPhoneNumber()); - return deleteCustomerShippingAddress($customerProfileId, $responsCreateShippinge->getCustomerShippingAddressId()); - } + + 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 runGetHostedProfilePage() + { + $response = createCustomerProfile(self::getEmail()); + $profileResponse = getHostedProfilePage($response->getCustomerProfileId()); + deleteCustomerProfile($response->getCustomerProfileId()); + + return $profileResponse; + } } \ No newline at end of file From 8225e32be5c8e73d25560160668a1ddad6169885 Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Thu, 14 Jan 2016 20:31:18 +0530 Subject: [PATCH 025/287] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2a9cd0d..0e88f4b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,4 +10,4 @@ before_script: - composer install --prefer-dist --dev script: - - vendor/phpunit/phpunit/phpunit + - phpunit test-runner.php From d97da7132c5d8f2c663497a3743f6f5572505d84 Mon Sep 17 00:00:00 2001 From: srathod Date: Thu, 14 Jan 2016 20:39:49 +0530 Subject: [PATCH 026/287] - Updated charge-credit-card.php, travis build fix. --- PaymentTransactions/charge-credit-card.php | 56 ---------------------- 1 file changed, 56 deletions(-) diff --git a/PaymentTransactions/charge-credit-card.php b/PaymentTransactions/charge-credit-card.php index 1619a3b..c58df9c 100644 --- a/PaymentTransactions/charge-credit-card.php +++ b/PaymentTransactions/charge-credit-card.php @@ -18,67 +18,11 @@ function chargeCreditCard($amount){ $paymentOne = new AnetAPI\PaymentType(); $paymentOne->setCreditCard($creditCard); - // Order info - $order = new AnetAPI\OrderType(); - $order->setInvoiceNumber("101"); - $order->setDescription("Golf Shirts"); - - // Line Item Info - $lineitem = new AnetAPI\LineItemType(); - $lineitem->setItemId("Shirts"); - $lineitem->setName("item1"); - $lineitem->setDescription("golf shirt"); - $lineitem->setQuantity("1"); - $lineitem->setUnitPrice($amount); - $lineitem->setTaxable(false); - - // Tax info - $tax = new AnetAPI\ExtendedAmountType(); - $tax->setName("level 2 tax name"); - $tax->setAmount($amount); - $tax->setDescription("level 2 tax"); - - // Customer info - $customer = new AnetAPI\CustomerDataType(); - $customer->setId("15"); - $customer->setEmail(rand(0,10000) . "@test.com"); - - // PO Number - $ponumber = "15"; - //Ship To Info - $shipto = new AnetAPI\NameAndAddressType(); - $shipto->setFirstName("Bayles"); - $shipto->setLastName("China"); - $shipto->setCompany("Thyme for Tea"); - $shipto->setAddress("12 Main Street"); - $shipto->setCity("Pecan Springs"); - $shipto->setState("TX"); - $shipto->setZip("44628"); - $shipto->setCountry("USA"); - - // Bill To - $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 transaction $transactionRequestType = new AnetAPI\TransactionRequestType(); $transactionRequestType->setTransactionType( "authCaptureTransaction"); $transactionRequestType->setAmount($amount); $transactionRequestType->setPayment($paymentOne); - $transactionRequestType->setOrder($order); - $transactionRequestType->addToLineItems($lineitem); - $transactionRequestType->setTax($tax); - $transactionRequestType->setPoNumber($ponumber); - $transactionRequestType->setCustomer($customer); - $transactionRequestType->setBillTo($billto); - $transactionRequestType->setShipTo($shipto); $request = new AnetAPI\CreateTransactionRequest(); $request->setMerchantAuthentication($merchantAuthentication); From bb9d6e2719cc408e5886ceacc0f593ba2120a932 Mon Sep 17 00:00:00 2001 From: srathod Date: Thu, 14 Jan 2016 21:05:48 +0530 Subject: [PATCH 027/287] - updated random email function. --- test-runner.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-runner.php b/test-runner.php index 69c5ca2..595adaf 100644 --- a/test-runner.php +++ b/test-runner.php @@ -33,7 +33,7 @@ public static function getAmount(){ } //random email for a new customer profile public static function getEmail(){ - return rand(0,10000) . "@test.com"; + return rand(0,10000) . "@test" .rand(0,10000) .".com"; } //random phonenumber for customer payment profile public static function getPhoneNumber(){ From a9b5e04571878d788bb5719ae91a248f8a3b304a Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Thu, 14 Jan 2016 21:09:54 +0530 Subject: [PATCH 028/287] Delete phpunit.xml.dist --- phpunit.xml.dist | 43 ------------------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 phpunit.xml.dist diff --git a/phpunit.xml.dist b/phpunit.xml.dist deleted file mode 100644 index d985ab5..0000000 --- a/phpunit.xml.dist +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - . - - - - - - ./lib - - ./vendor - ./tests - ./build - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From 8f84d041d38236530ece02b640a5c96a052d644f Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Thu, 14 Jan 2016 21:13:39 +0530 Subject: [PATCH 029/287] Update .travis.yml --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0e88f4b..6a8e3ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,9 +5,5 @@ php: sudo: false -before_script: - - pecl install xmldiff - - composer install --prefer-dist --dev - script: - phpunit test-runner.php From 2207aae3e84e770cba8d0d535eb644f7e9dd676f Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Thu, 14 Jan 2016 21:15:56 +0530 Subject: [PATCH 030/287] Update composer.json --- composer.json | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/composer.json b/composer.json index f5a176c..eb1a566 100644 --- a/composer.json +++ b/composer.json @@ -1,21 +1,11 @@ { - "require": { "php": ">=5.2.0", "ext-curl": "*", "authorizenet/authorizenet": "1.8.6.2", "jms/serializer": "xsd2php-dev as 0.18.0" -}, -"require-dev": { + }, + "require-dev": { "phpunit/phpunit": "~4.0", - "phpmd/phpmd": "~2.0", - "goetas/xsd2php":"2.*@dev", - "goetas/xsd-reader":"2.*@dev" -}, - -"repositories": [{ - "type": "vcs", - "url": "https://github.com/goetas/serializer.git" - }] - + } } From 97fcd611d121b187f5ad0e4537b124e22280d547 Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Thu, 14 Jan 2016 21:16:34 +0530 Subject: [PATCH 031/287] Update .travis.yml --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 6a8e3ae..20d22c8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,5 +5,8 @@ php: sudo: false +before_script: + - composer install --prefer-dist --dev + script: - phpunit test-runner.php From e68110748da6b4934fa98acc2fedc072d7d79c66 Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Thu, 14 Jan 2016 21:19:20 +0530 Subject: [PATCH 032/287] Update composer.json --- composer.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index eb1a566..302409a 100644 --- a/composer.json +++ b/composer.json @@ -2,10 +2,9 @@ "require": { "php": ">=5.2.0", "ext-curl": "*", - "authorizenet/authorizenet": "1.8.6.2", - "jms/serializer": "xsd2php-dev as 0.18.0" + "authorizenet/authorizenet": "1.8.6.2" }, "require-dev": { - "phpunit/phpunit": "~4.0", + "phpunit/phpunit": "~4.0" } } From 17bd2b95781ce378bc111e937265e4332dc1d3ef Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Thu, 14 Jan 2016 21:21:23 +0530 Subject: [PATCH 033/287] Update composer.json --- composer.json | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 302409a..782c113 100644 --- a/composer.json +++ b/composer.json @@ -5,6 +5,12 @@ "authorizenet/authorizenet": "1.8.6.2" }, "require-dev": { - "phpunit/phpunit": "~4.0" - } + "phpunit/phpunit": "~4.0", + "goetas/xsd2php": "2.*@dev", + "goetas/xsd-reader": "2.*@dev" + }, + "repositories": [{ + "type": "vcs", + "url": "https://github.com/goetas/serializer.git" + }] } From 3b0b05502c1f002d8ac858758708db900b93f183 Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Thu, 14 Jan 2016 21:24:54 +0530 Subject: [PATCH 034/287] Update composer.json --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 782c113..553a20a 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,8 @@ "require": { "php": ">=5.2.0", "ext-curl": "*", - "authorizenet/authorizenet": "1.8.6.2" + "authorizenet/authorizenet": "1.8.6.2", + "jms/serializer": "xsd2php-dev as 0.18.0" }, "require-dev": { "phpunit/phpunit": "~4.0", From 44f10a2e1f714d170b6a161aeb989f5468c7787a Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Thu, 14 Jan 2016 21:29:30 +0530 Subject: [PATCH 035/287] Create phpunit.xml.dist --- phpunit.xml.dist | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 phpunit.xml.dist diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..4d61151 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,43 @@ + + + + + + . + + + + + + ./lib + + ./vendor + ./tests + ./build + + + + + + + + + + + + + + + + + + + + + + + + From 0627d2e28d99546f8b37d681fcb965335194d2e2 Mon Sep 17 00:00:00 2001 From: ashtru Date: Mon, 18 Jan 2016 13:13:49 +0530 Subject: [PATCH 036/287] test-runner was running succssfully, update individual sample code to run without syntax errors --- CustomerProfiles/create-customer-payment-profile.php | 2 +- .../create-customer-profile-from-transaction.php | 3 ++- CustomerProfiles/create-customer-profile.php | 2 +- CustomerProfiles/create-customer-shipping-address.php | 2 +- CustomerProfiles/delete-customer-payment-profile.php | 2 +- CustomerProfiles/delete-customer-profile.php | 2 +- CustomerProfiles/delete-customer-shipping-address.php | 4 ++-- CustomerProfiles/get-customer-shipping-address.php | 2 +- CustomerProfiles/update-customer-shipping-address.php | 2 +- CustomerProfiles/validate-customer-payment-profile.php | 5 +++-- PaymentTransactions/authorize-credit-card.php | 2 +- .../capture-funds-authorized-through-another-channel.php | 2 +- .../capture-previously-authorized-amount.php | 4 ++-- PaymentTransactions/charge-credit-card.php | 6 +++--- PaymentTransactions/charge-customer-profile.php | 2 +- PaymentTransactions/charge-tokenized-credit-card.php | 2 +- PaymentTransactions/credit-bank-account.php | 6 +++--- PaymentTransactions/refund-transaction.php | 7 ++++--- PaymentTransactions/update-split-tender-group.php | 2 ++ PaymentTransactions/void-transaction.php | 4 +++- PaypalExpressCheckout/void.php | 4 ++-- RecurringBilling/cancel-subscription.php | 2 +- RecurringBilling/get-subscription-status.php | 2 +- RecurringBilling/update-subscription.php | 4 ++-- test-runner.php | 4 ++-- 25 files changed, 43 insertions(+), 36 deletions(-) diff --git a/CustomerProfiles/create-customer-payment-profile.php b/CustomerProfiles/create-customer-payment-profile.php index e85726c..5af3fc9 100644 --- a/CustomerProfiles/create-customer-payment-profile.php +++ b/CustomerProfiles/create-customer-payment-profile.php @@ -61,5 +61,5 @@ function createCustomerPaymentProfile($existingcustomerprofileid, $phoneNumber){ return $response; } if(!defined(DONT_RUN_SAMPLES)) - createCustomerPaymentProfile("35858366","000-000-0009"); + createCustomerPaymentProfile("36152127","000-000-0009"); ?> diff --git a/CustomerProfiles/create-customer-profile-from-transaction.php b/CustomerProfiles/create-customer-profile-from-transaction.php index 60a3790..5efb164 100644 --- a/CustomerProfiles/create-customer-profile-from-transaction.php +++ b/CustomerProfiles/create-customer-profile-from-transaction.php @@ -30,6 +30,7 @@ function createCustomerProfileFromTransaction($transId="2238251168") } return $response; } + //provide a transaction that has customer information if(!defined(DONT_RUN_SAMPLES)) - createCustomerProfileFromTransaction(); + createCustomerProfileFromTransaction("2249066517"); ?> diff --git a/CustomerProfiles/create-customer-profile.php b/CustomerProfiles/create-customer-profile.php index d17e57d..a6d3818 100644 --- a/CustomerProfiles/create-customer-profile.php +++ b/CustomerProfiles/create-customer-profile.php @@ -69,5 +69,5 @@ function createCustomerProfile($email){ return $response; } if(!defined(DONT_RUN_SAMPLES)) - createCustomerProfile(); + createCustomerProfile("test567@test.com"); ?> diff --git a/CustomerProfiles/create-customer-shipping-address.php b/CustomerProfiles/create-customer-shipping-address.php index e730534..dbddeee 100644 --- a/CustomerProfiles/create-customer-shipping-address.php +++ b/CustomerProfiles/create-customer-shipping-address.php @@ -3,7 +3,7 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - function createCustomerShippingAddress($existingcustomerprofileid = "35872074", $phoneNumber="000-000-0000") + function createCustomerShippingAddress($existingcustomerprofileid = "36152127", $phoneNumber="000-000-0000") { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); diff --git a/CustomerProfiles/delete-customer-payment-profile.php b/CustomerProfiles/delete-customer-payment-profile.php index 25c87da..2b0fea4 100644 --- a/CustomerProfiles/delete-customer-payment-profile.php +++ b/CustomerProfiles/delete-customer-payment-profile.php @@ -4,7 +4,7 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - function deleteCustomerPaymentProfile($customerProfileId="38900575", $customerpaymentprofileid = "35366197") + function deleteCustomerPaymentProfile($customerProfileId="36152127", $customerpaymentprofileid = "32689274") { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); diff --git a/CustomerProfiles/delete-customer-profile.php b/CustomerProfiles/delete-customer-profile.php index 815f960..f607c2c 100644 --- a/CustomerProfiles/delete-customer-profile.php +++ b/CustomerProfiles/delete-customer-profile.php @@ -34,5 +34,5 @@ function deleteCustomerProfile($customerProfileId) } if(!defined(DONT_RUN_SAMPLES)) - deleteCustomerProfile("2133432"); + deleteCustomerProfile("38958129"); ?> diff --git a/CustomerProfiles/delete-customer-shipping-address.php b/CustomerProfiles/delete-customer-shipping-address.php index 75f2f56..0a07da4 100644 --- a/CustomerProfiles/delete-customer-shipping-address.php +++ b/CustomerProfiles/delete-customer-shipping-address.php @@ -4,7 +4,7 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - function deleteCustomerShippingAddress($customerprofileid = "35872074", $customeraddressid = "36931511") + function deleteCustomerShippingAddress($customerprofileid = "36152127", $customeraddressid = "36976434") { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); @@ -22,7 +22,7 @@ function deleteCustomerShippingAddress($customerprofileid = "35872074", $custome $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) { - echo "Delete Customer Shipping Address SUCCESS:" . "\n"; + echo "Delete Customer Shipping Address SUCCESS" . "\n"; } else { diff --git a/CustomerProfiles/get-customer-shipping-address.php b/CustomerProfiles/get-customer-shipping-address.php index 0ec0052..9a06355 100644 --- a/CustomerProfiles/get-customer-shipping-address.php +++ b/CustomerProfiles/get-customer-shipping-address.php @@ -46,5 +46,5 @@ function getCustomerShippingAddress($customerprofileid, $customeraddressid) return $response; } if(!defined(DONT_RUN_SAMPLES)) - getCustomerShippingAddress(); + getCustomerShippingAddress("36152127", "36976566"); ?> diff --git a/CustomerProfiles/update-customer-shipping-address.php b/CustomerProfiles/update-customer-shipping-address.php index 241a718..a677fc4 100644 --- a/CustomerProfiles/update-customer-shipping-address.php +++ b/CustomerProfiles/update-customer-shipping-address.php @@ -46,5 +46,5 @@ function updateCustomerShippingAddress($customerprofileid, $customeraddressid) return $response; } if(!defined(DONT_RUN_SAMPLES)) - updateCustomerShippingAddress(); + updateCustomerShippingAddress("36152127", "36976566"); ?> diff --git a/CustomerProfiles/validate-customer-payment-profile.php b/CustomerProfiles/validate-customer-payment-profile.php index 050316e..2372e5d 100644 --- a/CustomerProfiles/validate-customer-payment-profile.php +++ b/CustomerProfiles/validate-customer-payment-profile.php @@ -16,9 +16,10 @@ function validateCustomerPaymentProfile($customerProfileId="36731856", $customer $validationmode = "testMode"; $request = new AnetAPI\ValidateCustomerPaymentProfileRequest(); + $request->setMerchantAuthentication($merchantAuthentication); - $request->setCustomerProfileId($customerprofileid); - $request->setCustomerPaymentProfileId($customerpaymentprofileid); + $request->setCustomerProfileId($customerProfileId); + $request->setCustomerPaymentProfileId($customerPaymentProfileId); $request->setValidationMode($validationmode); $controller = new AnetController\ValidateCustomerPaymentProfileController($request); diff --git a/PaymentTransactions/authorize-credit-card.php b/PaymentTransactions/authorize-credit-card.php index 7d9af0a..8029297 100644 --- a/PaymentTransactions/authorize-credit-card.php +++ b/PaymentTransactions/authorize-credit-card.php @@ -56,5 +56,5 @@ function authorizeCreditCard($amount){ return $response; } if(!defined(DONT_RUN_SAMPLES)) - authorizeCreditCard(); + authorizeCreditCard(12.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 b94ef37..fa0dd59 100644 --- a/PaymentTransactions/capture-funds-authorized-through-another-channel.php +++ b/PaymentTransactions/capture-funds-authorized-through-another-channel.php @@ -9,7 +9,7 @@ function captureFundsAuthorizedThroughAnotherChannel($amount){ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName("5KP3u95bQpv"); $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); - $refId = "123456"; + $refId = 'ref' . time(); $creditCard = new AnetAPI\CreditCardType(); $creditCard->setCardNumber( "4111111111111111"); diff --git a/PaymentTransactions/capture-previously-authorized-amount.php b/PaymentTransactions/capture-previously-authorized-amount.php index 7907885..e2664e7 100644 --- a/PaymentTransactions/capture-previously-authorized-amount.php +++ b/PaymentTransactions/capture-previously-authorized-amount.php @@ -9,7 +9,7 @@ function capturePreviouslyAuthorizedAmount($transactionid){ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName("5KP3u95bQpv"); $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); - $refId = "123456"; + $refId = 'ref' . time(); // Now capture the previously authorized amount echo "Capturing the Authorization with transaction ID : " . $transactionid . "\n"; @@ -45,5 +45,5 @@ function capturePreviouslyAuthorizedAmount($transactionid){ return $response; } if(!defined(DONT_RUN_SAMPLES)) - capturePreviouslyAuthorizedAmount(); + capturePreviouslyAuthorizedAmount(2245440574); ?> diff --git a/PaymentTransactions/charge-credit-card.php b/PaymentTransactions/charge-credit-card.php index c58df9c..9fec61a 100644 --- a/PaymentTransactions/charge-credit-card.php +++ b/PaymentTransactions/charge-credit-card.php @@ -31,11 +31,11 @@ function chargeCreditCard($amount){ $controller = new AnetController\CreateTransactionController($request); $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - if ($response != null) + if ($response != null) { $tresponse = $response->getTransactionResponse(); - if (($tresponse != null) && ($tresponse->getResponseCode()=="Ok") ) + if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) { echo "Charge Credit Card AUTH CODE : " . $tresponse->getAuthCode() . "\n"; echo "Charge Credit Card TRANS ID : " . $tresponse->getTransId() . "\n"; @@ -53,5 +53,5 @@ function chargeCreditCard($amount){ return $response; } if(!defined(DONT_RUN_SAMPLES)) - chargeCreditCard(); + chargeCreditCard(17.9); ?> diff --git a/PaymentTransactions/charge-customer-profile.php b/PaymentTransactions/charge-customer-profile.php index 8ea16b7..cdcbb5a 100644 --- a/PaymentTransactions/charge-customer-profile.php +++ b/PaymentTransactions/charge-customer-profile.php @@ -54,5 +54,5 @@ function chargeCustomerProfile($profileid, $paymentprofileid, $amount){ return $response; } if(!defined(DONT_RUN_SAMPLES)) - chargeCustomerProfile(); + chargeCustomerProfile("36152127", "32689274", 99.32); ?> diff --git a/PaymentTransactions/charge-tokenized-credit-card.php b/PaymentTransactions/charge-tokenized-credit-card.php index 241f403..54b83ab 100644 --- a/PaymentTransactions/charge-tokenized-credit-card.php +++ b/PaymentTransactions/charge-tokenized-credit-card.php @@ -55,5 +55,5 @@ function chargeTokenizedCreditCard($amount){ return $response; } if(!defined(DONT_RUN_SAMPLES)) - chargeTokenizedCreditCard(); + chargeTokenizedCreditCard(13.5); ?> diff --git a/PaymentTransactions/credit-bank-account.php b/PaymentTransactions/credit-bank-account.php index cbbb897..7b73b06 100644 --- a/PaymentTransactions/credit-bank-account.php +++ b/PaymentTransactions/credit-bank-account.php @@ -4,12 +4,12 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - function creditBankAccount($transactionid, $amount){ + function creditBankAccount($amount){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName("5KP3u95bQpv"); $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); - $refId = $transactionid; + $refId = 'ref' . time(); // Create the payment data for a Bank Account $bankAccount = new AnetAPI\BankAccountType(); $bankAccount->setRoutingNumber('125000024'); @@ -62,5 +62,5 @@ function creditBankAccount($transactionid, $amount){ return $response; } if(!defined(DONT_RUN_SAMPLES)) - creditBankAccount(); + creditBankAccount(21.54); ?> diff --git a/PaymentTransactions/refund-transaction.php b/PaymentTransactions/refund-transaction.php index 46ca639..42ee835 100644 --- a/PaymentTransactions/refund-transaction.php +++ b/PaymentTransactions/refund-transaction.php @@ -4,11 +4,12 @@ use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); - function refundTransaction($amount, $transactionid){ + function refundTransaction($amount){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName("5KP3u95bQpv"); $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $refId = 'ref' . time(); // Create the payment data for a credit card $creditCard = new AnetAPI\CreditCardType(); @@ -23,7 +24,7 @@ function refundTransaction($amount, $transactionid){ $transactionRequestType->setPayment($paymentOne); $request = new AnetAPI\CreateTransactionRequest(); $request->setMerchantAuthentication($merchantAuthentication); - $request->setRefId($transactionid); + $request->setRefId($refId); $request->setTransactionRequest( $transactionRequestType); $controller = new AnetController\CreateTransactionController($request); $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); @@ -47,5 +48,5 @@ function refundTransaction($amount, $transactionid){ return $response; } if(!defined(DONT_RUN_SAMPLES)) - refundTransaction(); + refundTransaction(32.14); ?> diff --git a/PaymentTransactions/update-split-tender-group.php b/PaymentTransactions/update-split-tender-group.php index 0747201..bee62e0 100644 --- a/PaymentTransactions/update-split-tender-group.php +++ b/PaymentTransactions/update-split-tender-group.php @@ -9,9 +9,11 @@ function updateSplitTenderGroup(){ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName( "8V4xFm3z"); $merchantAuthentication->setTransactionKey("655AS4Ek7TJ42snq"); + $refId = 'ref' . time(); $request = new AnetAPI\UpdateSplitTenderGroupRequest(); $request->setMerchantAuthentication($merchantAuthentication); + $request->setRefId($refId); $request->setSplitTenderId("116468"); $request->setSplitTenderStatus("voided"); diff --git a/PaymentTransactions/void-transaction.php b/PaymentTransactions/void-transaction.php index 825b073..a69748e 100644 --- a/PaymentTransactions/void-transaction.php +++ b/PaymentTransactions/void-transaction.php @@ -9,6 +9,7 @@ function voidTransaction($transactionid){ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName("5KP3u95bQpv"); $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $refId = 'ref' . time(); // Create the payment data for a credit card $creditCard = new AnetAPI\CreditCardType(); @@ -24,6 +25,7 @@ function voidTransaction($transactionid){ $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); @@ -48,5 +50,5 @@ function voidTransaction($transactionid){ return $response; } if(!defined(DONT_RUN_SAMPLES)) - voidTransaction(); + voidTransaction("2249063130"); ?> diff --git a/PaypalExpressCheckout/void.php b/PaypalExpressCheckout/void.php index 49fb761..da5f85d 100644 --- a/PaypalExpressCheckout/void.php +++ b/PaypalExpressCheckout/void.php @@ -32,8 +32,8 @@ function payPalVoid($transactionId) { $controller = new AnetController\CreateTransactionController($request); $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - - if ($response != null) + + if ($response != null) { $tresponse = $response->getTransactionResponse(); if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) diff --git a/RecurringBilling/cancel-subscription.php b/RecurringBilling/cancel-subscription.php index 0aa962c..6b7a996 100644 --- a/RecurringBilling/cancel-subscription.php +++ b/RecurringBilling/cancel-subscription.php @@ -38,6 +38,6 @@ function cancelSubscription($subscriptionId) { } if(!defined(DONT_RUN_SAMPLES)) - cancelSubscription("100748"); + cancelSubscription("3056945"); ?> diff --git a/RecurringBilling/get-subscription-status.php b/RecurringBilling/get-subscription-status.php index c8e7555..52b324f 100644 --- a/RecurringBilling/get-subscription-status.php +++ b/RecurringBilling/get-subscription-status.php @@ -37,6 +37,6 @@ function getSubscriptionStatus($subscriptionId) { } if(!defined(DONT_RUN_SAMPLES)) - getSubscriptionStatus("100748"); + getSubscriptionStatus("3056945"); ?> diff --git a/RecurringBilling/update-subscription.php b/RecurringBilling/update-subscription.php index f90a303..622c915 100644 --- a/RecurringBilling/update-subscription.php +++ b/RecurringBilling/update-subscription.php @@ -23,7 +23,7 @@ function updateSubscription($subscriptionId) { $payment->setCreditCard($creditCard); $subscription->setPayment($payment); - + $request = new AnetAPI\ARBUpdateSubscriptionRequest(); $request->setMerchantAuthentication($merchantAuthentication); $request->setRefId($refId); @@ -48,5 +48,5 @@ function updateSubscription($subscriptionId) { } if(!defined(DONT_RUN_SAMPLES)) - updateSubscription("100748"); + updateSubscription("3056948"); ?> diff --git a/test-runner.php b/test-runner.php index 595adaf..f211313 100644 --- a/test-runner.php +++ b/test-runner.php @@ -135,7 +135,7 @@ public static function runRefundTransaction() { $response = authorizeCreditCard.run(self::getAmount()); $response = capturePreviouslyAuthorizedAmount($response->getTransactionResponse()->getTransId()); - return refundTransaction(self::getAmount(), $response->getTransactionResponse()->getTransId()); + return refundTransaction(self::getAmount()); } public static function runVoidTransaction() @@ -146,7 +146,7 @@ public static function runVoidTransaction() public static function runCreditBankAccount() { - return creditBankAccount(self::$transactionID, self::getAmount()); + return creditBankAccount(self::getAmount()); } public static function runChargeCustomerProfile() From f893e2e0007da7c9d333fd315bdf58a92dcdc147 Mon Sep 17 00:00:00 2001 From: ashtru Date: Thu, 28 Jan 2016 15:28:58 +0530 Subject: [PATCH 037/287] Removed define("AUTHORIZENET_LOG_FILE".. It is already set in sdk-php. --- ApplePayTransactions/create-an-apple-pay-transaction.php | 2 -- CustomerProfiles/create-customer-payment-profile.php | 1 - CustomerProfiles/create-customer-profile-from-transaction.php | 1 - CustomerProfiles/create-customer-profile.php | 1 - CustomerProfiles/create-customer-shipping-address.php | 1 - CustomerProfiles/delete-customer-payment-profile.php | 1 - CustomerProfiles/delete-customer-profile.php | 1 - CustomerProfiles/delete-customer-shipping-address.php | 1 - CustomerProfiles/get-customer-payment-profile-list.php | 3 --- CustomerProfiles/get-customer-payment-profile.php | 2 -- CustomerProfiles/get-customer-profile-ids.php | 1 - CustomerProfiles/get-customer-profile.php | 1 - CustomerProfiles/get-customer-shipping-address.php | 1 - CustomerProfiles/get-hosted-profile-page.php | 1 - CustomerProfiles/update-customer-payment-profile.php | 1 - CustomerProfiles/update-customer-profile.php | 1 - CustomerProfiles/update-customer-shipping-address.php | 1 - CustomerProfiles/validate-customer-payment-profile.php | 1 - PaymentTransactions/authorize-credit-card.php | 2 -- .../capture-funds-authorized-through-another-channel.php | 1 - PaymentTransactions/capture-previously-authorized-amount.php | 1 - PaymentTransactions/charge-credit-card.php | 1 - PaymentTransactions/charge-customer-profile.php | 1 - PaymentTransactions/charge-tokenized-credit-card.php | 1 - PaymentTransactions/credit-bank-account.php | 1 - PaymentTransactions/debit-bank-account.php | 1 - PaymentTransactions/refund-transaction.php | 1 - PaymentTransactions/update-split-tender-group.php | 1 - PaymentTransactions/void-transaction.php | 1 - PaypalExpressCheckout/authorization-and-capture-continue.php | 1 - PaypalExpressCheckout/authorization-and-capture.php | 1 - PaypalExpressCheckout/authorization-only-continued.php | 2 -- PaypalExpressCheckout/authorization-only.php | 2 -- PaypalExpressCheckout/credit.php | 2 -- PaypalExpressCheckout/get-details.php | 2 -- PaypalExpressCheckout/prior-authorization-capture.php | 1 - PaypalExpressCheckout/void.php | 1 - RecurringBilling/cancel-subscription.php | 1 - RecurringBilling/create-subscription.php | 1 - RecurringBilling/get-list-of-subscriptions.php | 1 - RecurringBilling/get-subscription-status.php | 1 - RecurringBilling/get-subscription.php | 1 - RecurringBilling/update-subscription.php | 1 - TransactionReporting/get-batch-statistics.php | 1 - TransactionReporting/get-settled-batch-list.php | 1 - TransactionReporting/get-transaction-details.php | 1 - TransactionReporting/get-transaction-list.php | 1 - TransactionReporting/get-unsettled-transaction-list.php | 1 - VisaCheckout/create-visa-checkout-transaction.php | 2 -- VisaCheckout/decrypt-visa-checkout-data.php | 2 -- test-runner.php | 2 +- 51 files changed, 1 insertion(+), 62 deletions(-) diff --git a/ApplePayTransactions/create-an-apple-pay-transaction.php b/ApplePayTransactions/create-an-apple-pay-transaction.php index 5704383..751b93a 100644 --- a/ApplePayTransactions/create-an-apple-pay-transaction.php +++ b/ApplePayTransactions/create-an-apple-pay-transaction.php @@ -4,8 +4,6 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; -define("AUTHORIZENET_LOG_FILE", "phplog"); - function createAnApplePayTransaction(){ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName("5KP3u95bQpv"); diff --git a/CustomerProfiles/create-customer-payment-profile.php b/CustomerProfiles/create-customer-payment-profile.php index 5af3fc9..1ef640b 100644 --- a/CustomerProfiles/create-customer-payment-profile.php +++ b/CustomerProfiles/create-customer-payment-profile.php @@ -2,7 +2,6 @@ require 'vendor/autoload.php'; use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; - define("AUTHORIZENET_LOG_FILE", "phplog"); function createCustomerPaymentProfile($existingcustomerprofileid, $phoneNumber){ // Common setup for API credentials diff --git a/CustomerProfiles/create-customer-profile-from-transaction.php b/CustomerProfiles/create-customer-profile-from-transaction.php index 5efb164..22bd9f0 100644 --- a/CustomerProfiles/create-customer-profile-from-transaction.php +++ b/CustomerProfiles/create-customer-profile-from-transaction.php @@ -2,7 +2,6 @@ require 'vendor/autoload.php'; use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; - define("AUTHORIZENET_LOG_FILE", "phplog"); function createCustomerProfileFromTransaction($transId="2238251168") { diff --git a/CustomerProfiles/create-customer-profile.php b/CustomerProfiles/create-customer-profile.php index a6d3818..ea9066a 100644 --- a/CustomerProfiles/create-customer-profile.php +++ b/CustomerProfiles/create-customer-profile.php @@ -2,7 +2,6 @@ require 'vendor/autoload.php'; use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; - define("AUTHORIZENET_LOG_FILE", "phplog"); function createCustomerProfile($email){ diff --git a/CustomerProfiles/create-customer-shipping-address.php b/CustomerProfiles/create-customer-shipping-address.php index dbddeee..1183470 100644 --- a/CustomerProfiles/create-customer-shipping-address.php +++ b/CustomerProfiles/create-customer-shipping-address.php @@ -2,7 +2,6 @@ require 'vendor/autoload.php'; use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; - define("AUTHORIZENET_LOG_FILE", "phplog"); function createCustomerShippingAddress($existingcustomerprofileid = "36152127", $phoneNumber="000-000-0000") { // Common setup for API credentials diff --git a/CustomerProfiles/delete-customer-payment-profile.php b/CustomerProfiles/delete-customer-payment-profile.php index 2b0fea4..613bafe 100644 --- a/CustomerProfiles/delete-customer-payment-profile.php +++ b/CustomerProfiles/delete-customer-payment-profile.php @@ -2,7 +2,6 @@ require 'vendor/autoload.php'; use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; - define("AUTHORIZENET_LOG_FILE", "phplog"); function deleteCustomerPaymentProfile($customerProfileId="36152127", $customerpaymentprofileid = "32689274") { diff --git a/CustomerProfiles/delete-customer-profile.php b/CustomerProfiles/delete-customer-profile.php index f607c2c..5c15a22 100644 --- a/CustomerProfiles/delete-customer-profile.php +++ b/CustomerProfiles/delete-customer-profile.php @@ -2,7 +2,6 @@ require 'vendor/autoload.php'; use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; - define("AUTHORIZENET_LOG_FILE", "phplog"); function deleteCustomerProfile($customerProfileId) { diff --git a/CustomerProfiles/delete-customer-shipping-address.php b/CustomerProfiles/delete-customer-shipping-address.php index 0a07da4..fac5c20 100644 --- a/CustomerProfiles/delete-customer-shipping-address.php +++ b/CustomerProfiles/delete-customer-shipping-address.php @@ -2,7 +2,6 @@ require 'vendor/autoload.php'; use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; - define("AUTHORIZENET_LOG_FILE", "phplog"); function deleteCustomerShippingAddress($customerprofileid = "36152127", $customeraddressid = "36976434") { diff --git a/CustomerProfiles/get-customer-payment-profile-list.php b/CustomerProfiles/get-customer-payment-profile-list.php index 3c97953..8831476 100644 --- a/CustomerProfiles/get-customer-payment-profile-list.php +++ b/CustomerProfiles/get-customer-payment-profile-list.php @@ -1,13 +1,10 @@ Date: Fri, 29 Jan 2016 00:16:11 +0530 Subject: [PATCH 038/287] Fixed syntax for DONT_RUN_SAMPLES to solve warning "Undefined constant.." --- ApplePayTransactions/create-an-apple-pay-transaction.php | 2 +- CustomerProfiles/create-customer-payment-profile.php | 2 +- CustomerProfiles/create-customer-profile-from-transaction.php | 2 +- CustomerProfiles/create-customer-profile.php | 2 +- CustomerProfiles/create-customer-shipping-address.php | 2 +- CustomerProfiles/delete-customer-payment-profile.php | 2 +- CustomerProfiles/delete-customer-profile.php | 2 +- CustomerProfiles/delete-customer-shipping-address.php | 2 +- CustomerProfiles/get-customer-payment-profile-list.php | 2 +- CustomerProfiles/get-customer-payment-profile.php | 2 +- CustomerProfiles/get-customer-profile-ids.php | 2 +- CustomerProfiles/get-customer-shipping-address.php | 2 +- CustomerProfiles/get-hosted-profile-page.php | 2 +- CustomerProfiles/update-customer-payment-profile.php | 2 +- CustomerProfiles/update-customer-profile.php | 2 +- CustomerProfiles/update-customer-shipping-address.php | 2 +- CustomerProfiles/validate-customer-payment-profile.php | 2 +- PaymentTransactions/authorize-credit-card.php | 2 +- .../capture-funds-authorized-through-another-channel.php | 2 +- PaymentTransactions/capture-previously-authorized-amount.php | 2 +- PaymentTransactions/charge-credit-card.php | 2 +- PaymentTransactions/charge-customer-profile.php | 2 +- PaymentTransactions/charge-tokenized-credit-card.php | 2 +- PaymentTransactions/credit-bank-account.php | 2 +- PaymentTransactions/debit-bank-account.php | 2 +- PaymentTransactions/refund-transaction.php | 2 +- PaymentTransactions/update-split-tender-group.php | 2 +- PaymentTransactions/void-transaction.php | 2 +- PaypalExpressCheckout/authorization-and-capture-continue.php | 2 +- PaypalExpressCheckout/authorization-and-capture.php | 2 +- PaypalExpressCheckout/authorization-only-continued.php | 2 +- PaypalExpressCheckout/authorization-only.php | 2 +- PaypalExpressCheckout/credit.php | 2 +- PaypalExpressCheckout/get-details.php | 2 +- PaypalExpressCheckout/prior-authorization-capture.php | 2 +- PaypalExpressCheckout/void.php | 2 +- RecurringBilling/cancel-subscription.php | 2 +- RecurringBilling/create-subscription.php | 2 +- RecurringBilling/get-list-of-subscriptions.php | 2 +- RecurringBilling/get-subscription-status.php | 2 +- RecurringBilling/get-subscription.php | 2 +- RecurringBilling/update-subscription.php | 2 +- TransactionReporting/get-batch-statistics.php | 2 +- TransactionReporting/get-settled-batch-list.php | 2 +- TransactionReporting/get-transaction-details.php | 2 +- TransactionReporting/get-transaction-list.php | 2 +- TransactionReporting/get-unsettled-transaction-list.php | 2 +- VisaCheckout/create-visa-checkout-transaction.php | 2 +- VisaCheckout/decrypt-visa-checkout-data.php | 2 +- 49 files changed, 49 insertions(+), 49 deletions(-) diff --git a/ApplePayTransactions/create-an-apple-pay-transaction.php b/ApplePayTransactions/create-an-apple-pay-transaction.php index 751b93a..0eb11bc 100644 --- a/ApplePayTransactions/create-an-apple-pay-transaction.php +++ b/ApplePayTransactions/create-an-apple-pay-transaction.php @@ -52,6 +52,6 @@ function createAnApplePayTransaction(){ return $response; } -if(!defined(DONT_RUN_SAMPLES)) +if(!defined('DONT_RUN_SAMPLES')) createAnApplePayTransaction(); ?> diff --git a/CustomerProfiles/create-customer-payment-profile.php b/CustomerProfiles/create-customer-payment-profile.php index 1ef640b..5779fa1 100644 --- a/CustomerProfiles/create-customer-payment-profile.php +++ b/CustomerProfiles/create-customer-payment-profile.php @@ -59,6 +59,6 @@ function createCustomerPaymentProfile($existingcustomerprofileid, $phoneNumber){ } return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) createCustomerPaymentProfile("36152127","000-000-0009"); ?> diff --git a/CustomerProfiles/create-customer-profile-from-transaction.php b/CustomerProfiles/create-customer-profile-from-transaction.php index 22bd9f0..c35c92b 100644 --- a/CustomerProfiles/create-customer-profile-from-transaction.php +++ b/CustomerProfiles/create-customer-profile-from-transaction.php @@ -30,6 +30,6 @@ function createCustomerProfileFromTransaction($transId="2238251168") return $response; } //provide a transaction that has customer information - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) createCustomerProfileFromTransaction("2249066517"); ?> diff --git a/CustomerProfiles/create-customer-profile.php b/CustomerProfiles/create-customer-profile.php index ea9066a..15fabc4 100644 --- a/CustomerProfiles/create-customer-profile.php +++ b/CustomerProfiles/create-customer-profile.php @@ -67,6 +67,6 @@ function createCustomerProfile($email){ } return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) createCustomerProfile("test567@test.com"); ?> diff --git a/CustomerProfiles/create-customer-shipping-address.php b/CustomerProfiles/create-customer-shipping-address.php index 1183470..aeb5d73 100644 --- a/CustomerProfiles/create-customer-shipping-address.php +++ b/CustomerProfiles/create-customer-shipping-address.php @@ -43,6 +43,6 @@ function createCustomerShippingAddress($existingcustomerprofileid = "36152127", } return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) createCustomerShippingAddress(); ?> diff --git a/CustomerProfiles/delete-customer-payment-profile.php b/CustomerProfiles/delete-customer-payment-profile.php index 613bafe..61138ec 100644 --- a/CustomerProfiles/delete-customer-payment-profile.php +++ b/CustomerProfiles/delete-customer-payment-profile.php @@ -29,6 +29,6 @@ function deleteCustomerPaymentProfile($customerProfileId="36152127", $customerpa } return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) deleteCustomerPaymentProfile(); ?> diff --git a/CustomerProfiles/delete-customer-profile.php b/CustomerProfiles/delete-customer-profile.php index 5c15a22..5b9a688 100644 --- a/CustomerProfiles/delete-customer-profile.php +++ b/CustomerProfiles/delete-customer-profile.php @@ -32,6 +32,6 @@ function deleteCustomerProfile($customerProfileId) return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) deleteCustomerProfile("38958129"); ?> diff --git a/CustomerProfiles/delete-customer-shipping-address.php b/CustomerProfiles/delete-customer-shipping-address.php index fac5c20..3bac6b2 100644 --- a/CustomerProfiles/delete-customer-shipping-address.php +++ b/CustomerProfiles/delete-customer-shipping-address.php @@ -30,6 +30,6 @@ function deleteCustomerShippingAddress($customerprofileid = "36152127", $custome } return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) deleteCustomerShippingAddress(); ?> diff --git a/CustomerProfiles/get-customer-payment-profile-list.php b/CustomerProfiles/get-customer-payment-profile-list.php index 8831476..889f708 100644 --- a/CustomerProfiles/get-customer-payment-profile-list.php +++ b/CustomerProfiles/get-customer-payment-profile-list.php @@ -70,6 +70,6 @@ function getCustomerPaymentProfileList() } return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) getCustomerPaymentProfileList(); ?> diff --git a/CustomerProfiles/get-customer-payment-profile.php b/CustomerProfiles/get-customer-payment-profile.php index 1fa485d..f91e6b6 100644 --- a/CustomerProfiles/get-customer-payment-profile.php +++ b/CustomerProfiles/get-customer-payment-profile.php @@ -43,6 +43,6 @@ function getCustomerPaymentProfile($customerProfileId="36731856", $customerPayme } return $response; } -if(!defined(DONT_RUN_SAMPLES)) +if(!defined('DONT_RUN_SAMPLES')) getCustomerPaymentProfile(); ?> diff --git a/CustomerProfiles/get-customer-profile-ids.php b/CustomerProfiles/get-customer-profile-ids.php index e58cc48..e7dfeaf 100644 --- a/CustomerProfiles/get-customer-profile-ids.php +++ b/CustomerProfiles/get-customer-profile-ids.php @@ -28,6 +28,6 @@ function getCustomerProfileIds() } return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) getCustomerProfileIds(); ?> diff --git a/CustomerProfiles/get-customer-shipping-address.php b/CustomerProfiles/get-customer-shipping-address.php index 4a7f01b..3659810 100644 --- a/CustomerProfiles/get-customer-shipping-address.php +++ b/CustomerProfiles/get-customer-shipping-address.php @@ -44,6 +44,6 @@ function getCustomerShippingAddress($customerprofileid, $customeraddressid) } return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) getCustomerShippingAddress("36152127", "36976566"); ?> diff --git a/CustomerProfiles/get-hosted-profile-page.php b/CustomerProfiles/get-hosted-profile-page.php index 2af181b..66e443a 100644 --- a/CustomerProfiles/get-hosted-profile-page.php +++ b/CustomerProfiles/get-hosted-profile-page.php @@ -41,6 +41,6 @@ function getHostedProfilePage($customerprofileid = "37680862") } return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) getHostedProfilePage(); ?> \ No newline at end of file diff --git a/CustomerProfiles/update-customer-payment-profile.php b/CustomerProfiles/update-customer-payment-profile.php index 561b5dd..8a77b4b 100644 --- a/CustomerProfiles/update-customer-payment-profile.php +++ b/CustomerProfiles/update-customer-payment-profile.php @@ -89,6 +89,6 @@ function updateCustomerPaymentProfile($customerProfileId="36731856", $customerPa } return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) updateCustomerPaymentProfile(); ?> diff --git a/CustomerProfiles/update-customer-profile.php b/CustomerProfiles/update-customer-profile.php index 69ad2dd..c4d2a0f 100644 --- a/CustomerProfiles/update-customer-profile.php +++ b/CustomerProfiles/update-customer-profile.php @@ -105,6 +105,6 @@ function updateCustomerProfile() { } return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) updateCustomerProfile(); ?> diff --git a/CustomerProfiles/update-customer-shipping-address.php b/CustomerProfiles/update-customer-shipping-address.php index f0c8acf..0d2b065 100644 --- a/CustomerProfiles/update-customer-shipping-address.php +++ b/CustomerProfiles/update-customer-shipping-address.php @@ -44,6 +44,6 @@ function updateCustomerShippingAddress($customerprofileid, $customeraddressid) } return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) updateCustomerShippingAddress("36152127", "36976566"); ?> diff --git a/CustomerProfiles/validate-customer-payment-profile.php b/CustomerProfiles/validate-customer-payment-profile.php index 5ff7865..371106a 100644 --- a/CustomerProfiles/validate-customer-payment-profile.php +++ b/CustomerProfiles/validate-customer-payment-profile.php @@ -35,6 +35,6 @@ function validateCustomerPaymentProfile($customerProfileId="36731856", $customer } return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) validateCustomerPaymentProfile(); ?> diff --git a/PaymentTransactions/authorize-credit-card.php b/PaymentTransactions/authorize-credit-card.php index 2a8c943..68185ae 100644 --- a/PaymentTransactions/authorize-credit-card.php +++ b/PaymentTransactions/authorize-credit-card.php @@ -53,6 +53,6 @@ function authorizeCreditCard($amount){ } return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) authorizeCreditCard(12.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 1693d53..b503f54 100644 --- a/PaymentTransactions/capture-funds-authorized-through-another-channel.php +++ b/PaymentTransactions/capture-funds-authorized-through-another-channel.php @@ -53,6 +53,6 @@ function captureFundsAuthorizedThroughAnotherChannel($amount){ } return $response; } -if(!defined(DONT_RUN_SAMPLES)) +if(!defined('DONT_RUN_SAMPLES')) captureFundsAuthorizedThroughAnotherChannel(5.0); ?> diff --git a/PaymentTransactions/capture-previously-authorized-amount.php b/PaymentTransactions/capture-previously-authorized-amount.php index bfbcb3c..f80d3d0 100644 --- a/PaymentTransactions/capture-previously-authorized-amount.php +++ b/PaymentTransactions/capture-previously-authorized-amount.php @@ -43,6 +43,6 @@ function capturePreviouslyAuthorizedAmount($transactionid){ } return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) capturePreviouslyAuthorizedAmount(2245440574); ?> diff --git a/PaymentTransactions/charge-credit-card.php b/PaymentTransactions/charge-credit-card.php index 24e84fc..d01eade 100644 --- a/PaymentTransactions/charge-credit-card.php +++ b/PaymentTransactions/charge-credit-card.php @@ -51,6 +51,6 @@ function chargeCreditCard($amount){ } return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) chargeCreditCard(17.9); ?> diff --git a/PaymentTransactions/charge-customer-profile.php b/PaymentTransactions/charge-customer-profile.php index c96a424..cca3718 100644 --- a/PaymentTransactions/charge-customer-profile.php +++ b/PaymentTransactions/charge-customer-profile.php @@ -52,6 +52,6 @@ function chargeCustomerProfile($profileid, $paymentprofileid, $amount){ } return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) chargeCustomerProfile("36152127", "32689274", 99.32); ?> diff --git a/PaymentTransactions/charge-tokenized-credit-card.php b/PaymentTransactions/charge-tokenized-credit-card.php index 413cebd..59f6397 100644 --- a/PaymentTransactions/charge-tokenized-credit-card.php +++ b/PaymentTransactions/charge-tokenized-credit-card.php @@ -53,6 +53,6 @@ function chargeTokenizedCreditCard($amount){ } return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) chargeTokenizedCreditCard(13.5); ?> diff --git a/PaymentTransactions/credit-bank-account.php b/PaymentTransactions/credit-bank-account.php index 9e71294..1a9d0ab 100644 --- a/PaymentTransactions/credit-bank-account.php +++ b/PaymentTransactions/credit-bank-account.php @@ -60,6 +60,6 @@ function creditBankAccount($amount){ } return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) creditBankAccount(21.54); ?> diff --git a/PaymentTransactions/debit-bank-account.php b/PaymentTransactions/debit-bank-account.php index 3077b64..e050c63 100644 --- a/PaymentTransactions/debit-bank-account.php +++ b/PaymentTransactions/debit-bank-account.php @@ -65,6 +65,6 @@ function debitBankAccount($amount){ } return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) debitBankAccount(21.34); ?> diff --git a/PaymentTransactions/refund-transaction.php b/PaymentTransactions/refund-transaction.php index 1e32f26..629cf69 100644 --- a/PaymentTransactions/refund-transaction.php +++ b/PaymentTransactions/refund-transaction.php @@ -46,6 +46,6 @@ function refundTransaction($amount){ } return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) refundTransaction(32.14); ?> diff --git a/PaymentTransactions/update-split-tender-group.php b/PaymentTransactions/update-split-tender-group.php index 90832b4..5b96f8c 100644 --- a/PaymentTransactions/update-split-tender-group.php +++ b/PaymentTransactions/update-split-tender-group.php @@ -32,6 +32,6 @@ function updateSplitTenderGroup(){ return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) updateSplitTenderGroup(); ?> \ No newline at end of file diff --git a/PaymentTransactions/void-transaction.php b/PaymentTransactions/void-transaction.php index d82b032..4b6ff24 100644 --- a/PaymentTransactions/void-transaction.php +++ b/PaymentTransactions/void-transaction.php @@ -48,6 +48,6 @@ function voidTransaction($transactionid){ } return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) voidTransaction("2249063130"); ?> diff --git a/PaypalExpressCheckout/authorization-and-capture-continue.php b/PaypalExpressCheckout/authorization-and-capture-continue.php index 513b80d..e3c666f 100644 --- a/PaypalExpressCheckout/authorization-and-capture-continue.php +++ b/PaypalExpressCheckout/authorization-and-capture-continue.php @@ -59,6 +59,6 @@ function payPalAuthorizeCaptureContinue($refTransId, $payerID) { return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) payPalAuthorizeCaptureContinue("2241708986","6ZSCSYG33VP8Q"); ?> diff --git a/PaypalExpressCheckout/authorization-and-capture.php b/PaypalExpressCheckout/authorization-and-capture.php index 43be3a3..14f46cb 100644 --- a/PaypalExpressCheckout/authorization-and-capture.php +++ b/PaypalExpressCheckout/authorization-and-capture.php @@ -48,6 +48,6 @@ function payPalAuthorizeCapture($amount) { return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) payPalAuthorizeCapture(12.12); ?> diff --git a/PaypalExpressCheckout/authorization-only-continued.php b/PaypalExpressCheckout/authorization-only-continued.php index f703434..9759247 100644 --- a/PaypalExpressCheckout/authorization-only-continued.php +++ b/PaypalExpressCheckout/authorization-only-continued.php @@ -62,7 +62,7 @@ function payPalAuthorizeOnlyContinue($transactionId, $payerId) { return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) payPalAuthorizeOnlyContinue("2241711631", "JJLRRB29QC7RU"); ?> diff --git a/PaypalExpressCheckout/authorization-only.php b/PaypalExpressCheckout/authorization-only.php index 3f348bb..5ca4ebd 100644 --- a/PaypalExpressCheckout/authorization-only.php +++ b/PaypalExpressCheckout/authorization-only.php @@ -51,7 +51,7 @@ function payPalAuthorizeOnly($amount) { return $response; } -if(!defined(DONT_RUN_SAMPLES)) +if(!defined('DONT_RUN_SAMPLES')) payPalAuthorizeOnly(23.34); ?> diff --git a/PaypalExpressCheckout/credit.php b/PaypalExpressCheckout/credit.php index 9e9eeeb..36d358b 100644 --- a/PaypalExpressCheckout/credit.php +++ b/PaypalExpressCheckout/credit.php @@ -61,7 +61,7 @@ function payPalCredit($transactionId) { return $response; } -if(!defined(DONT_RUN_SAMPLES)) +if(!defined('DONT_RUN_SAMPLES')) payPalCredit("2241762126"); ?> diff --git a/PaypalExpressCheckout/get-details.php b/PaypalExpressCheckout/get-details.php index 2b4f68a..c83db8f 100644 --- a/PaypalExpressCheckout/get-details.php +++ b/PaypalExpressCheckout/get-details.php @@ -75,7 +75,7 @@ function payPalGetDetails($transactionId) { return $response; } -if(!defined(DONT_RUN_SAMPLES)) +if(!defined('DONT_RUN_SAMPLES')) payPalGetDetails("2241687090"); ?> \ No newline at end of file diff --git a/PaypalExpressCheckout/prior-authorization-capture.php b/PaypalExpressCheckout/prior-authorization-capture.php index eaf388b..62c1d50 100644 --- a/PaypalExpressCheckout/prior-authorization-capture.php +++ b/PaypalExpressCheckout/prior-authorization-capture.php @@ -53,6 +53,6 @@ function payPalPriorAuthorizationCapture($transactionId) { return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) payPalPriorAuthorizationCapture("2241687191"); ?> \ No newline at end of file diff --git a/PaypalExpressCheckout/void.php b/PaypalExpressCheckout/void.php index 7602be0..153eeba 100644 --- a/PaypalExpressCheckout/void.php +++ b/PaypalExpressCheckout/void.php @@ -52,7 +52,7 @@ function payPalVoid($transactionId) { return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) payPalVoid("2241706281"); ?> \ No newline at end of file diff --git a/RecurringBilling/cancel-subscription.php b/RecurringBilling/cancel-subscription.php index eaf06eb..9df68ba 100644 --- a/RecurringBilling/cancel-subscription.php +++ b/RecurringBilling/cancel-subscription.php @@ -36,7 +36,7 @@ function cancelSubscription($subscriptionId) { } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) cancelSubscription("3056945"); ?> diff --git a/RecurringBilling/create-subscription.php b/RecurringBilling/create-subscription.php index 8254e4a..f35df50 100644 --- a/RecurringBilling/create-subscription.php +++ b/RecurringBilling/create-subscription.php @@ -67,7 +67,7 @@ function createSubscription($intervalLength) { return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) createSubscription(23); ?> diff --git a/RecurringBilling/get-list-of-subscriptions.php b/RecurringBilling/get-list-of-subscriptions.php index f5c27fa..76f99fd 100644 --- a/RecurringBilling/get-list-of-subscriptions.php +++ b/RecurringBilling/get-list-of-subscriptions.php @@ -47,6 +47,6 @@ function getListOfSubscriptions() { return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) getListOfSubscriptions(); ?> diff --git a/RecurringBilling/get-subscription-status.php b/RecurringBilling/get-subscription-status.php index 06a143e..7e17b3f 100644 --- a/RecurringBilling/get-subscription-status.php +++ b/RecurringBilling/get-subscription-status.php @@ -35,7 +35,7 @@ function getSubscriptionStatus($subscriptionId) { return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) getSubscriptionStatus("3056945"); ?> diff --git a/RecurringBilling/get-subscription.php b/RecurringBilling/get-subscription.php index 5a02d13..28212af 100644 --- a/RecurringBilling/get-subscription.php +++ b/RecurringBilling/get-subscription.php @@ -55,6 +55,6 @@ function getSubscription($subscriptionId) { return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) getSubscription("2930242"); ?> diff --git a/RecurringBilling/update-subscription.php b/RecurringBilling/update-subscription.php index 8ab50b4..4fa2f7f 100644 --- a/RecurringBilling/update-subscription.php +++ b/RecurringBilling/update-subscription.php @@ -46,6 +46,6 @@ function updateSubscription($subscriptionId) { return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) updateSubscription("3056948"); ?> diff --git a/TransactionReporting/get-batch-statistics.php b/TransactionReporting/get-batch-statistics.php index 9772088..4dbaa4b 100644 --- a/TransactionReporting/get-batch-statistics.php +++ b/TransactionReporting/get-batch-statistics.php @@ -56,7 +56,7 @@ function getBatchStatistics() { return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) getBatchStatistics(); ?> \ No newline at end of file diff --git a/TransactionReporting/get-settled-batch-list.php b/TransactionReporting/get-settled-batch-list.php index 608ba8b..f92c876 100644 --- a/TransactionReporting/get-settled-batch-list.php +++ b/TransactionReporting/get-settled-batch-list.php @@ -63,7 +63,7 @@ function getSettledBatchList() { return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) getSettledBatchList(); ?> diff --git a/TransactionReporting/get-transaction-details.php b/TransactionReporting/get-transaction-details.php index 16905b0..1cfde4a 100644 --- a/TransactionReporting/get-transaction-details.php +++ b/TransactionReporting/get-transaction-details.php @@ -36,6 +36,6 @@ function getTransactionDetails($transactionId) { return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) getTransactionDetails("2238968786"); ?> \ No newline at end of file diff --git a/TransactionReporting/get-transaction-list.php b/TransactionReporting/get-transaction-list.php index 23b1901..f2ab420 100644 --- a/TransactionReporting/get-transaction-list.php +++ b/TransactionReporting/get-transaction-list.php @@ -47,6 +47,6 @@ function getTransactionList() { return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) getTransactionList(); ?> \ No newline at end of file diff --git a/TransactionReporting/get-unsettled-transaction-list.php b/TransactionReporting/get-unsettled-transaction-list.php index d6de5c8..cddcb39 100644 --- a/TransactionReporting/get-unsettled-transaction-list.php +++ b/TransactionReporting/get-unsettled-transaction-list.php @@ -38,7 +38,7 @@ function getUnsettledTransactionList() { return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) getUnsettledTransactionList(); ?> diff --git a/VisaCheckout/create-visa-checkout-transaction.php b/VisaCheckout/create-visa-checkout-transaction.php index 15bdef2..f9f2f3a 100644 --- a/VisaCheckout/create-visa-checkout-transaction.php +++ b/VisaCheckout/create-visa-checkout-transaction.php @@ -55,7 +55,7 @@ function createVisaCheckoutTransaction(){ return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) createVisaCheckoutTransaction(); ?> diff --git a/VisaCheckout/decrypt-visa-checkout-data.php b/VisaCheckout/decrypt-visa-checkout-data.php index 3885ee2..7c3c633 100644 --- a/VisaCheckout/decrypt-visa-checkout-data.php +++ b/VisaCheckout/decrypt-visa-checkout-data.php @@ -39,7 +39,7 @@ function decryptVisaCheckoutData(){ return $response; } - if(!defined(DONT_RUN_SAMPLES)) + if(!defined('DONT_RUN_SAMPLES')) decryptVisaCheckoutData(); ?> From 44f06e658011a2b86fe704aae70e8dca0b111b76 Mon Sep 17 00:00:00 2001 From: tyui Date: Fri, 29 Jan 2016 02:29:40 +0530 Subject: [PATCH 039/287] Added composer autoload attribute to use SampleCode namespace Added constants instead of value assignments in PaymentTransactions/ samples. capture-previously-authorized-amount failing --- PaymentTransactions/authorize-credit-card.php | 8 +++--- ...nds-authorized-through-another-channel.php | 8 +++--- .../capture-previously-authorized-amount.php | 4 +-- PaymentTransactions/charge-credit-card.php | 8 +++--- .../charge-customer-profile.php | 4 +-- .../charge-tokenized-credit-card.php | 8 +++--- PaymentTransactions/credit-bank-account.php | 14 +++++----- PaymentTransactions/debit-bank-account.php | 12 ++++----- PaymentTransactions/refund-transaction.php | 8 +++--- PaymentTransactions/void-transaction.php | 8 +++--- composer.json | 5 +++- constants/Constants.php | 26 +++++++++++++++++++ 12 files changed, 71 insertions(+), 42 deletions(-) create mode 100644 constants/Constants.php diff --git a/PaymentTransactions/authorize-credit-card.php b/PaymentTransactions/authorize-credit-card.php index 68185ae..2ee0b8e 100644 --- a/PaymentTransactions/authorize-credit-card.php +++ b/PaymentTransactions/authorize-credit-card.php @@ -7,14 +7,14 @@ function authorizeCreditCard($amount){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $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( "2038-12"); + $creditCard->setCardNumber( \SampleCode\Constants::CREDIT_CARD_NUMBER ); + $creditCard->setExpirationDate( \SampleCode\Constants::EXPIRY_DATE); $paymentOne = new AnetAPI\PaymentType(); $paymentOne->setCreditCard($creditCard); diff --git a/PaymentTransactions/capture-funds-authorized-through-another-channel.php b/PaymentTransactions/capture-funds-authorized-through-another-channel.php index b503f54..7737197 100644 --- a/PaymentTransactions/capture-funds-authorized-through-another-channel.php +++ b/PaymentTransactions/capture-funds-authorized-through-another-channel.php @@ -6,13 +6,13 @@ function captureFundsAuthorizedThroughAnotherChannel($amount){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); $refId = 'ref' . time(); $creditCard = new AnetAPI\CreditCardType(); - $creditCard->setCardNumber( "4111111111111111"); - $creditCard->setExpirationDate( "2038-12"); + $creditCard->setCardNumber( \SampleCode\Constants::CREDIT_CARD_NUMBER); + $creditCard->setExpirationDate( \SampleCode\Constants::EXPIRY_DATE); $paymentOne = new AnetAPI\PaymentType(); $paymentOne->setCreditCard($creditCard); diff --git a/PaymentTransactions/capture-previously-authorized-amount.php b/PaymentTransactions/capture-previously-authorized-amount.php index f80d3d0..aeb01ef 100644 --- a/PaymentTransactions/capture-previously-authorized-amount.php +++ b/PaymentTransactions/capture-previously-authorized-amount.php @@ -6,8 +6,8 @@ function capturePreviouslyAuthorizedAmount($transactionid){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); $refId = 'ref' . time(); // Now capture the previously authorized amount diff --git a/PaymentTransactions/charge-credit-card.php b/PaymentTransactions/charge-credit-card.php index d01eade..8f4083f 100644 --- a/PaymentTransactions/charge-credit-card.php +++ b/PaymentTransactions/charge-credit-card.php @@ -6,14 +6,14 @@ function chargeCreditCard($amount){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $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( "2038-12"); + $creditCard->setCardNumber(\SampleCode\Constants::CREDIT_CARD_NUMBER); + $creditCard->setExpirationDate(\SampleCode\Constants::EXPIRY_DATE); $paymentOne = new AnetAPI\PaymentType(); $paymentOne->setCreditCard($creditCard); diff --git a/PaymentTransactions/charge-customer-profile.php b/PaymentTransactions/charge-customer-profile.php index cca3718..f4dd204 100644 --- a/PaymentTransactions/charge-customer-profile.php +++ b/PaymentTransactions/charge-customer-profile.php @@ -6,8 +6,8 @@ function chargeCustomerProfile($profileid, $paymentprofileid, $amount){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); $refId = 'ref' . time(); $profileToCharge = new AnetAPI\CustomerProfilePaymentType(); diff --git a/PaymentTransactions/charge-tokenized-credit-card.php b/PaymentTransactions/charge-tokenized-credit-card.php index 59f6397..3f51b68 100644 --- a/PaymentTransactions/charge-tokenized-credit-card.php +++ b/PaymentTransactions/charge-tokenized-credit-card.php @@ -6,14 +6,14 @@ function chargeTokenizedCreditCard($amount){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $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( "2038-12"); + $creditCard->setCardNumber( \SampleCode\Constants::CREDIT_CARD_NUMBER ); + $creditCard->setExpirationDate( \SampleCode\Constants::EXPIRY_DATE); //Set the cryptogram $creditCard->setCryptogram("EjRWeJASNFZ4kBI0VniQEjRWeJA="); diff --git a/PaymentTransactions/credit-bank-account.php b/PaymentTransactions/credit-bank-account.php index 1a9d0ab..4886d63 100644 --- a/PaymentTransactions/credit-bank-account.php +++ b/PaymentTransactions/credit-bank-account.php @@ -6,22 +6,22 @@ function creditBankAccount($amount){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); $refId = 'ref' . time(); // Create the payment data for a Bank Account $bankAccount = new AnetAPI\BankAccountType(); - $bankAccount->setRoutingNumber('125000024'); - $bankAccount->setAccountNumber('12345678'); - $bankAccount->setNameOnAccount('John Doe'); + $bankAccount->setRoutingNumber(\SampleCode\Constants::ROUTING_NUMBER); + $bankAccount->setAccountNumber(\SampleCode\Constants::ACCOUNT_NUMBER); + $bankAccount->setNameOnAccount(\SampleCode\Constants::NAME_ON_ACCOUNT); $paymentBank= new AnetAPI\PaymentType(); $paymentBank->setBankAccount($bankAccount); // Order info $order = new AnetAPI\OrderType(); - $order->setInvoiceNumber("101"); - $order->setDescription("Golf Shirts"); + $order->setInvoiceNumber(\SampleCode\Constants::INVOICE_NUMBER); + $order->setDescription(\SampleCode\Constants::ORDER_DESCRIPTION); //create a debit card Bank transaction diff --git a/PaymentTransactions/debit-bank-account.php b/PaymentTransactions/debit-bank-account.php index e050c63..e854f8e 100644 --- a/PaymentTransactions/debit-bank-account.php +++ b/PaymentTransactions/debit-bank-account.php @@ -6,18 +6,18 @@ function debitBankAccount($amount){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); $refId = 'ref' . time(); // Create the payment data for a Bank Account $bankAccount = new AnetAPI\BankAccountType(); //$bankAccount->setAccountType('CHECKING'); $bankAccount->setEcheckType('WEB'); - $bankAccount->setRoutingNumber('121042882'); - $bankAccount->setAccountNumber('123456789123'); - $bankAccount->setNameOnAccount('Jane Doe'); - $bankAccount->setBankName('Bank of the Earth'); + $bankAccount->setRoutingNumber(\SampleCode\Constants::DEBIT_ROUTING_NUMBER); + $bankAccount->setAccountNumber(\SampleCode\Constants::DEBIT_ACCOUNT_NUMBER); + $bankAccount->setNameOnAccount(\SampleCode\Constants::NAME_ON_ACCOUNT); + $bankAccount->setBankName(\SampleCode\Constants::BANK_NAME); $paymentBank= new AnetAPI\PaymentType(); $paymentBank->setBankAccount($bankAccount); diff --git a/PaymentTransactions/refund-transaction.php b/PaymentTransactions/refund-transaction.php index 629cf69..0e6fadc 100644 --- a/PaymentTransactions/refund-transaction.php +++ b/PaymentTransactions/refund-transaction.php @@ -6,14 +6,14 @@ function refundTransaction($amount){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $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( "2038-12"); + $creditCard->setCardNumber( \SampleCode\Constants::CREDIT_CARD_NUMBER ); + $creditCard->setExpirationDate( \SampleCode\Constants::EXPIRY_DATE); $paymentOne = new AnetAPI\PaymentType(); $paymentOne->setCreditCard($creditCard); //create a transaction diff --git a/PaymentTransactions/void-transaction.php b/PaymentTransactions/void-transaction.php index 4b6ff24..0bf67ba 100644 --- a/PaymentTransactions/void-transaction.php +++ b/PaymentTransactions/void-transaction.php @@ -6,14 +6,14 @@ function voidTransaction($transactionid){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $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( "2038-12"); + $creditCard->setCardNumber( \SampleCode\Constants::CREDIT_CARD_NUMBER ); + $creditCard->setExpirationDate( \SampleCode\Constants::EXPIRY_DATE); $paymentOne = new AnetAPI\PaymentType(); $paymentOne->setCreditCard($creditCard); //create a transaction diff --git a/composer.json b/composer.json index 553a20a..0f3d438 100644 --- a/composer.json +++ b/composer.json @@ -13,5 +13,8 @@ "repositories": [{ "type": "vcs", "url": "https://github.com/goetas/serializer.git" - }] + }], + "autoload": { + "classmap": ["constants"] + } } diff --git a/constants/Constants.php b/constants/Constants.php new file mode 100644 index 0000000..ef32c58 --- /dev/null +++ b/constants/Constants.php @@ -0,0 +1,26 @@ + \ No newline at end of file From c1fcfbd23b76e7db00a3d37ea951fbde6df92ca1 Mon Sep 17 00:00:00 2001 From: ashtru Date: Fri, 29 Jan 2016 18:01:43 +0530 Subject: [PATCH 040/287] Added constants like merchant login id, transaction key. Fixed output logic of PaypalExpressCheckout\get-details.php --- .../create-an-apple-pay-transaction.php | 4 +- .../create-customer-payment-profile.php | 12 ++-- ...eate-customer-profile-from-transaction.php | 10 ++-- CustomerProfiles/create-customer-profile.php | 12 ++-- .../create-customer-shipping-address.php | 9 +-- .../delete-customer-payment-profile.php | 9 +-- CustomerProfiles/delete-customer-profile.php | 8 +-- .../delete-customer-shipping-address.php | 9 +-- .../get-customer-payment-profile-list.php | 6 +- .../get-customer-payment-profile.php | 7 ++- CustomerProfiles/get-customer-profile-ids.php | 4 +- CustomerProfiles/get-customer-profile.php | 4 +- .../get-customer-shipping-address.php | 9 +-- CustomerProfiles/get-hosted-profile-page.php | 8 +-- .../update-customer-payment-profile.php | 9 +-- CustomerProfiles/update-customer-profile.php | 4 +- .../update-customer-shipping-address.php | 9 +-- .../validate-customer-payment-profile.php | 9 +-- PaymentTransactions/authorize-credit-card.php | 4 +- ...nds-authorized-through-another-channel.php | 10 ++-- .../capture-previously-authorized-amount.php | 8 +-- PaymentTransactions/charge-credit-card.php | 4 +- .../charge-customer-profile.php | 5 +- .../charge-tokenized-credit-card.php | 6 +- PaymentTransactions/credit-bank-account.php | 4 +- PaymentTransactions/debit-bank-account.php | 4 +- PaymentTransactions/refund-transaction.php | 6 +- .../update-split-tender-group.php | 8 +-- PaymentTransactions/void-transaction.php | 7 ++- .../authorization-and-capture-continue.php | 7 ++- .../authorization-and-capture.php | 6 +- .../authorization-only-continued.php | 4 +- PaypalExpressCheckout/authorization-only.php | 4 +- PaypalExpressCheckout/credit.php | 12 ++-- PaypalExpressCheckout/get-details.php | 50 +++++++++++----- .../prior-authorization-capture.php | 8 ++- PaypalExpressCheckout/void.php | 4 +- RecurringBilling/cancel-subscription.php | 7 +-- RecurringBilling/create-subscription.php | 10 ++-- .../get-list-of-subscriptions.php | 6 +- RecurringBilling/get-subscription-status.php | 8 +-- RecurringBilling/get-subscription.php | 8 +-- RecurringBilling/update-subscription.php | 10 ++-- TransactionReporting/get-batch-statistics.php | 6 +- .../get-settled-batch-list.php | 4 +- .../get-transaction-details.php | 6 +- TransactionReporting/get-transaction-list.php | 4 +- .../get-unsettled-transaction-list.php | 4 +- .../create-visa-checkout-transaction.php | 10 ++-- VisaCheckout/decrypt-visa-checkout-data.php | 10 ++-- constants/Constants.php | 58 +++++++++++++++++++ 51 files changed, 271 insertions(+), 183 deletions(-) diff --git a/ApplePayTransactions/create-an-apple-pay-transaction.php b/ApplePayTransactions/create-an-apple-pay-transaction.php index 0eb11bc..91f7690 100644 --- a/ApplePayTransactions/create-an-apple-pay-transaction.php +++ b/ApplePayTransactions/create-an-apple-pay-transaction.php @@ -6,8 +6,8 @@ function createAnApplePayTransaction(){ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); $refId = 'ref' . time(); $op = new AnetAPI\OpaqueDataType(); diff --git a/CustomerProfiles/create-customer-payment-profile.php b/CustomerProfiles/create-customer-payment-profile.php index 5779fa1..fc707df 100644 --- a/CustomerProfiles/create-customer-payment-profile.php +++ b/CustomerProfiles/create-customer-payment-profile.php @@ -6,14 +6,14 @@ function createCustomerPaymentProfile($existingcustomerprofileid, $phoneNumber){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); $refId = 'ref' . time(); $creditCard = new AnetAPI\CreditCardType(); - $creditCard->setCardNumber( "4242424242424242" ); - $creditCard->setExpirationDate( "2038-11"); - $creditCard->setCardCode( "142"); + $creditCard->setCardNumber( \SampleCode\Constants::CREDIT_CARD_NUMBER_2); + $creditCard->setExpirationDate( \SampleCode\Constants::EXPIRY_DATE); + $creditCard->setCardCode( \SampleCode\Constants::CVV); $paymentCreditCard = new AnetAPI\PaymentType(); $paymentCreditCard->setCreditCard($creditCard); @@ -60,5 +60,5 @@ function createCustomerPaymentProfile($existingcustomerprofileid, $phoneNumber){ return $response; } if(!defined('DONT_RUN_SAMPLES')) - createCustomerPaymentProfile("36152127","000-000-0009"); + createCustomerPaymentProfile(\SampleCode\Constants::CUSTOMER_PROFILE_ID,"000-000-0009"); ?> diff --git a/CustomerProfiles/create-customer-profile-from-transaction.php b/CustomerProfiles/create-customer-profile-from-transaction.php index c35c92b..a32d64c 100644 --- a/CustomerProfiles/create-customer-profile-from-transaction.php +++ b/CustomerProfiles/create-customer-profile-from-transaction.php @@ -3,13 +3,13 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; - function createCustomerProfileFromTransaction($transId="2238251168") + function createCustomerProfileFromTransaction($transId= \SampleCode\Constants::TRANS_ID_TO_CREATE_CUSTOMER_PROFILE) { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); - + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $request = new AnetAPI\CreateCustomerProfileFromTransactionRequest(); $request->setMerchantAuthentication($merchantAuthentication); $request->setTransId($transId); @@ -31,5 +31,5 @@ function createCustomerProfileFromTransaction($transId="2238251168") } //provide a transaction that has customer information if(!defined('DONT_RUN_SAMPLES')) - createCustomerProfileFromTransaction("2249066517"); + createCustomerProfileFromTransaction(\SampleCode\Constants::TRANS_ID_TO_CREATE_CUSTOMER_PROFILE); ?> diff --git a/CustomerProfiles/create-customer-profile.php b/CustomerProfiles/create-customer-profile.php index 15fabc4..87e6465 100644 --- a/CustomerProfiles/create-customer-profile.php +++ b/CustomerProfiles/create-customer-profile.php @@ -7,14 +7,14 @@ function createCustomerProfile($email){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); - $refId = 'ref' . time(); + $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( "2038-12"); + $creditCard->setCardNumber( \SampleCode\Constants::CREDIT_CARD_NUMBER); + $creditCard->setExpirationDate( \SampleCode\Constants::EXPIRY_DATE); $paymentCreditCard = new AnetAPI\PaymentType(); $paymentCreditCard->setCreditCard($creditCard); @@ -68,5 +68,5 @@ function createCustomerProfile($email){ return $response; } if(!defined('DONT_RUN_SAMPLES')) - createCustomerProfile("test567@test.com"); + createCustomerProfile( \SampleCode\Constants::TEST_CUSTOMER_EMAIL); ?> diff --git a/CustomerProfiles/create-customer-shipping-address.php b/CustomerProfiles/create-customer-shipping-address.php index aeb5d73..1c31fff 100644 --- a/CustomerProfiles/create-customer-shipping-address.php +++ b/CustomerProfiles/create-customer-shipping-address.php @@ -2,13 +2,14 @@ require 'vendor/autoload.php'; use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; - function createCustomerShippingAddress($existingcustomerprofileid = "36152127", $phoneNumber="000-000-0000") + function createCustomerShippingAddress($existingcustomerprofileid = \SampleCode\Constants::CUSTOMER_PROFILE_ID, + $phoneNumber= \SampleCode\Constants::PHONE_NUMBER) { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); - + $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 // Create the customer shipping address diff --git a/CustomerProfiles/delete-customer-payment-profile.php b/CustomerProfiles/delete-customer-payment-profile.php index 61138ec..1967b00 100644 --- a/CustomerProfiles/delete-customer-payment-profile.php +++ b/CustomerProfiles/delete-customer-payment-profile.php @@ -3,13 +3,14 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; - function deleteCustomerPaymentProfile($customerProfileId="36152127", $customerpaymentprofileid = "32689274") + function deleteCustomerPaymentProfile($customerProfileId= \SampleCode\Constants::CUSTOMER_PROFILE_ID, + $customerpaymentprofileid = \SampleCode\Constants::CUSTOMER_PAYMENT_PROFILE_ID) { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); - + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + // Use an existing payment profile ID for this Merchant name and Transaction key $request = new AnetAPI\DeleteCustomerPaymentProfileRequest(); diff --git a/CustomerProfiles/delete-customer-profile.php b/CustomerProfiles/delete-customer-profile.php index 5b9a688..ded52a6 100644 --- a/CustomerProfiles/delete-customer-profile.php +++ b/CustomerProfiles/delete-customer-profile.php @@ -7,9 +7,9 @@ function deleteCustomerProfile($customerProfileId) { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); - $refId = 'ref' . time(); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $refId = 'ref' . time(); // Delete an existing customer profile $request = new AnetAPI\DeleteCustomerProfileRequest(); @@ -33,5 +33,5 @@ function deleteCustomerProfile($customerProfileId) } if(!defined('DONT_RUN_SAMPLES')) - deleteCustomerProfile("38958129"); + deleteCustomerProfile( \SampleCode\Constants::CUSTOMER_PAYMENT_PROFILE_ID_DELETE); ?> diff --git a/CustomerProfiles/delete-customer-shipping-address.php b/CustomerProfiles/delete-customer-shipping-address.php index 3bac6b2..a7983e6 100644 --- a/CustomerProfiles/delete-customer-shipping-address.php +++ b/CustomerProfiles/delete-customer-shipping-address.php @@ -3,13 +3,14 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; - function deleteCustomerShippingAddress($customerprofileid = "36152127", $customeraddressid = "36976434") + function deleteCustomerShippingAddress($customerprofileid = \SampleCode\Constants::CUSTOMER_PROFILE_ID_2, + $customeraddressid = "36976434") { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); - + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + // 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 $request = new AnetAPI\DeleteCustomerShippingAddressRequest(); diff --git a/CustomerProfiles/get-customer-payment-profile-list.php b/CustomerProfiles/get-customer-payment-profile-list.php index 889f708..5f1d61a 100644 --- a/CustomerProfiles/get-customer-payment-profile-list.php +++ b/CustomerProfiles/get-customer-payment-profile-list.php @@ -9,9 +9,9 @@ function getCustomerPaymentProfileList() { // Common setup for API credentials (merchant) $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); - $refId = 'ref' . time(); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $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 f91e6b6..171cf19 100644 --- a/CustomerProfiles/get-customer-payment-profile.php +++ b/CustomerProfiles/get-customer-payment-profile.php @@ -6,12 +6,13 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; -function getCustomerPaymentProfile($customerProfileId="36731856", $customerPaymentProfileId="33211899") +function getCustomerPaymentProfile($customerProfileId=\SampleCode\Constants::CUSTOMER_PROFILE_ID_2, + $customerPaymentProfileId= \SampleCode\Constants::CUSTOMER_PAYMENT_PROFILE_ID_GET) { // Common setup for API credentials (merchant) $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); -$merchantAuthentication->setName("5KP3u95bQpv"); -$merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); +$merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); +$merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); $refId = 'ref' . time(); //request requires customerProfileId and customerPaymentProfileId diff --git a/CustomerProfiles/get-customer-profile-ids.php b/CustomerProfiles/get-customer-profile-ids.php index e7dfeaf..d707ac2 100644 --- a/CustomerProfiles/get-customer-profile-ids.php +++ b/CustomerProfiles/get-customer-profile-ids.php @@ -6,8 +6,8 @@ function getCustomerProfileIds() { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); $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 8bf7f8c..82085bb 100644 --- a/CustomerProfiles/get-customer-profile.php +++ b/CustomerProfiles/get-customer-profile.php @@ -7,8 +7,8 @@ function getCustomerProfile(){ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $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 diff --git a/CustomerProfiles/get-customer-shipping-address.php b/CustomerProfiles/get-customer-shipping-address.php index 3659810..f209489 100644 --- a/CustomerProfiles/get-customer-shipping-address.php +++ b/CustomerProfiles/get-customer-shipping-address.php @@ -6,9 +6,9 @@ function getCustomerShippingAddress($customerprofileid, $customeraddressid) { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); - + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + // An existing customer profile id and shipping address id for this merchant name and transaction key $customerProfileId = $customerprofileid; $customerAddressId = $customeraddressid; @@ -45,5 +45,6 @@ function getCustomerShippingAddress($customerprofileid, $customeraddressid) return $response; } if(!defined('DONT_RUN_SAMPLES')) - getCustomerShippingAddress("36152127", "36976566"); + getCustomerShippingAddress(\SampleCode\Constants::CUSTOMER_PROFILE_ID, + \SampleCode\Constants::CUSTOMER_SHIPPING_ADDRESS_ID_GET); ?> diff --git a/CustomerProfiles/get-hosted-profile-page.php b/CustomerProfiles/get-hosted-profile-page.php index 66e443a..b145379 100644 --- a/CustomerProfiles/get-hosted-profile-page.php +++ b/CustomerProfiles/get-hosted-profile-page.php @@ -3,13 +3,13 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; - function getHostedProfilePage($customerprofileid = "37680862") + function getHostedProfilePage($customerprofileid = \SampleCode\Constants::CUSTOMER_PROFILE_ID_HOSTED_PAGE) { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); - + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + // Use an existing payment profile ID for this Merchant name and Transaction key $setting = new AnetAPI\SettingType(); diff --git a/CustomerProfiles/update-customer-payment-profile.php b/CustomerProfiles/update-customer-payment-profile.php index 8a77b4b..9aa15f5 100644 --- a/CustomerProfiles/update-customer-payment-profile.php +++ b/CustomerProfiles/update-customer-payment-profile.php @@ -2,13 +2,14 @@ require 'vendor/autoload.php'; use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; - function updateCustomerPaymentProfile($customerProfileId="36731856", $customerPaymentProfileId="33211899") + function updateCustomerPaymentProfile($customerProfileId= \SampleCode\Constants::CUSTOMER_PROFILE_ID_2, + $customerPaymentProfileId= \SampleCode\Constants::CUSTOMER_PAYMENT_PROFILE_ID_GET) { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); - $refId = 'ref' . time(); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $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 c4d2a0f..f8c8356 100644 --- a/CustomerProfiles/update-customer-profile.php +++ b/CustomerProfiles/update-customer-profile.php @@ -6,8 +6,8 @@ function updateCustomerProfile() { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $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 diff --git a/CustomerProfiles/update-customer-shipping-address.php b/CustomerProfiles/update-customer-shipping-address.php index 0d2b065..092aae3 100644 --- a/CustomerProfiles/update-customer-shipping-address.php +++ b/CustomerProfiles/update-customer-shipping-address.php @@ -6,8 +6,8 @@ function updateCustomerShippingAddress($customerprofileid, $customeraddressid) { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); // An existing customer profile id for this merchant name and transaction key $existingcustomerprofileid = $customerprofileid; @@ -35,7 +35,7 @@ function updateCustomerShippingAddress($customerprofileid, $customeraddressid) $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) { - echo "Update Customer Shipping Address SUCCESS:" . "\n"; + echo "Update Customer Shipping Address SUCCESS.\n"; } else { @@ -45,5 +45,6 @@ function updateCustomerShippingAddress($customerprofileid, $customeraddressid) return $response; } if(!defined('DONT_RUN_SAMPLES')) - updateCustomerShippingAddress("36152127", "36976566"); + updateCustomerShippingAddress( \SampleCode\Constants::CUSTOMER_PROFILE_ID, + \SampleCode\Constants::CUSTOMER_SHIPPING_ADDRESS_ID_GET); ?> diff --git a/CustomerProfiles/validate-customer-payment-profile.php b/CustomerProfiles/validate-customer-payment-profile.php index 371106a..9293fc3 100644 --- a/CustomerProfiles/validate-customer-payment-profile.php +++ b/CustomerProfiles/validate-customer-payment-profile.php @@ -3,13 +3,14 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; - function validateCustomerPaymentProfile($customerProfileId="36731856", $customerPaymentProfileId="33211899") + function validateCustomerPaymentProfile($customerProfileId= \SampleCode\Constants::CUSTOMER_PROFILE_ID_2, + $customerPaymentProfileId= \SampleCode\Constants::CUSTOMER_PAYMENT_PROFILE_ID_GET) { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); - + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + // Use an existing payment profile ID for this Merchant name and Transaction key //validationmode tests , does not send an email receipt $validationmode = "testMode"; diff --git a/PaymentTransactions/authorize-credit-card.php b/PaymentTransactions/authorize-credit-card.php index 2ee0b8e..dcce7e4 100644 --- a/PaymentTransactions/authorize-credit-card.php +++ b/PaymentTransactions/authorize-credit-card.php @@ -36,7 +36,7 @@ function authorizeCreditCard($amount){ { $tresponse = $response->getTransactionResponse(); - if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + if (($tresponse != null) && ($tresponse->getResponseCode()== \SampleCode\Constants::RESPONSE_OK) ) { echo " AUTH CODE : " . $tresponse->getAuthCode() . "\n"; echo " TRANS ID : " . $tresponse->getTransId() . "\n"; @@ -54,5 +54,5 @@ function authorizeCreditCard($amount){ return $response; } if(!defined('DONT_RUN_SAMPLES')) - authorizeCreditCard(12.23); + authorizeCreditCard( \SampleCode\Constants::SAMPLE_AMOUNT); ?> \ 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 7737197..4cc29ac 100644 --- a/PaymentTransactions/capture-funds-authorized-through-another-channel.php +++ b/PaymentTransactions/capture-funds-authorized-through-another-channel.php @@ -23,7 +23,7 @@ function captureFundsAuthorizedThroughAnotherChannel($amount){ $transactionRequestType->setPayment($paymentOne); //Auth code of the previously authorized amount - $transactionRequestType->setAuthCode("ROHNFQ"); + $transactionRequestType->setAuthCode(\SampleCode\Constants::SAMPLE_AUTH_CODE_AUTHORIZED); $request = new AnetAPI\CreateTransactionRequest(); @@ -36,10 +36,10 @@ function captureFundsAuthorizedThroughAnotherChannel($amount){ if ($response != null) { $tresponse = $response->getTransactionResponse(); - if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + if (($tresponse != null) && ($tresponse->getResponseCode()== \SampleCode\Constants::RESPONSE_OK) ) { echo "Successful." . "\n"; - echo "Capture funds authorized through another channel TRANS ID : " . $tresponse->getTransId() . "\n"; + echo "Capture funds authorized through another channel TRANS ID : " . $tresponse->getTransId() . " Amount : $amount \n"; } else { @@ -49,10 +49,10 @@ function captureFundsAuthorizedThroughAnotherChannel($amount){ } else { - echo "Capture funds authorized through another channel NULL Response Error\n"; + echo "Capture funds authorized through another channel, NULL Response Error\n"; } return $response; } if(!defined('DONT_RUN_SAMPLES')) - captureFundsAuthorizedThroughAnotherChannel(5.0); + captureFundsAuthorizedThroughAnotherChannel((rand(1, \SampleCode\Constants::MAX_AMOUNT)/12*12)); ?> diff --git a/PaymentTransactions/capture-previously-authorized-amount.php b/PaymentTransactions/capture-previously-authorized-amount.php index aeb01ef..03e8aca 100644 --- a/PaymentTransactions/capture-previously-authorized-amount.php +++ b/PaymentTransactions/capture-previously-authorized-amount.php @@ -27,10 +27,10 @@ function capturePreviouslyAuthorizedAmount($transactionid){ if ($response != null) { $tresponse = $response->getTransactionResponse(); - if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + if (($tresponse != null) && ($tresponse->getResponseCode()== \SampleCode\Constants::RESPONSE_OK) ) { echo "Successful." . "\n"; - echo "Capture Previously Authorized Amount TRANS ID : " . $tresponse->getTransId() . "\n"; + echo "Capture Previously Authorized Amount, Trans ID : " . $tresponse->getRefTransId() . "\n"; } else { @@ -39,10 +39,10 @@ function capturePreviouslyAuthorizedAmount($transactionid){ } else { - echo "Capture Previously Authorized Amount NULL Response Error\n"; + echo "Capture Previously Authorized Amount, NULL Response Error\n"; } return $response; } if(!defined('DONT_RUN_SAMPLES')) - capturePreviouslyAuthorizedAmount(2245440574); + capturePreviouslyAuthorizedAmount(\SampleCode\Constants::TRANS_ID_PREVIOUSLY_AUTHORIZED); ?> diff --git a/PaymentTransactions/charge-credit-card.php b/PaymentTransactions/charge-credit-card.php index 8f4083f..28033d1 100644 --- a/PaymentTransactions/charge-credit-card.php +++ b/PaymentTransactions/charge-credit-card.php @@ -34,7 +34,7 @@ function chargeCreditCard($amount){ { $tresponse = $response->getTransactionResponse(); - if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + if (($tresponse != null) && ($tresponse->getResponseCode()== \SampleCode\Constants::RESPONSE_OK) ) { echo "Charge Credit Card AUTH CODE : " . $tresponse->getAuthCode() . "\n"; echo "Charge Credit Card TRANS ID : " . $tresponse->getTransId() . "\n"; @@ -52,5 +52,5 @@ function chargeCreditCard($amount){ return $response; } if(!defined('DONT_RUN_SAMPLES')) - chargeCreditCard(17.9); + chargeCreditCard(\SampleCode\Constants::SAMPLE_AMOUNT); ?> diff --git a/PaymentTransactions/charge-customer-profile.php b/PaymentTransactions/charge-customer-profile.php index f4dd204..91441bc 100644 --- a/PaymentTransactions/charge-customer-profile.php +++ b/PaymentTransactions/charge-customer-profile.php @@ -31,7 +31,7 @@ function chargeCustomerProfile($profileid, $paymentprofileid, $amount){ if ($response != null) { $tresponse = $response->getTransactionResponse(); - if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + if (($tresponse != null) && ($tresponse->getResponseCode()== \SampleCode\Constants::RESPONSE_OK) ) { echo "Charge Customer Profile APPROVED :" . "\n"; echo " Charge Customer Profile AUTH CODE : " . $tresponse->getAuthCode() . "\n"; @@ -53,5 +53,6 @@ function chargeCustomerProfile($profileid, $paymentprofileid, $amount){ return $response; } if(!defined('DONT_RUN_SAMPLES')) - chargeCustomerProfile("36152127", "32689274", 99.32); + chargeCustomerProfile(\SampleCode\Constants::CUSTOMER_PROFILE_ID, + \SampleCode\Constants::CUSTOMER_PAYMENT_PROFILE_ID, \SampleCode\Constants::SAMPLE_AMOUNT); ?> diff --git a/PaymentTransactions/charge-tokenized-credit-card.php b/PaymentTransactions/charge-tokenized-credit-card.php index 3f51b68..5face6b 100644 --- a/PaymentTransactions/charge-tokenized-credit-card.php +++ b/PaymentTransactions/charge-tokenized-credit-card.php @@ -15,7 +15,7 @@ function chargeTokenizedCreditCard($amount){ $creditCard->setCardNumber( \SampleCode\Constants::CREDIT_CARD_NUMBER ); $creditCard->setExpirationDate( \SampleCode\Constants::EXPIRY_DATE); //Set the cryptogram - $creditCard->setCryptogram("EjRWeJASNFZ4kBI0VniQEjRWeJA="); + $creditCard->setCryptogram( \SampleCode\Constants::CRYPTOGRAM); $paymentOne = new AnetAPI\PaymentType(); $paymentOne->setCreditCard($creditCard); @@ -37,7 +37,7 @@ function chargeTokenizedCreditCard($amount){ if ($response != null) { $tresponse = $response->getTransactionResponse(); - if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + if (($tresponse != null) && ($tresponse->getResponseCode()== \SampleCode\Constants::RESPONSE_OK) ) { echo "Charge Tokenized Credit Card AUTH CODE : " . $tresponse->getAuthCode() . "\n"; echo "Charge Tokenized Credit Card TRANS ID : " . $tresponse->getTransId() . "\n"; @@ -54,5 +54,5 @@ function chargeTokenizedCreditCard($amount){ return $response; } if(!defined('DONT_RUN_SAMPLES')) - chargeTokenizedCreditCard(13.5); + chargeTokenizedCreditCard( \SampleCode\Constants::SAMPLE_AMOUNT); ?> diff --git a/PaymentTransactions/credit-bank-account.php b/PaymentTransactions/credit-bank-account.php index 4886d63..822266e 100644 --- a/PaymentTransactions/credit-bank-account.php +++ b/PaymentTransactions/credit-bank-account.php @@ -39,7 +39,7 @@ function creditBankAccount($amount){ if ($response != null) { $tresponse = $response->getTransactionResponse(); - if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + if (($tresponse != null) && ($tresponse->getResponseCode()== \SampleCode\Constants::RESPONSE_OK) ) { echo "Credit Bank Account APPROVED :" . "\n"; echo "Credit Bank Account AUTH CODE : " . $tresponse->getAuthCode() . "\n"; @@ -61,5 +61,5 @@ function creditBankAccount($amount){ return $response; } if(!defined('DONT_RUN_SAMPLES')) - creditBankAccount(21.54); + creditBankAccount( \SampleCode\Constants::SAMPLE_AMOUNT); ?> diff --git a/PaymentTransactions/debit-bank-account.php b/PaymentTransactions/debit-bank-account.php index e854f8e..1f69320 100644 --- a/PaymentTransactions/debit-bank-account.php +++ b/PaymentTransactions/debit-bank-account.php @@ -39,7 +39,7 @@ function debitBankAccount($amount){ if ($response != null) { $tresponse = $response->getTransactionResponse(); - if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + if (($tresponse != null) && ($tresponse->getResponseCode()== \SampleCode\Constants::RESPONSE_OK) ) { echo "Debit Bank Account APPROVED :" . "\n"; echo " Debit Bank Account AUTH CODE : " . $tresponse->getAuthCode() . "\n"; @@ -66,5 +66,5 @@ function debitBankAccount($amount){ return $response; } if(!defined('DONT_RUN_SAMPLES')) - debitBankAccount(21.34); + debitBankAccount( \SampleCode\Constants::SAMPLE_AMOUNT); ?> diff --git a/PaymentTransactions/refund-transaction.php b/PaymentTransactions/refund-transaction.php index 0e6fadc..2c90255 100644 --- a/PaymentTransactions/refund-transaction.php +++ b/PaymentTransactions/refund-transaction.php @@ -30,7 +30,7 @@ function refundTransaction($amount){ if ($response != null) { $tresponse = $response->getTransactionResponse(); - if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + if (($tresponse != null) && ($tresponse->getResponseCode()== \SampleCode\Constants::RESPONSE_OK) ) { echo "Refund SUCCESS: " . $tresponse->getTransId() . "\n"; } @@ -47,5 +47,5 @@ function refundTransaction($amount){ return $response; } if(!defined('DONT_RUN_SAMPLES')) - refundTransaction(32.14); -?> + refundTransaction( \SampleCode\Constants::SAMPLE_AMOUNT_REFUND); +?> \ No newline at end of file diff --git a/PaymentTransactions/update-split-tender-group.php b/PaymentTransactions/update-split-tender-group.php index 5b96f8c..998468c 100644 --- a/PaymentTransactions/update-split-tender-group.php +++ b/PaymentTransactions/update-split-tender-group.php @@ -6,15 +6,15 @@ function updateSplitTenderGroup(){ // Common Set Up for API Credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName( "8V4xFm3z"); - $merchantAuthentication->setTransactionKey("655AS4Ek7TJ42snq"); + $merchantAuthentication->setName( \SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); $refId = 'ref' . time(); $request = new AnetAPI\UpdateSplitTenderGroupRequest(); $request->setMerchantAuthentication($merchantAuthentication); $request->setRefId($refId); - $request->setSplitTenderId("116468"); - $request->setSplitTenderStatus("voided"); + $request->setSplitTenderId(\SampleCode\Constants::SPLIT_TENDER_ID); + $request->setSplitTenderStatus(\SampleCode\Constants::STATUS_VOID); $controller = new AnetController\UpdateSplitTenderGroupController($request); diff --git a/PaymentTransactions/void-transaction.php b/PaymentTransactions/void-transaction.php index 0bf67ba..5bc74a6 100644 --- a/PaymentTransactions/void-transaction.php +++ b/PaymentTransactions/void-transaction.php @@ -31,7 +31,7 @@ function voidTransaction($transactionid){ if ($response != null) { $tresponse = $response->getTransactionResponse(); - if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + if (($tresponse != null) && ($tresponse->getResponseCode()== \SampleCode\Constants::RESPONSE_OK) ) { echo "Void transaction SUCCESS AUTH CODE: " . $tresponse->getAuthCode() . "\n"; echo "Void transaction SUCCESS TRANS ID : " . $tresponse->getTransId() . "\n"; @@ -39,8 +39,9 @@ function voidTransaction($transactionid){ else { echo "void transaction ERROR : " . $tresponse->getResponseCode() . "\n"; + echo "Response Code : " . $response->getMessages()->getMessage()[0]->getCode() . " Resposne text: " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + //use print_r to see whole $response which will have the specific error messages } - } else { @@ -49,5 +50,5 @@ function voidTransaction($transactionid){ return $response; } if(!defined('DONT_RUN_SAMPLES')) - voidTransaction("2249063130"); + voidTransaction(\SampleCode\Constants::TRANS_ID_VOID); ?> diff --git a/PaypalExpressCheckout/authorization-and-capture-continue.php b/PaypalExpressCheckout/authorization-and-capture-continue.php index e3c666f..4d5199a 100644 --- a/PaypalExpressCheckout/authorization-and-capture-continue.php +++ b/PaypalExpressCheckout/authorization-and-capture-continue.php @@ -7,8 +7,8 @@ function payPalAuthorizeCaptureContinue($refTransId, $payerID) { // Common setup for API credentials (with PayPal compatible merchant credentials) $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); $payPalType=new AnetAPI\PayPalType(); $payPalType->setPayerID($payerID); @@ -60,5 +60,6 @@ function payPalAuthorizeCaptureContinue($refTransId, $payerID) { } if(!defined('DONT_RUN_SAMPLES')) - payPalAuthorizeCaptureContinue("2241708986","6ZSCSYG33VP8Q"); + payPalAuthorizeCaptureContinue(\SampleCode\Constants::TRANS_ID_PAYPAL, + \SampleCode\Constants::PAYER_ID); ?> diff --git a/PaypalExpressCheckout/authorization-and-capture.php b/PaypalExpressCheckout/authorization-and-capture.php index 14f46cb..b330806 100644 --- a/PaypalExpressCheckout/authorization-and-capture.php +++ b/PaypalExpressCheckout/authorization-and-capture.php @@ -7,8 +7,8 @@ function payPalAuthorizeCapture($amount) { // Common setup for API credentials (with PayPal compatible merchant credentials) $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $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"); @@ -49,5 +49,5 @@ function payPalAuthorizeCapture($amount) { } if(!defined('DONT_RUN_SAMPLES')) - payPalAuthorizeCapture(12.12); + payPalAuthorizeCapture(\SampleCode\Constants::SAMPLE_AMOUNT); ?> diff --git a/PaypalExpressCheckout/authorization-only-continued.php b/PaypalExpressCheckout/authorization-only-continued.php index 9759247..85216db 100644 --- a/PaypalExpressCheckout/authorization-only-continued.php +++ b/PaypalExpressCheckout/authorization-only-continued.php @@ -9,8 +9,8 @@ function payPalAuthorizeOnlyContinue($transactionId, $payerId) { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); $refId = 'ref' . time(); $paypal_type = new AnetAPI\PayPalType(); diff --git a/PaypalExpressCheckout/authorization-only.php b/PaypalExpressCheckout/authorization-only.php index 5ca4ebd..ae68ffc 100644 --- a/PaypalExpressCheckout/authorization-only.php +++ b/PaypalExpressCheckout/authorization-only.php @@ -7,8 +7,8 @@ function payPalAuthorizeOnly($amount) { // Common setup for API credentials (Paypal compatible merchant) $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); $refId = 'ref' . time(); // Create the payment data for a paypal account diff --git a/PaypalExpressCheckout/credit.php b/PaypalExpressCheckout/credit.php index 36d358b..41c5725 100644 --- a/PaypalExpressCheckout/credit.php +++ b/PaypalExpressCheckout/credit.php @@ -8,12 +8,11 @@ function payPalCredit($transactionId) { // Common setup for API credentials (Paypal compatible merchant) $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - // $merchantAuthentication->setName("mbld_api_-g9yGXH6"); - // $merchantAuthentication->setTransactionKey("8b948Sk5Tk5jBB6w"); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); $refId = 'ref' . time(); + //use transaction of already settled paypal checkout transaction $refTransId = $transactionId; // Create the payment data for a paypal account @@ -61,7 +60,8 @@ function payPalCredit($transactionId) { return $response; } -if(!defined('DONT_RUN_SAMPLES')) +if(!defined('DONT_RUN_SAMPLES')){ + //use transaction id of already settled transaction payPalCredit("2241762126"); - +} ?> diff --git a/PaypalExpressCheckout/get-details.php b/PaypalExpressCheckout/get-details.php index c83db8f..623e37b 100644 --- a/PaypalExpressCheckout/get-details.php +++ b/PaypalExpressCheckout/get-details.php @@ -10,8 +10,8 @@ function payPalGetDetails($transactionId) { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); $refId = 'ref' . time(); @@ -46,21 +46,39 @@ function payPalGetDetails($transactionId) { { $tresponse = $response->getTransactionResponse(); - if($tresponse != null) + if($tresponse != null) { - if ($tresponse->getResponseCode()=="1") - { - //parse the shipping information from response + if (($tresponse != null) && ($response->getMessages()->getResultCode()=="Ok")) + { + echo "Transaction Response...\n"; + echo "Received response code: ".$tresponse->getResponseCode()."\n"; + echo "Transaction ID: ".$tresponse->getTransId()."\n"; + //Valid response codes: 1=Approved, 2=Declined, 3=Error, 5=Need Payer Consent + if(null != $tresponse->getSecureAcceptance()) + { + echo "Payer ID : " . $tresponse->getSecureAcceptance()->getPayerID() . "\n"; + } + //parse the shipping information from response $shipping_response = $tresponse->getShipTo(); - echo "Shipping address : " . $shipping_response->getAddress() . ", " . $shipping_response->getCity() - . ", " . $shipping_response->getState() . ", " . $shipping_response->getCountry() . "\n"; - - //echo "Payer ID : " . $tresponse->getSecureAcceptance()->getPayerID(); - } - else - { - echo "ERROR : " . $tresponse->getResponseCode() . "\n"; - } + if(null != $shipping_response) + { + echo "Shipping address : " . $shipping_response->getAddress() . ", " . $shipping_response->getCity() + . ", " . $shipping_response->getState() . ", " . $shipping_response->getCountry() . "\n"; + } + } + else + echo "NULL transactionResponse Error\n"; + $messages=$response->getMessages(); + if (($messages != null)) + { + echo "Messages...\n"; + echo "Result code: ".$messages->getResultCode()."\n"; + $message0=$messages->getMessage()[0]; + if($message0!=null) + echo "Message: ".$message0->getCode().", ".$message0->getText()."\n"; + } + else + echo "NULL messages Error\n"; } else { @@ -76,6 +94,6 @@ function payPalGetDetails($transactionId) { } if(!defined('DONT_RUN_SAMPLES')) - payPalGetDetails("2241687090"); + payPalGetDetails( \SampleCode\Constants::TRANS_ID_PAYPAL_GET); ?> \ No newline at end of file diff --git a/PaypalExpressCheckout/prior-authorization-capture.php b/PaypalExpressCheckout/prior-authorization-capture.php index 62c1d50..6257c5b 100644 --- a/PaypalExpressCheckout/prior-authorization-capture.php +++ b/PaypalExpressCheckout/prior-authorization-capture.php @@ -7,8 +7,8 @@ function payPalPriorAuthorizationCapture($transactionId) { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); $refId = 'ref' . time(); $payPalType = new AnetAPI\PayPalType(); @@ -54,5 +54,7 @@ function payPalPriorAuthorizationCapture($transactionId) { } if(!defined('DONT_RUN_SAMPLES')) - payPalPriorAuthorizationCapture("2241687191"); + { + payPalPriorAuthorizationCapture( \SampleCode\Constants::TRANS_ID_PAYPAL_GET); + } ?> \ No newline at end of file diff --git a/PaypalExpressCheckout/void.php b/PaypalExpressCheckout/void.php index 153eeba..544a1b4 100644 --- a/PaypalExpressCheckout/void.php +++ b/PaypalExpressCheckout/void.php @@ -7,8 +7,8 @@ function payPalVoid($transactionId) { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); $refId = 'ref' . time(); $payPalType = new AnetAPI\PayPalType(); diff --git a/RecurringBilling/cancel-subscription.php b/RecurringBilling/cancel-subscription.php index 9df68ba..8768f07 100644 --- a/RecurringBilling/cancel-subscription.php +++ b/RecurringBilling/cancel-subscription.php @@ -7,9 +7,8 @@ function cancelSubscription($subscriptionId) { // Common Set Up for API Credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName( "5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); - + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); $refId = 'ref' . time(); $request = new AnetAPI\ARBCancelSubscriptionRequest(); @@ -37,6 +36,6 @@ function cancelSubscription($subscriptionId) { } if(!defined('DONT_RUN_SAMPLES')) - cancelSubscription("3056945"); + cancelSubscription(\SampleCode\Constants::SUBSCRIPTION_ID_CANCEL); ?> diff --git a/RecurringBilling/create-subscription.php b/RecurringBilling/create-subscription.php index f35df50..bb4f03a 100644 --- a/RecurringBilling/create-subscription.php +++ b/RecurringBilling/create-subscription.php @@ -8,9 +8,9 @@ function createSubscription($intervalLength) { // Common Set Up for API Credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName( "5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); - + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $refId = 'ref' . time(); // Subscription Type Info @@ -28,7 +28,7 @@ function createSubscription($intervalLength) { $paymentSchedule->setTrialOccurrences("1"); $subscription->setPaymentSchedule($paymentSchedule); - $subscription->setAmount("10.29"); + $subscription->setAmount(rand(1,99999)/12.0*12); $subscription->setTrialAmount("0.00"); $creditCard = new AnetAPI\CreditCardType(); @@ -68,6 +68,6 @@ function createSubscription($intervalLength) { } if(!defined('DONT_RUN_SAMPLES')) - createSubscription(23); + createSubscription( \SampleCode\Constants::SUBSCRIPTION_INTERVAL_DAYS); ?> diff --git a/RecurringBilling/get-list-of-subscriptions.php b/RecurringBilling/get-list-of-subscriptions.php index 76f99fd..301cd2a 100644 --- a/RecurringBilling/get-list-of-subscriptions.php +++ b/RecurringBilling/get-list-of-subscriptions.php @@ -7,9 +7,9 @@ function getListOfSubscriptions() { // Common Set Up for API Credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName( "5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); - + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $refId = 'ref' . time(); $sorting = new AnetAPI\ARBGetSubscriptionListSortingType(); diff --git a/RecurringBilling/get-subscription-status.php b/RecurringBilling/get-subscription-status.php index 7e17b3f..6e13736 100644 --- a/RecurringBilling/get-subscription-status.php +++ b/RecurringBilling/get-subscription-status.php @@ -7,9 +7,9 @@ function getSubscriptionStatus($subscriptionId) { // Common Set Up for API Credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName( "5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); - + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $refId = 'ref' . time(); $request = new AnetAPI\ARBGetSubscriptionStatusRequest(); @@ -36,6 +36,6 @@ function getSubscriptionStatus($subscriptionId) { } if(!defined('DONT_RUN_SAMPLES')) - getSubscriptionStatus("3056945"); + getSubscriptionStatus( \SampleCode\Constants::SUBSCRIPTION_ID_UPDATE); ?> diff --git a/RecurringBilling/get-subscription.php b/RecurringBilling/get-subscription.php index 28212af..f6d917f 100644 --- a/RecurringBilling/get-subscription.php +++ b/RecurringBilling/get-subscription.php @@ -8,9 +8,9 @@ function getSubscription($subscriptionId) { // Common Set Up for API Credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName( "5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); - + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $refId = 'ref' . time(); // Creating the API Request with required parameters @@ -56,5 +56,5 @@ function getSubscription($subscriptionId) { } if(!defined('DONT_RUN_SAMPLES')) - getSubscription("2930242"); + getSubscription( \SampleCode\Constants::SUBSCRIPTION_ID_GET); ?> diff --git a/RecurringBilling/update-subscription.php b/RecurringBilling/update-subscription.php index 4fa2f7f..ed967d0 100644 --- a/RecurringBilling/update-subscription.php +++ b/RecurringBilling/update-subscription.php @@ -7,9 +7,9 @@ function updateSubscription($subscriptionId) { // Common Set Up for API Credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName( "5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); - + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $refId = 'ref' . time(); $subscription = new AnetAPI\ARBSubscriptionType(); @@ -35,7 +35,7 @@ function updateSubscription($subscriptionId) { if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) { - echo "SUCCESS" . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + echo "SUCCESS, Response Code: " . $response->getMessages()->getMessage()[0]->getCode() . " Response Text: " .$response->getMessages()->getMessage()[0]->getText() . "\n"; } else { @@ -47,5 +47,5 @@ function updateSubscription($subscriptionId) { } if(!defined('DONT_RUN_SAMPLES')) - updateSubscription("3056948"); + updateSubscription( \SampleCode\Constants::SUBSCRIPTION_ID_UPDATE); ?> diff --git a/TransactionReporting/get-batch-statistics.php b/TransactionReporting/get-batch-statistics.php index 4dbaa4b..78dad37 100644 --- a/TransactionReporting/get-batch-statistics.php +++ b/TransactionReporting/get-batch-statistics.php @@ -7,12 +7,12 @@ function getBatchStatistics() { // Common Set Up for API Credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName( "5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); $refId = 'ref' . time(); //Setting a valid batch Id for the Merchant - $batchId = "4532808"; + $batchId = \SampleCode\Constants::BATCH_ID; // Creating a request $request = new AnetAPI\GetBatchStatisticsRequest(); diff --git a/TransactionReporting/get-settled-batch-list.php b/TransactionReporting/get-settled-batch-list.php index f92c876..255c675 100644 --- a/TransactionReporting/get-settled-batch-list.php +++ b/TransactionReporting/get-settled-batch-list.php @@ -7,8 +7,8 @@ function getSettledBatchList() { // Common Set Up for API Credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName( "5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); $request = new AnetAPI\GetSettledBatchListRequest(); $request->setMerchantAuthentication($merchantAuthentication); diff --git a/TransactionReporting/get-transaction-details.php b/TransactionReporting/get-transaction-details.php index 1cfde4a..070b009 100644 --- a/TransactionReporting/get-transaction-details.php +++ b/TransactionReporting/get-transaction-details.php @@ -7,8 +7,8 @@ function getTransactionDetails($transactionId) { // Common Set Up for API Credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName( "5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); $refId = 'ref' . time(); @@ -37,5 +37,5 @@ function getTransactionDetails($transactionId) { } if(!defined('DONT_RUN_SAMPLES')) - getTransactionDetails("2238968786"); + getTransactionDetails( \SampleCode\Constants::TRANS_ID); ?> \ No newline at end of file diff --git a/TransactionReporting/get-transaction-list.php b/TransactionReporting/get-transaction-list.php index f2ab420..cf38498 100644 --- a/TransactionReporting/get-transaction-list.php +++ b/TransactionReporting/get-transaction-list.php @@ -6,8 +6,8 @@ function getTransactionList() { // Common Set Up for API Credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName( "5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); $refId = 'ref' . time(); diff --git a/TransactionReporting/get-unsettled-transaction-list.php b/TransactionReporting/get-unsettled-transaction-list.php index cddcb39..5aaf0ee 100644 --- a/TransactionReporting/get-unsettled-transaction-list.php +++ b/TransactionReporting/get-unsettled-transaction-list.php @@ -6,8 +6,8 @@ function getUnsettledTransactionList() { // Common Set Up for API Credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName( "5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); $refId = 'ref' . time(); diff --git a/VisaCheckout/create-visa-checkout-transaction.php b/VisaCheckout/create-visa-checkout-transaction.php index f9f2f3a..4b91b7b 100644 --- a/VisaCheckout/create-visa-checkout-transaction.php +++ b/VisaCheckout/create-visa-checkout-transaction.php @@ -7,15 +7,15 @@ function createVisaCheckoutTransaction(){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); $refId = 'ref' . time(); // Create the payment data from a Visa Checkout blob $op = new AnetAPI\OpaqueDataType(); - $op->setDataDescriptor("COMMON.VCO.ONLINE.PAYMENT"); - $op->setDataValue("4Ng5pzJ6DXfAvLSzVauN9KTufx5lTHhFlnuIr248N3fjtyHrHqMuhOkB1BLiSjKWeTM9+BNj3+9nY56d7CsUfIuvVSTaJRhQQSex1dS2Y2Y+/cA5U+3D1pg5YtTmDVUGlsu1simAd3huwPnwD+CG6O8Ml0AmXvYHntmL3vFaJomadMQBy27k8Dbh5eplPBwyawKUVJ7GqTyKLe8aOYkBUHT5ANWkq2hlGps44BOoDHZ26JWjHdorBZtVIqMK1SIyW4Dih5c/Y//w2toA8WBTPILIvt4h6HPPvWZMZCHCqom9D2k4WGH5+BCEY2jHI7gfYV6xRx54i5vitsYTKm3CyA0C5+l0FNDkfUFHDvVUG9FVzRWVd0TXYhDwfa2pcfI68eYvkEfeT+ZNJ24ZXKPrJo6KZ3x6eZAhzgAMFiC+tPsiygb2zQy5PVoYoBIGj/NGNRqmhZTOEajcO3ZjWxfAnLZAmvMi+pEwJCMmuIY4qRU3RfcaXhAoaUPpDxqrSxR1m+CUKYVdt3nnnQeVaVqf+RaeV9cyFJvILeBPXTBVC50AckVLS37UuBWgWaWcchjRPk9mriDu2KlHQwdR4zu0jnLh4i3tbxV416QBcYLO6AF2Ixlm3GzqGE6QcVssgFCUAhklBWGNLP62O1jtyV4NgTD36QhvHEHby7o4XBB+mjlY6xSEXR+IW9u64AzfDCsTxWiAOE65le6cSk4NDV8DrtYeIozILivWu6wFSpy1gMfiDot4Ndv3C9xCFvH0Bzlky7NoZrvSolKTVNTs8W8UqMFV19qGl6SRaNUEhCqgso/FkdO0eGXFMdQPuP11wQzK/9F3yB9gS2rpXi9sy8DrCqnJ9EXMmliSstKuQl5+yfGc8K3Urot3t+BmNoOvzM9Aha/PzmbLnuKBN6/DUbIw5mhNMCvIA1ByispKpjeV682jl4uslkRsitGLcIOBREFXvGaLxRb37HJkXCHk+jorpDz7LUQhVkClN+hW0vXtgdHQFCIOL7uREdbvk6BZbQlFsuVEKGZxPbKPEJfqMbH54B4a4P5XNQHm4Yt4haH4T0JuYgzoSo76uuXD3g5IuUvy7x8Ykuja1rwW/k//SZAiGaZraRIIAEnzHiUP8dcufb/RonHGnJcYXIEWeIF1lX980bDA+H4vlO8/nN/Mj+EL6tT95MfRDiQHUW69qkqotQd7FJ5uWT+NtetzqDsN5s3sIhwkLKIn9EDLIav5v4SXKxkG+ycMJmGFcfhs7Td9O6hl+Om/JD3he3rgfClaFi/ZR7AVY6fWbAAm9QftKijQ6rskPDYL9Y3gVSA9rdduSg97fUHC+FdfyQXGH552cDLs2ZgzYw6KluXHEuwhACgNotxToPYTTdZxxNr1vPoqYCqHDL2dL8dkuO59/sbZE1m4ektKvUC2wz0UdTDVbHN8HSrLPn2hf/xQp5bKeDDjYkWvNKuwy+aug9H+Uu/m1LuPK/YdogVv9l25y/c2Qbj3dAJ9xTuKjmiJLKlRh4SUI9+05HjDF+i84AoUZ8LuC7LGtrN8ReYIktLhaXq9+XDh5fv4NYhnuYgWkUioKtx1dmfOMHjpLm4aE8Ra1gpJQcZAgwnqYubQvnYy0nY4VaykNix7m3vZwItpKOLqxDYxa3q0qUw25X9zafAM61kPW6EP+4idPzHNww6r1FD4Ihq644dCnCXwoSQ531DW6oAPot8iLZ/xXwoWwrW05k9t2RHjjLbw1L5r1CKgShJQfX7nkJxfGyuw1RmqoQDuNt/tj9M/dHOnoPnOYZZN0JX+Al8PI5zs+LLajw1imu9YcSpwMz3ZlfQqTfI0fjSCc8Is6qVYDMvKD0TweY4hiIxkzs+RyQmPgIeIWqf7Su5+RcnXitb3OuFibBGCjdDeG0ESG8qeiBQKZ3wEyZG09eDAfhuUR5kfZCG4Q01u2YDoRzObxLd8Ruf7HNvtefucFLubciWvOSzbDUisoz0wwOSgJGHucC3IR+1mb/4gz/dI2wvWFInhKcQz4ivkuHaFj8XwvZMcpkwPKtg3pRGTleX/gfjbHcx2VcWRcMPdlDMgTgst9ouN763TZUHHLxjECyB9pkLrR1nhG0cS/aig8Bq1+AH7tvl1wLVxm1Z77DVX4aUIxBH2YUcOgpe6mrWFi6LK3im4/grZECsL/XC4tsTEHjO/U3SazUuhP+6LiCYqp50+3zZf3RpWlxZoYjm5SJ9VIWabocO/Ef26G38lKottW1XsSQUan7myYFFyeyon2hnufzMuxpyXTJ7TLekXCi2gLYbGjldgiRmGShPXzSar+hC2"); - $op->setDataKey("JxAB39A9yUsf6wMD0jwGKCuY7mmzWaeEj85MH02AfKGUxOkJ00JK+o8vGG55cUF9voYU4QQ1Jec4p6nKmsxXmTREEaJwmQErotD4fpcFOyoqWTLMZfslrkHgiqbwru/V"); + $op->setDataDescriptor(\SampleCode\Constants::VC_DATA_DESCRIPTOR); + $op->setDataValue(\SampleCode\Constants::VC_DATA_VALUE); + $op->setDataKey(\SampleCode\Constants::VC_DATA_KEY); $paymentOne = new AnetAPI\PaymentType(); $paymentOne->setOpaqueData($op); diff --git a/VisaCheckout/decrypt-visa-checkout-data.php b/VisaCheckout/decrypt-visa-checkout-data.php index 7c3c633..4513ba3 100644 --- a/VisaCheckout/decrypt-visa-checkout-data.php +++ b/VisaCheckout/decrypt-visa-checkout-data.php @@ -7,15 +7,15 @@ function decryptVisaCheckoutData(){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("5KP3u95bQpv"); - $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); $refId = 'ref' . time(); // Create the payment data from a Visa Checkout blob $op = new AnetAPI\OpaqueDataType(); - $op->setDataDescriptor("COMMON.VCO.ONLINE.PAYMENT"); - $op->setDataValue("4Ng5pzJ6DXfAvLSzVauN9KTufx5lTHhFlnuIr248N3fjtyHrHqMuhOkB1BLiSjKWeTM9+BNj3+9nY56d7CsUfIuvVSTaJRhQQSex1dS2Y2Y+/cA5U+3D1pg5YtTmDVUGlsu1simAd3huwPnwD+CG6O8Ml0AmXvYHntmL3vFaJomadMQBy27k8Dbh5eplPBwyawKUVJ7GqTyKLe8aOYkBUHT5ANWkq2hlGps44BOoDHZ26JWjHdorBZtVIqMK1SIyW4Dih5c/Y//w2toA8WBTPILIvt4h6HPPvWZMZCHCqom9D2k4WGH5+BCEY2jHI7gfYV6xRx54i5vitsYTKm3CyA0C5+l0FNDkfUFHDvVUG9FVzRWVd0TXYhDwfa2pcfI68eYvkEfeT+ZNJ24ZXKPrJo6KZ3x6eZAhzgAMFiC+tPsiygb2zQy5PVoYoBIGj/NGNRqmhZTOEajcO3ZjWxfAnLZAmvMi+pEwJCMmuIY4qRU3RfcaXhAoaUPpDxqrSxR1m+CUKYVdt3nnnQeVaVqf+RaeV9cyFJvILeBPXTBVC50AckVLS37UuBWgWaWcchjRPk9mriDu2KlHQwdR4zu0jnLh4i3tbxV416QBcYLO6AF2Ixlm3GzqGE6QcVssgFCUAhklBWGNLP62O1jtyV4NgTD36QhvHEHby7o4XBB+mjlY6xSEXR+IW9u64AzfDCsTxWiAOE65le6cSk4NDV8DrtYeIozILivWu6wFSpy1gMfiDot4Ndv3C9xCFvH0Bzlky7NoZrvSolKTVNTs8W8UqMFV19qGl6SRaNUEhCqgso/FkdO0eGXFMdQPuP11wQzK/9F3yB9gS2rpXi9sy8DrCqnJ9EXMmliSstKuQl5+yfGc8K3Urot3t+BmNoOvzM9Aha/PzmbLnuKBN6/DUbIw5mhNMCvIA1ByispKpjeV682jl4uslkRsitGLcIOBREFXvGaLxRb37HJkXCHk+jorpDz7LUQhVkClN+hW0vXtgdHQFCIOL7uREdbvk6BZbQlFsuVEKGZxPbKPEJfqMbH54B4a4P5XNQHm4Yt4haH4T0JuYgzoSo76uuXD3g5IuUvy7x8Ykuja1rwW/k//SZAiGaZraRIIAEnzHiUP8dcufb/RonHGnJcYXIEWeIF1lX980bDA+H4vlO8/nN/Mj+EL6tT95MfRDiQHUW69qkqotQd7FJ5uWT+NtetzqDsN5s3sIhwkLKIn9EDLIav5v4SXKxkG+ycMJmGFcfhs7Td9O6hl+Om/JD3he3rgfClaFi/ZR7AVY6fWbAAm9QftKijQ6rskPDYL9Y3gVSA9rdduSg97fUHC+FdfyQXGH552cDLs2ZgzYw6KluXHEuwhACgNotxToPYTTdZxxNr1vPoqYCqHDL2dL8dkuO59/sbZE1m4ektKvUC2wz0UdTDVbHN8HSrLPn2hf/xQp5bKeDDjYkWvNKuwy+aug9H+Uu/m1LuPK/YdogVv9l25y/c2Qbj3dAJ9xTuKjmiJLKlRh4SUI9+05HjDF+i84AoUZ8LuC7LGtrN8ReYIktLhaXq9+XDh5fv4NYhnuYgWkUioKtx1dmfOMHjpLm4aE8Ra1gpJQcZAgwnqYubQvnYy0nY4VaykNix7m3vZwItpKOLqxDYxa3q0qUw25X9zafAM61kPW6EP+4idPzHNww6r1FD4Ihq644dCnCXwoSQ531DW6oAPot8iLZ/xXwoWwrW05k9t2RHjjLbw1L5r1CKgShJQfX7nkJxfGyuw1RmqoQDuNt/tj9M/dHOnoPnOYZZN0JX+Al8PI5zs+LLajw1imu9YcSpwMz3ZlfQqTfI0fjSCc8Is6qVYDMvKD0TweY4hiIxkzs+RyQmPgIeIWqf7Su5+RcnXitb3OuFibBGCjdDeG0ESG8qeiBQKZ3wEyZG09eDAfhuUR5kfZCG4Q01u2YDoRzObxLd8Ruf7HNvtefucFLubciWvOSzbDUisoz0wwOSgJGHucC3IR+1mb/4gz/dI2wvWFInhKcQz4ivkuHaFj8XwvZMcpkwPKtg3pRGTleX/gfjbHcx2VcWRcMPdlDMgTgst9ouN763TZUHHLxjECyB9pkLrR1nhG0cS/aig8Bq1+AH7tvl1wLVxm1Z77DVX4aUIxBH2YUcOgpe6mrWFi6LK3im4/grZECsL/XC4tsTEHjO/U3SazUuhP+6LiCYqp50+3zZf3RpWlxZoYjm5SJ9VIWabocO/Ef26G38lKottW1XsSQUan7myYFFyeyon2hnufzMuxpyXTJ7TLekXCi2gLYbGjldgiRmGShPXzSar+hC2"); - $op->setDataKey("JxAB39A9yUsf6wMD0jwGKCuY7mmzWaeEj85MH02AfKGUxOkJ00JK+o8vGG55cUF9voYU4QQ1Jec4p6nKmsxXmTREEaJwmQErotD4fpcFOyoqWTLMZfslrkHgiqbwru/V"); + $op->setDataDescriptor(\SampleCode\Constants::VC_DATA_DESCRIPTOR); + $op->setDataValue( \SampleCode\Constants::VC_DATA_VALUE); + $op->setDataKey( \SampleCode\Constants::VC_DATA_KEY); //create a decrypt request $decryptRequest = new AnetAPI\DecryptPaymentDataRequest(); diff --git a/constants/Constants.php b/constants/Constants.php index ef32c58..413dde6 100644 --- a/constants/Constants.php +++ b/constants/Constants.php @@ -9,7 +9,9 @@ class Constants //credit card fields const CREDIT_CARD_NUMBER = "4111111111111111"; + const CREDIT_CARD_NUMBER_2 = "4242424242424242"; const EXPIRY_DATE = "2038-12"; + const CVV = "142"; //bank account fields const ROUTING_NUMBER = '125000024'; @@ -22,5 +24,61 @@ class Constants //order info const INVOICE_NUMBER = "101"; const ORDER_DESCRIPTION = "Golf Shirts"; + //cryptogram + const CRYPTOGRAM = "EjRWeJASNFZ4kBI0VniQEjRWeJA="; + + //transaction-id's used by different samples + const TRANS_ID_PREVIOUSLY_AUTHORIZED = 2249839471; + const TRANS_ID_VOID = "2249063130"; + const TRANS_ID_TO_CREATE_CUSTOMER_PROFILE = "2249066517"; + + //split tender id + const SPLIT_TENDER_ID = "115901"; + //transaction status constants + const STATUS_VOID = "voided"; + + + //limits + const MAX_AMOUNT = 99999; + + //miscelaneous variables for individual samples + const SAMPLE_AMOUNT_REFUND = 32.14; + const SAMPLE_AMOUNT = 12.23; + const SAMPLE_AUTH_CODE_AUTHORIZED = "ROHNFQ"; + + //response + const RESPONSE_OK = "1"; + + //Recurring Billing + const SUBSCRIPTION_ID_CANCEL = "3056945"; + const SUBSCRIPTION_ID_UPDATE = "3056948"; + const SUBSCRIPTION_ID_GET = "2930242"; + const SUBSCRIPTION_INTERVAL_DAYS = 23; + + //Customer Profiles + const TEST_CUSTOMER_EMAIL = "test123@test.com"; + const CUSTOMER_PROFILE_ID = "36152127"; + const CUSTOMER_PROFILE_ID_2 = "36731856"; + const CUSTOMER_PROFILE_ID_HOSTED_PAGE = "123212"; + + const CUSTOMER_PAYMENT_PROFILE_ID = "32689274"; + const CUSTOMER_PAYMENT_PROFILE_ID_DELETE = "38958129"; + const CUSTOMER_PAYMENT_PROFILE_ID_GET = "33211899"; + const CUSTOMER_SHIPPING_ADDRESS_ID_GET = "36976566"; + const PHONE_NUMBER = "000-000-0000"; + + //Transaction Reporting + const TRANS_ID = "2238968786"; + const BATCH_ID = "4532808"; + + //Paypal express Checkout + const TRANS_ID_PAYPAL = "2241708986"; + const TRANS_ID_PAYPAL_GET = "2249863278"; + const PAYER_ID = "6ZSCSYG33VP8Q"; + + //Visa Checkout related values + const VC_DATA_DESCRIPTOR = "COMMON.VCO.ONLINE.PAYMENT"; + const VC_DATA_VALUE = "4Ng5pzJ6DXfAvLSzVauN9KTufx5lTHhFlnuIr248N3fjtyHrHqMuhOkB1BLiSjKWeTM9+BNj3+9nY56d7CsUfIuvVSTaJRhQQSex1dS2Y2Y+/cA5U+3D1pg5YtTmDVUGlsu1simAd3huwPnwD+CG6O8Ml0AmXvYHntmL3vFaJomadMQBy27k8Dbh5eplPBwyawKUVJ7GqTyKLe8aOYkBUHT5ANWkq2hlGps44BOoDHZ26JWjHdorBZtVIqMK1SIyW4Dih5c/Y//w2toA8WBTPILIvt4h6HPPvWZMZCHCqom9D2k4WGH5+BCEY2jHI7gfYV6xRx54i5vitsYTKm3CyA0C5+l0FNDkfUFHDvVUG9FVzRWVd0TXYhDwfa2pcfI68eYvkEfeT+ZNJ24ZXKPrJo6KZ3x6eZAhzgAMFiC+tPsiygb2zQy5PVoYoBIGj/NGNRqmhZTOEajcO3ZjWxfAnLZAmvMi+pEwJCMmuIY4qRU3RfcaXhAoaUPpDxqrSxR1m+CUKYVdt3nnnQeVaVqf+RaeV9cyFJvILeBPXTBVC50AckVLS37UuBWgWaWcchjRPk9mriDu2KlHQwdR4zu0jnLh4i3tbxV416QBcYLO6AF2Ixlm3GzqGE6QcVssgFCUAhklBWGNLP62O1jtyV4NgTD36QhvHEHby7o4XBB+mjlY6xSEXR+IW9u64AzfDCsTxWiAOE65le6cSk4NDV8DrtYeIozILivWu6wFSpy1gMfiDot4Ndv3C9xCFvH0Bzlky7NoZrvSolKTVNTs8W8UqMFV19qGl6SRaNUEhCqgso/FkdO0eGXFMdQPuP11wQzK/9F3yB9gS2rpXi9sy8DrCqnJ9EXMmliSstKuQl5+yfGc8K3Urot3t+BmNoOvzM9Aha/PzmbLnuKBN6/DUbIw5mhNMCvIA1ByispKpjeV682jl4uslkRsitGLcIOBREFXvGaLxRb37HJkXCHk+jorpDz7LUQhVkClN+hW0vXtgdHQFCIOL7uREdbvk6BZbQlFsuVEKGZxPbKPEJfqMbH54B4a4P5XNQHm4Yt4haH4T0JuYgzoSo76uuXD3g5IuUvy7x8Ykuja1rwW/k//SZAiGaZraRIIAEnzHiUP8dcufb/RonHGnJcYXIEWeIF1lX980bDA+H4vlO8/nN/Mj+EL6tT95MfRDiQHUW69qkqotQd7FJ5uWT+NtetzqDsN5s3sIhwkLKIn9EDLIav5v4SXKxkG+ycMJmGFcfhs7Td9O6hl+Om/JD3he3rgfClaFi/ZR7AVY6fWbAAm9QftKijQ6rskPDYL9Y3gVSA9rdduSg97fUHC+FdfyQXGH552cDLs2ZgzYw6KluXHEuwhACgNotxToPYTTdZxxNr1vPoqYCqHDL2dL8dkuO59/sbZE1m4ektKvUC2wz0UdTDVbHN8HSrLPn2hf/xQp5bKeDDjYkWvNKuwy+aug9H+Uu/m1LuPK/YdogVv9l25y/c2Qbj3dAJ9xTuKjmiJLKlRh4SUI9+05HjDF+i84AoUZ8LuC7LGtrN8ReYIktLhaXq9+XDh5fv4NYhnuYgWkUioKtx1dmfOMHjpLm4aE8Ra1gpJQcZAgwnqYubQvnYy0nY4VaykNix7m3vZwItpKOLqxDYxa3q0qUw25X9zafAM61kPW6EP+4idPzHNww6r1FD4Ihq644dCnCXwoSQ531DW6oAPot8iLZ/xXwoWwrW05k9t2RHjjLbw1L5r1CKgShJQfX7nkJxfGyuw1RmqoQDuNt/tj9M/dHOnoPnOYZZN0JX+Al8PI5zs+LLajw1imu9YcSpwMz3ZlfQqTfI0fjSCc8Is6qVYDMvKD0TweY4hiIxkzs+RyQmPgIeIWqf7Su5+RcnXitb3OuFibBGCjdDeG0ESG8qeiBQKZ3wEyZG09eDAfhuUR5kfZCG4Q01u2YDoRzObxLd8Ruf7HNvtefucFLubciWvOSzbDUisoz0wwOSgJGHucC3IR+1mb/4gz/dI2wvWFInhKcQz4ivkuHaFj8XwvZMcpkwPKtg3pRGTleX/gfjbHcx2VcWRcMPdlDMgTgst9ouN763TZUHHLxjECyB9pkLrR1nhG0cS/aig8Bq1+AH7tvl1wLVxm1Z77DVX4aUIxBH2YUcOgpe6mrWFi6LK3im4/grZECsL/XC4tsTEHjO/U3SazUuhP+6LiCYqp50+3zZf3RpWlxZoYjm5SJ9VIWabocO/Ef26G38lKottW1XsSQUan7myYFFyeyon2hnufzMuxpyXTJ7TLekXCi2gLYbGjldgiRmGShPXzSar+hC2"; + const VC_DATA_KEY = "JxAB39A9yUsf6wMD0jwGKCuY7mmzWaeEj85MH02AfKGUxOkJ00JK+o8vGG55cUF9voYU4QQ1Jec4p6nKmsxXmTREEaJwmQErotD4fpcFOyoqWTLMZfslrkHgiqbwru/V"; } ?> \ No newline at end of file From 7e75d6303622de509b80ff480bb391f220ed3982 Mon Sep 17 00:00:00 2001 From: ashtru Date: Fri, 19 Feb 2016 18:55:09 +0530 Subject: [PATCH 041/287] Readded define("AUTHORIZENET_LOG_FILE") to allow logging of request/responses in samples. Some indentation of the function definitions. --- .../create-an-apple-pay-transaction.php | 2 + .../create-customer-payment-profile.php | 2 + ...eate-customer-profile-from-transaction.php | 2 + CustomerProfiles/create-customer-profile.php | 4 +- .../create-customer-shipping-address.php | 3 + .../delete-customer-payment-profile.php | 4 +- CustomerProfiles/delete-customer-profile.php | 2 + .../delete-customer-shipping-address.php | 2 + .../get-customer-payment-profile-list.php | 111 ++++++------- .../get-customer-payment-profile.php | 65 ++++---- CustomerProfiles/get-customer-profile-ids.php | 3 + CustomerProfiles/get-customer-profile.php | 148 +++++++++--------- .../get-customer-shipping-address.php | 3 + CustomerProfiles/get-hosted-profile-page.php | 2 + .../update-customer-payment-profile.php | 3 + CustomerProfiles/update-customer-profile.php | 2 + .../update-customer-shipping-address.php | 3 + .../validate-customer-payment-profile.php | 2 + PaymentTransactions/authorize-credit-card.php | 2 + ...nds-authorized-through-another-channel.php | 2 + .../capture-previously-authorized-amount.php | 10 +- PaymentTransactions/charge-credit-card.php | 2 + .../charge-customer-profile.php | 2 + .../charge-tokenized-credit-card.php | 2 + PaymentTransactions/credit-bank-account.php | 2 + PaymentTransactions/debit-bank-account.php | 2 + PaymentTransactions/refund-transaction.php | 2 + .../update-split-tender-group.php | 2 + PaymentTransactions/void-transaction.php | 2 + .../authorization-and-capture-continue.php | 2 + .../authorization-and-capture.php | 2 + .../authorization-only-continued.php | 2 + PaypalExpressCheckout/authorization-only.php | 2 + PaypalExpressCheckout/credit.php | 2 + PaypalExpressCheckout/get-details.php | 2 + .../prior-authorization-capture.php | 2 + PaypalExpressCheckout/void.php | 2 + RecurringBilling/cancel-subscription.php | 2 + RecurringBilling/create-subscription.php | 2 + .../get-list-of-subscriptions.php | 2 + RecurringBilling/get-subscription-status.php | 2 + RecurringBilling/get-subscription.php | 2 + RecurringBilling/update-subscription.php | 2 + TransactionReporting/get-batch-statistics.php | 2 + .../get-settled-batch-list.php | 2 + .../get-transaction-details.php | 2 + TransactionReporting/get-transaction-list.php | 2 + .../get-unsettled-transaction-list.php | 2 + .../create-visa-checkout-transaction.php | 2 + VisaCheckout/decrypt-visa-checkout-data.php | 2 + 50 files changed, 269 insertions(+), 166 deletions(-) diff --git a/ApplePayTransactions/create-an-apple-pay-transaction.php b/ApplePayTransactions/create-an-apple-pay-transaction.php index 91f7690..6c8d93f 100644 --- a/ApplePayTransactions/create-an-apple-pay-transaction.php +++ b/ApplePayTransactions/create-an-apple-pay-transaction.php @@ -4,6 +4,8 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; +define("AUTHORIZENET_LOG_FILE", "phplog"); + function createAnApplePayTransaction(){ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); diff --git a/CustomerProfiles/create-customer-payment-profile.php b/CustomerProfiles/create-customer-payment-profile.php index fc707df..4841850 100644 --- a/CustomerProfiles/create-customer-payment-profile.php +++ b/CustomerProfiles/create-customer-payment-profile.php @@ -2,6 +2,8 @@ require 'vendor/autoload.php'; use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; + + define("AUTHORIZENET_LOG_FILE", "phplog"); function createCustomerPaymentProfile($existingcustomerprofileid, $phoneNumber){ // Common setup for API credentials diff --git a/CustomerProfiles/create-customer-profile-from-transaction.php b/CustomerProfiles/create-customer-profile-from-transaction.php index a32d64c..2e9b9e7 100644 --- a/CustomerProfiles/create-customer-profile-from-transaction.php +++ b/CustomerProfiles/create-customer-profile-from-transaction.php @@ -3,6 +3,8 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; + define("AUTHORIZENET_LOG_FILE", "phplog"); + function createCustomerProfileFromTransaction($transId= \SampleCode\Constants::TRANS_ID_TO_CREATE_CUSTOMER_PROFILE) { // Common setup for API credentials diff --git a/CustomerProfiles/create-customer-profile.php b/CustomerProfiles/create-customer-profile.php index 87e6465..1f27640 100644 --- a/CustomerProfiles/create-customer-profile.php +++ b/CustomerProfiles/create-customer-profile.php @@ -2,7 +2,9 @@ require 'vendor/autoload.php'; use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; - + + define("AUTHORIZENET_LOG_FILE", "phplog"); + function createCustomerProfile($email){ // Common setup for API credentials diff --git a/CustomerProfiles/create-customer-shipping-address.php b/CustomerProfiles/create-customer-shipping-address.php index 1c31fff..9aa8757 100644 --- a/CustomerProfiles/create-customer-shipping-address.php +++ b/CustomerProfiles/create-customer-shipping-address.php @@ -2,6 +2,9 @@ require 'vendor/autoload.php'; use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; + + define("AUTHORIZENET_LOG_FILE", "phplog"); + function createCustomerShippingAddress($existingcustomerprofileid = \SampleCode\Constants::CUSTOMER_PROFILE_ID, $phoneNumber= \SampleCode\Constants::PHONE_NUMBER) { diff --git a/CustomerProfiles/delete-customer-payment-profile.php b/CustomerProfiles/delete-customer-payment-profile.php index 1967b00..864c545 100644 --- a/CustomerProfiles/delete-customer-payment-profile.php +++ b/CustomerProfiles/delete-customer-payment-profile.php @@ -3,7 +3,9 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; - function deleteCustomerPaymentProfile($customerProfileId= \SampleCode\Constants::CUSTOMER_PROFILE_ID, + define("AUTHORIZENET_LOG_FILE", "phplog"); + + function deleteCustomerPaymentProfile($customerProfileId= \SampleCode\Constants::CUSTOMER_PROFILE_ID, $customerpaymentprofileid = \SampleCode\Constants::CUSTOMER_PAYMENT_PROFILE_ID) { // Common setup for API credentials diff --git a/CustomerProfiles/delete-customer-profile.php b/CustomerProfiles/delete-customer-profile.php index ded52a6..819b3d5 100644 --- a/CustomerProfiles/delete-customer-profile.php +++ b/CustomerProfiles/delete-customer-profile.php @@ -3,6 +3,8 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; + define("AUTHORIZENET_LOG_FILE", "phplog"); + function deleteCustomerProfile($customerProfileId) { // Common setup for API credentials diff --git a/CustomerProfiles/delete-customer-shipping-address.php b/CustomerProfiles/delete-customer-shipping-address.php index a7983e6..0163f75 100644 --- a/CustomerProfiles/delete-customer-shipping-address.php +++ b/CustomerProfiles/delete-customer-shipping-address.php @@ -3,6 +3,8 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; + define("AUTHORIZENET_LOG_FILE", "phplog"); + function deleteCustomerShippingAddress($customerprofileid = \SampleCode\Constants::CUSTOMER_PROFILE_ID_2, $customeraddressid = "36976434") { diff --git a/CustomerProfiles/get-customer-payment-profile-list.php b/CustomerProfiles/get-customer-payment-profile-list.php index 5f1d61a..a069cbb 100644 --- a/CustomerProfiles/get-customer-payment-profile-list.php +++ b/CustomerProfiles/get-customer-payment-profile-list.php @@ -1,74 +1,75 @@ - setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); - $refId = 'ref' . time(); - - //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"); + // 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(); + + //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"); - //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") + // Controller + $controller = new AnetController\GetCustomerPaymentProfileListController($request); + // Getting the response + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + + if(($response != null)) { - // Success - echo "GetCustomerPaymentProfileList SUCCESS: " . "\n"; - echo "Message Code: " . $response->getMessages()->getMessage()[0]->getCode() . "\n"; - echo "Message Text: " . $response->getMessages()->getMessage()[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 ) + if ($response->getMessages()->getResultCode() == "Ok") { - 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"; + // Success + echo "GetCustomerPaymentProfileList SUCCESS: " . "\n"; + echo "Message Code: " . $response->getMessages()->getMessage()[0]->getCode() . "\n"; + echo "Message Text: " . $response->getMessages()->getMessage()[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"; + echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; } } else { - // Error - echo "GetCustomerPaymentProfileList ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + // Failed to get the response + echo "NULL Response Error"; } - } - else - { - // Failed to get the response - echo "NULL Response Error"; - } - return $response; + return $response; } if(!defined('DONT_RUN_SAMPLES')) getCustomerPaymentProfileList(); diff --git a/CustomerProfiles/get-customer-payment-profile.php b/CustomerProfiles/get-customer-payment-profile.php index 171cf19..1d411a3 100644 --- a/CustomerProfiles/get-customer-payment-profile.php +++ b/CustomerProfiles/get-customer-payment-profile.php @@ -1,4 +1,3 @@ - setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); -$merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); -$refId = 'ref' . time(); + // 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(); -//request requires customerProfileId and customerPaymentProfileId -$request = new AnetAPI\GetCustomerPaymentProfileRequest(); -$request->setMerchantAuthentication($merchantAuthentication); -$request->setRefId( $refId); -$request->setCustomerProfileId($customerProfileId); -$request->setCustomerPaymentProfileId($customerPaymentProfileId); + //request requires customerProfileId and customerPaymentProfileId + $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)){ - 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"; - echo "Customer Payment Profile Card Last 4 " . $response->getPaymentProfile()->getPayment()->getCreditCard()->getCardNumber(). "\n"; + $controller = new AnetController\GetCustomerPaymentProfileController($request); + $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"; + echo "Customer Payment Profile Card Last 4 " . $response->getPaymentProfile()->getPayment()->getCreditCard()->getCardNumber(). "\n"; - } - else - { - echo "GetCustomerPaymentProfile ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; - } -} -else{ - echo "NULL Response Error"; -} -return $response; + } + else + { + echo "GetCustomerPaymentProfile ERROR : Invalid response\n"; + echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + } + } + else{ + echo "NULL Response Error"; + } + return $response; } if(!defined('DONT_RUN_SAMPLES')) getCustomerPaymentProfile(); diff --git a/CustomerProfiles/get-customer-profile-ids.php b/CustomerProfiles/get-customer-profile-ids.php index d707ac2..646f12f 100644 --- a/CustomerProfiles/get-customer-profile-ids.php +++ b/CustomerProfiles/get-customer-profile-ids.php @@ -2,6 +2,9 @@ require 'vendor/autoload.php'; use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; + + define("AUTHORIZENET_LOG_FILE", "phplog"); + function getCustomerProfileIds() { // Common setup for API credentials diff --git a/CustomerProfiles/get-customer-profile.php b/CustomerProfiles/get-customer-profile.php index 82085bb..7f2acc8 100644 --- a/CustomerProfiles/get-customer-profile.php +++ b/CustomerProfiles/get-customer-profile.php @@ -2,90 +2,92 @@ require 'vendor/autoload.php'; use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; - // Common setup for API credentials + + define("AUTHORIZENET_LOG_FILE", "phplog"); function getCustomerProfile(){ - - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->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( "2038-12"); - $paymentCreditCard = new AnetAPI\PaymentType(); - $paymentCreditCard->setCreditCard($creditCard); + // 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); - // 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 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 Customer Profile Request + // 1. create a Payment Profile + // 2. create a Customer Profile + // 3. Submit a CreateCustomerProfile Request + // 4. Validate Profiiel ID returned - $paymentprofile = new AnetAPI\CustomerPaymentProfileType(); + $paymentprofile = new AnetAPI\CustomerPaymentProfileType(); - $paymentprofile->setCustomerType('individual'); - $paymentprofile->setBillTo($billto); - $paymentprofile->setPayment($paymentCreditCard); - $paymentprofiles[] = $paymentprofile; - $customerprofile = new AnetAPI\CustomerProfileType(); - $customerprofile->setDescription("Customer 2 Test PHP"); - $merchantCustomerId = time().rand(1,150); - $customerprofile->setMerchantCustomerId($merchantCustomerId); - $customerprofile->setEmail("test2@domain.com"); - $customerprofile->setPaymentProfiles($paymentprofiles); + $paymentprofile->setCustomerType('individual'); + $paymentprofile->setBillTo($billto); + $paymentprofile->setPayment($paymentCreditCard); + $paymentprofiles[] = $paymentprofile; + $customerprofile = new AnetAPI\CustomerProfileType(); + $customerprofile->setDescription("Customer 2 Test PHP"); + $merchantCustomerId = time().rand(1,150); + $customerprofile->setMerchantCustomerId($merchantCustomerId); + $customerprofile->setEmail("test2@domain.com"); + $customerprofile->setPaymentProfiles($paymentprofiles); - $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 "SUCCESS: CreateCustomerProfile PROFILE ID : " . $response->getCustomerProfileId() . "\n"; + $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 "SUCCESS: CreateCustomerProfile PROFILE ID : " . $response->getCustomerProfileId() . "\n"; - $profileIdRequested = $response->getCustomerProfileId(); - } - else - { - echo "ERROR : CreateCustomerProfile: Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; - } - // Retrieve an existing customer profile along with all the associated payment profiles and shipping addresses + $profileIdRequested = $response->getCustomerProfileId(); + } + else + { + echo "ERROR : CreateCustomerProfile: Invalid response\n"; + echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + } + // Retrieve an existing customer profile along with all the associated payment profiles and shipping addresses - $request = new AnetAPI\GetCustomerProfileRequest(); - $request->setMerchantAuthentication($merchantAuthentication); - $request->setCustomerProfileId($profileIdRequested); - $controller = new AnetController\GetCustomerProfileController($request); - $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) - { - echo "GetCustomerProfile SUCCESS : " . "\n"; - $profileSelected = $response->getProfile(); - $paymentProfilesSelected = $profileSelected->getPaymentProfiles(); - echo "Profile Has " . count($paymentProfilesSelected). " Payment Profiles" . "\n"; + $request = new AnetAPI\GetCustomerProfileRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setCustomerProfileId($profileIdRequested); + $controller = new AnetController\GetCustomerProfileController($request); + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) + { + echo "GetCustomerProfile SUCCESS : " . "\n"; + $profileSelected = $response->getProfile(); + $paymentProfilesSelected = $profileSelected->getPaymentProfiles(); + echo "Profile Has " . count($paymentProfilesSelected). " Payment Profiles" . "\n"; - } - else - { - echo "ERROR : GetCustomerProfile: Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; - } - return $response; + } + else + { + echo "ERROR : GetCustomerProfile: Invalid response\n"; + echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + } + return $response; } if(!defined('DONT_RUN_SAMPLES')) { diff --git a/CustomerProfiles/get-customer-shipping-address.php b/CustomerProfiles/get-customer-shipping-address.php index f209489..5e2a46f 100644 --- a/CustomerProfiles/get-customer-shipping-address.php +++ b/CustomerProfiles/get-customer-shipping-address.php @@ -2,6 +2,9 @@ require 'vendor/autoload.php'; use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; + + define("AUTHORIZENET_LOG_FILE", "phplog"); + function getCustomerShippingAddress($customerprofileid, $customeraddressid) { // Common setup for API credentials diff --git a/CustomerProfiles/get-hosted-profile-page.php b/CustomerProfiles/get-hosted-profile-page.php index b145379..f1b5d69 100644 --- a/CustomerProfiles/get-hosted-profile-page.php +++ b/CustomerProfiles/get-hosted-profile-page.php @@ -3,6 +3,8 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; + define("AUTHORIZENET_LOG_FILE", "phplog"); + function getHostedProfilePage($customerprofileid = \SampleCode\Constants::CUSTOMER_PROFILE_ID_HOSTED_PAGE) { // Common setup for API credentials diff --git a/CustomerProfiles/update-customer-payment-profile.php b/CustomerProfiles/update-customer-payment-profile.php index 9aa15f5..02d3fae 100644 --- a/CustomerProfiles/update-customer-payment-profile.php +++ b/CustomerProfiles/update-customer-payment-profile.php @@ -2,6 +2,9 @@ require 'vendor/autoload.php'; use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; + + define("AUTHORIZENET_LOG_FILE", "phplog"); + function updateCustomerPaymentProfile($customerProfileId= \SampleCode\Constants::CUSTOMER_PROFILE_ID_2, $customerPaymentProfileId= \SampleCode\Constants::CUSTOMER_PAYMENT_PROFILE_ID_GET) { diff --git a/CustomerProfiles/update-customer-profile.php b/CustomerProfiles/update-customer-profile.php index f8c8356..f8e90a7 100644 --- a/CustomerProfiles/update-customer-profile.php +++ b/CustomerProfiles/update-customer-profile.php @@ -3,6 +3,8 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; + define("AUTHORIZENET_LOG_FILE", "phplog"); + function updateCustomerProfile() { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); diff --git a/CustomerProfiles/update-customer-shipping-address.php b/CustomerProfiles/update-customer-shipping-address.php index 092aae3..f801bd9 100644 --- a/CustomerProfiles/update-customer-shipping-address.php +++ b/CustomerProfiles/update-customer-shipping-address.php @@ -2,6 +2,9 @@ require 'vendor/autoload.php'; use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; + + define("AUTHORIZENET_LOG_FILE", "phplog"); + function updateCustomerShippingAddress($customerprofileid, $customeraddressid) { // Common setup for API credentials diff --git a/CustomerProfiles/validate-customer-payment-profile.php b/CustomerProfiles/validate-customer-payment-profile.php index 9293fc3..16539fc 100644 --- a/CustomerProfiles/validate-customer-payment-profile.php +++ b/CustomerProfiles/validate-customer-payment-profile.php @@ -3,6 +3,8 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; + define("AUTHORIZENET_LOG_FILE", "phplog"); + function validateCustomerPaymentProfile($customerProfileId= \SampleCode\Constants::CUSTOMER_PROFILE_ID_2, $customerPaymentProfileId= \SampleCode\Constants::CUSTOMER_PAYMENT_PROFILE_ID_GET) { diff --git a/PaymentTransactions/authorize-credit-card.php b/PaymentTransactions/authorize-credit-card.php index dcce7e4..2f9085e 100644 --- a/PaymentTransactions/authorize-credit-card.php +++ b/PaymentTransactions/authorize-credit-card.php @@ -4,6 +4,8 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; + define("AUTHORIZENET_LOG_FILE", "phplog"); + function authorizeCreditCard($amount){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); diff --git a/PaymentTransactions/capture-funds-authorized-through-another-channel.php b/PaymentTransactions/capture-funds-authorized-through-another-channel.php index 4cc29ac..4b0b668 100644 --- a/PaymentTransactions/capture-funds-authorized-through-another-channel.php +++ b/PaymentTransactions/capture-funds-authorized-through-another-channel.php @@ -3,6 +3,8 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; +define("AUTHORIZENET_LOG_FILE", "phplog"); + function captureFundsAuthorizedThroughAnotherChannel($amount){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); diff --git a/PaymentTransactions/capture-previously-authorized-amount.php b/PaymentTransactions/capture-previously-authorized-amount.php index 03e8aca..763f1c6 100644 --- a/PaymentTransactions/capture-previously-authorized-amount.php +++ b/PaymentTransactions/capture-previously-authorized-amount.php @@ -1,7 +1,9 @@ diff --git a/PaymentTransactions/charge-credit-card.php b/PaymentTransactions/charge-credit-card.php index 28033d1..5626919 100644 --- a/PaymentTransactions/charge-credit-card.php +++ b/PaymentTransactions/charge-credit-card.php @@ -3,6 +3,8 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; + define("AUTHORIZENET_LOG_FILE", "phplog"); + function chargeCreditCard($amount){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); diff --git a/PaymentTransactions/charge-customer-profile.php b/PaymentTransactions/charge-customer-profile.php index 91441bc..0cb8dfd 100644 --- a/PaymentTransactions/charge-customer-profile.php +++ b/PaymentTransactions/charge-customer-profile.php @@ -3,6 +3,8 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; + define("AUTHORIZENET_LOG_FILE", "phplog"); + function chargeCustomerProfile($profileid, $paymentprofileid, $amount){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); diff --git a/PaymentTransactions/charge-tokenized-credit-card.php b/PaymentTransactions/charge-tokenized-credit-card.php index 5face6b..cbb3a88 100644 --- a/PaymentTransactions/charge-tokenized-credit-card.php +++ b/PaymentTransactions/charge-tokenized-credit-card.php @@ -3,6 +3,8 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; + define("AUTHORIZENET_LOG_FILE", "phplog"); + function chargeTokenizedCreditCard($amount){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); diff --git a/PaymentTransactions/credit-bank-account.php b/PaymentTransactions/credit-bank-account.php index 822266e..69ce174 100644 --- a/PaymentTransactions/credit-bank-account.php +++ b/PaymentTransactions/credit-bank-account.php @@ -3,6 +3,8 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; + define("AUTHORIZENET_LOG_FILE", "phplog"); + function creditBankAccount($amount){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); diff --git a/PaymentTransactions/debit-bank-account.php b/PaymentTransactions/debit-bank-account.php index 1f69320..a9cc38a 100644 --- a/PaymentTransactions/debit-bank-account.php +++ b/PaymentTransactions/debit-bank-account.php @@ -3,6 +3,8 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; + define("AUTHORIZENET_LOG_FILE", "phplog"); + function debitBankAccount($amount){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); diff --git a/PaymentTransactions/refund-transaction.php b/PaymentTransactions/refund-transaction.php index 2c90255..8ba8f65 100644 --- a/PaymentTransactions/refund-transaction.php +++ b/PaymentTransactions/refund-transaction.php @@ -3,6 +3,8 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; + define("AUTHORIZENET_LOG_FILE", "phplog"); + function refundTransaction($amount){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); diff --git a/PaymentTransactions/update-split-tender-group.php b/PaymentTransactions/update-split-tender-group.php index 998468c..194717f 100644 --- a/PaymentTransactions/update-split-tender-group.php +++ b/PaymentTransactions/update-split-tender-group.php @@ -3,6 +3,8 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; + define("AUTHORIZENET_LOG_FILE", "phplog"); + function updateSplitTenderGroup(){ // Common Set Up for API Credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); diff --git a/PaymentTransactions/void-transaction.php b/PaymentTransactions/void-transaction.php index 5bc74a6..97a961c 100644 --- a/PaymentTransactions/void-transaction.php +++ b/PaymentTransactions/void-transaction.php @@ -2,6 +2,8 @@ require 'vendor/autoload.php'; use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; + + define("AUTHORIZENET_LOG_FILE", "phplog"); function voidTransaction($transactionid){ // Common setup for API credentials diff --git a/PaypalExpressCheckout/authorization-and-capture-continue.php b/PaypalExpressCheckout/authorization-and-capture-continue.php index 4d5199a..781b092 100644 --- a/PaypalExpressCheckout/authorization-and-capture-continue.php +++ b/PaypalExpressCheckout/authorization-and-capture-continue.php @@ -3,6 +3,8 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; + define("AUTHORIZENET_LOG_FILE", "phplog"); + function payPalAuthorizeCaptureContinue($refTransId, $payerID) { // Common setup for API credentials (with PayPal compatible merchant credentials) diff --git a/PaypalExpressCheckout/authorization-and-capture.php b/PaypalExpressCheckout/authorization-and-capture.php index b330806..5d73cb8 100644 --- a/PaypalExpressCheckout/authorization-and-capture.php +++ b/PaypalExpressCheckout/authorization-and-capture.php @@ -3,6 +3,8 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; + define("AUTHORIZENET_LOG_FILE", "phplog"); + function payPalAuthorizeCapture($amount) { // Common setup for API credentials (with PayPal compatible merchant credentials) diff --git a/PaypalExpressCheckout/authorization-only-continued.php b/PaypalExpressCheckout/authorization-only-continued.php index 85216db..e5c2711 100644 --- a/PaypalExpressCheckout/authorization-only-continued.php +++ b/PaypalExpressCheckout/authorization-only-continued.php @@ -4,6 +4,8 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; + define("AUTHORIZENET_LOG_FILE", "phplog"); + function payPalAuthorizeOnlyContinue($transactionId, $payerId) { echo "PayPal Authorize Only Continue Transaction\n"; diff --git a/PaypalExpressCheckout/authorization-only.php b/PaypalExpressCheckout/authorization-only.php index ae68ffc..3928890 100644 --- a/PaypalExpressCheckout/authorization-only.php +++ b/PaypalExpressCheckout/authorization-only.php @@ -4,6 +4,8 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; +define("AUTHORIZENET_LOG_FILE", "phplog"); + function payPalAuthorizeOnly($amount) { // Common setup for API credentials (Paypal compatible merchant) $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); diff --git a/PaypalExpressCheckout/credit.php b/PaypalExpressCheckout/credit.php index 41c5725..8e84885 100644 --- a/PaypalExpressCheckout/credit.php +++ b/PaypalExpressCheckout/credit.php @@ -4,6 +4,8 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; +define("AUTHORIZENET_LOG_FILE", "phplog"); + function payPalCredit($transactionId) { // Common setup for API credentials (Paypal compatible merchant) diff --git a/PaypalExpressCheckout/get-details.php b/PaypalExpressCheckout/get-details.php index 623e37b..4d64edc 100644 --- a/PaypalExpressCheckout/get-details.php +++ b/PaypalExpressCheckout/get-details.php @@ -4,6 +4,8 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; + define("AUTHORIZENET_LOG_FILE", "phplog"); + function payPalGetDetails($transactionId) { echo "PayPal Get Details Transaction\n"; diff --git a/PaypalExpressCheckout/prior-authorization-capture.php b/PaypalExpressCheckout/prior-authorization-capture.php index 6257c5b..fb8b0d8 100644 --- a/PaypalExpressCheckout/prior-authorization-capture.php +++ b/PaypalExpressCheckout/prior-authorization-capture.php @@ -3,6 +3,8 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; + define("AUTHORIZENET_LOG_FILE", "phplog"); + function payPalPriorAuthorizationCapture($transactionId) { // Common setup for API credentials diff --git a/PaypalExpressCheckout/void.php b/PaypalExpressCheckout/void.php index 544a1b4..4509e14 100644 --- a/PaypalExpressCheckout/void.php +++ b/PaypalExpressCheckout/void.php @@ -3,6 +3,8 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; + define("AUTHORIZENET_LOG_FILE", "phplog"); + function payPalVoid($transactionId) { // Common setup for API credentials diff --git a/RecurringBilling/cancel-subscription.php b/RecurringBilling/cancel-subscription.php index 8768f07..8ba6ac8 100644 --- a/RecurringBilling/cancel-subscription.php +++ b/RecurringBilling/cancel-subscription.php @@ -3,6 +3,8 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; + define("AUTHORIZENET_LOG_FILE", "phplog"); + function cancelSubscription($subscriptionId) { // Common Set Up for API Credentials diff --git a/RecurringBilling/create-subscription.php b/RecurringBilling/create-subscription.php index bb4f03a..0bc3845 100644 --- a/RecurringBilling/create-subscription.php +++ b/RecurringBilling/create-subscription.php @@ -4,6 +4,8 @@ use net\authorize\api\controller as AnetController; date_default_timezone_set('America/Los_Angeles'); + define("AUTHORIZENET_LOG_FILE", "phplog"); + function createSubscription($intervalLength) { // Common Set Up for API Credentials diff --git a/RecurringBilling/get-list-of-subscriptions.php b/RecurringBilling/get-list-of-subscriptions.php index 301cd2a..58cad5c 100644 --- a/RecurringBilling/get-list-of-subscriptions.php +++ b/RecurringBilling/get-list-of-subscriptions.php @@ -3,6 +3,8 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; + define("AUTHORIZENET_LOG_FILE", "phplog"); + function getListOfSubscriptions() { // Common Set Up for API Credentials diff --git a/RecurringBilling/get-subscription-status.php b/RecurringBilling/get-subscription-status.php index 6e13736..2506f0b 100644 --- a/RecurringBilling/get-subscription-status.php +++ b/RecurringBilling/get-subscription-status.php @@ -3,6 +3,8 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; + define("AUTHORIZENET_LOG_FILE", "phplog"); + function getSubscriptionStatus($subscriptionId) { // Common Set Up for API Credentials diff --git a/RecurringBilling/get-subscription.php b/RecurringBilling/get-subscription.php index f6d917f..ef2cb2b 100644 --- a/RecurringBilling/get-subscription.php +++ b/RecurringBilling/get-subscription.php @@ -4,6 +4,8 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; + define("AUTHORIZENET_LOG_FILE", "phplog"); + function getSubscription($subscriptionId) { // Common Set Up for API Credentials diff --git a/RecurringBilling/update-subscription.php b/RecurringBilling/update-subscription.php index ed967d0..c5121b6 100644 --- a/RecurringBilling/update-subscription.php +++ b/RecurringBilling/update-subscription.php @@ -3,6 +3,8 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; + define("AUTHORIZENET_LOG_FILE", "phplog"); + function updateSubscription($subscriptionId) { // Common Set Up for API Credentials diff --git a/TransactionReporting/get-batch-statistics.php b/TransactionReporting/get-batch-statistics.php index 78dad37..7bbc1dc 100644 --- a/TransactionReporting/get-batch-statistics.php +++ b/TransactionReporting/get-batch-statistics.php @@ -3,6 +3,8 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; + define("AUTHORIZENET_LOG_FILE", "phplog"); + function getBatchStatistics() { // Common Set Up for API Credentials diff --git a/TransactionReporting/get-settled-batch-list.php b/TransactionReporting/get-settled-batch-list.php index 255c675..93f5939 100644 --- a/TransactionReporting/get-settled-batch-list.php +++ b/TransactionReporting/get-settled-batch-list.php @@ -3,6 +3,8 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; + define("AUTHORIZENET_LOG_FILE", "phplog"); + function getSettledBatchList() { // Common Set Up for API Credentials diff --git a/TransactionReporting/get-transaction-details.php b/TransactionReporting/get-transaction-details.php index 070b009..554d62c 100644 --- a/TransactionReporting/get-transaction-details.php +++ b/TransactionReporting/get-transaction-details.php @@ -3,6 +3,8 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; + define("AUTHORIZENET_LOG_FILE", "phplog"); + function getTransactionDetails($transactionId) { // Common Set Up for API Credentials diff --git a/TransactionReporting/get-transaction-list.php b/TransactionReporting/get-transaction-list.php index cf38498..0b63a5a 100644 --- a/TransactionReporting/get-transaction-list.php +++ b/TransactionReporting/get-transaction-list.php @@ -3,6 +3,8 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; + define("AUTHORIZENET_LOG_FILE", "phplog"); + function getTransactionList() { // Common Set Up for API Credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); diff --git a/TransactionReporting/get-unsettled-transaction-list.php b/TransactionReporting/get-unsettled-transaction-list.php index 5aaf0ee..848fbd1 100644 --- a/TransactionReporting/get-unsettled-transaction-list.php +++ b/TransactionReporting/get-unsettled-transaction-list.php @@ -3,6 +3,8 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; + define("AUTHORIZENET_LOG_FILE", "phplog"); + function getUnsettledTransactionList() { // Common Set Up for API Credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); diff --git a/VisaCheckout/create-visa-checkout-transaction.php b/VisaCheckout/create-visa-checkout-transaction.php index 4b91b7b..926e8bf 100644 --- a/VisaCheckout/create-visa-checkout-transaction.php +++ b/VisaCheckout/create-visa-checkout-transaction.php @@ -4,6 +4,8 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; + define("AUTHORIZENET_LOG_FILE", "phplog"); + function createVisaCheckoutTransaction(){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); diff --git a/VisaCheckout/decrypt-visa-checkout-data.php b/VisaCheckout/decrypt-visa-checkout-data.php index 4513ba3..890d2ca 100644 --- a/VisaCheckout/decrypt-visa-checkout-data.php +++ b/VisaCheckout/decrypt-visa-checkout-data.php @@ -4,6 +4,8 @@ use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; + define("AUTHORIZENET_LOG_FILE", "phplog"); + function decryptVisaCheckoutData(){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); From b8b772f36fa869b9d72bd22c9c70642775637452 Mon Sep 17 00:00:00 2001 From: ashtru Date: Mon, 22 Feb 2016 11:51:57 +0530 Subject: [PATCH 042/287] Hide "constant not defined" notice while including sample codes in the same file --- test-runner.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test-runner.php b/test-runner.php index 88e90fa..65f436c 100644 --- a/test-runner.php +++ b/test-runner.php @@ -1,6 +1,6 @@ Date: Mon, 22 Feb 2016 21:58:07 +0530 Subject: [PATCH 043/287] - Updated test runner to take SampleCodeList.txt as parameter. --- test-runner.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test-runner.php b/test-runner.php index 65f436c..f68e5fb 100644 --- a/test-runner.php +++ b/test-runner.php @@ -44,7 +44,10 @@ public static function getDay(){ } public function testAllSampleCodes(){ $runTests = 0; - $file = 'SampleCodeList.txt'; + if ( $argc != 2 ) { + die('\n Usage: phpunit test-runner.php '); + } + $file = $argv[1]; $data = file($file) or die('\nCould not read SampleCodeList.'); foreach ($data as $line) { From a7a00374725306fb2a1c6690a8e64199896ad973 Mon Sep 17 00:00:00 2001 From: srathod Date: Mon, 22 Feb 2016 22:05:29 +0530 Subject: [PATCH 044/287] - Fixed the command line variable name. --- test-runner.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test-runner.php b/test-runner.php index f68e5fb..48641c4 100644 --- a/test-runner.php +++ b/test-runner.php @@ -44,10 +44,10 @@ public static function getDay(){ } public function testAllSampleCodes(){ $runTests = 0; - if ( $argc != 2 ) { + if ( $_SERVER['argc'] != 2 ) { die('\n Usage: phpunit test-runner.php '); } - $file = $argv[1]; + $file = $_SERVER['argv'][1]; $data = file($file) or die('\nCould not read SampleCodeList.'); foreach ($data as $line) { From 0a529a81eb261430139fb6c9f128f4e4840eef2a Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Mon, 22 Feb 2016 22:14:36 +0530 Subject: [PATCH 045/287] Update test-runner.php --- test-runner.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test-runner.php b/test-runner.php index 48641c4..55cdac1 100644 --- a/test-runner.php +++ b/test-runner.php @@ -44,6 +44,7 @@ public static function getDay(){ } public function testAllSampleCodes(){ $runTests = 0; + echo "argc : " .$_SERVER['argc'] . "\n"; if ( $_SERVER['argc'] != 2 ) { die('\n Usage: phpunit test-runner.php '); } @@ -375,4 +376,4 @@ public static function runGetHostedProfilePage() return $profileResponse; } -} \ No newline at end of file +} From 9edefaa80353936ae9934a21a96b441734d4e548 Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Mon, 22 Feb 2016 22:17:06 +0530 Subject: [PATCH 046/287] 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 55cdac1..cec6f1e 100644 --- a/test-runner.php +++ b/test-runner.php @@ -45,7 +45,7 @@ public static function getDay(){ public function testAllSampleCodes(){ $runTests = 0; echo "argc : " .$_SERVER['argc'] . "\n"; - if ( $_SERVER['argc'] != 2 ) { + if ( $_SERVER['argc'] != 3 ) { die('\n Usage: phpunit test-runner.php '); } $file = $_SERVER['argv'][1]; From b7d4450c81dccb2f2335735a092dc81a1b77c423 Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Mon, 22 Feb 2016 22:20:45 +0530 Subject: [PATCH 047/287] 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 cec6f1e..09c4402 100644 --- a/test-runner.php +++ b/test-runner.php @@ -48,7 +48,7 @@ public function testAllSampleCodes(){ if ( $_SERVER['argc'] != 3 ) { die('\n Usage: phpunit test-runner.php '); } - $file = $_SERVER['argv'][1]; + $file = $_SERVER['argv'][2]; $data = file($file) or die('\nCould not read SampleCodeList.'); foreach ($data as $line) { From 38dcfdae4e337459beb937adc2dd8181933dd1c5 Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Mon, 22 Feb 2016 22:21:57 +0530 Subject: [PATCH 048/287] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 20d22c8..f3c8888 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,4 +9,4 @@ before_script: - composer install --prefer-dist --dev script: - - phpunit test-runner.php + - phpunit test-runner.php SampleCodeList.txt From 73f1bf1cf0cf5b5aeb2280b6982494408f0850e1 Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Mon, 22 Feb 2016 22:26:27 +0530 Subject: [PATCH 049/287] 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 09c4402..68a019a 100644 --- a/test-runner.php +++ b/test-runner.php @@ -44,7 +44,7 @@ public static function getDay(){ } public function testAllSampleCodes(){ $runTests = 0; - echo "argc : " .$_SERVER['argc'] . "\n"; + if ( $_SERVER['argc'] != 3 ) { die('\n Usage: phpunit test-runner.php '); } From 48563594466c678c1a0e08c7395c8a8ee85aaae5 Mon Sep 17 00:00:00 2001 From: ashtru Date: Tue, 23 Feb 2016 10:34:21 +0530 Subject: [PATCH 050/287] Added directory prefix, so that test-runnner from sdk as well. --- test-runner.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/test-runner.php b/test-runner.php index 68a019a..8d068ea 100644 --- a/test-runner.php +++ b/test-runner.php @@ -5,6 +5,15 @@ define("DONT_RUN_SAMPLES", "true"); define("SAMPLE_CODE_NAME_HEADING", "SampleCodeName"); require 'vendor/autoload.php'; + +if ( $_SERVER['argc'] != 3 ) { + die('\n Usage: phpunit test-runner.php '); +} +$dirPath = $_SERVER['argv'][2]; +if(substr($dirPath, -1) != "/") + $dirPath = $dirPath."/"; + +$prefix = getDirectoryPrefix(); $directories = array( 'CustomerProfiles/', 'RecurringBilling/', @@ -14,12 +23,13 @@ 'ApplePayTransactions/', 'VisaCheckout/' ); -foreach ($directories as $directory) { +foreach ($directories as $dirPath.$directory) { foreach(glob($directory . "*.php") as $sample) { require_once $sample; //echo $sample; } } + error_reporting($errorlevel); class TestRunner extends PHPUnit_Framework_TestCase { @@ -45,10 +55,7 @@ public static function getDay(){ public function testAllSampleCodes(){ $runTests = 0; - if ( $_SERVER['argc'] != 3 ) { - die('\n Usage: phpunit test-runner.php '); - } - $file = $_SERVER['argv'][2]; + $file = $dirPath."SampleCodeList.txt"; $data = file($file) or die('\nCould not read SampleCodeList.'); foreach ($data as $line) { From c9e681061d9cea43b7b1537392054da175cbf9a9 Mon Sep 17 00:00:00 2001 From: ashtru Date: Tue, 23 Feb 2016 10:46:06 +0530 Subject: [PATCH 051/287] Added arguments to test-runner.php so that it can be run from sdk as well. --- test-runner.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test-runner.php b/test-runner.php index 8d068ea..921214c 100644 --- a/test-runner.php +++ b/test-runner.php @@ -1,7 +1,4 @@ '); } $dirPath = $_SERVER['argv'][2]; +echo $dirPath; if(substr($dirPath, -1) != "/") $dirPath = $dirPath."/"; -$prefix = getDirectoryPrefix(); $directories = array( 'CustomerProfiles/', 'RecurringBilling/', @@ -23,8 +20,11 @@ 'ApplePayTransactions/', 'VisaCheckout/' ); -foreach ($directories as $dirPath.$directory) { - foreach(glob($directory . "*.php") as $sample) { + +$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) { require_once $sample; //echo $sample; } @@ -55,7 +55,7 @@ public static function getDay(){ public function testAllSampleCodes(){ $runTests = 0; - $file = $dirPath."SampleCodeList.txt"; + $file = $GLOBALS["dirPath"]."SampleCodeList.txt"; $data = file($file) or die('\nCould not read SampleCodeList.'); foreach ($data as $line) { From 813bb09529a19c1a406e45b2228524eb737e8976 Mon Sep 17 00:00:00 2001 From: ashtru Date: Tue, 23 Feb 2016 10:49:19 +0530 Subject: [PATCH 052/287] Updated travis to pass default argument --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f3c8888..0f993e6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,4 +9,4 @@ before_script: - composer install --prefer-dist --dev script: - - phpunit test-runner.php SampleCodeList.txt + - phpunit test-runner.php . From 449194588d39e963b8de0f2a8b7d847ac6cf363e Mon Sep 17 00:00:00 2001 From: ashtru Date: Tue, 23 Feb 2016 12:12:23 +0530 Subject: [PATCH 053/287] Change travis for php7. Classmap not changed yet. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0f993e6..e4598aa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ php: sudo: false before_script: - - composer install --prefer-dist --dev + - composer install --prefer-dist --ignore-platform-reqs script: - phpunit test-runner.php . From 62d180ccad04c530060558b543fe5a969d3e85b1 Mon Sep 17 00:00:00 2001 From: ashtru Date: Tue, 23 Feb 2016 12:15:25 +0530 Subject: [PATCH 054/287] Added php 7 to be run in travis along with php5.6 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index e4598aa..3b2c7ce 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ language: php php: - 5.6 + - 7.0 sudo: false From d374ca10eb3f740878ee4a76b0294fa69aee4a3d Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Tue, 23 Feb 2016 13:01:46 +0530 Subject: [PATCH 055/287] 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 921214c..4f46a81 100644 --- a/test-runner.php +++ b/test-runner.php @@ -39,7 +39,7 @@ class TestRunner extends PHPUnit_Framework_TestCase public static $payerID = "LM6NCLZ5RAKBY"; //random amount for transactions/subscriptions public static function getAmount(){ - return 12 + (rand(1, 10000)/12); + return 12 + (rand(1, 900000)/12); } //random email for a new customer profile public static function getEmail(){ From a6d45105a516957a8e39c7657d3e8f4f8ab963d4 Mon Sep 17 00:00:00 2001 From: brianmc Date: Tue, 1 Mar 2016 15:16:32 -0800 Subject: [PATCH 056/287] Added customer ID to refund sample --- PaymentTransactions/refund-transaction.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/PaymentTransactions/refund-transaction.php b/PaymentTransactions/refund-transaction.php index 8ba8f65..dc27c20 100644 --- a/PaymentTransactions/refund-transaction.php +++ b/PaymentTransactions/refund-transaction.php @@ -19,14 +19,18 @@ function refundTransaction($amount){ $paymentOne = new AnetAPI\PaymentType(); $paymentOne->setCreditCard($creditCard); //create a transaction - $transactionRequestType = new AnetAPI\TransactionRequestType(); - $transactionRequestType->setTransactionType( "refundTransaction"); - $transactionRequestType->setAmount($amount); - $transactionRequestType->setPayment($paymentOne); + $transactionRequest = new AnetAPI\TransactionRequestType(); + $transactionRequest->setTransactionType( "refundTransaction"); + $transactionRequest->setAmount($amount); + $transactionRequest->setPayment($paymentOne); + $customer = new AnetAPI\CustomerDataType(); + $customer->setId("CUST001"); + $transactionRequest->setCustomer($customer); + $request = new AnetAPI\CreateTransactionRequest(); $request->setMerchantAuthentication($merchantAuthentication); $request->setRefId($refId); - $request->setTransactionRequest( $transactionRequestType); + $request->setTransactionRequest( $transactionRequest); $controller = new AnetController\CreateTransactionController($request); $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); if ($response != null) From 5da3c9eeb4d3b73ea31e6ba5159da887b1371b4d Mon Sep 17 00:00:00 2001 From: srathod Date: Wed, 9 Mar 2016 14:40:22 +0530 Subject: [PATCH 057/287] - Added sample code for create-subscription-from-customer-profile. - Updated test-runner. --- ...eate-customer-profile-from-transaction.php | 12 +++- ...ate-subscription-from-customer-profile.php | 67 +++++++++++++++++++ SampleCodeList.txt | 1 + test-runner.php | 15 +++++ 4 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 RecurringBilling/create-subscription-from-customer-profile.php diff --git a/CustomerProfiles/create-customer-profile-from-transaction.php b/CustomerProfiles/create-customer-profile-from-transaction.php index 2e9b9e7..204e87d 100644 --- a/CustomerProfiles/create-customer-profile-from-transaction.php +++ b/CustomerProfiles/create-customer-profile-from-transaction.php @@ -11,10 +11,20 @@ function createCustomerProfileFromTransaction($transId= \SampleCode\Constants::T $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + $customerProfile = new AnetAPI\CustomerProfileBaseType(); + $customerProfile->setMerchantCustomerId("123212"); + $customerProfile->setEmail(rand(0,10000) . "@test" .".com"); + $customerProfile->setDesciption(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"); $controller = new AnetController\CreateCustomerProfileFromTransactionController($request); @@ -23,7 +33,7 @@ function createCustomerProfileFromTransaction($transId= \SampleCode\Constants::T if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) { echo "SUCCESS: PROFILE ID : " . $response->getCustomerProfileId() . "\n"; - } + } else { echo "ERROR : Invalid response\n"; diff --git a/RecurringBilling/create-subscription-from-customer-profile.php b/RecurringBilling/create-subscription-from-customer-profile.php new file mode 100644 index 0000000..f2d6cba --- /dev/null +++ b/RecurringBilling/create-subscription-from-customer-profile.php @@ -0,0 +1,67 @@ +setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + $refId = 'ref' . time(); + + // Subscription Type Info + $subscription = new AnetAPI\ARBSubscriptionType(); + $subscription->setName("Sample Subscription"); + + $interval = new AnetAPI\PaymentScheduleType\IntervalAType(); + $interval->setLength($intervalLength); + $interval->setUnit("days"); + + $paymentSchedule = new AnetAPI\PaymentScheduleType(); + $paymentSchedule->setInterval($interval); + $paymentSchedule->setStartDate(new DateTime('2020-08-30')); + $paymentSchedule->setTotalOccurrences("12"); + $paymentSchedule->setTrialOccurrences("1"); + + $subscription->setPaymentSchedule($paymentSchedule); + $subscription->setAmount(rand(1,99999)/12.0*12); + $subscription->setTrialAmount("0.00"); + + $profile = new AnetAPI\CustomerProfileIdType(); + $profile->setCustomerProfileId($customerProfileId); + $profile->setCustomerPaymentProfileId($customerPaymentProfileId); + $profile->setCustomerAddressId($customerAddressId); + + $subscription->setProfile($profile); + + $request = new AnetAPI\ARBCreateSubscriptionRequest(); + $request->setmerchantAuthentication($merchantAuthentication); + $request->setRefId($refId); + $request->setSubscription($subscription); + $controller = new AnetController\ARBCreateSubscriptionController($request); + + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) + { + echo "SUCCESS: Subscription ID : " . $response->getSubscriptionId() . "\n"; + } + else + { + echo "ERROR : Invalid response\n"; + echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + } + + return $response; + } + + if(!defined('DONT_RUN_SAMPLES')) + createSubscriptionFromCustomerProfile( \SampleCode\Constants::SUBSCRIPTION_INTERVAL_DAYS, "247150", "215472", "189691"); + +?> diff --git a/SampleCodeList.txt b/SampleCodeList.txt index 861a537..1148f89 100644 --- a/SampleCodeList.txt +++ b/SampleCodeList.txt @@ -1,6 +1,7 @@ SampleCodeName,IsDependent,ShouldRun ChargeCreditCard,1,1 CreateSubscription,1,1 +CreateSubscriptionFromCustomerProfile,1,1 GetCustomerPaymentProfileList,0,1 GetTransactionList,0,1 CreateAnApplePayTransaction,0,0 diff --git a/test-runner.php b/test-runner.php index 4f46a81..19bb517 100644 --- a/test-runner.php +++ b/test-runner.php @@ -227,6 +227,21 @@ public static function runCreateSubscription() 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()); From 4268b91b3db96de75af177f81e43d5271de110a9 Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Wed, 16 Mar 2016 16:23:58 +0530 Subject: [PATCH 058/287] Updated create-customer-payment-profile to add randomization --- CustomerProfiles/create-customer-payment-profile.php | 4 ++-- constants/Constants.php | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CustomerProfiles/create-customer-payment-profile.php b/CustomerProfiles/create-customer-payment-profile.php index 4841850..1c47405 100644 --- a/CustomerProfiles/create-customer-payment-profile.php +++ b/CustomerProfiles/create-customer-payment-profile.php @@ -21,14 +21,14 @@ function createCustomerPaymentProfile($existingcustomerprofileid, $phoneNumber){ // Create the Bill To info for new payment type $billto = new AnetAPI\CustomerAddressType(); - $billto->setFirstName("Mrs Mary"); + $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("000-000-0000"); + $billto->setPhoneNumber($phoneNumber); $billto->setfaxNumber("999-999-9999"); $billto->setCountry("USA"); diff --git a/constants/Constants.php b/constants/Constants.php index 413dde6..e612aab 100644 --- a/constants/Constants.php +++ b/constants/Constants.php @@ -81,4 +81,5 @@ class Constants const VC_DATA_VALUE = "4Ng5pzJ6DXfAvLSzVauN9KTufx5lTHhFlnuIr248N3fjtyHrHqMuhOkB1BLiSjKWeTM9+BNj3+9nY56d7CsUfIuvVSTaJRhQQSex1dS2Y2Y+/cA5U+3D1pg5YtTmDVUGlsu1simAd3huwPnwD+CG6O8Ml0AmXvYHntmL3vFaJomadMQBy27k8Dbh5eplPBwyawKUVJ7GqTyKLe8aOYkBUHT5ANWkq2hlGps44BOoDHZ26JWjHdorBZtVIqMK1SIyW4Dih5c/Y//w2toA8WBTPILIvt4h6HPPvWZMZCHCqom9D2k4WGH5+BCEY2jHI7gfYV6xRx54i5vitsYTKm3CyA0C5+l0FNDkfUFHDvVUG9FVzRWVd0TXYhDwfa2pcfI68eYvkEfeT+ZNJ24ZXKPrJo6KZ3x6eZAhzgAMFiC+tPsiygb2zQy5PVoYoBIGj/NGNRqmhZTOEajcO3ZjWxfAnLZAmvMi+pEwJCMmuIY4qRU3RfcaXhAoaUPpDxqrSxR1m+CUKYVdt3nnnQeVaVqf+RaeV9cyFJvILeBPXTBVC50AckVLS37UuBWgWaWcchjRPk9mriDu2KlHQwdR4zu0jnLh4i3tbxV416QBcYLO6AF2Ixlm3GzqGE6QcVssgFCUAhklBWGNLP62O1jtyV4NgTD36QhvHEHby7o4XBB+mjlY6xSEXR+IW9u64AzfDCsTxWiAOE65le6cSk4NDV8DrtYeIozILivWu6wFSpy1gMfiDot4Ndv3C9xCFvH0Bzlky7NoZrvSolKTVNTs8W8UqMFV19qGl6SRaNUEhCqgso/FkdO0eGXFMdQPuP11wQzK/9F3yB9gS2rpXi9sy8DrCqnJ9EXMmliSstKuQl5+yfGc8K3Urot3t+BmNoOvzM9Aha/PzmbLnuKBN6/DUbIw5mhNMCvIA1ByispKpjeV682jl4uslkRsitGLcIOBREFXvGaLxRb37HJkXCHk+jorpDz7LUQhVkClN+hW0vXtgdHQFCIOL7uREdbvk6BZbQlFsuVEKGZxPbKPEJfqMbH54B4a4P5XNQHm4Yt4haH4T0JuYgzoSo76uuXD3g5IuUvy7x8Ykuja1rwW/k//SZAiGaZraRIIAEnzHiUP8dcufb/RonHGnJcYXIEWeIF1lX980bDA+H4vlO8/nN/Mj+EL6tT95MfRDiQHUW69qkqotQd7FJ5uWT+NtetzqDsN5s3sIhwkLKIn9EDLIav5v4SXKxkG+ycMJmGFcfhs7Td9O6hl+Om/JD3he3rgfClaFi/ZR7AVY6fWbAAm9QftKijQ6rskPDYL9Y3gVSA9rdduSg97fUHC+FdfyQXGH552cDLs2ZgzYw6KluXHEuwhACgNotxToPYTTdZxxNr1vPoqYCqHDL2dL8dkuO59/sbZE1m4ektKvUC2wz0UdTDVbHN8HSrLPn2hf/xQp5bKeDDjYkWvNKuwy+aug9H+Uu/m1LuPK/YdogVv9l25y/c2Qbj3dAJ9xTuKjmiJLKlRh4SUI9+05HjDF+i84AoUZ8LuC7LGtrN8ReYIktLhaXq9+XDh5fv4NYhnuYgWkUioKtx1dmfOMHjpLm4aE8Ra1gpJQcZAgwnqYubQvnYy0nY4VaykNix7m3vZwItpKOLqxDYxa3q0qUw25X9zafAM61kPW6EP+4idPzHNww6r1FD4Ihq644dCnCXwoSQ531DW6oAPot8iLZ/xXwoWwrW05k9t2RHjjLbw1L5r1CKgShJQfX7nkJxfGyuw1RmqoQDuNt/tj9M/dHOnoPnOYZZN0JX+Al8PI5zs+LLajw1imu9YcSpwMz3ZlfQqTfI0fjSCc8Is6qVYDMvKD0TweY4hiIxkzs+RyQmPgIeIWqf7Su5+RcnXitb3OuFibBGCjdDeG0ESG8qeiBQKZ3wEyZG09eDAfhuUR5kfZCG4Q01u2YDoRzObxLd8Ruf7HNvtefucFLubciWvOSzbDUisoz0wwOSgJGHucC3IR+1mb/4gz/dI2wvWFInhKcQz4ivkuHaFj8XwvZMcpkwPKtg3pRGTleX/gfjbHcx2VcWRcMPdlDMgTgst9ouN763TZUHHLxjECyB9pkLrR1nhG0cS/aig8Bq1+AH7tvl1wLVxm1Z77DVX4aUIxBH2YUcOgpe6mrWFi6LK3im4/grZECsL/XC4tsTEHjO/U3SazUuhP+6LiCYqp50+3zZf3RpWlxZoYjm5SJ9VIWabocO/Ef26G38lKottW1XsSQUan7myYFFyeyon2hnufzMuxpyXTJ7TLekXCi2gLYbGjldgiRmGShPXzSar+hC2"; const VC_DATA_KEY = "JxAB39A9yUsf6wMD0jwGKCuY7mmzWaeEj85MH02AfKGUxOkJ00JK+o8vGG55cUF9voYU4QQ1Jec4p6nKmsxXmTREEaJwmQErotD4fpcFOyoqWTLMZfslrkHgiqbwru/V"; } -?> \ No newline at end of file +?> + From f732951ed84e16d473829c2b948306634a3e00f3 Mon Sep 17 00:00:00 2001 From: Ashutosh Singh Date: Wed, 16 Mar 2016 21:53:36 +0530 Subject: [PATCH 059/287] Update create-customer-profile-from-transaction.php Fix spelling mistake --- CustomerProfiles/create-customer-profile-from-transaction.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CustomerProfiles/create-customer-profile-from-transaction.php b/CustomerProfiles/create-customer-profile-from-transaction.php index 204e87d..565f38e 100644 --- a/CustomerProfiles/create-customer-profile-from-transaction.php +++ b/CustomerProfiles/create-customer-profile-from-transaction.php @@ -15,7 +15,7 @@ function createCustomerProfileFromTransaction($transId= \SampleCode\Constants::T $customerProfile = new AnetAPI\CustomerProfileBaseType(); $customerProfile->setMerchantCustomerId("123212"); $customerProfile->setEmail(rand(0,10000) . "@test" .".com"); - $customerProfile->setDesciption(rand(0,10000) ."sample description"); + $customerProfile->setDescription(rand(0,10000) ."sample description"); $request = new AnetAPI\CreateCustomerProfileFromTransactionRequest(); $request->setMerchantAuthentication($merchantAuthentication); From bbd451717e25d24ce92f5a5c4c6b0e51a243944a Mon Sep 17 00:00:00 2001 From: srathod Date: Thu, 17 Mar 2016 17:20:58 +0530 Subject: [PATCH 060/287] - Adding retry in testrunner. --- test-runner.php | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/test-runner.php b/test-runner.php index 19bb517..b1acc10 100644 --- a/test-runner.php +++ b/test-runner.php @@ -77,23 +77,28 @@ public function testAllSampleCodes(){ } else { - if("0" === $isDependent) + for($i=0; $i<=1; $i++) { - echo "not dependent\n"; - $sampleMethodName = $apiName; - $sampleMethodName[0] = strtolower($sampleMethodName[0]); + 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; } - else - { - $sampleMethodName = "TestRunner::run" . $apiName; - echo " is dependent\n"; - } - - - //request the api - echo "Running sample: " . $sampleMethodName . "\n"; - - $response = call_user_func($sampleMethodName); //response must be successful $this->assertNotNull($response); From 9ebcbb9123d86f99251d5ded24f9a9f9738b3c48 Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Fri, 18 Mar 2016 19:33:18 +0530 Subject: [PATCH 061/287] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 0f3d438..53c8cb9 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "require": { "php": ">=5.2.0", "ext-curl": "*", - "authorizenet/authorizenet": "1.8.6.2", + "authorizenet/authorizenet": "1.8.8", "jms/serializer": "xsd2php-dev as 0.18.0" }, "require-dev": { From 5fd350bf6886135bc8e4f69cc9e3b643bf8843bf Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Fri, 18 Mar 2016 23:45:11 +0530 Subject: [PATCH 062/287] Update .travis.yml --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3b2c7ce..ada058f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ sudo: false before_script: - composer install --prefer-dist --ignore-platform-reqs - + script: - phpunit test-runner.php . + From 5673d0aa324eaec6789e012e6d37743ce27029a0 Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Fri, 18 Mar 2016 14:07:40 -0700 Subject: [PATCH 063/287] Update README.md --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index e0b2158..f171dca 100644 --- a/README.md +++ b/README.md @@ -15,3 +15,10 @@ Run the individual samples e.g. ```` php PaymentTransactions/charge-credit-card.php ```` + +##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 +require 'path/to/anet_php_sdk/autoload.php'; +``` From f43d557cfeea5edb990f7b872c5191b6fdb33ffb Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Mon, 21 Mar 2016 17:33:44 +0530 Subject: [PATCH 064/287] Added prints in get-customer-profile, get-customer-payment-profile and get-customer-shipping-address for subscriptionids --- CustomerProfiles/get-customer-payment-profile.php | 11 +++++++++++ CustomerProfiles/get-customer-profile.php | 11 +++++++++++ CustomerProfiles/get-customer-shipping-address.php | 12 ++++++++++++ RecurringBilling/update-subscription.php | 9 +++++++++ 4 files changed, 43 insertions(+) diff --git a/CustomerProfiles/get-customer-payment-profile.php b/CustomerProfiles/get-customer-payment-profile.php index 1d411a3..5046131 100644 --- a/CustomerProfiles/get-customer-payment-profile.php +++ b/CustomerProfiles/get-customer-payment-profile.php @@ -33,6 +33,17 @@ function getCustomerPaymentProfile($customerProfileId=\SampleCode\Constants::CUS echo "Customer Payment Profile Billing Address: " . $response->getPaymentProfile()->getbillTo()->getAddress(). "\n"; echo "Customer Payment Profile Card Last 4 " . $response->getPaymentProfile()->getPayment()->getCreditCard()->getCardNumber(). "\n"; + if($response->getPaymentProfile()->getSubscriptionIds() != null) + { + if(($response->getPaymentProfile()->getSubscriptionIds() != null) && + (!empty($response->getPaymentProfile()->getSubscriptionIds()))) + { + + echo "List of subscriptions:"; + foreach($response->getPaymentProfile()->getSubscriptionIds() as $subscriptionid) + echo $subscriptionid . "\n"; + } + } } else { diff --git a/CustomerProfiles/get-customer-profile.php b/CustomerProfiles/get-customer-profile.php index 7f2acc8..a3684bb 100644 --- a/CustomerProfiles/get-customer-profile.php +++ b/CustomerProfiles/get-customer-profile.php @@ -81,6 +81,17 @@ function getCustomerProfile(){ $paymentProfilesSelected = $profileSelected->getPaymentProfiles(); echo "Profile Has " . count($paymentProfilesSelected). " Payment Profiles" . "\n"; + if($response->getSubscriptionIds() != null) + { + if(($response->getSubscriptionIds() != null) && + (!empty($response->getSubscriptionIds()))) + { + + echo "List of subscriptions:"; + foreach($response->getSubscriptionIds() as $subscriptionid) + echo $subscriptionid . "\n"; + } + } } else { diff --git a/CustomerProfiles/get-customer-shipping-address.php b/CustomerProfiles/get-customer-shipping-address.php index 5e2a46f..ff93ff4 100644 --- a/CustomerProfiles/get-customer-shipping-address.php +++ b/CustomerProfiles/get-customer-shipping-address.php @@ -39,6 +39,18 @@ function getCustomerShippingAddress($customerprofileid, $customeraddressid) echo " Phone Number : " . $response->getAddress()->getPhoneNumber() . "\n"; echo " FAX Number : " . $response->getAddress()->getFaxNumber() . "\n"; echo "Customer AddressId : " . $response->getAddress()->getCustomerAddressId() . "\n"; + + if($response->getSubscriptionIds() != null) + { + if(($response->getSubscriptionIds() != null) && + (!empty($response->getSubscriptionIds()))) + { + + echo "List of subscriptions:"; + foreach($response->getSubscriptionIds() as $subscriptionid) + echo $subscriptionid . "\n"; + } + } } else { diff --git a/RecurringBilling/update-subscription.php b/RecurringBilling/update-subscription.php index c5121b6..270670e 100644 --- a/RecurringBilling/update-subscription.php +++ b/RecurringBilling/update-subscription.php @@ -23,7 +23,16 @@ function updateSubscription($subscriptionId) { $payment = new AnetAPI\PaymentType(); $payment->setCreditCard($creditCard); + //set profile information + $profile = new AnetAPI\CustomerProfileIdType(); + $profile->setCustomerProfileId("121212"); + $profile->setCustomerPaymentProfileId("131313"); + $profile->setCustomerAddressId("141414"); + $subscription->setPayment($payment); + + //set customer profile information + //$subscription->setProfile($profile); $request = new AnetAPI\ARBUpdateSubscriptionRequest(); $request->setMerchantAuthentication($merchantAuthentication); From a74841527c81bc3315ff825908e042cfa55eff8e Mon Sep 17 00:00:00 2001 From: brianmc Date: Wed, 6 Apr 2016 13:48:31 -0700 Subject: [PATCH 065/287] Added card code to samples --- PaymentTransactions/authorize-credit-card.php | 5 +++-- PaymentTransactions/charge-credit-card.php | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/PaymentTransactions/authorize-credit-card.php b/PaymentTransactions/authorize-credit-card.php index 2f9085e..4179620 100644 --- a/PaymentTransactions/authorize-credit-card.php +++ b/PaymentTransactions/authorize-credit-card.php @@ -15,8 +15,9 @@ function authorizeCreditCard($amount){ // Create the payment data for a credit card $creditCard = new AnetAPI\CreditCardType(); - $creditCard->setCardNumber( \SampleCode\Constants::CREDIT_CARD_NUMBER ); - $creditCard->setExpirationDate( \SampleCode\Constants::EXPIRY_DATE); + $creditCard->setCardNumber("4111111111111111"); + $creditCard->setExpirationDate("1226"); + $creditCard->setCardCode("123"); $paymentOne = new AnetAPI\PaymentType(); $paymentOne->setCreditCard($creditCard); diff --git a/PaymentTransactions/charge-credit-card.php b/PaymentTransactions/charge-credit-card.php index 5626919..0076fd5 100644 --- a/PaymentTransactions/charge-credit-card.php +++ b/PaymentTransactions/charge-credit-card.php @@ -14,8 +14,9 @@ function chargeCreditCard($amount){ // Create the payment data for a credit card $creditCard = new AnetAPI\CreditCardType(); - $creditCard->setCardNumber(\SampleCode\Constants::CREDIT_CARD_NUMBER); - $creditCard->setExpirationDate(\SampleCode\Constants::EXPIRY_DATE); + $creditCard->setCardNumber("4111111111111111"); + $creditCard->setExpirationDate("1226"); + $creditCard->setCardCode("123"); $paymentOne = new AnetAPI\PaymentType(); $paymentOne->setCreditCard($creditCard); From 5ae1d8c9fc22ccde0ed1c4e730f1faa9bbfb541d Mon Sep 17 00:00:00 2001 From: brianmc Date: Thu, 21 Apr 2016 13:59:07 -0700 Subject: [PATCH 066/287] Updated to remove function array indexers which is a 5.4 feature --- CustomerProfiles/create-customer-payment-profile.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CustomerProfiles/create-customer-payment-profile.php b/CustomerProfiles/create-customer-payment-profile.php index 1c47405..83c5d0d 100644 --- a/CustomerProfiles/create-customer-payment-profile.php +++ b/CustomerProfiles/create-customer-payment-profile.php @@ -56,7 +56,8 @@ function createCustomerPaymentProfile($existingcustomerprofileid, $phoneNumber){ else { echo "Create Customer Payment Profile: ERROR Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } return $response; From 9471da7662bd27a112036840e1a3c861848e6ef0 Mon Sep 17 00:00:00 2001 From: brianmc Date: Thu, 21 Apr 2016 15:36:27 -0700 Subject: [PATCH 067/287] Removed all the 5.4 dependencies --- ApplePayTransactions/create-an-apple-pay-transaction.php | 3 ++- .../create-customer-profile-from-transaction.php | 3 ++- CustomerProfiles/create-customer-profile.php | 4 ++-- CustomerProfiles/create-customer-shipping-address.php | 3 ++- CustomerProfiles/delete-customer-payment-profile.php | 3 ++- CustomerProfiles/delete-customer-profile.php | 4 ++-- CustomerProfiles/delete-customer-shipping-address.php | 3 ++- CustomerProfiles/get-customer-payment-profile-list.php | 7 ++++--- CustomerProfiles/get-customer-payment-profile.php | 3 ++- CustomerProfiles/get-customer-profile-ids.php | 3 ++- CustomerProfiles/get-customer-profile.php | 6 ++++-- CustomerProfiles/get-customer-shipping-address.php | 3 ++- CustomerProfiles/get-hosted-profile-page.php | 6 ++---- CustomerProfiles/update-customer-payment-profile.php | 6 ++++-- CustomerProfiles/update-customer-profile.php | 6 ++++-- CustomerProfiles/update-customer-shipping-address.php | 3 ++- CustomerProfiles/validate-customer-payment-profile.php | 6 ++++-- .../capture-funds-authorized-through-another-channel.php | 4 +++- PaymentTransactions/refund-transaction.php | 8 +++----- PaymentTransactions/update-split-tender-group.php | 8 +++++--- PaymentTransactions/void-transaction.php | 5 +++-- .../authorization-and-capture-continue.php | 5 ++--- PaypalExpressCheckout/get-details.php | 5 ++--- RecurringBilling/cancel-subscription.php | 7 +++++-- .../create-subscription-from-customer-profile.php | 3 ++- RecurringBilling/create-subscription.php | 3 ++- RecurringBilling/get-list-of-subscriptions.php | 4 ++-- RecurringBilling/get-subscription-status.php | 4 ++-- RecurringBilling/get-subscription.php | 4 ++-- RecurringBilling/update-subscription.php | 7 +++++-- TransactionReporting/get-batch-statistics.php | 4 ++-- TransactionReporting/get-settled-batch-list.php | 3 ++- TransactionReporting/get-transaction-details.php | 4 ++-- TransactionReporting/get-transaction-list.php | 4 ++-- TransactionReporting/get-unsettled-transaction-list.php | 4 ++-- 35 files changed, 92 insertions(+), 66 deletions(-) diff --git a/ApplePayTransactions/create-an-apple-pay-transaction.php b/ApplePayTransactions/create-an-apple-pay-transaction.php index 6c8d93f..b01dbcd 100644 --- a/ApplePayTransactions/create-an-apple-pay-transaction.php +++ b/ApplePayTransactions/create-an-apple-pay-transaction.php @@ -44,7 +44,8 @@ function createAnApplePayTransaction(){ else { echo "ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } } else diff --git a/CustomerProfiles/create-customer-profile-from-transaction.php b/CustomerProfiles/create-customer-profile-from-transaction.php index 565f38e..f7232fd 100644 --- a/CustomerProfiles/create-customer-profile-from-transaction.php +++ b/CustomerProfiles/create-customer-profile-from-transaction.php @@ -37,7 +37,8 @@ function createCustomerProfileFromTransaction($transId= \SampleCode\Constants::T else { echo "ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } return $response; } diff --git a/CustomerProfiles/create-customer-profile.php b/CustomerProfiles/create-customer-profile.php index 1f27640..1d7740f 100644 --- a/CustomerProfiles/create-customer-profile.php +++ b/CustomerProfiles/create-customer-profile.php @@ -64,8 +64,8 @@ function createCustomerProfile($email){ else { echo "ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; - + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } return $response; } diff --git a/CustomerProfiles/create-customer-shipping-address.php b/CustomerProfiles/create-customer-shipping-address.php index 9aa8757..51151dd 100644 --- a/CustomerProfiles/create-customer-shipping-address.php +++ b/CustomerProfiles/create-customer-shipping-address.php @@ -43,7 +43,8 @@ function createCustomerShippingAddress($existingcustomerprofileid = \SampleCode\ else { echo "Create Customer Shipping Address ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } return $response; } diff --git a/CustomerProfiles/delete-customer-payment-profile.php b/CustomerProfiles/delete-customer-payment-profile.php index 864c545..23238bd 100644 --- a/CustomerProfiles/delete-customer-payment-profile.php +++ b/CustomerProfiles/delete-customer-payment-profile.php @@ -28,7 +28,8 @@ function deleteCustomerPaymentProfile($customerProfileId= \SampleCode\Constants: else { echo "ERROR : Delete Customer Payment Profile: Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } return $response; } diff --git a/CustomerProfiles/delete-customer-profile.php b/CustomerProfiles/delete-customer-profile.php index 819b3d5..b253064 100644 --- a/CustomerProfiles/delete-customer-profile.php +++ b/CustomerProfiles/delete-customer-profile.php @@ -27,8 +27,8 @@ function deleteCustomerProfile($customerProfileId) else { echo "ERROR : DeleteCustomerProfile: Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; - + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } return $response; diff --git a/CustomerProfiles/delete-customer-shipping-address.php b/CustomerProfiles/delete-customer-shipping-address.php index 0163f75..127bfa1 100644 --- a/CustomerProfiles/delete-customer-shipping-address.php +++ b/CustomerProfiles/delete-customer-shipping-address.php @@ -29,7 +29,8 @@ function deleteCustomerShippingAddress($customerprofileid = \SampleCode\Constant else { echo "Delete Customer Shipping Address ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } return $response; } diff --git a/CustomerProfiles/get-customer-payment-profile-list.php b/CustomerProfiles/get-customer-payment-profile-list.php index a069cbb..1e337e9 100644 --- a/CustomerProfiles/get-customer-payment-profile-list.php +++ b/CustomerProfiles/get-customer-payment-profile-list.php @@ -44,8 +44,8 @@ function getCustomerPaymentProfileList() { // Success echo "GetCustomerPaymentProfileList SUCCESS: " . "\n"; - echo "Message Code: " . $response->getMessages()->getMessage()[0]->getCode() . "\n"; - echo "Message Text: " . $response->getMessages()->getMessage()[0]->getText() . "\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 ) @@ -61,7 +61,8 @@ function getCustomerPaymentProfileList() { // Error echo "GetCustomerPaymentProfileList ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } } else diff --git a/CustomerProfiles/get-customer-payment-profile.php b/CustomerProfiles/get-customer-payment-profile.php index 5046131..0bee43d 100644 --- a/CustomerProfiles/get-customer-payment-profile.php +++ b/CustomerProfiles/get-customer-payment-profile.php @@ -48,7 +48,8 @@ function getCustomerPaymentProfile($customerProfileId=\SampleCode\Constants::CUS else { echo "GetCustomerPaymentProfile ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } } else{ diff --git a/CustomerProfiles/get-customer-profile-ids.php b/CustomerProfiles/get-customer-profile-ids.php index 646f12f..d1ac23d 100644 --- a/CustomerProfiles/get-customer-profile-ids.php +++ b/CustomerProfiles/get-customer-profile-ids.php @@ -27,7 +27,8 @@ function getCustomerProfileIds() else { echo "GetCustomerProfileId's ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } return $response; } diff --git a/CustomerProfiles/get-customer-profile.php b/CustomerProfiles/get-customer-profile.php index a3684bb..ef6cff9 100644 --- a/CustomerProfiles/get-customer-profile.php +++ b/CustomerProfiles/get-customer-profile.php @@ -65,7 +65,8 @@ function getCustomerProfile(){ else { echo "ERROR : CreateCustomerProfile: Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } // Retrieve an existing customer profile along with all the associated payment profiles and shipping addresses @@ -96,7 +97,8 @@ function getCustomerProfile(){ else { echo "ERROR : GetCustomerProfile: Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } return $response; } diff --git a/CustomerProfiles/get-customer-shipping-address.php b/CustomerProfiles/get-customer-shipping-address.php index ff93ff4..184e86b 100644 --- a/CustomerProfiles/get-customer-shipping-address.php +++ b/CustomerProfiles/get-customer-shipping-address.php @@ -55,7 +55,8 @@ function getCustomerShippingAddress($customerprofileid, $customeraddressid) else { echo "Get Customer Shipping Address ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } return $response; } diff --git a/CustomerProfiles/get-hosted-profile-page.php b/CustomerProfiles/get-hosted-profile-page.php index f1b5d69..b572370 100644 --- a/CustomerProfiles/get-hosted-profile-page.php +++ b/CustomerProfiles/get-hosted-profile-page.php @@ -31,15 +31,13 @@ function getHostedProfilePage($customerprofileid = \SampleCode\Constants::CUSTOM if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) { - echo $response->getMessages()->getMessage()[0]->getCode()."\n"; - echo $response->getMessages()->getMessage()[0]->getText()."\n"; - echo $response->getToken()."\n"; } else { echo "ERROR : Failed to get hosted profile page\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } return $response; } diff --git a/CustomerProfiles/update-customer-payment-profile.php b/CustomerProfiles/update-customer-payment-profile.php index 02d3fae..b497807 100644 --- a/CustomerProfiles/update-customer-payment-profile.php +++ b/CustomerProfiles/update-customer-payment-profile.php @@ -78,7 +78,8 @@ function updateCustomerPaymentProfile($customerProfileId= \SampleCode\Constants: else { echo "GetCustomerPaymentProfile ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } } else{ @@ -89,7 +90,8 @@ function updateCustomerPaymentProfile($customerProfileId= \SampleCode\Constants: else { echo "Update Customer Payment Profile: ERROR Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } return $response; } diff --git a/CustomerProfiles/update-customer-profile.php b/CustomerProfiles/update-customer-profile.php index f8e90a7..87e61ac 100644 --- a/CustomerProfiles/update-customer-profile.php +++ b/CustomerProfiles/update-customer-profile.php @@ -97,13 +97,15 @@ function updateCustomerProfile() { else { echo "ERROR : GetCustomerProfile: Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } } else { echo "ERROR : UpdateCustomerProfile: Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } return $response; } diff --git a/CustomerProfiles/update-customer-shipping-address.php b/CustomerProfiles/update-customer-shipping-address.php index f801bd9..ea8295e 100644 --- a/CustomerProfiles/update-customer-shipping-address.php +++ b/CustomerProfiles/update-customer-shipping-address.php @@ -43,7 +43,8 @@ function updateCustomerShippingAddress($customerprofileid, $customeraddressid) else { echo "Update Customer Shipping Address ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } return $response; } diff --git a/CustomerProfiles/validate-customer-payment-profile.php b/CustomerProfiles/validate-customer-payment-profile.php index 16539fc..33288cb 100644 --- a/CustomerProfiles/validate-customer-payment-profile.php +++ b/CustomerProfiles/validate-customer-payment-profile.php @@ -29,12 +29,14 @@ function validateCustomerPaymentProfile($customerProfileId= \SampleCode\Constant if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) { - echo $response->getMessages()->getMessage()[0]->getText(); + $validationMessages = $response->getMessages()->getMessage(); + echo "Response : " . $validationMessages[0]->getCode() . " " .$validationMessages[0]->getText() . "\n"; } else { echo "ERROR : Validate Customer Payment Profile: Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } return $response; } diff --git a/PaymentTransactions/capture-funds-authorized-through-another-channel.php b/PaymentTransactions/capture-funds-authorized-through-another-channel.php index 4b0b668..ee857f2 100644 --- a/PaymentTransactions/capture-funds-authorized-through-another-channel.php +++ b/PaymentTransactions/capture-funds-authorized-through-another-channel.php @@ -46,7 +46,9 @@ function captureFundsAuthorizedThroughAnotherChannel($amount){ else { echo "Capture funds authorized through another channel ERROR: Invalid response\n"; - echo "Response Code: " . $response->getMessages()->getMessage()[0]->getCode() . " Response Text: " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; + } } } else diff --git a/PaymentTransactions/refund-transaction.php b/PaymentTransactions/refund-transaction.php index dc27c20..b30380b 100644 --- a/PaymentTransactions/refund-transaction.php +++ b/PaymentTransactions/refund-transaction.php @@ -14,8 +14,8 @@ function refundTransaction($amount){ // Create the payment data for a credit card $creditCard = new AnetAPI\CreditCardType(); - $creditCard->setCardNumber( \SampleCode\Constants::CREDIT_CARD_NUMBER ); - $creditCard->setExpirationDate( \SampleCode\Constants::EXPIRY_DATE); + $creditCard->setCardNumber("0015"); + $creditCard->setExpirationDate("XXXX"); $paymentOne = new AnetAPI\PaymentType(); $paymentOne->setCreditCard($creditCard); //create a transaction @@ -23,9 +23,7 @@ function refundTransaction($amount){ $transactionRequest->setTransactionType( "refundTransaction"); $transactionRequest->setAmount($amount); $transactionRequest->setPayment($paymentOne); - $customer = new AnetAPI\CustomerDataType(); - $customer->setId("CUST001"); - $transactionRequest->setCustomer($customer); + $request = new AnetAPI\CreateTransactionRequest(); $request->setMerchantAuthentication($merchantAuthentication); diff --git a/PaymentTransactions/update-split-tender-group.php b/PaymentTransactions/update-split-tender-group.php index 194717f..338ac09 100644 --- a/PaymentTransactions/update-split-tender-group.php +++ b/PaymentTransactions/update-split-tender-group.php @@ -23,13 +23,15 @@ function updateSplitTenderGroup(){ $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) - { - echo "SUCCESS : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + { + $errorMessages = $response->getMessages()->getMessage(); + echo "SUCCESS Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } else { echo "ERROR : Invalid response\n"; - echo "Response Code : " . $response->getMessages()->getMessage()[0]->getCode() . " Resposne text: " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } return $response; } diff --git a/PaymentTransactions/void-transaction.php b/PaymentTransactions/void-transaction.php index 97a961c..e4e9405 100644 --- a/PaymentTransactions/void-transaction.php +++ b/PaymentTransactions/void-transaction.php @@ -41,8 +41,9 @@ function voidTransaction($transactionid){ else { echo "void transaction ERROR : " . $tresponse->getResponseCode() . "\n"; - echo "Response Code : " . $response->getMessages()->getMessage()[0]->getCode() . " Resposne text: " .$response->getMessages()->getMessage()[0]->getText() . "\n"; - //use print_r to see whole $response which will have the specific error messages + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; + //use print_r to see whole $response which will have the specific error messages } } else diff --git a/PaypalExpressCheckout/authorization-and-capture-continue.php b/PaypalExpressCheckout/authorization-and-capture-continue.php index 781b092..ade134b 100644 --- a/PaypalExpressCheckout/authorization-and-capture-continue.php +++ b/PaypalExpressCheckout/authorization-and-capture-continue.php @@ -48,9 +48,8 @@ function payPalAuthorizeCaptureContinue($refTransId, $payerID) { { echo "Messages...\n"; echo "Result code: ".$messages->getResultCode()."\n"; - $message0=$messages->getMessage()[0]; - if($message0!=null) - echo "Message: ".$message0->getCode().", ".$message0->getText()."\n"; + $errorMessages = $messages->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } else echo "NULL messages Error\n"; diff --git a/PaypalExpressCheckout/get-details.php b/PaypalExpressCheckout/get-details.php index 4d64edc..199d2b6 100644 --- a/PaypalExpressCheckout/get-details.php +++ b/PaypalExpressCheckout/get-details.php @@ -75,9 +75,8 @@ function payPalGetDetails($transactionId) { { echo "Messages...\n"; echo "Result code: ".$messages->getResultCode()."\n"; - $message0=$messages->getMessage()[0]; - if($message0!=null) - echo "Message: ".$message0->getCode().", ".$message0->getText()."\n"; + $errorMessages = $messages->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } else echo "NULL messages Error\n"; diff --git a/RecurringBilling/cancel-subscription.php b/RecurringBilling/cancel-subscription.php index 8ba6ac8..cb7205b 100644 --- a/RecurringBilling/cancel-subscription.php +++ b/RecurringBilling/cancel-subscription.php @@ -24,12 +24,15 @@ function cancelSubscription($subscriptionId) { if (($response != null) && ($response->getMessages()->getResultCode() == "Ok")) { - echo "SUCCESS" . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + $successMessages = $response->getMessages()->getMessage(); + echo "SUCCESS : " . $successMessages[0]->getCode() . " " .$successMessages[0]->getText() . "\n"; + } else { echo "ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } diff --git a/RecurringBilling/create-subscription-from-customer-profile.php b/RecurringBilling/create-subscription-from-customer-profile.php index f2d6cba..33c7419 100644 --- a/RecurringBilling/create-subscription-from-customer-profile.php +++ b/RecurringBilling/create-subscription-from-customer-profile.php @@ -55,7 +55,8 @@ function createSubscriptionFromCustomerProfile($intervalLength, $customerProfile else { echo "ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } return $response; diff --git a/RecurringBilling/create-subscription.php b/RecurringBilling/create-subscription.php index 0bc3845..bca64d0 100644 --- a/RecurringBilling/create-subscription.php +++ b/RecurringBilling/create-subscription.php @@ -63,7 +63,8 @@ function createSubscription($intervalLength) { else { echo "ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } return $response; diff --git a/RecurringBilling/get-list-of-subscriptions.php b/RecurringBilling/get-list-of-subscriptions.php index 58cad5c..74fdab8 100644 --- a/RecurringBilling/get-list-of-subscriptions.php +++ b/RecurringBilling/get-list-of-subscriptions.php @@ -42,8 +42,8 @@ function getListOfSubscriptions() { else { echo "ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; - + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } return $response; diff --git a/RecurringBilling/get-subscription-status.php b/RecurringBilling/get-subscription-status.php index 2506f0b..1b71589 100644 --- a/RecurringBilling/get-subscription-status.php +++ b/RecurringBilling/get-subscription-status.php @@ -30,8 +30,8 @@ function getSubscriptionStatus($subscriptionId) { else { echo "ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; - + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } return $response; diff --git a/RecurringBilling/get-subscription.php b/RecurringBilling/get-subscription.php index ef2cb2b..be43d20 100644 --- a/RecurringBilling/get-subscription.php +++ b/RecurringBilling/get-subscription.php @@ -44,8 +44,8 @@ function getSubscription($subscriptionId) { { // Error echo "ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; - + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } } else diff --git a/RecurringBilling/update-subscription.php b/RecurringBilling/update-subscription.php index 270670e..cd58a43 100644 --- a/RecurringBilling/update-subscription.php +++ b/RecurringBilling/update-subscription.php @@ -46,12 +46,15 @@ function updateSubscription($subscriptionId) { if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) { - echo "SUCCESS, Response Code: " . $response->getMessages()->getMessage()[0]->getCode() . " Response Text: " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "SUCCESS Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; + } else { echo "ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } return $response; diff --git a/TransactionReporting/get-batch-statistics.php b/TransactionReporting/get-batch-statistics.php index 7bbc1dc..a5cf7b0 100644 --- a/TransactionReporting/get-batch-statistics.php +++ b/TransactionReporting/get-batch-statistics.php @@ -51,8 +51,8 @@ function getBatchStatistics() { else { echo "ERROR : Failed to get the batch statistics\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; - + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } return $response; diff --git a/TransactionReporting/get-settled-batch-list.php b/TransactionReporting/get-settled-batch-list.php index 93f5939..150512b 100644 --- a/TransactionReporting/get-settled-batch-list.php +++ b/TransactionReporting/get-settled-batch-list.php @@ -59,7 +59,8 @@ function getSettledBatchList() { else { echo "ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } return $response; diff --git a/TransactionReporting/get-transaction-details.php b/TransactionReporting/get-transaction-details.php index 554d62c..1ed8ede 100644 --- a/TransactionReporting/get-transaction-details.php +++ b/TransactionReporting/get-transaction-details.php @@ -31,8 +31,8 @@ function getTransactionDetails($transactionId) { else { echo "ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; - + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } return $response; diff --git a/TransactionReporting/get-transaction-list.php b/TransactionReporting/get-transaction-list.php index 0b63a5a..db83004 100644 --- a/TransactionReporting/get-transaction-list.php +++ b/TransactionReporting/get-transaction-list.php @@ -42,8 +42,8 @@ function getTransactionList() { else { echo "ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; - + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } return $response; diff --git a/TransactionReporting/get-unsettled-transaction-list.php b/TransactionReporting/get-unsettled-transaction-list.php index 848fbd1..4301421 100644 --- a/TransactionReporting/get-unsettled-transaction-list.php +++ b/TransactionReporting/get-unsettled-transaction-list.php @@ -33,8 +33,8 @@ function getUnsettledTransactionList() { else { echo "ERROR : Invalid response\n"; - echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; - + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } return $response; From b7169cde747166ba797f5831bf8743355e8aac29 Mon Sep 17 00:00:00 2001 From: brianmc Date: Thu, 21 Apr 2016 15:50:55 -0700 Subject: [PATCH 068/287] Removed all the 5.4 dependencies --- CustomerProfiles/create-customer-profile.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CustomerProfiles/create-customer-profile.php b/CustomerProfiles/create-customer-profile.php index 1d7740f..9f54d8b 100644 --- a/CustomerProfiles/create-customer-profile.php +++ b/CustomerProfiles/create-customer-profile.php @@ -59,7 +59,8 @@ function createCustomerProfile($email){ if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) { echo "Succesfully create customer profile : " . $response->getCustomerProfileId() . "\n"; - echo "SUCCESS: PAYMENT PROFILE ID : " . $response->getCustomerPaymentProfileIdList()[0] . "\n"; + $paymentProfiles = $response->getCustomerPaymentProfileIdList(); + echo "SUCCESS: PAYMENT PROFILE ID : " . $paymentProfiles[0] . "\n"; } else { From e3ac5be90b334e20c9b71d972a024f784b6c735d Mon Sep 17 00:00:00 2001 From: brianmc Date: Thu, 21 Apr 2016 16:01:21 -0700 Subject: [PATCH 069/287] Extra bracket --- .../capture-funds-authorized-through-another-channel.php | 1 - 1 file changed, 1 deletion(-) diff --git a/PaymentTransactions/capture-funds-authorized-through-another-channel.php b/PaymentTransactions/capture-funds-authorized-through-another-channel.php index ee857f2..0062e0b 100644 --- a/PaymentTransactions/capture-funds-authorized-through-another-channel.php +++ b/PaymentTransactions/capture-funds-authorized-through-another-channel.php @@ -48,7 +48,6 @@ function captureFundsAuthorizedThroughAnotherChannel($amount){ echo "Capture funds authorized through another channel ERROR: Invalid response\n"; $errorMessages = $response->getMessages()->getMessage(); echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; - } } } else From cafc3faf508b92f2fd17d22487abc30e9e60bf13 Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Thu, 21 Apr 2016 16:02:54 -0700 Subject: [PATCH 070/287] Update .travis.yml --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index ada058f..a335fce 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: php php: + - 5.3 - 5.6 - 7.0 From 8aecec86988d098d2b090237b9b81f44eaeba42b Mon Sep 17 00:00:00 2001 From: brianmc Date: Thu, 21 Apr 2016 16:22:25 -0700 Subject: [PATCH 071/287] 5.4 feature --- CustomerProfiles/get-customer-payment-profile.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CustomerProfiles/get-customer-payment-profile.php b/CustomerProfiles/get-customer-payment-profile.php index 0bee43d..7323653 100644 --- a/CustomerProfiles/get-customer-payment-profile.php +++ b/CustomerProfiles/get-customer-payment-profile.php @@ -35,8 +35,7 @@ function getCustomerPaymentProfile($customerProfileId=\SampleCode\Constants::CUS if($response->getPaymentProfile()->getSubscriptionIds() != null) { - if(($response->getPaymentProfile()->getSubscriptionIds() != null) && - (!empty($response->getPaymentProfile()->getSubscriptionIds()))) + if($response->getPaymentProfile()->getSubscriptionIds() != null) { echo "List of subscriptions:"; From e86fc6fa51e27fbf7f16672cdaf40711b849d908 Mon Sep 17 00:00:00 2001 From: brianmc Date: Thu, 21 Apr 2016 16:48:45 -0700 Subject: [PATCH 072/287] 5.4 feature --- CustomerProfiles/get-customer-profile.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CustomerProfiles/get-customer-profile.php b/CustomerProfiles/get-customer-profile.php index ef6cff9..6af433a 100644 --- a/CustomerProfiles/get-customer-profile.php +++ b/CustomerProfiles/get-customer-profile.php @@ -84,8 +84,7 @@ function getCustomerProfile(){ if($response->getSubscriptionIds() != null) { - if(($response->getSubscriptionIds() != null) && - (!empty($response->getSubscriptionIds()))) + if($response->getSubscriptionIds() != null) { echo "List of subscriptions:"; From bf1c3d9ac727d482c200af3c3af0cb76fc33a6e5 Mon Sep 17 00:00:00 2001 From: brianmc Date: Thu, 21 Apr 2016 16:52:59 -0700 Subject: [PATCH 073/287] 5.4 feature --- CustomerProfiles/get-customer-shipping-address.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CustomerProfiles/get-customer-shipping-address.php b/CustomerProfiles/get-customer-shipping-address.php index 184e86b..9abeff5 100644 --- a/CustomerProfiles/get-customer-shipping-address.php +++ b/CustomerProfiles/get-customer-shipping-address.php @@ -42,8 +42,7 @@ function getCustomerShippingAddress($customerprofileid, $customeraddressid) if($response->getSubscriptionIds() != null) { - if(($response->getSubscriptionIds() != null) && - (!empty($response->getSubscriptionIds()))) + if($response->getSubscriptionIds() != null) { echo "List of subscriptions:"; From 2e2acc630fccf08b21aac1ddf72e7df18561f290 Mon Sep 17 00:00:00 2001 From: brianmc Date: Thu, 21 Apr 2016 17:02:51 -0700 Subject: [PATCH 074/287] 5.4 feature --- PaymentTransactions/debit-bank-account.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PaymentTransactions/debit-bank-account.php b/PaymentTransactions/debit-bank-account.php index a9cc38a..85a9caf 100644 --- a/PaymentTransactions/debit-bank-account.php +++ b/PaymentTransactions/debit-bank-account.php @@ -50,7 +50,8 @@ function debitBankAccount($amount){ elseif (($tresponse != null) && ($tresponse->getResponseCode()=="2") ) { echo "Debit Bank Account ERROR : DECLINED" . "\n"; - echo "Error : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; + $errorMessages = $tresponse->getErrors(); + echo "Error : " . $errorMessages[0]->getErrorText() . "\n"; } elseif (($tresponse != null) && ($tresponse->getResponseCode()=="4") ) { From f1deb99f11c529517c9161cfdde736fb975bb33d Mon Sep 17 00:00:00 2001 From: brianmc Date: Wed, 4 May 2016 09:32:06 -0700 Subject: [PATCH 075/287] PaymentTransactions/charge-credit-card.php --- PaymentTransactions/charge-credit-card.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/PaymentTransactions/charge-credit-card.php b/PaymentTransactions/charge-credit-card.php index 0076fd5..759c3f0 100644 --- a/PaymentTransactions/charge-credit-card.php +++ b/PaymentTransactions/charge-credit-card.php @@ -20,11 +20,16 @@ function chargeCreditCard($amount){ $paymentOne = new AnetAPI\PaymentType(); $paymentOne->setCreditCard($creditCard); + $order = new AnetAPI\OrderType(); + $order->setDescription("New Item"); + //create a transaction $transactionRequestType = new AnetAPI\TransactionRequestType(); $transactionRequestType->setTransactionType( "authCaptureTransaction"); $transactionRequestType->setAmount($amount); + $transactionRequestType->setOrder($order); $transactionRequestType->setPayment($paymentOne); + $request = new AnetAPI\CreateTransactionRequest(); $request->setMerchantAuthentication($merchantAuthentication); From 6934626467b98d3a270f36d1e38e9444d8b22b13 Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Fri, 27 May 2016 08:17:53 -0700 Subject: [PATCH 076/287] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 53c8cb9..269c7a6 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ }, "require-dev": { "phpunit/phpunit": "~4.0", - "goetas/xsd2php": "2.*@dev", + "goetas/xsd2php": "2.0.x-dev#fdc2ab0bb3f2b3ab796ca567cf8c0f3446a7ea3a", "goetas/xsd-reader": "2.*@dev" }, "repositories": [{ From f200c59161ef794275f87b0baceb80d789be13d9 Mon Sep 17 00:00:00 2001 From: Ashish Kankaria Date: Thu, 2 Jun 2016 11:53:28 +0530 Subject: [PATCH 077/287] Adding build status widget --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index f171dca..a625e61 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ # Sample PHP Code for Authorize.Net +[![Build Status](https://travis-ci.org/AuthorizeNet/sample-code-php.png?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. The samples are organized just like our API, which you can also try out directly here: http://developer.authorize.net/api/reference From 7e7954f203027a01fbc3f35ad7597140a537e611 Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Wed, 15 Jun 2016 08:17:16 -0700 Subject: [PATCH 078/287] Update composer.json --- composer.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 269c7a6..642f683 100644 --- a/composer.json +++ b/composer.json @@ -2,13 +2,13 @@ "require": { "php": ">=5.2.0", "ext-curl": "*", - "authorizenet/authorizenet": "1.8.8", - "jms/serializer": "xsd2php-dev as 0.18.0" + "authorizenet/authorizenet": "1.8.9", + "jms/serializer": "serializer-master-dev as 1.0" }, "require-dev": { "phpunit/phpunit": "~4.0", - "goetas/xsd2php": "2.0.x-dev#fdc2ab0bb3f2b3ab796ca567cf8c0f3446a7ea3a", - "goetas/xsd-reader": "2.*@dev" + "goetas-webservices/xsd2php-runtime":"^0.2", + "goetas-webservices/xsd-reader": "^0.1", }, "repositories": [{ "type": "vcs", From f4a555361a2ccd5d432f6bd9d32f8974d864967f Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Wed, 15 Jun 2016 08:23:44 -0700 Subject: [PATCH 079/287] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 642f683..2cf7d6a 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ "require-dev": { "phpunit/phpunit": "~4.0", "goetas-webservices/xsd2php-runtime":"^0.2", - "goetas-webservices/xsd-reader": "^0.1", + "goetas-webservices/xsd-reader": "^0.1" }, "repositories": [{ "type": "vcs", From 7f7fa55de5944da34939b9d9fc7fb677079d0af2 Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Wed, 15 Jun 2016 08:29:35 -0700 Subject: [PATCH 080/287] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 2cf7d6a..222c579 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "require": { - "php": ">=5.2.0", + "php": ">=5.5", "ext-curl": "*", "authorizenet/authorizenet": "1.8.9", "jms/serializer": "serializer-master-dev as 1.0" From b0c97175a3b9a4b7202e44fa4d5c0ac2ad8bb39e Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Wed, 15 Jun 2016 08:29:58 -0700 Subject: [PATCH 081/287] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a335fce..f47fce1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: php php: - - 5.3 + - 5.5 - 5.6 - 7.0 From 94527d2e41c86e2eb7f601e59d7d80e3b6b68456 Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Wed, 15 Jun 2016 09:53:54 -0700 Subject: [PATCH 082/287] Update composer.json --- composer.json | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/composer.json b/composer.json index 222c579..8157d27 100644 --- a/composer.json +++ b/composer.json @@ -2,18 +2,8 @@ "require": { "php": ">=5.5", "ext-curl": "*", - "authorizenet/authorizenet": "1.8.9", - "jms/serializer": "serializer-master-dev as 1.0" + "authorizenet/authorizenet": "1.8.9" }, - "require-dev": { - "phpunit/phpunit": "~4.0", - "goetas-webservices/xsd2php-runtime":"^0.2", - "goetas-webservices/xsd-reader": "^0.1" - }, - "repositories": [{ - "type": "vcs", - "url": "https://github.com/goetas/serializer.git" - }], "autoload": { "classmap": ["constants"] } From 6219926e3bd6ae066d31645ba4e1bf4f1e919f48 Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Wed, 15 Jun 2016 09:56:45 -0700 Subject: [PATCH 083/287] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index f171dca..ab5b792 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +[![Travis](https://img.shields.io/travis/AuthorizeNet/sample-code-php/master.svg)] +(https://travis-ci.org/AuthorizeNet/sample-code-php) + # Sample PHP Code for Authorize.Net This repository contains working code samples which demonstrate PHP integration with the Authorize.Net PHP SDK. From 12ad486881a7d67287a776f421f7418cb3802b89 Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Wed, 15 Jun 2016 10:05:02 -0700 Subject: [PATCH 084/287] Update composer.json --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 8157d27..f505f8b 100644 --- a/composer.json +++ b/composer.json @@ -4,6 +4,7 @@ "ext-curl": "*", "authorizenet/authorizenet": "1.8.9" }, + "minimum-stability": "dev", "autoload": { "classmap": ["constants"] } From a86dd3fa92a75d8b7e7e46ad9fac368edfa1a894 Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Wed, 15 Jun 2016 10:25:29 -0700 Subject: [PATCH 085/287] Update composer.json --- composer.json | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index f505f8b..5b8e535 100644 --- a/composer.json +++ b/composer.json @@ -2,9 +2,13 @@ "require": { "php": ">=5.5", "ext-curl": "*", - "authorizenet/authorizenet": "1.8.9" + "authorizenet/authorizenet": "1.8.9", + "jms/serializer": "serializer-master-dev as 1.0" }, - "minimum-stability": "dev", + "repositories": [{ + "type": "vcs", + "url": "https://github.com/goetas/serializer.git" + }], "autoload": { "classmap": ["constants"] } From f4bda7e6f3574b3323359595172f8352dddf752c Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Mon, 20 Jun 2016 22:29:51 -0700 Subject: [PATCH 086/287] Update composer.json --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 5b8e535..4a259cb 100644 --- a/composer.json +++ b/composer.json @@ -2,6 +2,7 @@ "require": { "php": ">=5.5", "ext-curl": "*", + "phpunit/phpunit": "~4.0", "authorizenet/authorizenet": "1.8.9", "jms/serializer": "serializer-master-dev as 1.0" }, From 540f33c38c2676e4d4f6a9999748e3e985784318 Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Wed, 29 Jun 2016 11:30:04 +0530 Subject: [PATCH 087/287] Update README.md --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index ecd1920..a625e61 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,3 @@ -[![Travis](https://img.shields.io/travis/AuthorizeNet/sample-code-php/master.svg)] -(https://travis-ci.org/AuthorizeNet/sample-code-php) - # Sample PHP Code for Authorize.Net [![Build Status](https://travis-ci.org/AuthorizeNet/sample-code-php.png?branch=master)] (https://travis-ci.org/AuthorizeNet/sample-code-php) From 322c97b7c405e4994247c2249be4d656eece8b96 Mon Sep 17 00:00:00 2001 From: srathod Date: Wed, 29 Jun 2016 12:28:47 +0530 Subject: [PATCH 088/287] - Patched patch 1 from ashtru's Constants removal. --- .../create-customer-payment-profile.php | 8 +-- ...eate-customer-profile-from-transaction.php | 4 +- CustomerProfiles/create-customer-profile.php | 6 +- .../create-customer-shipping-address.php | 4 +- .../delete-customer-payment-profile.php | 4 +- CustomerProfiles/delete-customer-profile.php | 2 +- .../delete-customer-shipping-address.php | 3 +- .../get-customer-payment-profile.php | 4 +- .../get-customer-shipping-address.php | 3 +- CustomerProfiles/get-hosted-profile-page.php | 2 +- .../update-customer-payment-profile.php | 4 +- .../update-customer-shipping-address.php | 3 +- .../validate-customer-payment-profile.php | 4 +- ...nds-authorized-through-another-channel.php | 8 +-- .../capture-previously-authorized-amount.php | 2 +- .../charge-customer-profile.php | 3 +- .../charge-tokenized-credit-card.php | 8 +-- PaymentTransactions/credit-bank-account.php | 12 ++-- PaymentTransactions/debit-bank-account.php | 10 ++-- .../update-split-tender-group.php | 2 +- PaymentTransactions/void-transaction.php | 6 +- constants/Constants.php | 56 +++++++++---------- 22 files changed, 77 insertions(+), 81 deletions(-) diff --git a/CustomerProfiles/create-customer-payment-profile.php b/CustomerProfiles/create-customer-payment-profile.php index 83c5d0d..da6f78c 100644 --- a/CustomerProfiles/create-customer-payment-profile.php +++ b/CustomerProfiles/create-customer-payment-profile.php @@ -13,9 +13,9 @@ function createCustomerPaymentProfile($existingcustomerprofileid, $phoneNumber){ $refId = 'ref' . time(); $creditCard = new AnetAPI\CreditCardType(); - $creditCard->setCardNumber( \SampleCode\Constants::CREDIT_CARD_NUMBER_2); - $creditCard->setExpirationDate( \SampleCode\Constants::EXPIRY_DATE); - $creditCard->setCardCode( \SampleCode\Constants::CVV); + $creditCard->setCardNumber( "4242424242424242"); + $creditCard->setExpirationDate( "2038-12"); + $creditCard->setCardCode( "142"); $paymentCreditCard = new AnetAPI\PaymentType(); $paymentCreditCard->setCreditCard($creditCard); @@ -63,5 +63,5 @@ function createCustomerPaymentProfile($existingcustomerprofileid, $phoneNumber){ return $response; } if(!defined('DONT_RUN_SAMPLES')) - createCustomerPaymentProfile(\SampleCode\Constants::CUSTOMER_PROFILE_ID,"000-000-0009"); + createCustomerPaymentProfile("36152127","000-000-0009"); ?> diff --git a/CustomerProfiles/create-customer-profile-from-transaction.php b/CustomerProfiles/create-customer-profile-from-transaction.php index f7232fd..86683e6 100644 --- a/CustomerProfiles/create-customer-profile-from-transaction.php +++ b/CustomerProfiles/create-customer-profile-from-transaction.php @@ -5,7 +5,7 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function createCustomerProfileFromTransaction($transId= \SampleCode\Constants::TRANS_ID_TO_CREATE_CUSTOMER_PROFILE) + function createCustomerProfileFromTransaction($transId= "2249066517") { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); @@ -44,5 +44,5 @@ function createCustomerProfileFromTransaction($transId= \SampleCode\Constants::T } //provide a transaction that has customer information if(!defined('DONT_RUN_SAMPLES')) - createCustomerProfileFromTransaction(\SampleCode\Constants::TRANS_ID_TO_CREATE_CUSTOMER_PROFILE); + createCustomerProfileFromTransaction("2249066517"); ?> diff --git a/CustomerProfiles/create-customer-profile.php b/CustomerProfiles/create-customer-profile.php index 9f54d8b..38d82d1 100644 --- a/CustomerProfiles/create-customer-profile.php +++ b/CustomerProfiles/create-customer-profile.php @@ -15,8 +15,8 @@ function createCustomerProfile($email){ // Create the payment data for a credit card $creditCard = new AnetAPI\CreditCardType(); - $creditCard->setCardNumber( \SampleCode\Constants::CREDIT_CARD_NUMBER); - $creditCard->setExpirationDate( \SampleCode\Constants::EXPIRY_DATE); + $creditCard->setCardNumber( "4111111111111111"); + $creditCard->setExpirationDate( "2038-12"); $paymentCreditCard = new AnetAPI\PaymentType(); $paymentCreditCard->setCreditCard($creditCard); @@ -71,5 +71,5 @@ function createCustomerProfile($email){ return $response; } if(!defined('DONT_RUN_SAMPLES')) - createCustomerProfile( \SampleCode\Constants::TEST_CUSTOMER_EMAIL); + createCustomerProfile("test123@test.com"); ?> diff --git a/CustomerProfiles/create-customer-shipping-address.php b/CustomerProfiles/create-customer-shipping-address.php index 51151dd..7ee5536 100644 --- a/CustomerProfiles/create-customer-shipping-address.php +++ b/CustomerProfiles/create-customer-shipping-address.php @@ -5,8 +5,8 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function createCustomerShippingAddress($existingcustomerprofileid = \SampleCode\Constants::CUSTOMER_PROFILE_ID, - $phoneNumber= \SampleCode\Constants::PHONE_NUMBER) + function createCustomerShippingAddress($existingcustomerprofileid = "36152127", + $phoneNumber="000-000-0000") { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); diff --git a/CustomerProfiles/delete-customer-payment-profile.php b/CustomerProfiles/delete-customer-payment-profile.php index 23238bd..8f9d309 100644 --- a/CustomerProfiles/delete-customer-payment-profile.php +++ b/CustomerProfiles/delete-customer-payment-profile.php @@ -5,8 +5,8 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function deleteCustomerPaymentProfile($customerProfileId= \SampleCode\Constants::CUSTOMER_PROFILE_ID, - $customerpaymentprofileid = \SampleCode\Constants::CUSTOMER_PAYMENT_PROFILE_ID) + function deleteCustomerPaymentProfile($customerProfileId= "36152127", + $customerpaymentprofileid = "32689274") { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); diff --git a/CustomerProfiles/delete-customer-profile.php b/CustomerProfiles/delete-customer-profile.php index b253064..ea33cc7 100644 --- a/CustomerProfiles/delete-customer-profile.php +++ b/CustomerProfiles/delete-customer-profile.php @@ -35,5 +35,5 @@ function deleteCustomerProfile($customerProfileId) } if(!defined('DONT_RUN_SAMPLES')) - deleteCustomerProfile( \SampleCode\Constants::CUSTOMER_PAYMENT_PROFILE_ID_DELETE); + deleteCustomerProfile("38958129"); ?> diff --git a/CustomerProfiles/delete-customer-shipping-address.php b/CustomerProfiles/delete-customer-shipping-address.php index 127bfa1..fedfac3 100644 --- a/CustomerProfiles/delete-customer-shipping-address.php +++ b/CustomerProfiles/delete-customer-shipping-address.php @@ -5,8 +5,7 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function deleteCustomerShippingAddress($customerprofileid = \SampleCode\Constants::CUSTOMER_PROFILE_ID_2, - $customeraddressid = "36976434") + function deleteCustomerShippingAddress($customerprofileid = "36731856", $customeraddressid = "36976434") { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); diff --git a/CustomerProfiles/get-customer-payment-profile.php b/CustomerProfiles/get-customer-payment-profile.php index 7323653..9279a1b 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=\SampleCode\Constants::CUSTOMER_PROFILE_ID_2, - $customerPaymentProfileId= \SampleCode\Constants::CUSTOMER_PAYMENT_PROFILE_ID_GET) +function getCustomerPaymentProfile($customerProfileId="36731856", + $customerPaymentProfileId= "33211899") { // Common setup for API credentials (merchant) $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); diff --git a/CustomerProfiles/get-customer-shipping-address.php b/CustomerProfiles/get-customer-shipping-address.php index 9abeff5..53b9b66 100644 --- a/CustomerProfiles/get-customer-shipping-address.php +++ b/CustomerProfiles/get-customer-shipping-address.php @@ -60,6 +60,5 @@ function getCustomerShippingAddress($customerprofileid, $customeraddressid) return $response; } if(!defined('DONT_RUN_SAMPLES')) - getCustomerShippingAddress(\SampleCode\Constants::CUSTOMER_PROFILE_ID, - \SampleCode\Constants::CUSTOMER_SHIPPING_ADDRESS_ID_GET); + getCustomerShippingAddress("36152127","36976566"); ?> diff --git a/CustomerProfiles/get-hosted-profile-page.php b/CustomerProfiles/get-hosted-profile-page.php index b572370..a846d31 100644 --- a/CustomerProfiles/get-hosted-profile-page.php +++ b/CustomerProfiles/get-hosted-profile-page.php @@ -5,7 +5,7 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function getHostedProfilePage($customerprofileid = \SampleCode\Constants::CUSTOMER_PROFILE_ID_HOSTED_PAGE) + function getHostedProfilePage($customerprofileid = "123212") { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); diff --git a/CustomerProfiles/update-customer-payment-profile.php b/CustomerProfiles/update-customer-payment-profile.php index b497807..ecf034f 100644 --- a/CustomerProfiles/update-customer-payment-profile.php +++ b/CustomerProfiles/update-customer-payment-profile.php @@ -5,8 +5,8 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function updateCustomerPaymentProfile($customerProfileId= \SampleCode\Constants::CUSTOMER_PROFILE_ID_2, - $customerPaymentProfileId= \SampleCode\Constants::CUSTOMER_PAYMENT_PROFILE_ID_GET) + function updateCustomerPaymentProfile($customerProfileId = "36731856", + $customerPaymentProfileId = "33211899") { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); diff --git a/CustomerProfiles/update-customer-shipping-address.php b/CustomerProfiles/update-customer-shipping-address.php index ea8295e..ea4b496 100644 --- a/CustomerProfiles/update-customer-shipping-address.php +++ b/CustomerProfiles/update-customer-shipping-address.php @@ -49,6 +49,5 @@ function updateCustomerShippingAddress($customerprofileid, $customeraddressid) return $response; } if(!defined('DONT_RUN_SAMPLES')) - updateCustomerShippingAddress( \SampleCode\Constants::CUSTOMER_PROFILE_ID, - \SampleCode\Constants::CUSTOMER_SHIPPING_ADDRESS_ID_GET); + updateCustomerShippingAddress( "36152127","36976566"); ?> diff --git a/CustomerProfiles/validate-customer-payment-profile.php b/CustomerProfiles/validate-customer-payment-profile.php index 33288cb..565d03a 100644 --- a/CustomerProfiles/validate-customer-payment-profile.php +++ b/CustomerProfiles/validate-customer-payment-profile.php @@ -5,8 +5,8 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function validateCustomerPaymentProfile($customerProfileId= \SampleCode\Constants::CUSTOMER_PROFILE_ID_2, - $customerPaymentProfileId= \SampleCode\Constants::CUSTOMER_PAYMENT_PROFILE_ID_GET) + function validateCustomerPaymentProfile($customerProfileId= "36731856", + $customerPaymentProfileId= "33211899") { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); diff --git a/PaymentTransactions/capture-funds-authorized-through-another-channel.php b/PaymentTransactions/capture-funds-authorized-through-another-channel.php index 0062e0b..5baf471 100644 --- a/PaymentTransactions/capture-funds-authorized-through-another-channel.php +++ b/PaymentTransactions/capture-funds-authorized-through-another-channel.php @@ -13,8 +13,8 @@ function captureFundsAuthorizedThroughAnotherChannel($amount){ $refId = 'ref' . time(); $creditCard = new AnetAPI\CreditCardType(); - $creditCard->setCardNumber( \SampleCode\Constants::CREDIT_CARD_NUMBER); - $creditCard->setExpirationDate( \SampleCode\Constants::EXPIRY_DATE); + $creditCard->setCardNumber("4111111111111111"); + $creditCard->setExpirationDate("2038-12"); $paymentOne = new AnetAPI\PaymentType(); $paymentOne->setCreditCard($creditCard); @@ -25,7 +25,7 @@ function captureFundsAuthorizedThroughAnotherChannel($amount){ $transactionRequestType->setPayment($paymentOne); //Auth code of the previously authorized amount - $transactionRequestType->setAuthCode(\SampleCode\Constants::SAMPLE_AUTH_CODE_AUTHORIZED); + $transactionRequestType->setAuthCode("ROHNFQ"); $request = new AnetAPI\CreateTransactionRequest(); @@ -57,5 +57,5 @@ function captureFundsAuthorizedThroughAnotherChannel($amount){ return $response; } if(!defined('DONT_RUN_SAMPLES')) - captureFundsAuthorizedThroughAnotherChannel((rand(1, \SampleCode\Constants::MAX_AMOUNT)/12*12)); + captureFundsAuthorizedThroughAnotherChannel((rand(1, 99999)/12*12)); ?> diff --git a/PaymentTransactions/capture-previously-authorized-amount.php b/PaymentTransactions/capture-previously-authorized-amount.php index 763f1c6..b3466d8 100644 --- a/PaymentTransactions/capture-previously-authorized-amount.php +++ b/PaymentTransactions/capture-previously-authorized-amount.php @@ -46,5 +46,5 @@ function capturePreviouslyAuthorizedAmount($transactionid){ return $response; } if(!defined('DONT_RUN_SAMPLES')) - capturePreviouslyAuthorizedAmount(\SampleCode\Constants::TRANS_ID_PREVIOUSLY_AUTHORIZED); + capturePreviouslyAuthorizedAmount(2249839471); ?> diff --git a/PaymentTransactions/charge-customer-profile.php b/PaymentTransactions/charge-customer-profile.php index 0cb8dfd..691dc80 100644 --- a/PaymentTransactions/charge-customer-profile.php +++ b/PaymentTransactions/charge-customer-profile.php @@ -55,6 +55,5 @@ function chargeCustomerProfile($profileid, $paymentprofileid, $amount){ return $response; } if(!defined('DONT_RUN_SAMPLES')) - chargeCustomerProfile(\SampleCode\Constants::CUSTOMER_PROFILE_ID, - \SampleCode\Constants::CUSTOMER_PAYMENT_PROFILE_ID, \SampleCode\Constants::SAMPLE_AMOUNT); + chargeCustomerProfile("36731856","32689274",12.23); ?> diff --git a/PaymentTransactions/charge-tokenized-credit-card.php b/PaymentTransactions/charge-tokenized-credit-card.php index cbb3a88..19537a1 100644 --- a/PaymentTransactions/charge-tokenized-credit-card.php +++ b/PaymentTransactions/charge-tokenized-credit-card.php @@ -14,10 +14,10 @@ function chargeTokenizedCreditCard($amount){ // Create the payment data for a credit card $creditCard = new AnetAPI\CreditCardType(); - $creditCard->setCardNumber( \SampleCode\Constants::CREDIT_CARD_NUMBER ); - $creditCard->setExpirationDate( \SampleCode\Constants::EXPIRY_DATE); + $creditCard->setCardNumber("4111111111111111" ); + $creditCard->setExpirationDate("2038-12"); //Set the cryptogram - $creditCard->setCryptogram( \SampleCode\Constants::CRYPTOGRAM); + $creditCard->setCryptogram("EjRWeJASNFZ4kBI0VniQEjRWeJA="); $paymentOne = new AnetAPI\PaymentType(); $paymentOne->setCreditCard($creditCard); @@ -56,5 +56,5 @@ function chargeTokenizedCreditCard($amount){ return $response; } if(!defined('DONT_RUN_SAMPLES')) - chargeTokenizedCreditCard( \SampleCode\Constants::SAMPLE_AMOUNT); + chargeTokenizedCreditCard(12.23); ?> diff --git a/PaymentTransactions/credit-bank-account.php b/PaymentTransactions/credit-bank-account.php index 69ce174..63d86e5 100644 --- a/PaymentTransactions/credit-bank-account.php +++ b/PaymentTransactions/credit-bank-account.php @@ -13,17 +13,17 @@ function creditBankAccount($amount){ $refId = 'ref' . time(); // Create the payment data for a Bank Account $bankAccount = new AnetAPI\BankAccountType(); - $bankAccount->setRoutingNumber(\SampleCode\Constants::ROUTING_NUMBER); - $bankAccount->setAccountNumber(\SampleCode\Constants::ACCOUNT_NUMBER); - $bankAccount->setNameOnAccount(\SampleCode\Constants::NAME_ON_ACCOUNT); + $bankAccount->setRoutingNumber('125000024'); + $bankAccount->setAccountNumber('12345678'); + $bankAccount->setNameOnAccount('Jane Doe'); $paymentBank= new AnetAPI\PaymentType(); $paymentBank->setBankAccount($bankAccount); // Order info $order = new AnetAPI\OrderType(); - $order->setInvoiceNumber(\SampleCode\Constants::INVOICE_NUMBER); - $order->setDescription(\SampleCode\Constants::ORDER_DESCRIPTION); + $order->setInvoiceNumber("101"); + $order->setDescription("Golf Shirts"); //create a debit card Bank transaction @@ -63,5 +63,5 @@ function creditBankAccount($amount){ return $response; } if(!defined('DONT_RUN_SAMPLES')) - creditBankAccount( \SampleCode\Constants::SAMPLE_AMOUNT); + creditBankAccount(12.23); ?> diff --git a/PaymentTransactions/debit-bank-account.php b/PaymentTransactions/debit-bank-account.php index 85a9caf..79ec013 100644 --- a/PaymentTransactions/debit-bank-account.php +++ b/PaymentTransactions/debit-bank-account.php @@ -16,10 +16,10 @@ function debitBankAccount($amount){ $bankAccount = new AnetAPI\BankAccountType(); //$bankAccount->setAccountType('CHECKING'); $bankAccount->setEcheckType('WEB'); - $bankAccount->setRoutingNumber(\SampleCode\Constants::DEBIT_ROUTING_NUMBER); - $bankAccount->setAccountNumber(\SampleCode\Constants::DEBIT_ACCOUNT_NUMBER); - $bankAccount->setNameOnAccount(\SampleCode\Constants::NAME_ON_ACCOUNT); - $bankAccount->setBankName(\SampleCode\Constants::BANK_NAME); + $bankAccount->setRoutingNumber('121042882'); + $bankAccount->setAccountNumber('123456789123'); + $bankAccount->setNameOnAccount('Jane Doe'); + $bankAccount->setBankName('Bank of the Earth'); $paymentBank= new AnetAPI\PaymentType(); $paymentBank->setBankAccount($bankAccount); @@ -69,5 +69,5 @@ function debitBankAccount($amount){ return $response; } if(!defined('DONT_RUN_SAMPLES')) - debitBankAccount( \SampleCode\Constants::SAMPLE_AMOUNT); + debitBankAccount(12.23); ?> diff --git a/PaymentTransactions/update-split-tender-group.php b/PaymentTransactions/update-split-tender-group.php index 338ac09..cc9820c 100644 --- a/PaymentTransactions/update-split-tender-group.php +++ b/PaymentTransactions/update-split-tender-group.php @@ -15,7 +15,7 @@ function updateSplitTenderGroup(){ $request = new AnetAPI\UpdateSplitTenderGroupRequest(); $request->setMerchantAuthentication($merchantAuthentication); $request->setRefId($refId); - $request->setSplitTenderId(\SampleCode\Constants::SPLIT_TENDER_ID); + $request->setSplitTenderId("115901"); $request->setSplitTenderStatus(\SampleCode\Constants::STATUS_VOID); $controller = new AnetController\UpdateSplitTenderGroupController($request); diff --git a/PaymentTransactions/void-transaction.php b/PaymentTransactions/void-transaction.php index e4e9405..15a5922 100644 --- a/PaymentTransactions/void-transaction.php +++ b/PaymentTransactions/void-transaction.php @@ -14,8 +14,8 @@ function voidTransaction($transactionid){ // Create the payment data for a credit card $creditCard = new AnetAPI\CreditCardType(); - $creditCard->setCardNumber( \SampleCode\Constants::CREDIT_CARD_NUMBER ); - $creditCard->setExpirationDate( \SampleCode\Constants::EXPIRY_DATE); + $creditCard->setCardNumber("4111111111111111" ); + $creditCard->setExpirationDate("2038-12"); $paymentOne = new AnetAPI\PaymentType(); $paymentOne->setCreditCard($creditCard); //create a transaction @@ -53,5 +53,5 @@ function voidTransaction($transactionid){ return $response; } if(!defined('DONT_RUN_SAMPLES')) - voidTransaction(\SampleCode\Constants::TRANS_ID_VOID); + voidTransaction("2249063130"); ?> diff --git a/constants/Constants.php b/constants/Constants.php index e612aab..4717796 100644 --- a/constants/Constants.php +++ b/constants/Constants.php @@ -8,43 +8,43 @@ class Constants const MERCHANT_TRANSACTION_KEY = "4Ktq966gC55GAX7S"; //credit card fields - const CREDIT_CARD_NUMBER = "4111111111111111"; - const CREDIT_CARD_NUMBER_2 = "4242424242424242"; - const EXPIRY_DATE = "2038-12"; - const CVV = "142"; + //const CREDIT_CARD_NUMBER = "4111111111111111"; + //const CREDIT_CARD_NUMBER_2 = "4242424242424242"; + //const EXPIRY_DATE = "2038-12"; + //const CVV = "142"; //bank account fields - const ROUTING_NUMBER = '125000024'; - const DEBIT_ROUTING_NUMBER = '121042882'; - const ACCOUNT_NUMBER = '125000024'; - const DEBIT_ACCOUNT_NUMBER = '123456789123'; - const NAME_ON_ACCOUNT = 'Jane Doe'; - const BANK_NAME= 'Bank of the Earth'; + //const ROUTING_NUMBER = '125000024'; + //const DEBIT_ROUTING_NUMBER = '121042882'; + //const ACCOUNT_NUMBER = '125000024'; + //const DEBIT_ACCOUNT_NUMBER = '123456789123'; + //const NAME_ON_ACCOUNT = 'Jane Doe'; + //const BANK_NAME= 'Bank of the Earth'; //order info - const INVOICE_NUMBER = "101"; - const ORDER_DESCRIPTION = "Golf Shirts"; + //const INVOICE_NUMBER = "101"; + //const ORDER_DESCRIPTION = "Golf Shirts"; //cryptogram - const CRYPTOGRAM = "EjRWeJASNFZ4kBI0VniQEjRWeJA="; + //const CRYPTOGRAM = "EjRWeJASNFZ4kBI0VniQEjRWeJA="; //transaction-id's used by different samples const TRANS_ID_PREVIOUSLY_AUTHORIZED = 2249839471; - const TRANS_ID_VOID = "2249063130"; + //const TRANS_ID_VOID = "2249063130"; const TRANS_ID_TO_CREATE_CUSTOMER_PROFILE = "2249066517"; //split tender id - const SPLIT_TENDER_ID = "115901"; + //const SPLIT_TENDER_ID = "115901"; //transaction status constants const STATUS_VOID = "voided"; //limits - const MAX_AMOUNT = 99999; + //const MAX_AMOUNT = 99999; //miscelaneous variables for individual samples - const SAMPLE_AMOUNT_REFUND = 32.14; - const SAMPLE_AMOUNT = 12.23; - const SAMPLE_AUTH_CODE_AUTHORIZED = "ROHNFQ"; + //const SAMPLE_AMOUNT_REFUND = 12.14; + //const SAMPLE_AMOUNT = 12.23; + //const SAMPLE_AUTH_CODE_AUTHORIZED = "ROHNFQ"; //response const RESPONSE_OK = "1"; @@ -56,16 +56,16 @@ class Constants const SUBSCRIPTION_INTERVAL_DAYS = 23; //Customer Profiles - const TEST_CUSTOMER_EMAIL = "test123@test.com"; - const CUSTOMER_PROFILE_ID = "36152127"; - const CUSTOMER_PROFILE_ID_2 = "36731856"; - const CUSTOMER_PROFILE_ID_HOSTED_PAGE = "123212"; + //const TEST_CUSTOMER_EMAIL = "test123@test.com"; + //const CUSTOMER_PROFILE_ID = "36152127"; + //const CUSTOMER_PROFILE_ID_2 = "36731856"; + //const CUSTOMER_PROFILE_ID_HOSTED_PAGE = "123212"; - const CUSTOMER_PAYMENT_PROFILE_ID = "32689274"; - const CUSTOMER_PAYMENT_PROFILE_ID_DELETE = "38958129"; - const CUSTOMER_PAYMENT_PROFILE_ID_GET = "33211899"; - const CUSTOMER_SHIPPING_ADDRESS_ID_GET = "36976566"; - const PHONE_NUMBER = "000-000-0000"; + //const CUSTOMER_PAYMENT_PROFILE_ID = "32689274"; + //const CUSTOMER_PAYMENT_PROFILE_ID_DELETE = "38958129"; + //const CUSTOMER_PAYMENT_PROFILE_ID_GET = "33211899"; + //const CUSTOMER_SHIPPING_ADDRESS_ID_GET = "36976566"; + //const PHONE_NUMBER = "000-000-0000"; //Transaction Reporting const TRANS_ID = "2238968786"; From 21eccf92183e8f8dcfa1a7f466bcdecab2fc5bb3 Mon Sep 17 00:00:00 2001 From: srathod Date: Wed, 29 Jun 2016 13:58:36 +0530 Subject: [PATCH 089/287] - Patching ashtru's Constants handling. --- .../authorization-and-capture-continue.php | 3 +-- .../authorization-and-capture.php | 2 +- PaypalExpressCheckout/get-details.php | 2 +- .../prior-authorization-capture.php | 2 +- TransactionReporting/get-batch-statistics.php | 2 +- TransactionReporting/get-transaction-details.php | 2 +- VisaCheckout/create-visa-checkout-transaction.php | 6 +++--- VisaCheckout/decrypt-visa-checkout-data.php | 6 +++--- constants/Constants.php | 14 +++++++------- 9 files changed, 19 insertions(+), 20 deletions(-) diff --git a/PaypalExpressCheckout/authorization-and-capture-continue.php b/PaypalExpressCheckout/authorization-and-capture-continue.php index ade134b..6be5f75 100644 --- a/PaypalExpressCheckout/authorization-and-capture-continue.php +++ b/PaypalExpressCheckout/authorization-and-capture-continue.php @@ -61,6 +61,5 @@ function payPalAuthorizeCaptureContinue($refTransId, $payerID) { } if(!defined('DONT_RUN_SAMPLES')) - payPalAuthorizeCaptureContinue(\SampleCode\Constants::TRANS_ID_PAYPAL, - \SampleCode\Constants::PAYER_ID); + payPalAuthorizeCaptureContinue("2241708986","6ZSCSYG33VP8Q"); ?> diff --git a/PaypalExpressCheckout/authorization-and-capture.php b/PaypalExpressCheckout/authorization-and-capture.php index 5d73cb8..b3cf013 100644 --- a/PaypalExpressCheckout/authorization-and-capture.php +++ b/PaypalExpressCheckout/authorization-and-capture.php @@ -51,5 +51,5 @@ function payPalAuthorizeCapture($amount) { } if(!defined('DONT_RUN_SAMPLES')) - payPalAuthorizeCapture(\SampleCode\Constants::SAMPLE_AMOUNT); + payPalAuthorizeCapture(12.23); ?> diff --git a/PaypalExpressCheckout/get-details.php b/PaypalExpressCheckout/get-details.php index 199d2b6..32f0d45 100644 --- a/PaypalExpressCheckout/get-details.php +++ b/PaypalExpressCheckout/get-details.php @@ -95,6 +95,6 @@ function payPalGetDetails($transactionId) { } if(!defined('DONT_RUN_SAMPLES')) - payPalGetDetails( \SampleCode\Constants::TRANS_ID_PAYPAL_GET); + payPalGetDetails("2249863278"); ?> \ No newline at end of file diff --git a/PaypalExpressCheckout/prior-authorization-capture.php b/PaypalExpressCheckout/prior-authorization-capture.php index fb8b0d8..3c0bb24 100644 --- a/PaypalExpressCheckout/prior-authorization-capture.php +++ b/PaypalExpressCheckout/prior-authorization-capture.php @@ -57,6 +57,6 @@ function payPalPriorAuthorizationCapture($transactionId) { if(!defined('DONT_RUN_SAMPLES')) { - payPalPriorAuthorizationCapture( \SampleCode\Constants::TRANS_ID_PAYPAL_GET); + payPalPriorAuthorizationCapture("2249863278"); } ?> \ No newline at end of file diff --git a/TransactionReporting/get-batch-statistics.php b/TransactionReporting/get-batch-statistics.php index a5cf7b0..def63e8 100644 --- a/TransactionReporting/get-batch-statistics.php +++ b/TransactionReporting/get-batch-statistics.php @@ -14,7 +14,7 @@ function getBatchStatistics() { $refId = 'ref' . time(); //Setting a valid batch Id for the Merchant - $batchId = \SampleCode\Constants::BATCH_ID; + $batchId = "4532808"; // Creating a request $request = new AnetAPI\GetBatchStatisticsRequest(); diff --git a/TransactionReporting/get-transaction-details.php b/TransactionReporting/get-transaction-details.php index 1ed8ede..89ef217 100644 --- a/TransactionReporting/get-transaction-details.php +++ b/TransactionReporting/get-transaction-details.php @@ -39,5 +39,5 @@ function getTransactionDetails($transactionId) { } if(!defined('DONT_RUN_SAMPLES')) - getTransactionDetails( \SampleCode\Constants::TRANS_ID); + getTransactionDetails("2238968786"); ?> \ No newline at end of file diff --git a/VisaCheckout/create-visa-checkout-transaction.php b/VisaCheckout/create-visa-checkout-transaction.php index 926e8bf..1e32a68 100644 --- a/VisaCheckout/create-visa-checkout-transaction.php +++ b/VisaCheckout/create-visa-checkout-transaction.php @@ -15,9 +15,9 @@ function createVisaCheckoutTransaction(){ // Create the payment data from a Visa Checkout blob $op = new AnetAPI\OpaqueDataType(); - $op->setDataDescriptor(\SampleCode\Constants::VC_DATA_DESCRIPTOR); - $op->setDataValue(\SampleCode\Constants::VC_DATA_VALUE); - $op->setDataKey(\SampleCode\Constants::VC_DATA_KEY); + $op->setDataDescriptor("COMMON.VCO.ONLINE.PAYMENT"); + $op->setDataValue("4Ng5pzJ6DXfAvLSzVauN9KTufx5lTHhFlnuIr248N3fjtyHrHqMuhOkB1BLiSjKWeTM9+BNj3+9nY56d7CsUfIuvVSTaJRhQQSex1dS2Y2Y+/cA5U+3D1pg5YtTmDVUGlsu1simAd3huwPnwD+CG6O8Ml0AmXvYHntmL3vFaJomadMQBy27k8Dbh5eplPBwyawKUVJ7GqTyKLe8aOYkBUHT5ANWkq2hlGps44BOoDHZ26JWjHdorBZtVIqMK1SIyW4Dih5c/Y//w2toA8WBTPILIvt4h6HPPvWZMZCHCqom9D2k4WGH5+BCEY2jHI7gfYV6xRx54i5vitsYTKm3CyA0C5+l0FNDkfUFHDvVUG9FVzRWVd0TXYhDwfa2pcfI68eYvkEfeT+ZNJ24ZXKPrJo6KZ3x6eZAhzgAMFiC+tPsiygb2zQy5PVoYoBIGj/NGNRqmhZTOEajcO3ZjWxfAnLZAmvMi+pEwJCMmuIY4qRU3RfcaXhAoaUPpDxqrSxR1m+CUKYVdt3nnnQeVaVqf+RaeV9cyFJvILeBPXTBVC50AckVLS37UuBWgWaWcchjRPk9mriDu2KlHQwdR4zu0jnLh4i3tbxV416QBcYLO6AF2Ixlm3GzqGE6QcVssgFCUAhklBWGNLP62O1jtyV4NgTD36QhvHEHby7o4XBB+mjlY6xSEXR+IW9u64AzfDCsTxWiAOE65le6cSk4NDV8DrtYeIozILivWu6wFSpy1gMfiDot4Ndv3C9xCFvH0Bzlky7NoZrvSolKTVNTs8W8UqMFV19qGl6SRaNUEhCqgso/FkdO0eGXFMdQPuP11wQzK/9F3yB9gS2rpXi9sy8DrCqnJ9EXMmliSstKuQl5+yfGc8K3Urot3t+BmNoOvzM9Aha/PzmbLnuKBN6/DUbIw5mhNMCvIA1ByispKpjeV682jl4uslkRsitGLcIOBREFXvGaLxRb37HJkXCHk+jorpDz7LUQhVkClN+hW0vXtgdHQFCIOL7uREdbvk6BZbQlFsuVEKGZxPbKPEJfqMbH54B4a4P5XNQHm4Yt4haH4T0JuYgzoSo76uuXD3g5IuUvy7x8Ykuja1rwW/k//SZAiGaZraRIIAEnzHiUP8dcufb/RonHGnJcYXIEWeIF1lX980bDA+H4vlO8/nN/Mj+EL6tT95MfRDiQHUW69qkqotQd7FJ5uWT+NtetzqDsN5s3sIhwkLKIn9EDLIav5v4SXKxkG+ycMJmGFcfhs7Td9O6hl+Om/JD3he3rgfClaFi/ZR7AVY6fWbAAm9QftKijQ6rskPDYL9Y3gVSA9rdduSg97fUHC+FdfyQXGH552cDLs2ZgzYw6KluXHEuwhACgNotxToPYTTdZxxNr1vPoqYCqHDL2dL8dkuO59/sbZE1m4ektKvUC2wz0UdTDVbHN8HSrLPn2hf/xQp5bKeDDjYkWvNKuwy+aug9H+Uu/m1LuPK/YdogVv9l25y/c2Qbj3dAJ9xTuKjmiJLKlRh4SUI9+05HjDF+i84AoUZ8LuC7LGtrN8ReYIktLhaXq9+XDh5fv4NYhnuYgWkUioKtx1dmfOMHjpLm4aE8Ra1gpJQcZAgwnqYubQvnYy0nY4VaykNix7m3vZwItpKOLqxDYxa3q0qUw25X9zafAM61kPW6EP+4idPzHNww6r1FD4Ihq644dCnCXwoSQ531DW6oAPot8iLZ/xXwoWwrW05k9t2RHjjLbw1L5r1CKgShJQfX7nkJxfGyuw1RmqoQDuNt/tj9M/dHOnoPnOYZZN0JX+Al8PI5zs+LLajw1imu9YcSpwMz3ZlfQqTfI0fjSCc8Is6qVYDMvKD0TweY4hiIxkzs+RyQmPgIeIWqf7Su5+RcnXitb3OuFibBGCjdDeG0ESG8qeiBQKZ3wEyZG09eDAfhuUR5kfZCG4Q01u2YDoRzObxLd8Ruf7HNvtefucFLubciWvOSzbDUisoz0wwOSgJGHucC3IR+1mb/4gz/dI2wvWFInhKcQz4ivkuHaFj8XwvZMcpkwPKtg3pRGTleX/gfjbHcx2VcWRcMPdlDMgTgst9ouN763TZUHHLxjECyB9pkLrR1nhG0cS/aig8Bq1+AH7tvl1wLVxm1Z77DVX4aUIxBH2YUcOgpe6mrWFi6LK3im4/grZECsL/XC4tsTEHjO/U3SazUuhP+6LiCYqp50+3zZf3RpWlxZoYjm5SJ9VIWabocO/Ef26G38lKottW1XsSQUan7myYFFyeyon2hnufzMuxpyXTJ7TLekXCi2gLYbGjldgiRmGShPXzSar+hC2"); + $op->setDataKey("JxAB39A9yUsf6wMD0jwGKCuY7mmzWaeEj85MH02AfKGUxOkJ00JK+o8vGG55cUF9voYU4QQ1Jec4p6nKmsxXmTREEaJwmQErotD4fpcFOyoqWTLMZfslrkHgiqbwru/V"); $paymentOne = new AnetAPI\PaymentType(); $paymentOne->setOpaqueData($op); diff --git a/VisaCheckout/decrypt-visa-checkout-data.php b/VisaCheckout/decrypt-visa-checkout-data.php index 890d2ca..0f9b633 100644 --- a/VisaCheckout/decrypt-visa-checkout-data.php +++ b/VisaCheckout/decrypt-visa-checkout-data.php @@ -15,9 +15,9 @@ function decryptVisaCheckoutData(){ // Create the payment data from a Visa Checkout blob $op = new AnetAPI\OpaqueDataType(); - $op->setDataDescriptor(\SampleCode\Constants::VC_DATA_DESCRIPTOR); - $op->setDataValue( \SampleCode\Constants::VC_DATA_VALUE); - $op->setDataKey( \SampleCode\Constants::VC_DATA_KEY); + $op->setDataDescriptor("COMMON.VCO.ONLINE.PAYMENT"); + $op->setDataValue("4Ng5pzJ6DXfAvLSzVauN9KTufx5lTHhFlnuIr248N3fjtyHrHqMuhOkB1BLiSjKWeTM9+BNj3+9nY56d7CsUfIuvVSTaJRhQQSex1dS2Y2Y+/cA5U+3D1pg5YtTmDVUGlsu1simAd3huwPnwD+CG6O8Ml0AmXvYHntmL3vFaJomadMQBy27k8Dbh5eplPBwyawKUVJ7GqTyKLe8aOYkBUHT5ANWkq2hlGps44BOoDHZ26JWjHdorBZtVIqMK1SIyW4Dih5c/Y//w2toA8WBTPILIvt4h6HPPvWZMZCHCqom9D2k4WGH5+BCEY2jHI7gfYV6xRx54i5vitsYTKm3CyA0C5+l0FNDkfUFHDvVUG9FVzRWVd0TXYhDwfa2pcfI68eYvkEfeT+ZNJ24ZXKPrJo6KZ3x6eZAhzgAMFiC+tPsiygb2zQy5PVoYoBIGj/NGNRqmhZTOEajcO3ZjWxfAnLZAmvMi+pEwJCMmuIY4qRU3RfcaXhAoaUPpDxqrSxR1m+CUKYVdt3nnnQeVaVqf+RaeV9cyFJvILeBPXTBVC50AckVLS37UuBWgWaWcchjRPk9mriDu2KlHQwdR4zu0jnLh4i3tbxV416QBcYLO6AF2Ixlm3GzqGE6QcVssgFCUAhklBWGNLP62O1jtyV4NgTD36QhvHEHby7o4XBB+mjlY6xSEXR+IW9u64AzfDCsTxWiAOE65le6cSk4NDV8DrtYeIozILivWu6wFSpy1gMfiDot4Ndv3C9xCFvH0Bzlky7NoZrvSolKTVNTs8W8UqMFV19qGl6SRaNUEhCqgso/FkdO0eGXFMdQPuP11wQzK/9F3yB9gS2rpXi9sy8DrCqnJ9EXMmliSstKuQl5+yfGc8K3Urot3t+BmNoOvzM9Aha/PzmbLnuKBN6/DUbIw5mhNMCvIA1ByispKpjeV682jl4uslkRsitGLcIOBREFXvGaLxRb37HJkXCHk+jorpDz7LUQhVkClN+hW0vXtgdHQFCIOL7uREdbvk6BZbQlFsuVEKGZxPbKPEJfqMbH54B4a4P5XNQHm4Yt4haH4T0JuYgzoSo76uuXD3g5IuUvy7x8Ykuja1rwW/k//SZAiGaZraRIIAEnzHiUP8dcufb/RonHGnJcYXIEWeIF1lX980bDA+H4vlO8/nN/Mj+EL6tT95MfRDiQHUW69qkqotQd7FJ5uWT+NtetzqDsN5s3sIhwkLKIn9EDLIav5v4SXKxkG+ycMJmGFcfhs7Td9O6hl+Om/JD3he3rgfClaFi/ZR7AVY6fWbAAm9QftKijQ6rskPDYL9Y3gVSA9rdduSg97fUHC+FdfyQXGH552cDLs2ZgzYw6KluXHEuwhACgNotxToPYTTdZxxNr1vPoqYCqHDL2dL8dkuO59/sbZE1m4ektKvUC2wz0UdTDVbHN8HSrLPn2hf/xQp5bKeDDjYkWvNKuwy+aug9H+Uu/m1LuPK/YdogVv9l25y/c2Qbj3dAJ9xTuKjmiJLKlRh4SUI9+05HjDF+i84AoUZ8LuC7LGtrN8ReYIktLhaXq9+XDh5fv4NYhnuYgWkUioKtx1dmfOMHjpLm4aE8Ra1gpJQcZAgwnqYubQvnYy0nY4VaykNix7m3vZwItpKOLqxDYxa3q0qUw25X9zafAM61kPW6EP+4idPzHNww6r1FD4Ihq644dCnCXwoSQ531DW6oAPot8iLZ/xXwoWwrW05k9t2RHjjLbw1L5r1CKgShJQfX7nkJxfGyuw1RmqoQDuNt/tj9M/dHOnoPnOYZZN0JX+Al8PI5zs+LLajw1imu9YcSpwMz3ZlfQqTfI0fjSCc8Is6qVYDMvKD0TweY4hiIxkzs+RyQmPgIeIWqf7Su5+RcnXitb3OuFibBGCjdDeG0ESG8qeiBQKZ3wEyZG09eDAfhuUR5kfZCG4Q01u2YDoRzObxLd8Ruf7HNvtefucFLubciWvOSzbDUisoz0wwOSgJGHucC3IR+1mb/4gz/dI2wvWFInhKcQz4ivkuHaFj8XwvZMcpkwPKtg3pRGTleX/gfjbHcx2VcWRcMPdlDMgTgst9ouN763TZUHHLxjECyB9pkLrR1nhG0cS/aig8Bq1+AH7tvl1wLVxm1Z77DVX4aUIxBH2YUcOgpe6mrWFi6LK3im4/grZECsL/XC4tsTEHjO/U3SazUuhP+6LiCYqp50+3zZf3RpWlxZoYjm5SJ9VIWabocO/Ef26G38lKottW1XsSQUan7myYFFyeyon2hnufzMuxpyXTJ7TLekXCi2gLYbGjldgiRmGShPXzSar+hC2"); + $op->setDataKey("JxAB39A9yUsf6wMD0jwGKCuY7mmzWaeEj85MH02AfKGUxOkJ00JK+o8vGG55cUF9voYU4QQ1Jec4p6nKmsxXmTREEaJwmQErotD4fpcFOyoqWTLMZfslrkHgiqbwru/V"); //create a decrypt request $decryptRequest = new AnetAPI\DecryptPaymentDataRequest(); diff --git a/constants/Constants.php b/constants/Constants.php index 4717796..c38a36b 100644 --- a/constants/Constants.php +++ b/constants/Constants.php @@ -69,17 +69,17 @@ class Constants //Transaction Reporting const TRANS_ID = "2238968786"; - const BATCH_ID = "4532808"; + //const BATCH_ID = "4532808"; //Paypal express Checkout - const TRANS_ID_PAYPAL = "2241708986"; - const TRANS_ID_PAYPAL_GET = "2249863278"; - const PAYER_ID = "6ZSCSYG33VP8Q"; + //const TRANS_ID_PAYPAL = "2241708986"; + //const TRANS_ID_PAYPAL_GET = "2249863278"; + //const PAYER_ID = "6ZSCSYG33VP8Q"; //Visa Checkout related values - const VC_DATA_DESCRIPTOR = "COMMON.VCO.ONLINE.PAYMENT"; - const VC_DATA_VALUE = "4Ng5pzJ6DXfAvLSzVauN9KTufx5lTHhFlnuIr248N3fjtyHrHqMuhOkB1BLiSjKWeTM9+BNj3+9nY56d7CsUfIuvVSTaJRhQQSex1dS2Y2Y+/cA5U+3D1pg5YtTmDVUGlsu1simAd3huwPnwD+CG6O8Ml0AmXvYHntmL3vFaJomadMQBy27k8Dbh5eplPBwyawKUVJ7GqTyKLe8aOYkBUHT5ANWkq2hlGps44BOoDHZ26JWjHdorBZtVIqMK1SIyW4Dih5c/Y//w2toA8WBTPILIvt4h6HPPvWZMZCHCqom9D2k4WGH5+BCEY2jHI7gfYV6xRx54i5vitsYTKm3CyA0C5+l0FNDkfUFHDvVUG9FVzRWVd0TXYhDwfa2pcfI68eYvkEfeT+ZNJ24ZXKPrJo6KZ3x6eZAhzgAMFiC+tPsiygb2zQy5PVoYoBIGj/NGNRqmhZTOEajcO3ZjWxfAnLZAmvMi+pEwJCMmuIY4qRU3RfcaXhAoaUPpDxqrSxR1m+CUKYVdt3nnnQeVaVqf+RaeV9cyFJvILeBPXTBVC50AckVLS37UuBWgWaWcchjRPk9mriDu2KlHQwdR4zu0jnLh4i3tbxV416QBcYLO6AF2Ixlm3GzqGE6QcVssgFCUAhklBWGNLP62O1jtyV4NgTD36QhvHEHby7o4XBB+mjlY6xSEXR+IW9u64AzfDCsTxWiAOE65le6cSk4NDV8DrtYeIozILivWu6wFSpy1gMfiDot4Ndv3C9xCFvH0Bzlky7NoZrvSolKTVNTs8W8UqMFV19qGl6SRaNUEhCqgso/FkdO0eGXFMdQPuP11wQzK/9F3yB9gS2rpXi9sy8DrCqnJ9EXMmliSstKuQl5+yfGc8K3Urot3t+BmNoOvzM9Aha/PzmbLnuKBN6/DUbIw5mhNMCvIA1ByispKpjeV682jl4uslkRsitGLcIOBREFXvGaLxRb37HJkXCHk+jorpDz7LUQhVkClN+hW0vXtgdHQFCIOL7uREdbvk6BZbQlFsuVEKGZxPbKPEJfqMbH54B4a4P5XNQHm4Yt4haH4T0JuYgzoSo76uuXD3g5IuUvy7x8Ykuja1rwW/k//SZAiGaZraRIIAEnzHiUP8dcufb/RonHGnJcYXIEWeIF1lX980bDA+H4vlO8/nN/Mj+EL6tT95MfRDiQHUW69qkqotQd7FJ5uWT+NtetzqDsN5s3sIhwkLKIn9EDLIav5v4SXKxkG+ycMJmGFcfhs7Td9O6hl+Om/JD3he3rgfClaFi/ZR7AVY6fWbAAm9QftKijQ6rskPDYL9Y3gVSA9rdduSg97fUHC+FdfyQXGH552cDLs2ZgzYw6KluXHEuwhACgNotxToPYTTdZxxNr1vPoqYCqHDL2dL8dkuO59/sbZE1m4ektKvUC2wz0UdTDVbHN8HSrLPn2hf/xQp5bKeDDjYkWvNKuwy+aug9H+Uu/m1LuPK/YdogVv9l25y/c2Qbj3dAJ9xTuKjmiJLKlRh4SUI9+05HjDF+i84AoUZ8LuC7LGtrN8ReYIktLhaXq9+XDh5fv4NYhnuYgWkUioKtx1dmfOMHjpLm4aE8Ra1gpJQcZAgwnqYubQvnYy0nY4VaykNix7m3vZwItpKOLqxDYxa3q0qUw25X9zafAM61kPW6EP+4idPzHNww6r1FD4Ihq644dCnCXwoSQ531DW6oAPot8iLZ/xXwoWwrW05k9t2RHjjLbw1L5r1CKgShJQfX7nkJxfGyuw1RmqoQDuNt/tj9M/dHOnoPnOYZZN0JX+Al8PI5zs+LLajw1imu9YcSpwMz3ZlfQqTfI0fjSCc8Is6qVYDMvKD0TweY4hiIxkzs+RyQmPgIeIWqf7Su5+RcnXitb3OuFibBGCjdDeG0ESG8qeiBQKZ3wEyZG09eDAfhuUR5kfZCG4Q01u2YDoRzObxLd8Ruf7HNvtefucFLubciWvOSzbDUisoz0wwOSgJGHucC3IR+1mb/4gz/dI2wvWFInhKcQz4ivkuHaFj8XwvZMcpkwPKtg3pRGTleX/gfjbHcx2VcWRcMPdlDMgTgst9ouN763TZUHHLxjECyB9pkLrR1nhG0cS/aig8Bq1+AH7tvl1wLVxm1Z77DVX4aUIxBH2YUcOgpe6mrWFi6LK3im4/grZECsL/XC4tsTEHjO/U3SazUuhP+6LiCYqp50+3zZf3RpWlxZoYjm5SJ9VIWabocO/Ef26G38lKottW1XsSQUan7myYFFyeyon2hnufzMuxpyXTJ7TLekXCi2gLYbGjldgiRmGShPXzSar+hC2"; - const VC_DATA_KEY = "JxAB39A9yUsf6wMD0jwGKCuY7mmzWaeEj85MH02AfKGUxOkJ00JK+o8vGG55cUF9voYU4QQ1Jec4p6nKmsxXmTREEaJwmQErotD4fpcFOyoqWTLMZfslrkHgiqbwru/V"; + //const VC_DATA_DESCRIPTOR = "COMMON.VCO.ONLINE.PAYMENT"; + //const VC_DATA_VALUE = "4Ng5pzJ6DXfAvLSzVauN9KTufx5lTHhFlnuIr248N3fjtyHrHqMuhOkB1BLiSjKWeTM9+BNj3+9nY56d7CsUfIuvVSTaJRhQQSex1dS2Y2Y+/cA5U+3D1pg5YtTmDVUGlsu1simAd3huwPnwD+CG6O8Ml0AmXvYHntmL3vFaJomadMQBy27k8Dbh5eplPBwyawKUVJ7GqTyKLe8aOYkBUHT5ANWkq2hlGps44BOoDHZ26JWjHdorBZtVIqMK1SIyW4Dih5c/Y//w2toA8WBTPILIvt4h6HPPvWZMZCHCqom9D2k4WGH5+BCEY2jHI7gfYV6xRx54i5vitsYTKm3CyA0C5+l0FNDkfUFHDvVUG9FVzRWVd0TXYhDwfa2pcfI68eYvkEfeT+ZNJ24ZXKPrJo6KZ3x6eZAhzgAMFiC+tPsiygb2zQy5PVoYoBIGj/NGNRqmhZTOEajcO3ZjWxfAnLZAmvMi+pEwJCMmuIY4qRU3RfcaXhAoaUPpDxqrSxR1m+CUKYVdt3nnnQeVaVqf+RaeV9cyFJvILeBPXTBVC50AckVLS37UuBWgWaWcchjRPk9mriDu2KlHQwdR4zu0jnLh4i3tbxV416QBcYLO6AF2Ixlm3GzqGE6QcVssgFCUAhklBWGNLP62O1jtyV4NgTD36QhvHEHby7o4XBB+mjlY6xSEXR+IW9u64AzfDCsTxWiAOE65le6cSk4NDV8DrtYeIozILivWu6wFSpy1gMfiDot4Ndv3C9xCFvH0Bzlky7NoZrvSolKTVNTs8W8UqMFV19qGl6SRaNUEhCqgso/FkdO0eGXFMdQPuP11wQzK/9F3yB9gS2rpXi9sy8DrCqnJ9EXMmliSstKuQl5+yfGc8K3Urot3t+BmNoOvzM9Aha/PzmbLnuKBN6/DUbIw5mhNMCvIA1ByispKpjeV682jl4uslkRsitGLcIOBREFXvGaLxRb37HJkXCHk+jorpDz7LUQhVkClN+hW0vXtgdHQFCIOL7uREdbvk6BZbQlFsuVEKGZxPbKPEJfqMbH54B4a4P5XNQHm4Yt4haH4T0JuYgzoSo76uuXD3g5IuUvy7x8Ykuja1rwW/k//SZAiGaZraRIIAEnzHiUP8dcufb/RonHGnJcYXIEWeIF1lX980bDA+H4vlO8/nN/Mj+EL6tT95MfRDiQHUW69qkqotQd7FJ5uWT+NtetzqDsN5s3sIhwkLKIn9EDLIav5v4SXKxkG+ycMJmGFcfhs7Td9O6hl+Om/JD3he3rgfClaFi/ZR7AVY6fWbAAm9QftKijQ6rskPDYL9Y3gVSA9rdduSg97fUHC+FdfyQXGH552cDLs2ZgzYw6KluXHEuwhACgNotxToPYTTdZxxNr1vPoqYCqHDL2dL8dkuO59/sbZE1m4ektKvUC2wz0UdTDVbHN8HSrLPn2hf/xQp5bKeDDjYkWvNKuwy+aug9H+Uu/m1LuPK/YdogVv9l25y/c2Qbj3dAJ9xTuKjmiJLKlRh4SUI9+05HjDF+i84AoUZ8LuC7LGtrN8ReYIktLhaXq9+XDh5fv4NYhnuYgWkUioKtx1dmfOMHjpLm4aE8Ra1gpJQcZAgwnqYubQvnYy0nY4VaykNix7m3vZwItpKOLqxDYxa3q0qUw25X9zafAM61kPW6EP+4idPzHNww6r1FD4Ihq644dCnCXwoSQ531DW6oAPot8iLZ/xXwoWwrW05k9t2RHjjLbw1L5r1CKgShJQfX7nkJxfGyuw1RmqoQDuNt/tj9M/dHOnoPnOYZZN0JX+Al8PI5zs+LLajw1imu9YcSpwMz3ZlfQqTfI0fjSCc8Is6qVYDMvKD0TweY4hiIxkzs+RyQmPgIeIWqf7Su5+RcnXitb3OuFibBGCjdDeG0ESG8qeiBQKZ3wEyZG09eDAfhuUR5kfZCG4Q01u2YDoRzObxLd8Ruf7HNvtefucFLubciWvOSzbDUisoz0wwOSgJGHucC3IR+1mb/4gz/dI2wvWFInhKcQz4ivkuHaFj8XwvZMcpkwPKtg3pRGTleX/gfjbHcx2VcWRcMPdlDMgTgst9ouN763TZUHHLxjECyB9pkLrR1nhG0cS/aig8Bq1+AH7tvl1wLVxm1Z77DVX4aUIxBH2YUcOgpe6mrWFi6LK3im4/grZECsL/XC4tsTEHjO/U3SazUuhP+6LiCYqp50+3zZf3RpWlxZoYjm5SJ9VIWabocO/Ef26G38lKottW1XsSQUan7myYFFyeyon2hnufzMuxpyXTJ7TLekXCi2gLYbGjldgiRmGShPXzSar+hC2"; + //const VC_DATA_KEY = "JxAB39A9yUsf6wMD0jwGKCuY7mmzWaeEj85MH02AfKGUxOkJ00JK+o8vGG55cUF9voYU4QQ1Jec4p6nKmsxXmTREEaJwmQErotD4fpcFOyoqWTLMZfslrkHgiqbwru/V"; } ?> From 11a051f46c2be244d460e3dcc43667e368d765a0 Mon Sep 17 00:00:00 2001 From: srathod Date: Wed, 29 Jun 2016 14:00:31 +0530 Subject: [PATCH 090/287] Patching ashtru's fix. --- constants/Constants.php | 40 ---------------------------------------- 1 file changed, 40 deletions(-) diff --git a/constants/Constants.php b/constants/Constants.php index c38a36b..c3fc78f 100644 --- a/constants/Constants.php +++ b/constants/Constants.php @@ -7,46 +7,6 @@ class Constants const MERCHANT_LOGIN_ID = "5KP3u95bQpv"; const MERCHANT_TRANSACTION_KEY = "4Ktq966gC55GAX7S"; - //credit card fields - //const CREDIT_CARD_NUMBER = "4111111111111111"; - //const CREDIT_CARD_NUMBER_2 = "4242424242424242"; - //const EXPIRY_DATE = "2038-12"; - //const CVV = "142"; - - //bank account fields - //const ROUTING_NUMBER = '125000024'; - //const DEBIT_ROUTING_NUMBER = '121042882'; - //const ACCOUNT_NUMBER = '125000024'; - //const DEBIT_ACCOUNT_NUMBER = '123456789123'; - //const NAME_ON_ACCOUNT = 'Jane Doe'; - //const BANK_NAME= 'Bank of the Earth'; - - //order info - //const INVOICE_NUMBER = "101"; - //const ORDER_DESCRIPTION = "Golf Shirts"; - //cryptogram - //const CRYPTOGRAM = "EjRWeJASNFZ4kBI0VniQEjRWeJA="; - - //transaction-id's used by different samples - const TRANS_ID_PREVIOUSLY_AUTHORIZED = 2249839471; - //const TRANS_ID_VOID = "2249063130"; - const TRANS_ID_TO_CREATE_CUSTOMER_PROFILE = "2249066517"; - - //split tender id - //const SPLIT_TENDER_ID = "115901"; - //transaction status constants - const STATUS_VOID = "voided"; - - - //limits - //const MAX_AMOUNT = 99999; - - //miscelaneous variables for individual samples - //const SAMPLE_AMOUNT_REFUND = 12.14; - //const SAMPLE_AMOUNT = 12.23; - //const SAMPLE_AUTH_CODE_AUTHORIZED = "ROHNFQ"; - - //response const RESPONSE_OK = "1"; //Recurring Billing From 9c598d4e8c76362cafc767b634344eae947007ae Mon Sep 17 00:00:00 2001 From: Ashutosh Singh Date: Wed, 16 Mar 2016 14:45:36 +0530 Subject: [PATCH 091/287] Update update-split-tender-group.php --- PaymentTransactions/update-split-tender-group.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PaymentTransactions/update-split-tender-group.php b/PaymentTransactions/update-split-tender-group.php index cc9820c..2805bf6 100644 --- a/PaymentTransactions/update-split-tender-group.php +++ b/PaymentTransactions/update-split-tender-group.php @@ -16,7 +16,7 @@ function updateSplitTenderGroup(){ $request->setMerchantAuthentication($merchantAuthentication); $request->setRefId($refId); $request->setSplitTenderId("115901"); - $request->setSplitTenderStatus(\SampleCode\Constants::STATUS_VOID); + $request->setSplitTenderStatus("voided"); $controller = new AnetController\UpdateSplitTenderGroupController($request); @@ -38,4 +38,4 @@ function updateSplitTenderGroup(){ if(!defined('DONT_RUN_SAMPLES')) updateSplitTenderGroup(); - ?> \ No newline at end of file + ?> From eae1bf7625fcc971637524a0062a8c92a6bb380b Mon Sep 17 00:00:00 2001 From: ashtru Date: Fri, 1 Apr 2016 11:59:35 +0530 Subject: [PATCH 092/287] Fix get-unsettled-transaction-list.php when no unsettled transactions for the merchant. --- .../get-unsettled-transaction-list.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/TransactionReporting/get-unsettled-transaction-list.php b/TransactionReporting/get-unsettled-transaction-list.php index 4301421..8649cf7 100644 --- a/TransactionReporting/get-unsettled-transaction-list.php +++ b/TransactionReporting/get-unsettled-transaction-list.php @@ -8,8 +8,8 @@ function getUnsettledTransactionList() { // Common Set Up for API Credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $merchantAuthentication->setName("4gf2H89Xc"); + $merchantAuthentication->setTransactionKey("3T32UcwyCL555U6J"); $refId = 'ref' . time(); @@ -24,12 +24,17 @@ function getUnsettledTransactionList() { if (($response != null) && ($response->getMessages()->getResultCode() == "Ok")) { - foreach($response->getTransactions() as $tx) - { - echo "SUCCESS: TransactionID: " . $tx->getTransId() . "\n"; + if(null != $response->getTransactions()) + { + foreach($response->getTransactions() as $tx) + { + echo "SUCCESS: TransactionID: " . $tx->getTransId() . "\n"; + } } - - } + else{ + echo "No unsettled transactions for the merchant." . "\n"; + } + } else { echo "ERROR : Invalid response\n"; From af4173b5bf7fde3e68694c1756b137758b842eff Mon Sep 17 00:00:00 2001 From: ashtru Date: Fri, 1 Apr 2016 12:14:06 +0530 Subject: [PATCH 093/287] Update get-unsettled-transaction-list.php to Default merchant credentials --- TransactionReporting/get-unsettled-transaction-list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TransactionReporting/get-unsettled-transaction-list.php b/TransactionReporting/get-unsettled-transaction-list.php index 8649cf7..2793fd8 100644 --- a/TransactionReporting/get-unsettled-transaction-list.php +++ b/TransactionReporting/get-unsettled-transaction-list.php @@ -8,8 +8,8 @@ function getUnsettledTransactionList() { // Common Set Up for API Credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); - $merchantAuthentication->setName("4gf2H89Xc"); - $merchantAuthentication->setTransactionKey("3T32UcwyCL555U6J"); + $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); $refId = 'ref' . time(); From 4c20876867d5720fa0cb8b5898d73a52f090cae1 Mon Sep 17 00:00:00 2001 From: Ashish Kankaria Date: Wed, 29 Jun 2016 14:14:31 +0530 Subject: [PATCH 094/287] Updating the transaction key --- phpunit.xml.dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 4d61151..19a10f4 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -26,7 +26,7 @@ - + From c67e9fb2ecf128a49aad8541f8469b6a6e51eb51 Mon Sep 17 00:00:00 2001 From: Ashish Kankaria Date: Wed, 29 Jun 2016 14:15:36 +0530 Subject: [PATCH 095/287] Updating the transaction key --- constants/Constants.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/constants/Constants.php b/constants/Constants.php index e612aab..1e68157 100644 --- a/constants/Constants.php +++ b/constants/Constants.php @@ -5,7 +5,7 @@ class Constants { //merchant credentials const MERCHANT_LOGIN_ID = "5KP3u95bQpv"; - const MERCHANT_TRANSACTION_KEY = "4Ktq966gC55GAX7S"; + const MERCHANT_TRANSACTION_KEY = "346HZ32z3fP4hTG2"; //credit card fields const CREDIT_CARD_NUMBER = "4111111111111111"; From 7260018d3e583dc3558bc43a4cf1df56f10cb5e2 Mon Sep 17 00:00:00 2001 From: Ashish Kankaria Date: Wed, 29 Jun 2016 14:16:24 +0530 Subject: [PATCH 096/287] Updating the transaction key --- test-runner.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-runner.php b/test-runner.php index b1acc10..eb7d849 100644 --- a/test-runner.php +++ b/test-runner.php @@ -34,7 +34,7 @@ class TestRunner extends PHPUnit_Framework_TestCase { public static $apiLoginId = "5KP3u95bQpv"; - public static $transactionKey = "4Ktq966gC55GAX7S"; + public static $transactionKey = "346HZ32z3fP4hTG2"; public static $transactionID = "2245440957"; public static $payerID = "LM6NCLZ5RAKBY"; //random amount for transactions/subscriptions From 6286ba83a9cee80560c5b03c59058668c72a90cd Mon Sep 17 00:00:00 2001 From: srathod Date: Wed, 29 Jun 2016 14:50:43 +0530 Subject: [PATCH 097/287] - Patching RecurringBilling changes related to Constants. --- RecurringBilling/cancel-subscription.php | 2 +- RecurringBilling/create-subscription.php | 2 +- RecurringBilling/get-subscription-status.php | 2 +- RecurringBilling/get-subscription.php | 7 ++++--- RecurringBilling/update-subscription.php | 2 +- constants/Constants.php | 6 +++--- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/RecurringBilling/cancel-subscription.php b/RecurringBilling/cancel-subscription.php index cb7205b..bfe1adb 100644 --- a/RecurringBilling/cancel-subscription.php +++ b/RecurringBilling/cancel-subscription.php @@ -41,6 +41,6 @@ function cancelSubscription($subscriptionId) { } if(!defined('DONT_RUN_SAMPLES')) - cancelSubscription(\SampleCode\Constants::SUBSCRIPTION_ID_CANCEL); + cancelSubscription("3056945"); ?> diff --git a/RecurringBilling/create-subscription.php b/RecurringBilling/create-subscription.php index bca64d0..83beefd 100644 --- a/RecurringBilling/create-subscription.php +++ b/RecurringBilling/create-subscription.php @@ -71,6 +71,6 @@ function createSubscription($intervalLength) { } if(!defined('DONT_RUN_SAMPLES')) - createSubscription( \SampleCode\Constants::SUBSCRIPTION_INTERVAL_DAYS); + createSubscription(23); ?> diff --git a/RecurringBilling/get-subscription-status.php b/RecurringBilling/get-subscription-status.php index 1b71589..4b8d7fa 100644 --- a/RecurringBilling/get-subscription-status.php +++ b/RecurringBilling/get-subscription-status.php @@ -38,6 +38,6 @@ function getSubscriptionStatus($subscriptionId) { } if(!defined('DONT_RUN_SAMPLES')) - getSubscriptionStatus( \SampleCode\Constants::SUBSCRIPTION_ID_UPDATE); + getSubscriptionStatus("3056948"); ?> diff --git a/RecurringBilling/get-subscription.php b/RecurringBilling/get-subscription.php index be43d20..35dcb11 100644 --- a/RecurringBilling/get-subscription.php +++ b/RecurringBilling/get-subscription.php @@ -26,7 +26,7 @@ function getSubscription($subscriptionId) { // Getting the response $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - + if ($response != null) { if($response->getMessages()->getResultCode() == "Ok") @@ -39,11 +39,12 @@ function getSubscription($subscriptionId) { 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"; + echo "ERROR : Invalid response\n"; $errorMessages = $response->getMessages()->getMessage(); echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } @@ -58,5 +59,5 @@ function getSubscription($subscriptionId) { } if(!defined('DONT_RUN_SAMPLES')) - getSubscription( \SampleCode\Constants::SUBSCRIPTION_ID_GET); + getSubscription("2930242"); ?> diff --git a/RecurringBilling/update-subscription.php b/RecurringBilling/update-subscription.php index cd58a43..703b369 100644 --- a/RecurringBilling/update-subscription.php +++ b/RecurringBilling/update-subscription.php @@ -61,5 +61,5 @@ function updateSubscription($subscriptionId) { } if(!defined('DONT_RUN_SAMPLES')) - updateSubscription( \SampleCode\Constants::SUBSCRIPTION_ID_UPDATE); + updateSubscription("3056948"); ?> diff --git a/constants/Constants.php b/constants/Constants.php index c3fc78f..2d87198 100644 --- a/constants/Constants.php +++ b/constants/Constants.php @@ -10,10 +10,10 @@ class Constants const RESPONSE_OK = "1"; //Recurring Billing - const SUBSCRIPTION_ID_CANCEL = "3056945"; - const SUBSCRIPTION_ID_UPDATE = "3056948"; + //const SUBSCRIPTION_ID_CANCEL = "3056945"; + //const SUBSCRIPTION_ID_UPDATE = "3056948"; const SUBSCRIPTION_ID_GET = "2930242"; - const SUBSCRIPTION_INTERVAL_DAYS = 23; + //const SUBSCRIPTION_INTERVAL_DAYS = 23; //Customer Profiles //const TEST_CUSTOMER_EMAIL = "test123@test.com"; From 704d91bdf0174b220f86d900843f8729fbdef367 Mon Sep 17 00:00:00 2001 From: srathod Date: Wed, 29 Jun 2016 15:03:27 +0530 Subject: [PATCH 098/287] - Removed comments in Constants. --- constants/Constants.php | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/constants/Constants.php b/constants/Constants.php index 2d87198..2900941 100644 --- a/constants/Constants.php +++ b/constants/Constants.php @@ -10,36 +10,10 @@ class Constants const RESPONSE_OK = "1"; //Recurring Billing - //const SUBSCRIPTION_ID_CANCEL = "3056945"; - //const SUBSCRIPTION_ID_UPDATE = "3056948"; const SUBSCRIPTION_ID_GET = "2930242"; - //const SUBSCRIPTION_INTERVAL_DAYS = 23; - - //Customer Profiles - //const TEST_CUSTOMER_EMAIL = "test123@test.com"; - //const CUSTOMER_PROFILE_ID = "36152127"; - //const CUSTOMER_PROFILE_ID_2 = "36731856"; - //const CUSTOMER_PROFILE_ID_HOSTED_PAGE = "123212"; - - //const CUSTOMER_PAYMENT_PROFILE_ID = "32689274"; - //const CUSTOMER_PAYMENT_PROFILE_ID_DELETE = "38958129"; - //const CUSTOMER_PAYMENT_PROFILE_ID_GET = "33211899"; - //const CUSTOMER_SHIPPING_ADDRESS_ID_GET = "36976566"; - //const PHONE_NUMBER = "000-000-0000"; - + //Transaction Reporting const TRANS_ID = "2238968786"; - //const BATCH_ID = "4532808"; - - //Paypal express Checkout - //const TRANS_ID_PAYPAL = "2241708986"; - //const TRANS_ID_PAYPAL_GET = "2249863278"; - //const PAYER_ID = "6ZSCSYG33VP8Q"; - - //Visa Checkout related values - //const VC_DATA_DESCRIPTOR = "COMMON.VCO.ONLINE.PAYMENT"; - //const VC_DATA_VALUE = "4Ng5pzJ6DXfAvLSzVauN9KTufx5lTHhFlnuIr248N3fjtyHrHqMuhOkB1BLiSjKWeTM9+BNj3+9nY56d7CsUfIuvVSTaJRhQQSex1dS2Y2Y+/cA5U+3D1pg5YtTmDVUGlsu1simAd3huwPnwD+CG6O8Ml0AmXvYHntmL3vFaJomadMQBy27k8Dbh5eplPBwyawKUVJ7GqTyKLe8aOYkBUHT5ANWkq2hlGps44BOoDHZ26JWjHdorBZtVIqMK1SIyW4Dih5c/Y//w2toA8WBTPILIvt4h6HPPvWZMZCHCqom9D2k4WGH5+BCEY2jHI7gfYV6xRx54i5vitsYTKm3CyA0C5+l0FNDkfUFHDvVUG9FVzRWVd0TXYhDwfa2pcfI68eYvkEfeT+ZNJ24ZXKPrJo6KZ3x6eZAhzgAMFiC+tPsiygb2zQy5PVoYoBIGj/NGNRqmhZTOEajcO3ZjWxfAnLZAmvMi+pEwJCMmuIY4qRU3RfcaXhAoaUPpDxqrSxR1m+CUKYVdt3nnnQeVaVqf+RaeV9cyFJvILeBPXTBVC50AckVLS37UuBWgWaWcchjRPk9mriDu2KlHQwdR4zu0jnLh4i3tbxV416QBcYLO6AF2Ixlm3GzqGE6QcVssgFCUAhklBWGNLP62O1jtyV4NgTD36QhvHEHby7o4XBB+mjlY6xSEXR+IW9u64AzfDCsTxWiAOE65le6cSk4NDV8DrtYeIozILivWu6wFSpy1gMfiDot4Ndv3C9xCFvH0Bzlky7NoZrvSolKTVNTs8W8UqMFV19qGl6SRaNUEhCqgso/FkdO0eGXFMdQPuP11wQzK/9F3yB9gS2rpXi9sy8DrCqnJ9EXMmliSstKuQl5+yfGc8K3Urot3t+BmNoOvzM9Aha/PzmbLnuKBN6/DUbIw5mhNMCvIA1ByispKpjeV682jl4uslkRsitGLcIOBREFXvGaLxRb37HJkXCHk+jorpDz7LUQhVkClN+hW0vXtgdHQFCIOL7uREdbvk6BZbQlFsuVEKGZxPbKPEJfqMbH54B4a4P5XNQHm4Yt4haH4T0JuYgzoSo76uuXD3g5IuUvy7x8Ykuja1rwW/k//SZAiGaZraRIIAEnzHiUP8dcufb/RonHGnJcYXIEWeIF1lX980bDA+H4vlO8/nN/Mj+EL6tT95MfRDiQHUW69qkqotQd7FJ5uWT+NtetzqDsN5s3sIhwkLKIn9EDLIav5v4SXKxkG+ycMJmGFcfhs7Td9O6hl+Om/JD3he3rgfClaFi/ZR7AVY6fWbAAm9QftKijQ6rskPDYL9Y3gVSA9rdduSg97fUHC+FdfyQXGH552cDLs2ZgzYw6KluXHEuwhACgNotxToPYTTdZxxNr1vPoqYCqHDL2dL8dkuO59/sbZE1m4ektKvUC2wz0UdTDVbHN8HSrLPn2hf/xQp5bKeDDjYkWvNKuwy+aug9H+Uu/m1LuPK/YdogVv9l25y/c2Qbj3dAJ9xTuKjmiJLKlRh4SUI9+05HjDF+i84AoUZ8LuC7LGtrN8ReYIktLhaXq9+XDh5fv4NYhnuYgWkUioKtx1dmfOMHjpLm4aE8Ra1gpJQcZAgwnqYubQvnYy0nY4VaykNix7m3vZwItpKOLqxDYxa3q0qUw25X9zafAM61kPW6EP+4idPzHNww6r1FD4Ihq644dCnCXwoSQ531DW6oAPot8iLZ/xXwoWwrW05k9t2RHjjLbw1L5r1CKgShJQfX7nkJxfGyuw1RmqoQDuNt/tj9M/dHOnoPnOYZZN0JX+Al8PI5zs+LLajw1imu9YcSpwMz3ZlfQqTfI0fjSCc8Is6qVYDMvKD0TweY4hiIxkzs+RyQmPgIeIWqf7Su5+RcnXitb3OuFibBGCjdDeG0ESG8qeiBQKZ3wEyZG09eDAfhuUR5kfZCG4Q01u2YDoRzObxLd8Ruf7HNvtefucFLubciWvOSzbDUisoz0wwOSgJGHucC3IR+1mb/4gz/dI2wvWFInhKcQz4ivkuHaFj8XwvZMcpkwPKtg3pRGTleX/gfjbHcx2VcWRcMPdlDMgTgst9ouN763TZUHHLxjECyB9pkLrR1nhG0cS/aig8Bq1+AH7tvl1wLVxm1Z77DVX4aUIxBH2YUcOgpe6mrWFi6LK3im4/grZECsL/XC4tsTEHjO/U3SazUuhP+6LiCYqp50+3zZf3RpWlxZoYjm5SJ9VIWabocO/Ef26G38lKottW1XsSQUan7myYFFyeyon2hnufzMuxpyXTJ7TLekXCi2gLYbGjldgiRmGShPXzSar+hC2"; - //const VC_DATA_KEY = "JxAB39A9yUsf6wMD0jwGKCuY7mmzWaeEj85MH02AfKGUxOkJ00JK+o8vGG55cUF9voYU4QQ1Jec4p6nKmsxXmTREEaJwmQErotD4fpcFOyoqWTLMZfslrkHgiqbwru/V"; } ?> From 3c3e727b9f4bbf8175dd831f257617d0c42b56e5 Mon Sep 17 00:00:00 2001 From: ashtru Date: Mon, 22 Aug 2016 16:06:56 +0530 Subject: [PATCH 099/287] Adding samples for Accept and Android Pay --- .../create-an-accept-transaction.php | 60 +++++++++++++++++++ .../create-an-android-pay-transaction.php | 60 +++++++++++++++++++ .../create-an-apple-pay-transaction.php | 0 SampleCodeList.txt | 4 +- test-runner.php | 2 +- 5 files changed, 124 insertions(+), 2 deletions(-) create mode 100644 MobileInAppTransactions/create-an-accept-transaction.php create mode 100644 MobileInAppTransactions/create-an-android-pay-transaction.php rename {ApplePayTransactions => MobileInAppTransactions}/create-an-apple-pay-transaction.php (100%) diff --git a/MobileInAppTransactions/create-an-accept-transaction.php b/MobileInAppTransactions/create-an-accept-transaction.php new file mode 100644 index 0000000..1d3368b --- /dev/null +++ b/MobileInAppTransactions/create-an-accept-transaction.php @@ -0,0 +1,60 @@ +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"); + $paymentOne = new AnetAPI\PaymentType(); + $paymentOne->setOpaqueData($op); + + //create a transaction + $transactionRequestType = new AnetAPI\TransactionRequestType(); + $transactionRequestType->setTransactionType( "authCaptureTransaction"); + $transactionRequestType->setAmount(151); + $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) + { + $tresponse = $response->getTransactionResponse(); + + if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + { + echo " AUTH CODE : " . $tresponse->getAuthCode() . "\n"; + echo " TRANS ID : " . $tresponse->getTransId() . "\n"; + } + else + { + echo "ERROR : Invalid response\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; + } + } + else + { + echo "Null response"; + } + return $response; +} + +if(!defined('DONT_RUN_SAMPLES')) + createAnAcceptTransaction(); +?> diff --git a/MobileInAppTransactions/create-an-android-pay-transaction.php b/MobileInAppTransactions/create-an-android-pay-transaction.php new file mode 100644 index 0000000..b1a6685 --- /dev/null +++ b/MobileInAppTransactions/create-an-android-pay-transaction.php @@ -0,0 +1,60 @@ +setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $refId = 'ref' . time(); + + $op = new AnetAPI\OpaqueDataType(); + $op->setDataDescriptor("COMMON.ANDROID.INAPP.PAYMENT"); + $op->setDataValue("eyJkYXRhIjoiQkRQTldTdE1tR2V3UVVXR2c0bzdFXC9qKzFjcTFUNzhxeVU4NGI2N2l0amNZSTh3UFlBT2hzaGpoWlBycWRVcjRYd1BNYmo0emNHTWR5KysxSDJWa1BPWStCT01GMjV1YjE5Y1g0bkN2a1hVVU9UakRsbEIxVGdTcjhKSFp4Z3A5ckNnc1NVZ2JCZ0tmNjBYS3V0WGY2YWpcL284WkliS25yS1E4U2gwb3VMQUtsb1VNbit2UHU0K0E3V0tycXJhdXo5SnZPUXA2dmhJcStIS2pVY1VOQ0lUUHlGaG1PRXRxK0grdzB2UmExQ0U2V2hGQk5uQ0hxenpXS2NrQlwvMG5xTFpSVFliRjBwK3Z5QmlWYVdIZWdoRVJmSHhSdGJ6cGVjelJQUHVGc2ZwSFZzNDhvUExDXC9rXC8xTU5kNDdrelwvcEhEY1JcL0R5NmFVTStsTmZvaWx5XC9RSk4rdFMzbTBIZk90SVNBUHFPbVhlbXZyNnhKQ2pDWmxDdXcwQzltWHpcL29iSHBvZnVJRVM4cjljcUdHc1VBUERwdzdnNjQybTRQendLRitIQnVZVW5lV0RCTlNEMnU2amJBRzMiLCJ2ZXJzaW9uIjoiRUNfdjEiLCJoZWFkZXIiOnsiYXBwbGljYXRpb25EYXRhIjoiOTRlZTA1OTMzNWU1ODdlNTAxY2M0YmY5MDYxM2UwODE0ZjAwYTdiMDhiYzdjNjQ4ZmQ4NjVhMmFmNmEyMmNjMiIsInRyYW5zYWN0aW9uSWQiOiJjMWNhZjVhZTcyZjAwMzlhODJiYWQ5MmI4MjgzNjM3MzRmODViZjJmOWNhZGYxOTNkMWJhZDlkZGNiNjBhNzk1IiwiZXBoZW1lcmFsUHVibGljS2V5IjoiTUlJQlN6Q0NBUU1HQnlxR1NNNDlBZ0V3Z2ZjQ0FRRXdMQVlIS29aSXpqMEJBUUloQVBcL1wvXC9cLzhBQUFBQkFBQUFBQUFBQUFBQUFBQUFcL1wvXC9cL1wvXC9cL1wvXC9cL1wvXC9cL1wvXC9cL01Gc0VJUFwvXC9cL1wvOEFBQUFCQUFBQUFBQUFBQUFBQUFBQVwvXC9cL1wvXC9cL1wvXC9cL1wvXC9cL1wvXC9cLzhCQ0JheGpYWXFqcVQ1N1BydlZWMm1JYThaUjBHc014VHNQWTd6ancrSjlKZ1N3TVZBTVNkTmdpRzV3U1RhbVo0NFJPZEpyZUJuMzZRQkVFRWF4ZlI4dUVzUWtmNHZPYmxZNlJBOG5jRGZZRXQ2ek9nOUtFNVJkaVl3cFpQNDBMaVwvaHBcL200N242MHA4RDU0V0s4NHpWMnN4WHM3THRrQm9ONzlSOVFJaEFQXC9cL1wvXC84QUFBQUFcL1wvXC9cL1wvXC9cL1wvXC9cLys4NXZxdHB4ZWVoUE81eXNMOFl5VlJBZ0VCQTBJQUJHbStnc2wwUFpGVFwva0RkVVNreHd5Zm84SnB3VFFRekJtOWxKSm5tVGw0REdVdkFENEdzZUdqXC9wc2hCWjBLM1RldXFEdFwvdERMYkUrOFwvbTB5Q21veHc9IiwicHVibGljS2V5SGFzaCI6IlwvYmI5Q05DMzZ1QmhlSEZQYm1vaEI3T28xT3NYMkora0pxdjQ4ek9WVmlRPSJ9LCJzaWduYXR1cmUiOiJNSUlEUWdZSktvWklodmNOQVFjQ29JSURNekNDQXk4Q0FRRXhDekFKQmdVckRnTUNHZ1VBTUFzR0NTcUdTSWIzRFFFSEFhQ0NBaXN3Z2dJbk1JSUJsS0FEQWdFQ0FoQmNsK1BmMytVNHBrMTNuVkQ5bndRUU1Ba0dCU3NPQXdJZEJRQXdKekVsTUNNR0ExVUVBeDRjQUdNQWFBQnRBR0VBYVFCQUFIWUFhUUJ6QUdFQUxnQmpBRzhBYlRBZUZ3MHhOREF4TURFd05qQXdNREJhRncweU5EQXhNREV3TmpBd01EQmFNQ2N4SlRBakJnTlZCQU1lSEFCakFHZ0FiUUJoQUdrQVFBQjJBR2tBY3dCaEFDNEFZd0J2QUcwd2daOHdEUVlKS29aSWh2Y05BUUVCQlFBRGdZMEFNSUdKQW9HQkFOQzgra2d0Z212V0YxT3pqZ0ROcmpURUJSdW9cLzVNS3ZsTTE0NnBBZjdHeDQxYmxFOXc0ZklYSkFEN0ZmTzdRS2pJWFlOdDM5ckx5eTd4RHdiXC81SWtaTTYwVFoyaUkxcGo1NVVjOGZkNGZ6T3BrM2Z0WmFRR1hOTFlwdEcxZDlWN0lTODJPdXA5TU1vMUJQVnJYVFBITmNzTTk5RVBVblBxZGJlR2M4N20wckFnTUJBQUdqWERCYU1GZ0dBMVVkQVFSUk1FK0FFSFpXUHJXdEpkN1laNDMxaENnN1lGU2hLVEFuTVNVd0l3WURWUVFESGh3QVl3Qm9BRzBBWVFCcEFFQUFkZ0JwQUhNQVlRQXVBR01BYndCdGdoQmNsK1BmMytVNHBrMTNuVkQ5bndRUU1Ba0dCU3NPQXdJZEJRQURnWUVBYlVLWUNrdUlLUzlRUTJtRmNNWVJFSW0ybCtYZzhcL0pYditHQlZRSmtPS29zY1k0aU5ERkFcL2JRbG9nZjlMTFU4NFRId05SbnN2VjNQcnY3UlRZODFncTBkdEM4elljQWFBa0NISUkzeXFNbko0QU91NkVPVzlrSmsyMzJnU0U3V2xDdEhiZkxTS2Z1U2dRWDhLWFFZdVpMazJScjYzTjhBcFhzWHdCTDNjSjB4Z2VBd2dkMENBUUV3T3pBbk1TVXdJd1lEVlFRREhod0FZd0JvQUcwQVlRQnBBRUFBZGdCcEFITUFZUUF1QUdNQWJ3QnRBaEJjbCtQZjMrVTRwazEzblZEOW53UVFNQWtHQlNzT0F3SWFCUUF3RFFZSktvWklodmNOQVFFQkJRQUVnWUJhSzNFbE9zdGJIOFdvb3NlREFCZitKZ1wvMTI5SmNJYXdtN2M2VnhuN1phc05iQXEzdEF0OFB0eSt1UUNnc3NYcVprTEE3a3oyR3pNb2xOdHY5d1ltdTlVandhcjFQSFlTK0JcL29Hbm96NTkxd2phZ1hXUnowbk1vNXkzTzFLelgwZDhDUkhBVmE4OFNyVjFhNUpJaVJldjNvU3RJcXd2NXh1WmxkYWc2VHI4dz09In0="); + $paymentOne = new AnetAPI\PaymentType(); + $paymentOne->setOpaqueData($op); + + //create a transaction + $transactionRequestType = new AnetAPI\TransactionRequestType(); + $transactionRequestType->setTransactionType( "authCaptureTransaction"); + $transactionRequestType->setAmount(151); + $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) + { + $tresponse = $response->getTransactionResponse(); + + if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + { + echo " AUTH CODE : " . $tresponse->getAuthCode() . "\n"; + echo " TRANS ID : " . $tresponse->getTransId() . "\n"; + } + else + { + echo "ERROR : Invalid response\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; + } + } + else + { + echo "Null response"; + } + return $response; +} + +if(!defined('DONT_RUN_SAMPLES')) + createAnAndroidPayTransaction(); +?> diff --git a/ApplePayTransactions/create-an-apple-pay-transaction.php b/MobileInAppTransactions/create-an-apple-pay-transaction.php similarity index 100% rename from ApplePayTransactions/create-an-apple-pay-transaction.php rename to MobileInAppTransactions/create-an-apple-pay-transaction.php diff --git a/SampleCodeList.txt b/SampleCodeList.txt index 1148f89..7e8db67 100644 --- a/SampleCodeList.txt +++ b/SampleCodeList.txt @@ -5,6 +5,8 @@ CreateSubscriptionFromCustomerProfile,1,1 GetCustomerPaymentProfileList,0,1 GetTransactionList,0,1 CreateAnApplePayTransaction,0,0 +CreateAnAcceptTransaction,0,0 +CreateAnAndroidPayTransaction,0,0 DecryptVisaCheckoutData,0,1 CreateVisaCheckoutTransaction,0,0 CaptureFundsAuthorizedThroughAnotherChannel,1,1 @@ -49,4 +51,4 @@ GetSubscription,1,1 UpdateSubscription,1,1 CreateCustomerProfile,1,1 CreateCustomerPaymentProfile,1,1 -ValidateCustomerPaymentProfile,1,0 \ No newline at end of file +ValidateCustomerPaymentProfile,1,0 diff --git a/test-runner.php b/test-runner.php index eb7d849..1d82ce6 100644 --- a/test-runner.php +++ b/test-runner.php @@ -17,7 +17,7 @@ 'PaypalExpressCheckout/', 'PaymentTransactions/', 'TransactionReporting/', - 'ApplePayTransactions/', + 'MobileInAppTransactions/', 'VisaCheckout/' ); From 46d6fe5a07051bb273317b3eab6001cc4016b906 Mon Sep 17 00:00:00 2001 From: ashtru Date: Mon, 22 Aug 2016 16:10:12 +0530 Subject: [PATCH 100/287] using latest sdk version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4a259cb..422a735 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "php": ">=5.5", "ext-curl": "*", "phpunit/phpunit": "~4.0", - "authorizenet/authorizenet": "1.8.9", + "authorizenet/authorizenet": "1.9.0", "jms/serializer": "serializer-master-dev as 1.0" }, "repositories": [{ From c3bea7eec9a337784ae3f59270d6b16de3d2c7cc Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Wed, 24 Aug 2016 17:01:24 +0530 Subject: [PATCH 101/287] Rename MobileInAppTransactions/create-an-accept-transaction.php to MobileInappTransactions/create-an-accept-transaction.php --- .../create-an-accept-transaction.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {MobileInAppTransactions => MobileInappTransactions}/create-an-accept-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 From 63039e5eb60c514f7eccb9fb6c03c405624e20e2 Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Wed, 24 Aug 2016 17:01:47 +0530 Subject: [PATCH 102/287] Rename MobileInAppTransactions/create-an-android-pay-transaction.php to MobileInappTransactions/create-an-android-pay-transaction.php --- .../create-an-android-pay-transaction.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {MobileInAppTransactions => MobileInappTransactions}/create-an-android-pay-transaction.php (100%) 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 From e5418d67cc15bbe7bc43df334db8b311b0f4b4c7 Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Wed, 24 Aug 2016 17:02:14 +0530 Subject: [PATCH 103/287] Rename MobileInAppTransactions/create-an-apple-pay-transaction.php to MobileInappTransactions/create-an-apple-pay-transaction.php --- .../create-an-apple-pay-transaction.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {MobileInAppTransactions => MobileInappTransactions}/create-an-apple-pay-transaction.php (100%) 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 03612c90c34b2f81cd3acb59bd44d1413692a460 Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Wed, 24 Aug 2016 17:06:55 +0530 Subject: [PATCH 104/287] 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 1d82ce6..35a76bf 100644 --- a/test-runner.php +++ b/test-runner.php @@ -17,7 +17,7 @@ 'PaypalExpressCheckout/', 'PaymentTransactions/', 'TransactionReporting/', - 'MobileInAppTransactions/', + 'MobileInappTransactions/', 'VisaCheckout/' ); From bb512d9fa5ac352d48a9d6f7e5d12acea65a60b2 Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Wed, 24 Aug 2016 17:12:15 +0530 Subject: [PATCH 105/287] Rename MobileInappTransactions/create-an-accept-transaction.php to MobileInAppTransactions/create-an-accept-transaction.php --- .../create-an-accept-transaction.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {MobileInappTransactions => MobileInAppTransactions}/create-an-accept-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 From ef856ace197452b7ede86333e046e577bda3019f Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Wed, 24 Aug 2016 17:12:35 +0530 Subject: [PATCH 106/287] Rename MobileInappTransactions/create-an-android-pay-transaction.php to MobileInAppTransactions/create-an-android-pay-transaction.php --- .../create-an-android-pay-transaction.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {MobileInappTransactions => MobileInAppTransactions}/create-an-android-pay-transaction.php (100%) 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 From d5bd779d8893f016d9a7b41e9c0064e863d8e13b Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Wed, 24 Aug 2016 17:13:20 +0530 Subject: [PATCH 107/287] Rename MobileInappTransactions/create-an-apple-pay-transaction.php to MobileInAppTransactions/create-an-apple-pay-transaction.php --- .../create-an-apple-pay-transaction.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {MobileInappTransactions => MobileInAppTransactions}/create-an-apple-pay-transaction.php (100%) 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 d6869e65c28ef595aa82d0eeb569df3c1ed08a5d Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Wed, 24 Aug 2016 18:26:37 +0530 Subject: [PATCH 108/287] Rename MobileInAppTransactions/create-an-accept-transaction.php to MobileInappTransactions/create-an-accept-transaction.php --- .../create-an-accept-transaction.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {MobileInAppTransactions => MobileInappTransactions}/create-an-accept-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 From a5b2cd41523e3a19f70b3d194d72ae225e0648d3 Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Wed, 24 Aug 2016 18:26:54 +0530 Subject: [PATCH 109/287] Rename MobileInAppTransactions/create-an-android-pay-transaction.php to MobileInappTransactions/create-an-android-pay-transaction.php --- .../create-an-android-pay-transaction.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {MobileInAppTransactions => MobileInappTransactions}/create-an-android-pay-transaction.php (100%) 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 From 4a4d422619bd150ed3258cb54fc9174901a0beef Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Wed, 24 Aug 2016 18:27:08 +0530 Subject: [PATCH 110/287] Rename MobileInAppTransactions/create-an-apple-pay-transaction.php to MobileInappTransactions/create-an-apple-pay-transaction.php --- .../create-an-apple-pay-transaction.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {MobileInAppTransactions => MobileInappTransactions}/create-an-apple-pay-transaction.php (100%) 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 cb2d1ae64445bad8a2fa948df99df5e492826b9f Mon Sep 17 00:00:00 2001 From: akankari Date: Fri, 26 Aug 2016 15:29:58 +0530 Subject: [PATCH 111/287] Changes for proper error handling in create Transaction requests --- .../create-an-accept-transaction.php | 40 +++++++-- .../create-an-android-pay-transaction.php | 36 ++++++-- .../create-an-apple-pay-transaction.php | 37 ++++++-- PaymentTransactions/authorize-credit-card.php | 46 +++++++--- ...nds-authorized-through-another-channel.php | 38 ++++++-- .../capture-previously-authorized-amount.php | 43 ++++++++-- PaymentTransactions/charge-credit-card.php | 46 +++++++--- .../charge-customer-profile.php | 50 ++++++++--- .../charge-tokenized-credit-card.php | 41 +++++++-- PaymentTransactions/credit-bank-account.php | 51 ++++++++--- PaymentTransactions/debit-bank-account.php | 54 ++++++++---- PaymentTransactions/refund-transaction.php | 43 ++++++++-- PaymentTransactions/void-transaction.php | 49 ++++++++--- .../authorization-and-capture-continue.php | 62 ++++++++----- .../authorization-and-capture.php | 57 +++++++++--- .../authorization-only-continued.php | 43 +++++++--- PaypalExpressCheckout/authorization-only.php | 39 +++++++-- PaypalExpressCheckout/credit.php | 33 ++++++- PaypalExpressCheckout/get-details.php | 86 +++++++++++-------- .../prior-authorization-capture.php | 40 +++++++-- PaypalExpressCheckout/void.php | 42 +++++++-- .../create-visa-checkout-transaction.php | 44 ++++++++-- constants/Constants.php | 4 +- 23 files changed, 783 insertions(+), 241 deletions(-) diff --git a/MobileInappTransactions/create-an-accept-transaction.php b/MobileInappTransactions/create-an-accept-transaction.php index 1d3368b..ff0e12e 100644 --- a/MobileInappTransactions/create-an-accept-transaction.php +++ b/MobileInappTransactions/create-an-accept-transaction.php @@ -34,24 +34,48 @@ function createAnAcceptTransaction(){ if ($response != null) { + if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) + { $tresponse = $response->getTransactionResponse(); - - if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) + { + 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 " AUTH CODE : " . $tresponse->getAuthCode() . "\n"; - echo " TRANS ID : " . $tresponse->getTransId() . "\n"; + 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 : Invalid response\n"; - $errorMessages = $response->getMessages()->getMessage(); - echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; + echo " Error code : " . $response->getMessages()->getMessage()[0]->getCode() . "\n"; + echo " Error message : " . $response->getMessages()->getMessage()[0]->getText() . "\n"; } + } } else { - echo "Null response"; + echo "No response returned \n"; } + return $response; } diff --git a/MobileInappTransactions/create-an-android-pay-transaction.php b/MobileInappTransactions/create-an-android-pay-transaction.php index b1a6685..3c1fe85 100644 --- a/MobileInappTransactions/create-an-android-pay-transaction.php +++ b/MobileInappTransactions/create-an-android-pay-transaction.php @@ -34,24 +34,48 @@ function createAnAndroidPayTransaction(){ if ($response != null) { + if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) + { $tresponse = $response->getTransactionResponse(); - - if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) { 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 : Invalid response\n"; - $errorMessages = $response->getMessages()->getMessage(); - echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; + echo " Error code : " . $response->getMessages()->getMessage()[0]->getCode() . "\n"; + echo " Error message : " . $response->getMessages()->getMessage()[0]->getText() . "\n"; } + } } else { - echo "Null response"; + echo "No response returned \n"; } + return $response; } diff --git a/MobileInappTransactions/create-an-apple-pay-transaction.php b/MobileInappTransactions/create-an-apple-pay-transaction.php index b01dbcd..b37be2a 100644 --- a/MobileInappTransactions/create-an-apple-pay-transaction.php +++ b/MobileInappTransactions/create-an-apple-pay-transaction.php @@ -32,26 +32,51 @@ function createAnApplePayTransaction(){ $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->getResponseCode()=="1") ) + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) { 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 "ERROR : Invalid response\n"; - $errorMessages = $response->getMessages()->getMessage(); - echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; + 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 "Null response"; + echo "No response returned \n"; } + return $response; } diff --git a/PaymentTransactions/authorize-credit-card.php b/PaymentTransactions/authorize-credit-card.php index 4179620..87c0450 100644 --- a/PaymentTransactions/authorize-credit-card.php +++ b/PaymentTransactions/authorize-credit-card.php @@ -37,25 +37,51 @@ function authorizeCreditCard($amount){ if ($response != null) { - $tresponse = $response->getTransactionResponse(); - - if (($tresponse != null) && ($tresponse->getResponseCode()== \SampleCode\Constants::RESPONSE_OK) ) + if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { - echo " AUTH CODE : " . $tresponse->getAuthCode() . "\n"; - echo " TRANS ID : " . $tresponse->getTransId() . "\n"; + $tresponse = $response->getTransactionResponse(); + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) + { + echo " Successfully created a transaction with 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 "ERROR : " . $tresponse->getResponseCode() . "\n"; - } - + echo "Transaction Failed \n"; + $tresponse = $response->getTransactionResponse(); + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\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"; + echo "No response returned \n"; } + return $response; } if(!defined('DONT_RUN_SAMPLES')) - authorizeCreditCard( \SampleCode\Constants::SAMPLE_AMOUNT); + authorizeCreditCard( 23.32); ?> \ 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 5baf471..abc5a89 100644 --- a/PaymentTransactions/capture-funds-authorized-through-another-channel.php +++ b/PaymentTransactions/capture-funds-authorized-through-another-channel.php @@ -27,7 +27,6 @@ function captureFundsAuthorizedThroughAnotherChannel($amount){ //Auth code of the previously authorized amount $transactionRequestType->setAuthCode("ROHNFQ"); - $request = new AnetAPI\CreateTransactionRequest(); $request->setMerchantAuthentication($merchantAuthentication); $request->setTransactionRequest( $transactionRequestType); @@ -37,25 +36,50 @@ function captureFundsAuthorizedThroughAnotherChannel($amount){ if ($response != null) { + if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) + { $tresponse = $response->getTransactionResponse(); - if (($tresponse != null) && ($tresponse->getResponseCode()== \SampleCode\Constants::RESPONSE_OK) ) + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) { echo "Successful." . "\n"; echo "Capture funds authorized through another channel TRANS ID : " . $tresponse->getTransId() . " Amount : $amount \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 "Capture funds authorized through another channel ERROR: Invalid response\n"; - $errorMessages = $response->getMessages()->getMessage(); - echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; + echo " Error code : " . $response->getMessages()->getMessage()[0]->getCode() . "\n"; + echo " Error message : " . $response->getMessages()->getMessage()[0]->getText() . "\n"; } + } } else { - echo "Capture funds authorized through another channel, NULL Response Error\n"; + echo "No response returned \n"; } + return $response; } if(!defined('DONT_RUN_SAMPLES')) - captureFundsAuthorizedThroughAnotherChannel((rand(1, 99999)/12*12)); + captureFundsAuthorizedThroughAnotherChannel((rand(1, 999)/12*12)); ?> diff --git a/PaymentTransactions/capture-previously-authorized-amount.php b/PaymentTransactions/capture-previously-authorized-amount.php index b3466d8..7d177f1 100644 --- a/PaymentTransactions/capture-previously-authorized-amount.php +++ b/PaymentTransactions/capture-previously-authorized-amount.php @@ -28,23 +28,50 @@ function capturePreviouslyAuthorizedAmount($transactionid){ if ($response != null) { - $tresponse = $response->getTransactionResponse(); - if (($tresponse != null) && ($tresponse->getResponseCode()== \SampleCode\Constants::RESPONSE_OK) ) + if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { - echo "Successful." . "\n"; - echo "Capture Previously Authorized Amount, Trans ID : " . $tresponse->getRefTransId() . "\n"; + $tresponse = $response->getTransactionResponse(); + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) + { + echo "Successful." . "\n"; + echo "Capture Previously Authorized Amount, Trans ID : " . $tresponse->getRefTransId() . "\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 " Capture Previously Authorized Amount: Invalid response\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 "Capture Previously Authorized Amount, NULL Response Error\n"; + echo "No response returned \n"; } + return $response; } if(!defined('DONT_RUN_SAMPLES')) - capturePreviouslyAuthorizedAmount(2249839471); + capturePreviouslyAuthorizedAmount(60007076002); ?> diff --git a/PaymentTransactions/charge-credit-card.php b/PaymentTransactions/charge-credit-card.php index 759c3f0..1116250 100644 --- a/PaymentTransactions/charge-credit-card.php +++ b/PaymentTransactions/charge-credit-card.php @@ -38,25 +38,51 @@ function chargeCreditCard($amount){ $controller = new AnetController\CreateTransactionController($request); $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - if ($response != null) - { - $tresponse = $response->getTransactionResponse(); - if (($tresponse != null) && ($tresponse->getResponseCode()== \SampleCode\Constants::RESPONSE_OK) ) + if ($response != null) + { + if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { - echo "Charge Credit Card AUTH CODE : " . $tresponse->getAuthCode() . "\n"; - echo "Charge Credit Card TRANS ID : " . $tresponse->getTransId() . "\n"; + $tresponse = $response->getTransactionResponse(); + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) + { + 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"; + } + } } else { - echo "Charge Credit Card ERROR : Invalid response\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 "Charge Credit card Null response returned"; + echo "No response returned \n"; } + return $response; } if(!defined('DONT_RUN_SAMPLES')) diff --git a/PaymentTransactions/charge-customer-profile.php b/PaymentTransactions/charge-customer-profile.php index 691dc80..1a69ff1 100644 --- a/PaymentTransactions/charge-customer-profile.php +++ b/PaymentTransactions/charge-customer-profile.php @@ -18,7 +18,6 @@ function chargeCustomerProfile($profileid, $paymentprofileid, $amount){ $paymentProfile->setPaymentProfileId($paymentprofileid); $profileToCharge->setPaymentProfile($paymentProfile); - $transactionRequestType = new AnetAPI\TransactionRequestType(); $transactionRequestType->setTransactionType( "authCaptureTransaction"); $transactionRequestType->setAmount($amount); @@ -30,30 +29,55 @@ function chargeCustomerProfile($profileid, $paymentprofileid, $amount){ $request->setTransactionRequest( $transactionRequestType); $controller = new AnetController\CreateTransactionController($request); $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + if ($response != null) { - $tresponse = $response->getTransactionResponse(); - if (($tresponse != null) && ($tresponse->getResponseCode()== \SampleCode\Constants::RESPONSE_OK) ) - { - echo "Charge Customer Profile APPROVED :" . "\n"; - echo " Charge Customer Profile AUTH CODE : " . $tresponse->getAuthCode() . "\n"; - echo " Charge Customer Profile TRANS ID : " . $tresponse->getTransId() . "\n"; - } - elseif (($tresponse != null) && ($tresponse->getResponseCode()=="2") ) + if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { - echo "ERROR" . "\n"; + $tresponse = $response->getTransactionResponse(); + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) + { + echo "Charge Customer Profile APPROVED :" . "\n"; + echo " Charge Customer Profile AUTH CODE : " . $tresponse->getAuthCode() . "\n"; + echo " Charge Customer Profile 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"; + } + } } - elseif (($tresponse != null) && ($tresponse->getResponseCode()=="4") ) + else { - echo "ERROR: HELD FOR REVIEW:" . "\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"; + echo "No response returned \n"; } + return $response; } + if(!defined('DONT_RUN_SAMPLES')) chargeCustomerProfile("36731856","32689274",12.23); ?> diff --git a/PaymentTransactions/charge-tokenized-credit-card.php b/PaymentTransactions/charge-tokenized-credit-card.php index 19537a1..34bf0ea 100644 --- a/PaymentTransactions/charge-tokenized-credit-card.php +++ b/PaymentTransactions/charge-tokenized-credit-card.php @@ -38,21 +38,48 @@ function chargeTokenizedCreditCard($amount){ if ($response != null) { - $tresponse = $response->getTransactionResponse(); - if (($tresponse != null) && ($tresponse->getResponseCode()== \SampleCode\Constants::RESPONSE_OK) ) + if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { - echo "Charge Tokenized Credit Card AUTH CODE : " . $tresponse->getAuthCode() . "\n"; - echo "Charge Tokenized Credit Card TRANS ID : " . $tresponse->getTransId() . "\n"; + $tresponse = $response->getTransactionResponse(); + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) + { + 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 "Charge Tokenized Credit Card ERROR : Invalid response\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 "Charge Tokenized Credit Card Null response returned"; + echo "No response returned \n"; } + return $response; } if(!defined('DONT_RUN_SAMPLES')) diff --git a/PaymentTransactions/credit-bank-account.php b/PaymentTransactions/credit-bank-account.php index 63d86e5..e973075 100644 --- a/PaymentTransactions/credit-bank-account.php +++ b/PaymentTransactions/credit-bank-account.php @@ -38,28 +38,53 @@ function creditBankAccount($amount){ $request->setTransactionRequest( $transactionRequestType); $controller = new AnetController\CreateTransactionController($request); $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + + if ($response != null) { - $tresponse = $response->getTransactionResponse(); - if (($tresponse != null) && ($tresponse->getResponseCode()== \SampleCode\Constants::RESPONSE_OK) ) - { - echo "Credit Bank Account APPROVED :" . "\n"; - echo "Credit Bank Account AUTH CODE : " . $tresponse->getAuthCode() . "\n"; - echo "Credit Bank Account TRANS ID : " . $tresponse->getTransId() . "\n"; - } - elseif (($tresponse != null) && ($tresponse->getResponseCode()=="2") ) + if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { - echo "Credit Bank Account ERROR : DECLINED" . "\n"; + $tresponse = $response->getTransactionResponse(); + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) + { + 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"; + } + } } - elseif (($tresponse != null) && ($tresponse->getResponseCode()=="4") ) + else { - echo "Credit Bank Account ERROR: HELD FOR REVIEW:" . "\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 "Credit Bank Account No response returned"; + echo "No response returned \n"; } + return $response; } if(!defined('DONT_RUN_SAMPLES')) diff --git a/PaymentTransactions/debit-bank-account.php b/PaymentTransactions/debit-bank-account.php index 79ec013..866d0ff 100644 --- a/PaymentTransactions/debit-bank-account.php +++ b/PaymentTransactions/debit-bank-account.php @@ -38,34 +38,52 @@ function debitBankAccount($amount){ $request->setTransactionRequest( $transactionRequestType); $controller = new AnetController\CreateTransactionController($request); $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + if ($response != null) { - $tresponse = $response->getTransactionResponse(); - if (($tresponse != null) && ($tresponse->getResponseCode()== \SampleCode\Constants::RESPONSE_OK) ) - { - echo "Debit Bank Account APPROVED :" . "\n"; - echo " Debit Bank Account AUTH CODE : " . $tresponse->getAuthCode() . "\n"; - echo " Debit Banlk Account TRANS ID : " . $tresponse->getTransId() . "\n"; - } - elseif (($tresponse != null) && ($tresponse->getResponseCode()=="2") ) + if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { - echo "Debit Bank Account ERROR : DECLINED" . "\n"; - $errorMessages = $tresponse->getErrors(); - echo "Error : " . $errorMessages[0]->getErrorText() . "\n"; - } - elseif (($tresponse != null) && ($tresponse->getResponseCode()=="4") ) - { - echo "Debit Bank Account ERROR: HELD FOR REVIEW:" . "\n"; + $tresponse = $response->getTransactionResponse(); + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) + { + 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 " 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 "Debit Bank Account 3 response returned"; - } + 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 "Debit Bank Account Null response returned"; + echo "No response returned \n"; } + return $response; } if(!defined('DONT_RUN_SAMPLES')) diff --git a/PaymentTransactions/refund-transaction.php b/PaymentTransactions/refund-transaction.php index b30380b..313e8b6 100644 --- a/PaymentTransactions/refund-transaction.php +++ b/PaymentTransactions/refund-transaction.php @@ -10,7 +10,7 @@ function refundTransaction($amount){ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); - $refId = 'ref' . time(); + $refId = 'ref' . time(); // Create the payment data for a credit card $creditCard = new AnetAPI\CreditCardType(); @@ -31,23 +31,50 @@ function refundTransaction($amount){ $request->setTransactionRequest( $transactionRequest); $controller = new AnetController\CreateTransactionController($request); $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + if ($response != null) { - $tresponse = $response->getTransactionResponse(); - if (($tresponse != null) && ($tresponse->getResponseCode()== \SampleCode\Constants::RESPONSE_OK) ) + if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { - echo "Refund SUCCESS: " . $tresponse->getTransId() . "\n"; + $tresponse = $response->getTransactionResponse(); + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) + { + echo "Refund SUCCESS: " . $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 "Refund ERROR : " . $tresponse->getResponseCode() . "\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 "Refund Null response returned"; + echo "No response returned \n"; } + return $response; } if(!defined('DONT_RUN_SAMPLES')) diff --git a/PaymentTransactions/void-transaction.php b/PaymentTransactions/void-transaction.php index 15a5922..b848059 100644 --- a/PaymentTransactions/void-transaction.php +++ b/PaymentTransactions/void-transaction.php @@ -10,7 +10,7 @@ function voidTransaction($transactionid){ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); - $refId = 'ref' . time(); + $refId = 'ref' . time(); // Create the payment data for a credit card $creditCard = new AnetAPI\CreditCardType(); @@ -26,30 +26,55 @@ function voidTransaction($transactionid){ $request = new AnetAPI\CreateTransactionRequest(); $request->setMerchantAuthentication($merchantAuthentication); - $request->setRefId($refId); + $request->setRefId($refId); $request->setTransactionRequest( $transactionRequestType); $controller = new AnetController\CreateTransactionController($request); $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + if ($response != null) { - $tresponse = $response->getTransactionResponse(); - if (($tresponse != null) && ($tresponse->getResponseCode()== \SampleCode\Constants::RESPONSE_OK) ) + if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { - echo "Void transaction SUCCESS AUTH CODE: " . $tresponse->getAuthCode() . "\n"; - echo "Void transaction SUCCESS TRANS ID : " . $tresponse->getTransId() . "\n"; + $tresponse = $response->getTransactionResponse(); + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) + { + echo "Void transaction SUCCESS AUTH CODE: " . $tresponse->getAuthCode() . "\n"; + echo "Void transaction SUCCESS 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 "void transaction ERROR : " . $tresponse->getResponseCode() . "\n"; - $errorMessages = $response->getMessages()->getMessage(); - echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; - //use print_r to see whole $response which will have the specific error messages - } + 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 "Void transaction Null esponse returned"; + echo "No response returned \n"; } + return $response; } if(!defined('DONT_RUN_SAMPLES')) diff --git a/PaypalExpressCheckout/authorization-and-capture-continue.php b/PaypalExpressCheckout/authorization-and-capture-continue.php index 6be5f75..f21ebab 100644 --- a/PaypalExpressCheckout/authorization-and-capture-continue.php +++ b/PaypalExpressCheckout/authorization-and-capture-continue.php @@ -30,32 +30,52 @@ function payPalAuthorizeCaptureContinue($refTransId, $payerID) { $controller = new AnetController\CreateTransactionController($request); $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - if ($response != null) - { - $tresponse = $response->getTransactionResponse(); - if (($tresponse != null)) - { + if ($response != null) + { + if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) + { + $tresponse = $response->getTransactionResponse(); + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) + { echo "Transaction Response...\n"; echo "Received 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"; - } - else - echo "NULL transactionResponse Error\n"; - $messages=$response->getMessages(); - if (($messages != null)) - { - echo "Messages...\n"; - echo "Result code: ".$messages->getResultCode()."\n"; - $errorMessages = $messages->getMessage(); - echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; - } - else - echo "NULL messages Error\n"; - } - else - echo "NULL response Error\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; } diff --git a/PaypalExpressCheckout/authorization-and-capture.php b/PaypalExpressCheckout/authorization-and-capture.php index b3cf013..d3e048a 100644 --- a/PaypalExpressCheckout/authorization-and-capture.php +++ b/PaypalExpressCheckout/authorization-and-capture.php @@ -31,25 +31,58 @@ function payPalAuthorizeCapture($amount) { $controller = new AnetController\CreateTransactionController($request); $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - if ($response != null) - { - $tresponse = $response->getTransactionResponse(); - if (($tresponse != null)) - { + if ($response != null) + { + if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) + { + $tresponse = $response->getTransactionResponse(); + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) + { echo "Received 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"; - } - else - echo "NULL transactionResponse Error\n"; - } - else - echo "NULL response Error\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(); + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\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')) - payPalAuthorizeCapture(12.23); + payPalAuthorizeCapture(12.322); ?> diff --git a/PaypalExpressCheckout/authorization-only-continued.php b/PaypalExpressCheckout/authorization-only-continued.php index e5c2711..2865720 100644 --- a/PaypalExpressCheckout/authorization-only-continued.php +++ b/PaypalExpressCheckout/authorization-only-continued.php @@ -41,24 +41,45 @@ function payPalAuthorizeOnlyContinue($transactionId, $payerId) { if ($response != null) { - $tresponse = $response->getTransactionResponse(); - - if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { - //echo " RESULT CODE : " . $response->getResultCode() . "\n"; - echo " TRANS ID : " . $tresponse->getTransId() . "\n"; - echo "Payer ID : " . $tresponse->getSecureAcceptance()->getPayerID(); + $tresponse = $response->getTransactionResponse(); + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) + { + 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 { - //print_r($tresponse); - echo "ERROR : " . $tresponse->getResponseCode() . "\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"; + echo "No response returned \n"; } return $response; diff --git a/PaypalExpressCheckout/authorization-only.php b/PaypalExpressCheckout/authorization-only.php index 3928890..6628cfc 100644 --- a/PaypalExpressCheckout/authorization-only.php +++ b/PaypalExpressCheckout/authorization-only.php @@ -34,21 +34,50 @@ function payPalAuthorizeOnly($amount) { $controller = new AnetController\CreateTransactionController($request); $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - if (($response != null)) + if ($response != null) { + if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) + { $tresponse = $response->getTransactionResponse(); - if (($tresponse != null)&& ($response->getMessages()->getResultCode()=="Ok")) + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) { echo "Received response code: ".$tresponse->getResponseCode()."\n"; //Valid response codes: 1=Approved, 2=Declined, 3=Error, 5=Need Payer Consent\n"; echo "Secure acceptance URL: ".$tresponse->getSecureAcceptance()->getSecureAcceptanceUrl()."\n"; + echo " Code : " . $tresponse->getMessages()[0]->getCode() . "\n"; + echo " Description : " . $tresponse->getMessages()[0]->getDescription() . "\n"; } - else{ - echo "ERROR : " . $tresponse->getResponseCode() . "\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 "NULL response Error\n"; + { + echo "No response returned \n"; + } return $response; } diff --git a/PaypalExpressCheckout/credit.php b/PaypalExpressCheckout/credit.php index 8e84885..4b8ba4a 100644 --- a/PaypalExpressCheckout/credit.php +++ b/PaypalExpressCheckout/credit.php @@ -42,21 +42,46 @@ function payPalCredit($transactionId) { if ($response != null) { + if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) + { $tresponse = $response->getTransactionResponse(); - - if (($tresponse != null)&& ($response->getMessages()->getResultCode()=="Ok")) + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) { echo "Credit SUCCESS AUTH CODE : " . $tresponse->getAuthCode() . "\n"; echo "Credit 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 "Credit ERROR : " . $tresponse->getResponseCode() . "\n"; + echo " Error code : " . $response->getMessages()->getMessage()[0]->getCode() . "\n"; + echo " Error message : " . $response->getMessages()->getMessage()[0]->getText() . "\n"; } + } } else { - echo "No response returned"; + echo "No response returned \n"; } return $response; diff --git a/PaypalExpressCheckout/get-details.php b/PaypalExpressCheckout/get-details.php index 32f0d45..a8958b6 100644 --- a/PaypalExpressCheckout/get-details.php +++ b/PaypalExpressCheckout/get-details.php @@ -46,55 +46,67 @@ function payPalGetDetails($transactionId) { if ($response != null) { - $tresponse = $response->getTransactionResponse(); - - if($tresponse != null) + if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { - if (($tresponse != null) && ($response->getMessages()->getResultCode()=="Ok")) - { - echo "Transaction Response...\n"; - echo "Received response code: ".$tresponse->getResponseCode()."\n"; - echo "Transaction ID: ".$tresponse->getTransId()."\n"; - //Valid response codes: 1=Approved, 2=Declined, 3=Error, 5=Need Payer Consent - if(null != $tresponse->getSecureAcceptance()) - { - echo "Payer ID : " . $tresponse->getSecureAcceptance()->getPayerID() . "\n"; - } - //parse the shipping information from response - $shipping_response = $tresponse->getShipTo(); - if(null != $shipping_response) - { - echo "Shipping address : " . $shipping_response->getAddress() . ", " . $shipping_response->getCity() - . ", " . $shipping_response->getState() . ", " . $shipping_response->getCountry() . "\n"; - } - } - else - echo "NULL transactionResponse Error\n"; - $messages=$response->getMessages(); - if (($messages != null)) - { - echo "Messages...\n"; - echo "Result code: ".$messages->getResultCode()."\n"; - $errorMessages = $messages->getMessage(); - echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; - } - else - echo "NULL messages Error\n"; + $tresponse = $response->getTransactionResponse(); + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) + { + echo "Transaction Response...\n"; + echo "Received response code: ".$tresponse->getResponseCode()."\n"; + echo "Transaction ID: ".$tresponse->getTransId()."\n"; + //Valid response codes: 1=Approved, 2=Declined, 3=Error, 5=Need Payer Consent + if(null != $tresponse->getSecureAcceptance()) + { + echo "Payer ID : " . $tresponse->getSecureAcceptance()->getPayerID() . "\n"; + } + + //parse the shipping information from response + $shipping_response = $tresponse->getShipTo(); + if(null != $shipping_response) + { + echo "Shipping address : " . $shipping_response->getAddress() . ", " . $shipping_response->getCity() + . ", " . $shipping_response->getState() . ", " . $shipping_response->getCountry() . "\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 "No response returned"; - } + 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"; + echo "No response returned \n"; } return $response; } if(!defined('DONT_RUN_SAMPLES')) - payPalGetDetails("2249863278"); + payPalGetDetails("60007107304"); ?> \ No newline at end of file diff --git a/PaypalExpressCheckout/prior-authorization-capture.php b/PaypalExpressCheckout/prior-authorization-capture.php index 3c0bb24..912f64f 100644 --- a/PaypalExpressCheckout/prior-authorization-capture.php +++ b/PaypalExpressCheckout/prior-authorization-capture.php @@ -35,21 +35,47 @@ function payPalPriorAuthorizationCapture($transactionId) { $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) + if ($response != null) { - $tresponse = $response->getTransactionResponse(); - if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { - echo "Prior Authorization capture AUTH CODE : " . $tresponse->getAuthCode() . "\n"; + $tresponse = $response->getTransactionResponse(); + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) + { + echo "Prior Authorization capture AUTH CODE : " . $tresponse->getAuthCode() . "\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 "Prior Authorization capture ERROR : Invalid response\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 "PriorAuthorizationCapture ERROR : Invalid response\n"; + echo "No response returned \n"; } return $response; diff --git a/PaypalExpressCheckout/void.php b/PaypalExpressCheckout/void.php index 4509e14..7415c86 100644 --- a/PaypalExpressCheckout/void.php +++ b/PaypalExpressCheckout/void.php @@ -33,22 +33,48 @@ function payPalVoid($transactionId) { $controller = new AnetController\CreateTransactionController($request); $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); - - if ($response != null) + + if ($response != null) { - $tresponse = $response->getTransactionResponse(); - if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { - echo "Void transaction SUCCESS TRANS ID : " . $tresponse->getTransId() . "\n"; + $tresponse = $response->getTransactionResponse(); + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) + { + echo "Void transaction SUCCESS 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 "Void transaction ERROR : " . $tresponse->getResponseCode() . "\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 "Void transaction Null esponse returned"; + echo "No response returned \n"; } return $response; diff --git a/VisaCheckout/create-visa-checkout-transaction.php b/VisaCheckout/create-visa-checkout-transaction.php index 1e32a68..223af3b 100644 --- a/VisaCheckout/create-visa-checkout-transaction.php +++ b/VisaCheckout/create-visa-checkout-transaction.php @@ -24,7 +24,7 @@ function createVisaCheckoutTransaction(){ //create a transaction $transactionRequestType = new AnetAPI\TransactionRequestType(); $transactionRequestType->setTransactionType( "authCaptureTransaction"); - $transactionRequestType->setAmount(151); + $transactionRequestType->setAmount(76); $transactionRequestType->setCallId("9004180129978687101"); $transactionRequestType->setPayment($paymentOne); @@ -38,22 +38,48 @@ function createVisaCheckoutTransaction(){ if ($response != null) { - $tresponse = $response->getTransactionResponse(); - - if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) + if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { - echo " AUTH CODE : " . $tresponse->getAuthCode() . "\n"; - echo " TRANS ID : " . $tresponse->getTransId() . "\n"; + $tresponse = $response->getTransactionResponse(); + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) + { + 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 "BAD NEWS : " . $tresponse->getResponseCode() . "\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 "REALLY BAD NEWS : "; + echo "No response returned \n"; } + return $response; } diff --git a/constants/Constants.php b/constants/Constants.php index 581e482..d1ce2da 100644 --- a/constants/Constants.php +++ b/constants/Constants.php @@ -7,13 +7,15 @@ class Constants const MERCHANT_LOGIN_ID = "5KP3u95bQpv"; const MERCHANT_TRANSACTION_KEY = "346HZ32z3fP4hTG2"; - const RESPONSE_OK = "1"; + const RESPONSE_OK = "Ok"; //Recurring Billing const SUBSCRIPTION_ID_GET = "2930242"; //Transaction Reporting const TRANS_ID = "2238968786"; + + const SAMPLE_AMOUNT = "2.23"; } ?> From d0c1db8dd800cc6acd8f0918d572e8915ae4dab9 Mon Sep 17 00:00:00 2001 From: akankari Date: Mon, 29 Aug 2016 10:24:22 +0530 Subject: [PATCH 112/287] Correcting order of print statements --- .../create-an-accept-transaction.php | 3 ++- .../create-an-android-pay-transaction.php | 11 ++++++----- .../create-an-apple-pay-transaction.php | 11 ++++++----- PaymentTransactions/authorize-credit-card.php | 5 +++-- ...pture-funds-authorized-through-another-channel.php | 11 ++++++----- .../capture-previously-authorized-amount.php | 3 ++- PaymentTransactions/charge-credit-card.php | 3 ++- PaymentTransactions/charge-customer-profile.php | 3 ++- PaymentTransactions/charge-tokenized-credit-card.php | 3 ++- PaymentTransactions/credit-bank-account.php | 3 ++- PaymentTransactions/debit-bank-account.php | 3 ++- PaymentTransactions/refund-transaction.php | 3 ++- PaymentTransactions/void-transaction.php | 3 ++- .../authorization-and-capture-continue.php | 4 ++-- PaypalExpressCheckout/authorization-and-capture.php | 6 +++--- .../authorization-only-continued.php | 3 ++- PaypalExpressCheckout/authorization-only.php | 3 ++- PaypalExpressCheckout/credit.php | 3 ++- PaypalExpressCheckout/get-details.php | 3 ++- PaypalExpressCheckout/prior-authorization-capture.php | 3 ++- PaypalExpressCheckout/void.php | 3 ++- VisaCheckout/create-visa-checkout-transaction.php | 2 +- 22 files changed, 57 insertions(+), 38 deletions(-) diff --git a/MobileInappTransactions/create-an-accept-transaction.php b/MobileInappTransactions/create-an-accept-transaction.php index ff0e12e..670dbe5 100644 --- a/MobileInappTransactions/create-an-accept-transaction.php +++ b/MobileInappTransactions/create-an-accept-transaction.php @@ -37,9 +37,10 @@ function createAnAcceptTransaction(){ if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { $tresponse = $response->getTransactionResponse(); - echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + 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"; diff --git a/MobileInappTransactions/create-an-android-pay-transaction.php b/MobileInappTransactions/create-an-android-pay-transaction.php index 3c1fe85..ebd0176 100644 --- a/MobileInappTransactions/create-an-android-pay-transaction.php +++ b/MobileInappTransactions/create-an-android-pay-transaction.php @@ -37,13 +37,14 @@ function createAnAndroidPayTransaction(){ if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { $tresponse = $response->getTransactionResponse(); - echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) { - 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"; + 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 { diff --git a/MobileInappTransactions/create-an-apple-pay-transaction.php b/MobileInappTransactions/create-an-apple-pay-transaction.php index b37be2a..387d33f 100644 --- a/MobileInappTransactions/create-an-apple-pay-transaction.php +++ b/MobileInappTransactions/create-an-apple-pay-transaction.php @@ -38,13 +38,14 @@ function createAnApplePayTransaction(){ if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { $tresponse = $response->getTransactionResponse(); - echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) { - 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"; + 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 { diff --git a/PaymentTransactions/authorize-credit-card.php b/PaymentTransactions/authorize-credit-card.php index 87c0450..ea75b01 100644 --- a/PaymentTransactions/authorize-credit-card.php +++ b/PaymentTransactions/authorize-credit-card.php @@ -40,9 +40,10 @@ function authorizeCreditCard($amount){ if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { $tresponse = $response->getTransactionResponse(); - echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + 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 " Code : " . $tresponse->getMessages()[0]->getCode() . "\n"; @@ -62,7 +63,7 @@ function authorizeCreditCard($amount){ { echo "Transaction Failed \n"; $tresponse = $response->getTransactionResponse(); - echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + if($tresponse != null && $tresponse->getErrors() != null) { echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; diff --git a/PaymentTransactions/capture-funds-authorized-through-another-channel.php b/PaymentTransactions/capture-funds-authorized-through-another-channel.php index abc5a89..791cc60 100644 --- a/PaymentTransactions/capture-funds-authorized-through-another-channel.php +++ b/PaymentTransactions/capture-funds-authorized-through-another-channel.php @@ -39,13 +39,14 @@ function captureFundsAuthorizedThroughAnotherChannel($amount){ if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { $tresponse = $response->getTransactionResponse(); - echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) { - echo "Successful." . "\n"; - echo "Capture funds authorized through another channel TRANS ID : " . $tresponse->getTransId() . " Amount : $amount \n"; - echo " Code : " . $tresponse->getMessages()[0]->getCode() . "\n"; - echo " Description : " . $tresponse->getMessages()[0]->getDescription() . "\n"; + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + echo "Successful." . "\n"; + echo "Capture funds authorized through another channel TRANS ID : " . $tresponse->getTransId() . " Amount : $amount \n"; + echo " Code : " . $tresponse->getMessages()[0]->getCode() . "\n"; + echo " Description : " . $tresponse->getMessages()[0]->getDescription() . "\n"; } else { diff --git a/PaymentTransactions/capture-previously-authorized-amount.php b/PaymentTransactions/capture-previously-authorized-amount.php index 7d177f1..0221eb6 100644 --- a/PaymentTransactions/capture-previously-authorized-amount.php +++ b/PaymentTransactions/capture-previously-authorized-amount.php @@ -31,9 +31,10 @@ function capturePreviouslyAuthorizedAmount($transactionid){ if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { $tresponse = $response->getTransactionResponse(); - echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) { + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; echo "Successful." . "\n"; echo "Capture Previously Authorized Amount, Trans ID : " . $tresponse->getRefTransId() . "\n"; echo " Code : " . $tresponse->getMessages()[0]->getCode() . "\n"; diff --git a/PaymentTransactions/charge-credit-card.php b/PaymentTransactions/charge-credit-card.php index 1116250..f80ee1d 100644 --- a/PaymentTransactions/charge-credit-card.php +++ b/PaymentTransactions/charge-credit-card.php @@ -44,9 +44,10 @@ function chargeCreditCard($amount){ if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { $tresponse = $response->getTransactionResponse(); - echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + 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"; diff --git a/PaymentTransactions/charge-customer-profile.php b/PaymentTransactions/charge-customer-profile.php index 1a69ff1..e90e41f 100644 --- a/PaymentTransactions/charge-customer-profile.php +++ b/PaymentTransactions/charge-customer-profile.php @@ -35,9 +35,10 @@ function chargeCustomerProfile($profileid, $paymentprofileid, $amount){ if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { $tresponse = $response->getTransactionResponse(); - echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) { + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; echo "Charge Customer Profile APPROVED :" . "\n"; echo " Charge Customer Profile AUTH CODE : " . $tresponse->getAuthCode() . "\n"; echo " Charge Customer Profile TRANS ID : " . $tresponse->getTransId() . "\n"; diff --git a/PaymentTransactions/charge-tokenized-credit-card.php b/PaymentTransactions/charge-tokenized-credit-card.php index 34bf0ea..72c4088 100644 --- a/PaymentTransactions/charge-tokenized-credit-card.php +++ b/PaymentTransactions/charge-tokenized-credit-card.php @@ -41,9 +41,10 @@ function chargeTokenizedCreditCard($amount){ if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { $tresponse = $response->getTransactionResponse(); - echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + 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"; diff --git a/PaymentTransactions/credit-bank-account.php b/PaymentTransactions/credit-bank-account.php index e973075..0ba4d07 100644 --- a/PaymentTransactions/credit-bank-account.php +++ b/PaymentTransactions/credit-bank-account.php @@ -45,9 +45,10 @@ function creditBankAccount($amount){ if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { $tresponse = $response->getTransactionResponse(); - echo " Transaction Response code : " . $tresponse->getResponseCode() . "\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"; diff --git a/PaymentTransactions/debit-bank-account.php b/PaymentTransactions/debit-bank-account.php index 866d0ff..e2d0fc6 100644 --- a/PaymentTransactions/debit-bank-account.php +++ b/PaymentTransactions/debit-bank-account.php @@ -44,9 +44,10 @@ function debitBankAccount($amount){ if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { $tresponse = $response->getTransactionResponse(); - echo " Transaction Response code : " . $tresponse->getResponseCode() . "\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 Banlk Account TRANS ID : " . $tresponse->getTransId() . "\n"; diff --git a/PaymentTransactions/refund-transaction.php b/PaymentTransactions/refund-transaction.php index 313e8b6..3de5edf 100644 --- a/PaymentTransactions/refund-transaction.php +++ b/PaymentTransactions/refund-transaction.php @@ -37,9 +37,10 @@ function refundTransaction($amount){ if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { $tresponse = $response->getTransactionResponse(); - echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) { + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; echo "Refund SUCCESS: " . $tresponse->getTransId() . "\n"; echo " Code : " . $tresponse->getMessages()[0]->getCode() . "\n"; echo " Description : " . $tresponse->getMessages()[0]->getDescription() . "\n"; diff --git a/PaymentTransactions/void-transaction.php b/PaymentTransactions/void-transaction.php index b848059..31b0f3c 100644 --- a/PaymentTransactions/void-transaction.php +++ b/PaymentTransactions/void-transaction.php @@ -36,9 +36,10 @@ function voidTransaction($transactionid){ if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { $tresponse = $response->getTransactionResponse(); - echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) { + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; echo "Void transaction SUCCESS AUTH CODE: " . $tresponse->getAuthCode() . "\n"; echo "Void transaction SUCCESS TRANS ID : " . $tresponse->getTransId() . "\n"; echo " Code : " . $tresponse->getMessages()[0]->getCode() . "\n"; diff --git a/PaypalExpressCheckout/authorization-and-capture-continue.php b/PaypalExpressCheckout/authorization-and-capture-continue.php index f21ebab..aff5f46 100644 --- a/PaypalExpressCheckout/authorization-and-capture-continue.php +++ b/PaypalExpressCheckout/authorization-and-capture-continue.php @@ -35,11 +35,11 @@ function payPalAuthorizeCaptureContinue($refTransId, $payerID) { if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { $tresponse = $response->getTransactionResponse(); - echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) { echo "Transaction Response...\n"; - echo "Received response code: ".$tresponse->getResponseCode()."\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"; diff --git a/PaypalExpressCheckout/authorization-and-capture.php b/PaypalExpressCheckout/authorization-and-capture.php index d3e048a..562bfeb 100644 --- a/PaypalExpressCheckout/authorization-and-capture.php +++ b/PaypalExpressCheckout/authorization-and-capture.php @@ -36,10 +36,10 @@ function payPalAuthorizeCapture($amount) { if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { $tresponse = $response->getTransactionResponse(); - echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) { - echo "Received response code: ".$tresponse->getResponseCode()."\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"; @@ -61,7 +61,7 @@ function payPalAuthorizeCapture($amount) { { echo "Transaction Failed \n"; $tresponse = $response->getTransactionResponse(); - echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + if($tresponse != null && $tresponse->getErrors() != null) { diff --git a/PaypalExpressCheckout/authorization-only-continued.php b/PaypalExpressCheckout/authorization-only-continued.php index 2865720..0664290 100644 --- a/PaypalExpressCheckout/authorization-only-continued.php +++ b/PaypalExpressCheckout/authorization-only-continued.php @@ -44,9 +44,10 @@ function payPalAuthorizeOnlyContinue($transactionId, $payerId) { if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { $tresponse = $response->getTransactionResponse(); - echo " Transaction Response code : " . $tresponse->getResponseCode() . "\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"; diff --git a/PaypalExpressCheckout/authorization-only.php b/PaypalExpressCheckout/authorization-only.php index 6628cfc..f95f47f 100644 --- a/PaypalExpressCheckout/authorization-only.php +++ b/PaypalExpressCheckout/authorization-only.php @@ -39,9 +39,10 @@ function payPalAuthorizeOnly($amount) { if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { $tresponse = $response->getTransactionResponse(); - echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) { + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; echo "Received response code: ".$tresponse->getResponseCode()."\n"; //Valid response codes: 1=Approved, 2=Declined, 3=Error, 5=Need Payer Consent\n"; echo "Secure acceptance URL: ".$tresponse->getSecureAcceptance()->getSecureAcceptanceUrl()."\n"; diff --git a/PaypalExpressCheckout/credit.php b/PaypalExpressCheckout/credit.php index 4b8ba4a..0a19fa8 100644 --- a/PaypalExpressCheckout/credit.php +++ b/PaypalExpressCheckout/credit.php @@ -45,9 +45,10 @@ function payPalCredit($transactionId) { if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { $tresponse = $response->getTransactionResponse(); - echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) { + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; echo "Credit SUCCESS AUTH CODE : " . $tresponse->getAuthCode() . "\n"; echo "Credit TRANS ID : " . $tresponse->getTransId() . "\n"; echo " Code : " . $tresponse->getMessages()[0]->getCode() . "\n"; diff --git a/PaypalExpressCheckout/get-details.php b/PaypalExpressCheckout/get-details.php index a8958b6..683f774 100644 --- a/PaypalExpressCheckout/get-details.php +++ b/PaypalExpressCheckout/get-details.php @@ -49,9 +49,10 @@ function payPalGetDetails($transactionId) { if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { $tresponse = $response->getTransactionResponse(); - echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) { + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; echo "Transaction Response...\n"; echo "Received response code: ".$tresponse->getResponseCode()."\n"; echo "Transaction ID: ".$tresponse->getTransId()."\n"; diff --git a/PaypalExpressCheckout/prior-authorization-capture.php b/PaypalExpressCheckout/prior-authorization-capture.php index 912f64f..679af87 100644 --- a/PaypalExpressCheckout/prior-authorization-capture.php +++ b/PaypalExpressCheckout/prior-authorization-capture.php @@ -40,9 +40,10 @@ function payPalPriorAuthorizationCapture($transactionId) { if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { $tresponse = $response->getTransactionResponse(); - echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) { + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; echo "Prior Authorization capture AUTH CODE : " . $tresponse->getAuthCode() . "\n"; echo " Code : " . $tresponse->getMessages()[0]->getCode() . "\n"; echo " Description : " . $tresponse->getMessages()[0]->getDescription() . "\n"; diff --git a/PaypalExpressCheckout/void.php b/PaypalExpressCheckout/void.php index 7415c86..bd3c67c 100644 --- a/PaypalExpressCheckout/void.php +++ b/PaypalExpressCheckout/void.php @@ -39,9 +39,10 @@ function payPalVoid($transactionId) { if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { $tresponse = $response->getTransactionResponse(); - echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) { + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; echo "Void transaction SUCCESS TRANS ID : " . $tresponse->getTransId() . "\n"; echo " Code : " . $tresponse->getMessages()[0]->getCode() . "\n"; echo " Description : " . $tresponse->getMessages()[0]->getDescription() . "\n"; diff --git a/VisaCheckout/create-visa-checkout-transaction.php b/VisaCheckout/create-visa-checkout-transaction.php index 223af3b..ff72a58 100644 --- a/VisaCheckout/create-visa-checkout-transaction.php +++ b/VisaCheckout/create-visa-checkout-transaction.php @@ -42,8 +42,8 @@ function createVisaCheckoutTransaction(){ { $tresponse = $response->getTransactionResponse(); echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; - 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"; From 9687d4c61756cd7a0b23c56c53abbcd5e74635b8 Mon Sep 17 00:00:00 2001 From: akankari Date: Mon, 29 Aug 2016 10:38:35 +0530 Subject: [PATCH 113/287] Fixing syntax error --- VisaCheckout/create-visa-checkout-transaction.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VisaCheckout/create-visa-checkout-transaction.php b/VisaCheckout/create-visa-checkout-transaction.php index ff72a58..f9debcf 100644 --- a/VisaCheckout/create-visa-checkout-transaction.php +++ b/VisaCheckout/create-visa-checkout-transaction.php @@ -41,7 +41,7 @@ function createVisaCheckoutTransaction(){ if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) { $tresponse = $response->getTransactionResponse(); - echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + if ($tresponse != null && $tresponse->getMessages() != null) { echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; echo " AUTH CODE : " . $tresponse->getAuthCode() . "\n"; From 0a8e0113301491275b3f0242570b6f6433cdabe5 Mon Sep 17 00:00:00 2001 From: brianmc Date: Wed, 28 Sep 2016 12:14:28 -0700 Subject: [PATCH 114/287] added Accept sample for Customer Profile creation --- ...ate-customer-profile-with-accept-nonce.php | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 CustomerProfiles/create-customer-profile-with-accept-nonce.php diff --git a/CustomerProfiles/create-customer-profile-with-accept-nonce.php b/CustomerProfiles/create-customer-profile-with-accept-nonce.php new file mode 100644 index 0000000..148b251 --- /dev/null +++ b/CustomerProfiles/create-customer-profile-with-accept-nonce.php @@ -0,0 +1,75 @@ +setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + $refId = 'ref' . time(); + + // 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 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 + + $paymentprofile = new AnetAPI\CustomerPaymentProfileType(); + + $paymentprofile->setCustomerType('individual'); + $paymentprofile->setBillTo($billto); + $paymentprofile->setPayment($paymentOne); + $paymentprofiles[] = $paymentprofile; + $customerprofile = new AnetAPI\CustomerProfileType(); + $customerprofile->setDescription("Customer Test PHP Accept Test"); + + $customerprofile->setMerchantCustomerId("M_".$email); + $customerprofile->setEmail($email); + $customerprofile->setPaymentProfiles($paymentprofiles); + + $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"); +?> From 4a882b41d7cea924457e638f02f1009519f15d6c Mon Sep 17 00:00:00 2001 From: Ashutosh Singh Date: Wed, 19 Oct 2016 12:15:48 +0530 Subject: [PATCH 115/287] Removed credit card from void request A void transaction request only requires the transaction id of the transaction to be cancelled. Unlike a refund request, void request does not need any credit card details. --- PaymentTransactions/void-transaction.php | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/PaymentTransactions/void-transaction.php b/PaymentTransactions/void-transaction.php index 31b0f3c..82af5ae 100644 --- a/PaymentTransactions/void-transaction.php +++ b/PaymentTransactions/void-transaction.php @@ -11,17 +11,10 @@ function voidTransaction($transactionid){ $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("2038-12"); - $paymentOne = new AnetAPI\PaymentType(); - $paymentOne->setCreditCard($creditCard); + //create a transaction $transactionRequestType = new AnetAPI\TransactionRequestType(); $transactionRequestType->setTransactionType( "voidTransaction"); - $transactionRequestType->setPayment($paymentOne); $transactionRequestType->setRefTransId($transactionid); $request = new AnetAPI\CreateTransactionRequest(); @@ -40,8 +33,8 @@ function voidTransaction($transactionid){ if ($tresponse != null && $tresponse->getMessages() != null) { echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; - echo "Void transaction SUCCESS AUTH CODE: " . $tresponse->getAuthCode() . "\n"; - echo "Void transaction SUCCESS TRANS ID : " . $tresponse->getTransId() . "\n"; + echo " Void transaction SUCCESS AUTH CODE: " . $tresponse->getAuthCode() . "\n"; + echo " Void transaction SUCCESS TRANS ID : " . $tresponse->getTransId() . "\n"; echo " Code : " . $tresponse->getMessages()[0]->getCode() . "\n"; echo " Description : " . $tresponse->getMessages()[0]->getDescription() . "\n"; } @@ -79,5 +72,5 @@ function voidTransaction($transactionid){ return $response; } if(!defined('DONT_RUN_SAMPLES')) - voidTransaction("2249063130"); + voidTransaction("60009605785"); ?> From b1455cb85c9db3b99eab9b77449012f3452f407d Mon Sep 17 00:00:00 2001 From: Ashutosh Singh Date: Wed, 19 Oct 2016 14:04:44 +0530 Subject: [PATCH 116/287] Renamed method name Unique method names are required by test-runner --- .../create-customer-profile-with-accept-nonce.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CustomerProfiles/create-customer-profile-with-accept-nonce.php b/CustomerProfiles/create-customer-profile-with-accept-nonce.php index 148b251..41ab983 100644 --- a/CustomerProfiles/create-customer-profile-with-accept-nonce.php +++ b/CustomerProfiles/create-customer-profile-with-accept-nonce.php @@ -5,7 +5,7 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function createCustomerProfile($email){ + function createCustomerProfileWithAcceptNonce($email){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); @@ -71,5 +71,5 @@ function createCustomerProfile($email){ return $response; } if(!defined('DONT_RUN_SAMPLES')) - createCustomerProfile("test123@test.com"); + createCustomerProfileWithAcceptNonce("test123@test.com"); ?> From 56ed30657684734e533c9dca8cbc5f0068372ed2 Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Thu, 27 Oct 2016 07:33:42 -0700 Subject: [PATCH 117/287] Update and rename get-hosted-profile-page.php to get-accept-customer-profile-page.php --- ...-profile-page.php => get-accept-customer-profile-page.php} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename CustomerProfiles/{get-hosted-profile-page.php => get-accept-customer-profile-page.php} (95%) diff --git a/CustomerProfiles/get-hosted-profile-page.php b/CustomerProfiles/get-accept-customer-profile-page.php similarity index 95% rename from CustomerProfiles/get-hosted-profile-page.php rename to CustomerProfiles/get-accept-customer-profile-page.php index a846d31..b881158 100644 --- a/CustomerProfiles/get-hosted-profile-page.php +++ b/CustomerProfiles/get-accept-customer-profile-page.php @@ -5,7 +5,7 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function getHostedProfilePage($customerprofileid = "123212") + function getAcceptCustomerProfilePage($customerprofileid = "123212") { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); @@ -43,4 +43,4 @@ function getHostedProfilePage($customerprofileid = "123212") } if(!defined('DONT_RUN_SAMPLES')) getHostedProfilePage(); -?> \ No newline at end of file +?> From 86c9dd7b7c990369e1701ba90c9b150adb9ebd25 Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Thu, 27 Oct 2016 07:34:37 -0700 Subject: [PATCH 118/287] Update SampleCodeList.txt --- SampleCodeList.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SampleCodeList.txt b/SampleCodeList.txt index 7e8db67..a51576c 100644 --- a/SampleCodeList.txt +++ b/SampleCodeList.txt @@ -25,7 +25,7 @@ UpdateCustomerPaymentProfile,1,1 GetCustomerShippingAddress,1,1 GetCustomerProfileIds,0,1 GetCustomerProfile,1,1 -GetHostedProfilePage,1,1 +GetAcceptCustomerProfilePage,1,1 GetCustomerPaymentProfile,1,1 DeleteCustomerShippingAddress,1,1 DeleteCustomerProfile,1,1 From 66c98fbb0e23ba51c59a32f204be233301024e5e Mon Sep 17 00:00:00 2001 From: Ashish Kankaria Date: Mon, 14 Nov 2016 12:06:16 +0530 Subject: [PATCH 119/287] Update create-subscription.php Changes to add description while creating subscription --- RecurringBilling/create-subscription.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/RecurringBilling/create-subscription.php b/RecurringBilling/create-subscription.php index 83beefd..e635f9a 100644 --- a/RecurringBilling/create-subscription.php +++ b/RecurringBilling/create-subscription.php @@ -39,9 +39,13 @@ function createSubscription($intervalLength) { $payment = new AnetAPI\PaymentType(); $payment->setCreditCard($creditCard); - $subscription->setPayment($payment); + $order = new AnetAPI\OrderType(); + $order->setInvoiceNumber("1234354"); + $order->setDescription("Description of the subscription"); + $subscription->setOrder($order); + $billTo = new AnetAPI\NameAndAddressType(); $billTo->setFirstName("John"); $billTo->setLastName("Smith"); From 271449cb88d0666e87d9f83f6c47013fd43e708c Mon Sep 17 00:00:00 2001 From: akankaria Date: Mon, 14 Nov 2016 12:23:03 +0530 Subject: [PATCH 120/287] Renaming getHostedProfilePage to GetAcceptCustomerProfilePage in test runner --- CustomerProfiles/get-accept-customer-profile-page.php | 2 +- test-runner.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CustomerProfiles/get-accept-customer-profile-page.php b/CustomerProfiles/get-accept-customer-profile-page.php index b881158..02a3b08 100644 --- a/CustomerProfiles/get-accept-customer-profile-page.php +++ b/CustomerProfiles/get-accept-customer-profile-page.php @@ -5,7 +5,7 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function getAcceptCustomerProfilePage($customerprofileid = "123212") + function GetAcceptCustomerProfilePage($customerprofileid = "123212") { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); diff --git a/test-runner.php b/test-runner.php index 35a76bf..58ab80f 100644 --- a/test-runner.php +++ b/test-runner.php @@ -395,10 +395,10 @@ public static function runGetCustomerShippingAddress() return $getResponse; } - public static function runGetHostedProfilePage() + public static function GetAcceptCustomerProfilePage() { $response = createCustomerProfile(self::getEmail()); - $profileResponse = getHostedProfilePage($response->getCustomerProfileId()); + $profileResponse = GetAcceptCustomerProfilePage($response->getCustomerProfileId()); deleteCustomerProfile($response->getCustomerProfileId()); return $profileResponse; From 0a44a2f676a0fc7e1f964ee10163333d23744735 Mon Sep 17 00:00:00 2001 From: Ashish Kankaria Date: Mon, 14 Nov 2016 12:26:24 +0530 Subject: [PATCH 121/287] 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 58ab80f..fc2e00c 100644 --- a/test-runner.php +++ b/test-runner.php @@ -395,7 +395,7 @@ public static function runGetCustomerShippingAddress() return $getResponse; } - public static function GetAcceptCustomerProfilePage() + public static function runGetAcceptCustomerProfilePage() { $response = createCustomerProfile(self::getEmail()); $profileResponse = GetAcceptCustomerProfilePage($response->getCustomerProfileId()); From ab32b0fa142b828bf4d99b136b0546ad9522f973 Mon Sep 17 00:00:00 2001 From: Ashutosh Singh Date: Tue, 22 Nov 2016 19:12:55 +0530 Subject: [PATCH 122/287] Update test-runner to limit debit amount Cannot debit more than 100 from bank account --- test-runner.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-runner.php b/test-runner.php index 35a76bf..a9b55cb 100644 --- a/test-runner.php +++ b/test-runner.php @@ -128,7 +128,7 @@ public static function runCaptureFundsAuthorizedThroughAnotherChannel() public static function runDebitBankAccount() { - return debitBankAccount(self::getAmount()); + return debitBankAccount(self::getAmount()%98+1); //cannot debit more than 100 } public static function runChargeTokenizedCreditCard() From f32704d9b95b45a65480884f7a3f8e6b158e16ac Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Thu, 24 Nov 2016 19:04:33 +0530 Subject: [PATCH 123/287] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 422a735..2493fe2 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "php": ">=5.5", "ext-curl": "*", "phpunit/phpunit": "~4.0", - "authorizenet/authorizenet": "1.9.0", + "authorizenet/authorizenet": "1.9.1", "jms/serializer": "serializer-master-dev as 1.0" }, "repositories": [{ From 3d4be5c1e8f9a4b2e7409131abec37854346cb9e Mon Sep 17 00:00:00 2001 From: Gaurav Mokhasi Date: Thu, 24 Nov 2016 21:27:12 +0530 Subject: [PATCH 124/287] added sample code for GetMerchantDetails --- SampleCodeList.txt | 1 + TransactionReporting/get-merchant-details.php | 43 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 TransactionReporting/get-merchant-details.php diff --git a/SampleCodeList.txt b/SampleCodeList.txt index a51576c..a865f98 100644 --- a/SampleCodeList.txt +++ b/SampleCodeList.txt @@ -52,3 +52,4 @@ UpdateSubscription,1,1 CreateCustomerProfile,1,1 CreateCustomerPaymentProfile,1,1 ValidateCustomerPaymentProfile,1,0 +GetMerchantDetails,0,1 \ No newline at end of file diff --git a/TransactionReporting/get-merchant-details.php b/TransactionReporting/get-merchant-details.php new file mode 100644 index 0000000..e2ec958 --- /dev/null +++ b/TransactionReporting/get-merchant-details.php @@ -0,0 +1,43 @@ +setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + $refId = 'ref' . time(); + + $request = new AnetAPI\GetMerchantDetailsRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + + $controller = new AnetController\GetMerchantDetailsController($request); + + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok")) + { + echo "Merchant Name: " . $response->getMerchantName() . "\n"; + echo "Gateway ID: " . $response->getGatewayId() . "\n"; + echo "Processors: "; + foreach ($response->getProcessors() as $processor) + { + echo $processor->getName() . "; "; + } + } + else + { + echo "No response returned \n"; + } + + return $response; + } + + if(!defined('DONT_RUN_SAMPLES')) + getMerchantDetails(); +?> \ No newline at end of file From 522e39138bc112256070241a93c8c4d6f112e24b Mon Sep 17 00:00:00 2001 From: Ashutosh Singh Date: Fri, 25 Nov 2016 17:19:48 +0530 Subject: [PATCH 125/287] Adding new APIs --- .../create-customer-payment-profile.php | 5 +- CustomerProfiles/create-customer-profile.php | 4 +- .../get-accept-customer-profile-page.php | 2 +- CustomerProfiles/get-hosted-payment-page.php | 68 ++++++++++++++ .../update-held-transaction.php | 88 +++++++++++++++++++ RecurringBilling/create-subscription.php | 6 +- SampleCodeList.txt | 4 +- TransactionReporting/get-merchant-details.php | 26 +++--- 8 files changed, 182 insertions(+), 21 deletions(-) create mode 100644 CustomerProfiles/get-hosted-payment-page.php create mode 100644 PaymentTransactions/update-held-transaction.php diff --git a/CustomerProfiles/create-customer-payment-profile.php b/CustomerProfiles/create-customer-payment-profile.php index da6f78c..b61c8d4 100644 --- a/CustomerProfiles/create-customer-payment-profile.php +++ b/CustomerProfiles/create-customer-payment-profile.php @@ -8,7 +8,7 @@ function createCustomerPaymentProfile($existingcustomerprofileid, $phoneNumber){ // Common setup for API credentials $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(); @@ -37,6 +37,7 @@ function createCustomerPaymentProfile($existingcustomerprofileid, $phoneNumber){ $paymentprofile->setCustomerType('individual'); $paymentprofile->setBillTo($billto); $paymentprofile->setPayment($paymentCreditCard); + $paymentprofile->setDefaultPaymentProfile(true); $paymentprofiles[] = $paymentprofile; @@ -63,5 +64,5 @@ function createCustomerPaymentProfile($existingcustomerprofileid, $phoneNumber){ return $response; } if(!defined('DONT_RUN_SAMPLES')) - createCustomerPaymentProfile("36152127","000-000-0009"); + createCustomerPaymentProfile("1807545561","000-000-0009"); ?> diff --git a/CustomerProfiles/create-customer-profile.php b/CustomerProfiles/create-customer-profile.php index 38d82d1..ffaf655 100644 --- a/CustomerProfiles/create-customer-profile.php +++ b/CustomerProfiles/create-customer-profile.php @@ -7,8 +7,8 @@ function createCustomerProfile($email){ - // Common setup for API credentials - $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + // 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(); diff --git a/CustomerProfiles/get-accept-customer-profile-page.php b/CustomerProfiles/get-accept-customer-profile-page.php index 02a3b08..b881158 100644 --- a/CustomerProfiles/get-accept-customer-profile-page.php +++ b/CustomerProfiles/get-accept-customer-profile-page.php @@ -5,7 +5,7 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function GetAcceptCustomerProfilePage($customerprofileid = "123212") + function getAcceptCustomerProfilePage($customerprofileid = "123212") { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); diff --git a/CustomerProfiles/get-hosted-payment-page.php b/CustomerProfiles/get-hosted-payment-page.php new file mode 100644 index 0000000..9656a9f --- /dev/null +++ b/CustomerProfiles/get-hosted-payment-page.php @@ -0,0 +1,68 @@ +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); + + $order = new AnetAPI\OrderType(); + $order->setDescription("New Item"); + + //create a transaction + $transactionRequestType = new AnetAPI\TransactionRequestType(); + $transactionRequestType->setTransactionType( "authCaptureTransaction"); + $transactionRequestType->setAmount("12.23"); + + // Use an existing payment profile ID for this Merchant name and Transaction key + + $setting = new AnetAPI\SettingType(); + $setting->setSettingName("hostedPaymentButtonOptions"); + $setting->setSettingValue("{\"text\": \"Pay\"}"); + $setting2 = new AnetAPI\SettingType(); + $setting2->setSettingName("hostedPaymentOrderOptions"); + $setting2->setSettingValue("{\"show\": false}"); + + //$alist = new AnetAPI\ArrayOfSettingType(); + //$alist->addToSetting($setting); + + $request = new AnetAPI\GetHostedPaymentPageRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setTransactionRequest($transactionRequestType); + + $request->addToHostedPaymentSettings($setting); + $request->addToHostedPaymentSettings($setting2); + + $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 profile page\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; + } + return $response; + } + if(!defined('DONT_RUN_SAMPLES')) + getHostedPaymentPage(); +?> diff --git a/PaymentTransactions/update-held-transaction.php b/PaymentTransactions/update-held-transaction.php new file mode 100644 index 0000000..3d541c5 --- /dev/null +++ b/PaymentTransactions/update-held-transaction.php @@ -0,0 +1,88 @@ +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); + + $order = new AnetAPI\OrderType(); + $order->setDescription("New Item"); + + //create a transaction + $transactionRequestType = new AnetAPI\HeldTransactionRequestType(); + $transactionRequestType->setAction("approve"); //other possible value: decline + $transactionRequestType->setRefTransId("412121"); + + + $request = new AnetAPI\UpdateHeldTransactionRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setHeldTransactionRequest( $transactionRequestType); + $controller = new AnetController\UpdateHeldTransactionController($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 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"; + } + } + } + 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')) + updateHeldTransaction(); +?> diff --git a/RecurringBilling/create-subscription.php b/RecurringBilling/create-subscription.php index e635f9a..83beefd 100644 --- a/RecurringBilling/create-subscription.php +++ b/RecurringBilling/create-subscription.php @@ -39,13 +39,9 @@ function createSubscription($intervalLength) { $payment = new AnetAPI\PaymentType(); $payment->setCreditCard($creditCard); + $subscription->setPayment($payment); - $order = new AnetAPI\OrderType(); - $order->setInvoiceNumber("1234354"); - $order->setDescription("Description of the subscription"); - $subscription->setOrder($order); - $billTo = new AnetAPI\NameAndAddressType(); $billTo->setFirstName("John"); $billTo->setLastName("Smith"); diff --git a/SampleCodeList.txt b/SampleCodeList.txt index a865f98..bbb7f6e 100644 --- a/SampleCodeList.txt +++ b/SampleCodeList.txt @@ -52,4 +52,6 @@ UpdateSubscription,1,1 CreateCustomerProfile,1,1 CreateCustomerPaymentProfile,1,1 ValidateCustomerPaymentProfile,1,0 -GetMerchantDetails,0,1 \ No newline at end of file +GetMerchantDetails,0,1 +UpdateHeldTransaction,1,0 +GetHostedPaymentPage,0,1 diff --git a/TransactionReporting/get-merchant-details.php b/TransactionReporting/get-merchant-details.php index e2ec958..1ec4714 100644 --- a/TransactionReporting/get-merchant-details.php +++ b/TransactionReporting/get-merchant-details.php @@ -6,6 +6,7 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); function getMerchantDetails() { + // Common Set Up for API Credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); @@ -22,17 +23,22 @@ function getMerchantDetails() { if (($response != null) && ($response->getMessages()->getResultCode() == "Ok")) { - echo "Merchant Name: " . $response->getMerchantName() . "\n"; - echo "Gateway ID: " . $response->getGatewayId() . "\n"; - echo "Processors: "; - foreach ($response->getProcessors() as $processor) - { - echo $processor->getName() . "; "; - } - } + echo "SUCCESS: Merchant Name:" . $response->getMerchantName() . "\n"; + echo " Gateway Id:" . $response->getGatewayId(). "\n"; + + foreach ($response->getProcessors() as $processor) { + echo " ->Name : " . $processor->getName() . "\n"; + } + + foreach ($response->getCurrencies() as $currency) { + echo " ->Currency : " . $currency . "\n"; + } + } else { - echo "No response returned \n"; + echo "ERROR : Invalid response\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } return $response; @@ -40,4 +46,4 @@ function getMerchantDetails() { if(!defined('DONT_RUN_SAMPLES')) getMerchantDetails(); -?> \ No newline at end of file +?> From 8005ea94536b100c43b7a4a40e3263ba13bd8644 Mon Sep 17 00:00:00 2001 From: Ashutosh Singh Date: Fri, 25 Nov 2016 17:28:05 +0530 Subject: [PATCH 126/287] Added order information in recurring billing --- RecurringBilling/create-subscription.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/RecurringBilling/create-subscription.php b/RecurringBilling/create-subscription.php index 83beefd..e635f9a 100644 --- a/RecurringBilling/create-subscription.php +++ b/RecurringBilling/create-subscription.php @@ -39,9 +39,13 @@ function createSubscription($intervalLength) { $payment = new AnetAPI\PaymentType(); $payment->setCreditCard($creditCard); - $subscription->setPayment($payment); + $order = new AnetAPI\OrderType(); + $order->setInvoiceNumber("1234354"); + $order->setDescription("Description of the subscription"); + $subscription->setOrder($order); + $billTo = new AnetAPI\NameAndAddressType(); $billTo->setFirstName("John"); $billTo->setLastName("Smith"); From 969e4ccdd92812dff0dc5941a3b0a03ab8420b71 Mon Sep 17 00:00:00 2001 From: Ashutosh Singh Date: Fri, 25 Nov 2016 17:32:47 +0530 Subject: [PATCH 127/287] Updated to call the current function in the file --- CustomerProfiles/get-accept-customer-profile-page.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CustomerProfiles/get-accept-customer-profile-page.php b/CustomerProfiles/get-accept-customer-profile-page.php index b881158..a1450af 100644 --- a/CustomerProfiles/get-accept-customer-profile-page.php +++ b/CustomerProfiles/get-accept-customer-profile-page.php @@ -42,5 +42,5 @@ function getAcceptCustomerProfilePage($customerprofileid = "123212") return $response; } if(!defined('DONT_RUN_SAMPLES')) - getHostedProfilePage(); + getAcceptCustomerProfilePage(); ?> From ed7414cd2076373e46bc6c1dddbcd2072d784fd0 Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Fri, 25 Nov 2016 18:19:10 +0530 Subject: [PATCH 128/287] Rename CustomerProfiles/get-hosted-payment-page.php to PaymentTransactions/get-hosted-payment-page.php --- .../get-hosted-payment-page.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {CustomerProfiles => PaymentTransactions}/get-hosted-payment-page.php (100%) diff --git a/CustomerProfiles/get-hosted-payment-page.php b/PaymentTransactions/get-hosted-payment-page.php similarity index 100% rename from CustomerProfiles/get-hosted-payment-page.php rename to PaymentTransactions/get-hosted-payment-page.php From d37d0af2fa1781aeef03f2a9bb4a23b7e841f220 Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Fri, 25 Nov 2016 19:50:16 -0800 Subject: [PATCH 129/287] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a625e61..4b2b653 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Build Status](https://travis-ci.org/AuthorizeNet/sample-code-php.png?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. +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 e3de4e8db04c16c5a397ff1e1ed3de549f0c6b1a Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Sun, 4 Dec 2016 23:26:46 -0800 Subject: [PATCH 130/287] Update composer.json --- composer.json | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 2493fe2..a0188d1 100644 --- a/composer.json +++ b/composer.json @@ -3,13 +3,8 @@ "php": ">=5.5", "ext-curl": "*", "phpunit/phpunit": "~4.0", - "authorizenet/authorizenet": "1.9.1", - "jms/serializer": "serializer-master-dev as 1.0" + "authorizenet/authorizenet": "1.9.2" }, - "repositories": [{ - "type": "vcs", - "url": "https://github.com/goetas/serializer.git" - }], "autoload": { "classmap": ["constants"] } From bfa2ae0b52a860ca14699117e1f07dece1bf8634 Mon Sep 17 00:00:00 2001 From: brianmc Date: Wed, 7 Dec 2016 23:52:18 -0800 Subject: [PATCH 131/287] added Fraud Mgmt samples --- FraudManagement/get-held-transactions.php | 52 +++++++++++++++++++ .../update-held-transaction.php | 13 +---- 2 files changed, 53 insertions(+), 12 deletions(-) create mode 100644 FraudManagement/get-held-transactions.php rename {PaymentTransactions => FraudManagement}/update-held-transaction.php (86%) diff --git a/FraudManagement/get-held-transactions.php b/FraudManagement/get-held-transactions.php new file mode 100644 index 0000000..7896f8a --- /dev/null +++ b/FraudManagement/get-held-transactions.php @@ -0,0 +1,52 @@ +setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + $refId = 'ref' . time(); + + + $request = new AnetAPI\GetUnsettledTransactionListRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setStatus("pendingApproval"); + + + $controller = new AnetController\GetUnsettledTransactionListController($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 suspicious transactions for the merchant." . "\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')) + getHeldTransactions(); + +?> diff --git a/PaymentTransactions/update-held-transaction.php b/FraudManagement/update-held-transaction.php similarity index 86% rename from PaymentTransactions/update-held-transaction.php rename to FraudManagement/update-held-transaction.php index 3d541c5..0195f57 100644 --- a/PaymentTransactions/update-held-transaction.php +++ b/FraudManagement/update-held-transaction.php @@ -12,21 +12,10 @@ function updateHeldTransaction(){ $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); - - $order = new AnetAPI\OrderType(); - $order->setDescription("New Item"); - //create a transaction $transactionRequestType = new AnetAPI\HeldTransactionRequestType(); $transactionRequestType->setAction("approve"); //other possible value: decline - $transactionRequestType->setRefTransId("412121"); + $transactionRequestType->setRefTransId("60012148205"); $request = new AnetAPI\UpdateHeldTransactionRequest(); From 9b0bceecf42aced42298d8d1dbff2e7ccc96714a Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Thu, 8 Dec 2016 09:05:02 -0800 Subject: [PATCH 132/287] Update and rename get-held-transactions.php to get-held-transaction-list.php --- ...{get-held-transactions.php => get-held-transaction-list.php} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename FraudManagement/{get-held-transactions.php => get-held-transaction-list.php} (97%) diff --git a/FraudManagement/get-held-transactions.php b/FraudManagement/get-held-transaction-list.php similarity index 97% rename from FraudManagement/get-held-transactions.php rename to FraudManagement/get-held-transaction-list.php index 7896f8a..b6be049 100644 --- a/FraudManagement/get-held-transactions.php +++ b/FraudManagement/get-held-transaction-list.php @@ -5,7 +5,7 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function getHeldTransactions() { + function getHeldTransactionList() { // Common Set Up for API Credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); From 7f2c039683ed0e2c32fa576ebc38f27e3cc5254a Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Thu, 8 Dec 2016 09:05:37 -0800 Subject: [PATCH 133/287] Update and rename update-held-transaction.php to approve-or-decline-held-transaction.php --- ...-transaction.php => approve-or-decline-held-transaction.php} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename FraudManagement/{update-held-transaction.php => approve-or-decline-held-transaction.php} (98%) diff --git a/FraudManagement/update-held-transaction.php b/FraudManagement/approve-or-decline-held-transaction.php similarity index 98% rename from FraudManagement/update-held-transaction.php rename to FraudManagement/approve-or-decline-held-transaction.php index 0195f57..e538b58 100644 --- a/FraudManagement/update-held-transaction.php +++ b/FraudManagement/approve-or-decline-held-transaction.php @@ -5,7 +5,7 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function updateHeldTransaction(){ + function approveOrDeclineHeldTransaction(){ // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); From d5bedcf0477b509a5c9c3b3a6c69d69e949e4a3d Mon Sep 17 00:00:00 2001 From: ANET Developer Date: Mon, 23 Jan 2017 16:34:11 -0700 Subject: [PATCH 134/287] cleanup get-hosted-payment-page.php --- .../get-hosted-payment-page.php | 40 ++++++++----------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/PaymentTransactions/get-hosted-payment-page.php b/PaymentTransactions/get-hosted-payment-page.php index 9656a9f..2a0c11a 100644 --- a/PaymentTransactions/get-hosted-payment-page.php +++ b/PaymentTransactions/get-hosted-payment-page.php @@ -5,49 +5,41 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function getHostedPaymentPage($customerprofileid = "123212") + function getHostedPaymentPage() { // 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); - - $order = new AnetAPI\OrderType(); - $order->setDescription("New Item"); //create a transaction $transactionRequestType = new AnetAPI\TransactionRequestType(); $transactionRequestType->setTransactionType( "authCaptureTransaction"); $transactionRequestType->setAmount("12.23"); - // Use an existing payment profile ID for this Merchant name and Transaction key - - $setting = new AnetAPI\SettingType(); - $setting->setSettingName("hostedPaymentButtonOptions"); - $setting->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}"); - - //$alist = new AnetAPI\ArrayOfSettingType(); - //$alist->addToSetting($setting); - + + $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); - $request->addToHostedPaymentSettings($setting); + $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); @@ -57,7 +49,7 @@ function getHostedPaymentPage($customerprofileid = "123212") } else { - echo "ERROR : Failed to get hosted profile page\n"; + echo "ERROR : Failed to get hosted payment page token\n"; $errorMessages = $response->getMessages()->getMessage(); echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } From b880ac498e53aac8464ddc1059cc09ad2bfebe63 Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Wed, 25 Jan 2017 07:15:53 -0800 Subject: [PATCH 135/287] Rename get-hosted-payment-page.php to get-an-accept-payment-page.php --- ...get-hosted-payment-page.php => get-an-accept-payment-page.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename PaymentTransactions/{get-hosted-payment-page.php => get-an-accept-payment-page.php} (100%) diff --git a/PaymentTransactions/get-hosted-payment-page.php b/PaymentTransactions/get-an-accept-payment-page.php similarity index 100% rename from PaymentTransactions/get-hosted-payment-page.php rename to PaymentTransactions/get-an-accept-payment-page.php From bfe909aa1f6c6d5ac0d21ac12804d644763d5df8 Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Wed, 25 Jan 2017 07:40:06 -0800 Subject: [PATCH 136/287] Update get-an-accept-payment-page.php --- 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 2a0c11a..c14a370 100644 --- a/PaymentTransactions/get-an-accept-payment-page.php +++ b/PaymentTransactions/get-an-accept-payment-page.php @@ -5,7 +5,7 @@ define("AUTHORIZENET_LOG_FILE", "phplog"); - function getHostedPaymentPage() + function getAnAcceptPaymentPage() { // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); From b6289797e0385923a54faabea874c211b8da665e Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Wed, 25 Jan 2017 07:40:46 -0800 Subject: [PATCH 137/287] Update get-an-accept-payment-page.php --- 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 c14a370..05ebb64 100644 --- a/PaymentTransactions/get-an-accept-payment-page.php +++ b/PaymentTransactions/get-an-accept-payment-page.php @@ -56,5 +56,5 @@ function getAnAcceptPaymentPage() return $response; } if(!defined('DONT_RUN_SAMPLES')) - getHostedPaymentPage(); + getAnAcceptPaymentPage(); ?> From 0f887c0b6d74d4a2e4d477077c8e62299c1d5f76 Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Wed, 25 Jan 2017 07:41:50 -0800 Subject: [PATCH 138/287] Update SampleCodeList.txt --- SampleCodeList.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SampleCodeList.txt b/SampleCodeList.txt index bbb7f6e..ef5fe79 100644 --- a/SampleCodeList.txt +++ b/SampleCodeList.txt @@ -54,4 +54,4 @@ CreateCustomerPaymentProfile,1,1 ValidateCustomerPaymentProfile,1,0 GetMerchantDetails,0,1 UpdateHeldTransaction,1,0 -GetHostedPaymentPage,0,1 +GetAnAcceptPaymentPage,0,1 From a382848e7f1b3a05687fd4d6c484acfb5337de0a Mon Sep 17 00:00:00 2001 From: Gaurav Srikant Mokhasi Date: Tue, 31 Jan 2017 11:22:39 +0530 Subject: [PATCH 139/287] 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 140/287] 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 141/287] 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 142/287] 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 143/287] 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 144/287] 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 145/287] 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 146/287] 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 147/287] 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 148/287] 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 149/287] 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 150/287] 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 151/287] 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 152/287] 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 153/287] 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 154/287] 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 155/287] 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 156/287] 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 157/287] 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 158/287] 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 159/287] 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 160/287] 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 161/287] 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 162/287] 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 163/287] 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 164/287] 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 165/287] 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 166/287] 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 167/287] 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 168/287] 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 169/287] 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 170/287] 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 171/287] 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 172/287] 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 173/287] 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 174/287] 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 175/287] 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 176/287] 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 177/287] 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 178/287] 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 179/287] 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 180/287] 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 181/287] 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 182/287] 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 183/287] 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 184/287] 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 185/287] 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 186/287] 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 187/287] 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 188/287] 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 189/287] 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 190/287] 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 191/287] 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 192/287] 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 193/287] 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 194/287] 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 195/287] 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 196/287] 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 197/287] 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 198/287] 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 199/287] 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 200/287] 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 201/287] 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 202/287] 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 203/287] 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 204/287] 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 205/287] 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 206/287] 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 207/287] 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 208/287] 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 209/287] 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 210/287] 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 211/287] 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 212/287] 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 213/287] 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 214/287] 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 215/287] 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 216/287] 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 217/287] 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 218/287] 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 219/287] 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 220/287] 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 221/287] 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 222/287] 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 223/287] 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 224/287] 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 225/287] 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 226/287] 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 227/287] 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 228/287] 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 229/287] 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 230/287] 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 231/287] 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 232/287] 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 233/287] 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 234/287] 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 235/287] 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 236/287] 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 237/287] 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 238/287] 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 239/287] 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 240/287] 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 241/287] 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 242/287] 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 243/287] 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 244/287] 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 245/287] 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 246/287] + 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 247/287] + 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 248/287] 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 249/287] 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 250/287] 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 251/287] 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 252/287] 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 253/287] 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 254/287] 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 255/287] 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 256/287] + 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 257/287] 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 258/287] 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 259/287] + 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 260/287] 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 261/287] 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 262/287] 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 263/287] 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 264/287] 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 265/287] 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 266/287] 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 267/287] 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 268/287] 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 269/287] 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 270/287] + 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 271/287] 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 272/287] 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 273/287] 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 274/287] 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 275/287] 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 276/287] 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 277/287] 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 278/287] 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 279/287] 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 280/287] 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 281/287] 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 282/287] 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 283/287] 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 284/287] 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 285/287] 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 286/287] 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 287/287] 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