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/.travis.yml b/.travis.yml index 0d096c4..45de70f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,35 @@ language: php -php: - - 5.6 - - 7.0 - - 7.1 - +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 before_script: - - composer install --prefer-dist + - composer require "phpunit/phpunit:${PHPUNIT_VERSION}" --no-update + - composer update --prefer-dist script: - - phpunit test-runner.php . + - phpunit TestRunner.php . diff --git a/PaymentTransactions/create-an-accept-payment-transaction.php b/AcceptSuite/create-an-accept-payment-transaction.php similarity index 94% rename from PaymentTransactions/create-an-accept-payment-transaction.php rename to AcceptSuite/create-an-accept-payment-transaction.php index caa2fb2..562d514 100644 --- a/PaymentTransactions/create-an-accept-payment-transaction.php +++ b/AcceptSuite/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); + createAnAcceptPaymentTransaction("2.23"); } ?> \ No newline at end of file diff --git a/CustomerProfiles/get-accept-customer-profile-page.php b/AcceptSuite/get-accept-customer-profile-page.php similarity index 88% rename from CustomerProfiles/get-accept-customer-profile-page.php rename to AcceptSuite/get-accept-customer-profile-page.php index 35e7293..e784f06 100644 --- a/CustomerProfiles/get-accept-customer-profile-page.php +++ b/AcceptSuite/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/PaymentTransactions/get-an-accept-payment-page.php b/AcceptSuite/get-an-accept-payment-page.php similarity index 91% rename from PaymentTransactions/get-an-accept-payment-page.php rename to AcceptSuite/get-an-accept-payment-page.php index 6d600be..30fe57e 100644 --- a/PaymentTransactions/get-an-accept-payment-page.php +++ b/AcceptSuite/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/CustomerProfiles/create-customer-payment-profile.php b/CustomerProfiles/create-customer-payment-profile.php index 451a641..3c3812f 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(); @@ -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-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..abce577 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(); @@ -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 diff --git a/CustomerProfiles/create-customer-profile.php b/CustomerProfiles/create-customer-profile.php index c58c197..49fb43f 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(); @@ -67,7 +67,6 @@ function createCustomerProfile($email) $paymentProfile->setCustomerType('individual'); $paymentProfile->setBillTo($billTo); $paymentProfile->setPayment($paymentCreditCard); - $paymentProfile->setDefaultpaymentProfile(true); $paymentProfiles[] = $paymentProfile; diff --git a/CustomerProfiles/create-customer-shipping-address.php b/CustomerProfiles/create-customer-shipping-address.php index d1f9579..3044353 100644 --- a/CustomerProfiles/create-customer-shipping-address.php +++ b/CustomerProfiles/create-customer-shipping-address.php @@ -1,18 +1,19 @@ 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..ce3e6ca 100644 --- a/CustomerProfiles/delete-customer-payment-profile.php +++ b/CustomerProfiles/delete-customer-payment-profile.php @@ -1,18 +1,19 @@ -]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..ee918cc 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(); @@ -38,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 48a03c4..d3f2ccc 100644 --- a/CustomerProfiles/delete-customer-shipping-address.php +++ b/CustomerProfiles/delete-customer-shipping-address.php @@ -1,17 +1,18 @@ 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..6e056a5 100644 --- a/CustomerProfiles/get-customer-payment-profile.php +++ b/CustomerProfiles/get-customer-payment-profile.php @@ -1,20 +1,20 @@ 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..484d5e5 100644 --- a/CustomerProfiles/update-customer-payment-profile.php +++ b/CustomerProfiles/update-customer-payment-profile.php @@ -1,103 +1,95 @@ 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(); - //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 if ($response != null) + { + $errorMessages = $response->getMessages()->getMessage(); + 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(); ?> 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..36ad6ad 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(); @@ -53,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 63215fc..ca57209 100644 --- a/CustomerProfiles/validate-customer-payment-profile.php +++ b/CustomerProfiles/validate-customer-payment-profile.php @@ -1,18 +1,19 @@ 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/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/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-chase-pay-transaction.php b/PaymentTransactions/create-chase-pay-transaction.php new file mode 100644 index 0000000..ccf1b02 --- /dev/null +++ b/PaymentTransactions/create-chase-pay-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); +?> diff --git a/PaymentTransactions/credit-bank-account.php b/PaymentTransactions/credit-bank-account.php index cb04582..b68f771 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(); + //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('125008547'); //('122235821'); //('125008547'); - $bankAccount->setAccountNumber('1234567890'); + $bankAccount->setRoutingNumber('122000661'); //('122235821'); //('125008547'); + $bankAccount->setAccountNumber($randomAccountNumber); $bankAccount->setNameOnAccount('John Doe'); $bankAccount->setBankName('Wells Fargo Bank NA'); @@ -49,7 +53,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 46580df..6d50388 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(); + //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('125008547'); - $bankAccount->setAccountNumber('1234567890'); + $bankAccount->setRoutingNumber('122000661'); + + $bankAccount->setAccountNumber(rand(10000,999999999999)); + $bankAccount->setNameOnAccount('John Doe'); $bankAccount->setBankName('Wells Fargo Bank NA'); @@ -49,7 +55,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/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..e386750 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(); $request = new AnetAPI\UpdateSplitTenderGroupRequest(); $request->setMerchantAuthentication($merchantAuthentication); - $request->setRefId($refId); + $request->setRefId($refId); $request->setSplitTenderId("115901"); $request->setSplitTenderStatus("voided"); 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/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 diff --git a/RecurringBilling/cancel-subscription.php b/RecurringBilling/cancel-subscription.php index 378345b..59f8553 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(); @@ -44,6 +45,6 @@ function cancelSubscription($subscriptionId) } if(!defined('DONT_RUN_SAMPLES')) - cancelSubscription("3056945"); + cancelSubscription("7087965"); ?> diff --git a/RecurringBilling/create-subscription-from-customer-profile.php b/RecurringBilling/create-subscription-from-customer-profile.php index 9a53131..8681182 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(); @@ -28,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"); diff --git a/RecurringBilling/create-subscription.php b/RecurringBilling/create-subscription.php index fa6b675..1bf6fba 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(); @@ -27,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/RecurringBilling/get-list-of-subscriptions.php b/RecurringBilling/get-list-of-subscriptions.php index 444c9f5..72330e8 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(); @@ -21,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(); @@ -38,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/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 93e30c6..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(); @@ -43,9 +44,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 { 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/SampleCodeList.txt b/SampleCodeList.txt index 621aa28..5119f91 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,0 +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/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 @@ + diff --git a/test-runner.php b/TestRunner.php similarity index 96% rename from test-runner.php rename to TestRunner.php index e381c5b..61c981c 100644 --- a/test-runner.php +++ b/TestRunner.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 '); @@ -20,7 +20,8 @@ 'PaymentTransactions/', 'TransactionReporting/', 'MobileInappTransactions/', - 'VisaCheckout/' + 'VisaCheckout/', + 'AcceptSuite/' ); $errorlevel=error_reporting(); @@ -42,7 +43,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 +71,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 +92,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 +104,7 @@ public function testAllSampleCodes() //response must be successful $this->assertNotNull($response); $this->assertEquals($response->getMessages()->getResultCode(), "Ok"); + echo $sampleMethodName . " - OK \n"; $runTests++; } } 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..1822d78 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 + // 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(); @@ -42,4 +46,4 @@ function getTransactionDetails($transactionId) if(!defined('DONT_RUN_SAMPLES')) getTransactionDetails("2238968786"); -?> \ No newline at end of file +?> diff --git a/TransactionReporting/get-transaction-list.php b/TransactionReporting/get-transaction-list.php index 3ca299d..ccf86c1 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(); @@ -29,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"; 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-src-transaction.php similarity index 94% rename from VisaCheckout/create-visa-checkout-transaction.php rename to VisaCheckout/create-visa-src-transaction.php index e39795f..1edcf11 100644 --- a/VisaCheckout/create-visa-checkout-transaction.php +++ b/VisaCheckout/create-visa-src-transaction.php @@ -1,18 +1,18 @@ 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) @@ -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 93% rename from VisaCheckout/decrypt-visa-checkout-data.php rename to VisaCheckout/decrypt-visa-src-data.php index 21f8e94..2b2b791 100644 --- a/VisaCheckout/decrypt-visa-checkout-data.php +++ b/VisaCheckout/decrypt-visa-src-data.php @@ -1,18 +1,18 @@ 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(); @@ -46,6 +46,6 @@ function decryptVisaCheckoutData() } if(!defined('DONT_RUN_SAMPLES')) - decryptVisaCheckoutData(); + decryptVisaSrcData(); ?> diff --git a/composer.json b/composer.json index 34b5710..08f03a6 100644 --- a/composer.json +++ b/composer.json @@ -2,10 +2,6 @@ "require": { "php": ">=5.6", "ext-curl": "*", - "phpunit/phpunit": "~4.8||~6.0", - "authorizenet/authorizenet": ">=1.9.6 || <2.0" - }, - "autoload": { - "classmap": ["constants"] + "authorizenet/authorizenet": ">=2.0 || <2.1" } } diff --git a/composer.json.sdk-dev b/composer.json.sdk-dev new file mode 100644 index 0000000..9caf00c --- /dev/null +++ b/composer.json.sdk-dev @@ -0,0 +1,11 @@ +{ + "require": { + "php": ">=5.6", + "ext-curl": "*", + "phpunit/phpunit": "~9.0||~9.5", + "authorizenet/authorizenet": ">=2.0 || <2.1" + }, + "autoload": { + "classmap": ["constants", "lib"] + } +} 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 @@ + +