From f200c59161ef794275f87b0baceb80d789be13d9 Mon Sep 17 00:00:00 2001 From: Ashish Kankaria Date: Thu, 2 Jun 2016 11:53:28 +0530 Subject: [PATCH 001/211] 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 002/211] 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 003/211] 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 004/211] 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 005/211] 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 006/211] 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 007/211] 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 008/211] 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 009/211] 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 010/211] 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 011/211] 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 012/211] - 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 013/211] - 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 014/211] 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 015/211] 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 016/211] 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 017/211] 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 018/211] 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 019/211] 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 020/211] 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 021/211] - 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 022/211] - 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 023/211] 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 024/211] 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 025/211] 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 026/211] 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 027/211] 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 028/211] 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 029/211] 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 030/211] 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 031/211] 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 032/211] 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 033/211] 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 034/211] 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 035/211] 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 036/211] 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 037/211] 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 038/211] 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 039/211] 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 040/211] 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 041/211] 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 042/211] 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 043/211] 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 044/211] 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 045/211] 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 046/211] 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 047/211] 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 048/211] 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 049/211] 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 050/211] 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 051/211] 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 052/211] 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 053/211] 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 054/211] 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 055/211] 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 056/211] 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 057/211] 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 058/211] 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 059/211] 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 060/211] 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 061/211] 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 062/211] 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 063/211] 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 064/211] 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 065/211] 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 066/211] 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 067/211] 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 068/211] 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 069/211] 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 070/211] 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 071/211] 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 072/211] 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 073/211] 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 074/211] 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 075/211] 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 076/211] 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 077/211] 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 078/211] 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 079/211] 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 080/211] 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 081/211] 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 082/211] 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 083/211] 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 084/211] 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 085/211] 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 086/211] 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 087/211] 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 088/211] 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 089/211] 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 090/211] 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 091/211] 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 092/211] 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 093/211] 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 094/211] 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 095/211] 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 096/211] 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 097/211] 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 098/211] 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 099/211] 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 100/211] 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 101/211] 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 102/211] 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 103/211] 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 104/211] 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 105/211] 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 106/211] 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 107/211] 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 108/211] 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 109/211] 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 110/211] 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 111/211] 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 112/211] 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 113/211] 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 114/211] 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 115/211] 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 116/211] 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 117/211] 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 118/211] 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 119/211] 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 120/211] 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 121/211] 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 122/211] 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 123/211] 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 124/211] 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 125/211] 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 126/211] 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 127/211] 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 128/211] 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 129/211] 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 130/211] 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 131/211] 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 132/211] 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 133/211] 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 134/211] 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 135/211] 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 136/211] 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 137/211] 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 138/211] 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 139/211] 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 140/211] 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 141/211] 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 142/211] 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 143/211] 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 144/211] 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 145/211] 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 146/211] 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 147/211] 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 148/211] 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 149/211] 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 150/211] 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 151/211] 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 152/211] 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 153/211] 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 154/211] 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 155/211] 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 156/211] 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 157/211] 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 158/211] 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 159/211] 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 160/211] 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 161/211] 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 162/211] 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 163/211] 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 164/211] 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 165/211] 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 166/211] 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 167/211] 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 168/211] 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 169/211] 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 170/211] + 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 171/211] + 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 172/211] 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 173/211] 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 174/211] 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 175/211] 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 176/211] 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 177/211] 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 178/211] 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 179/211] 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 180/211] + 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 181/211] 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 182/211] 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 183/211] + 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 184/211] 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 185/211] 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 186/211] 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 187/211] 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 188/211] 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 189/211] 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 190/211] 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 191/211] 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 192/211] 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 193/211] 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 194/211] + 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 195/211] 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 196/211] 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 197/211] 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 198/211] 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 199/211] 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 200/211] 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 201/211] 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 202/211] 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 203/211] 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 204/211] 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 205/211] 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 206/211] 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 207/211] 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 208/211] 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 209/211] 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 210/211] 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 211/211] 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