diff --git a/.gitignore b/.gitignore
index 301b14c..5e1ed6a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -43,3 +43,8 @@
# PHP Storm
/.idea/*
+# Operating system files
+.DS_Store
+/lib
+/*.cache
+/testslog
diff --git a/.travis.yml b/.travis.yml
index a335fce..45de70f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,15 +1,35 @@
language: php
-php:
- - 5.3
- - 5.6
- - 7.0
-
+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 --ignore-platform-reqs
+ - composer require "phpunit/phpunit:${PHPUNIT_VERSION}" --no-update
+ - composer update --prefer-dist
script:
- - phpunit test-runner.php .
+ - phpunit TestRunner.php .
diff --git a/AcceptSuite/create-an-accept-payment-transaction.php b/AcceptSuite/create-an-accept-payment-transaction.php
new file mode 100644
index 0000000..562d514
--- /dev/null
+++ b/AcceptSuite/create-an-accept-payment-transaction.php
@@ -0,0 +1,133 @@
+setName(\SampleCodeConstants::MERCHANT_LOGIN_ID);
+ $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY);
+
+ // Set the transaction's refId
+ $refId = 'ref' . time();
+
+ // Create the payment object for a payment nonce
+ $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);
+
+ // Create order information
+ $order = new AnetAPI\OrderType();
+ $order->setInvoiceNumber("10101");
+ $order->setDescription("Golf Shirts");
+
+ // 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("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();
+ $transactionRequestType->setTransactionType("authCaptureTransaction");
+ $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);
+
+ // Create the controller and get the 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() == "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->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("2.23");
+}
+?>
\ No newline at end of file
diff --git a/CustomerProfiles/get-hosted-profile-page.php b/AcceptSuite/get-accept-customer-profile-page.php
similarity index 70%
rename from CustomerProfiles/get-hosted-profile-page.php
rename to AcceptSuite/get-accept-customer-profile-page.php
index b572370..e784f06 100644
--- a/CustomerProfiles/get-hosted-profile-page.php
+++ b/AcceptSuite/get-accept-customer-profile-page.php
@@ -1,16 +1,21 @@
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(\SampleCodeConstants::MERCHANT_LOGIN_ID);
+ $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY);
+
+ // Set the transaction's refId
+ $refId = 'ref' . time();
// Use an existing payment profile ID for this Merchant name and Transaction key
@@ -42,5 +47,5 @@ function getHostedProfilePage($customerprofileid = \SampleCode\Constants::CUSTOM
return $response;
}
if(!defined('DONT_RUN_SAMPLES'))
- getHostedProfilePage();
-?>
\ No newline at end of file
+ getAcceptCustomerProfilePage();
+?>
diff --git a/AcceptSuite/get-an-accept-payment-page.php b/AcceptSuite/get-an-accept-payment-page.php
new file mode 100644
index 0000000..30fe57e
--- /dev/null
+++ b/AcceptSuite/get-an-accept-payment-page.php
@@ -0,0 +1,65 @@
+setName(\SampleCodeConstants::MERCHANT_LOGIN_ID);
+ $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY);
+
+ // Set the transaction's refId
+ $refId = 'ref' . time();
+
+ //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\"}");
+
+ $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}"
+ );
+
+ // Build transaction request
+ $request = new AnetAPI\GetHostedPaymentPageRequest();
+ $request->setMerchantAuthentication($merchantAuthentication);
+ $request->setRefId($refId);
+ $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;
+}
+if (!defined('DONT_RUN_SAMPLES')) {
+ getAnAcceptPaymentPage();
+}
diff --git a/CustomerProfiles/create-customer-payment-profile.php b/CustomerProfiles/create-customer-payment-profile.php
index 83c5d0d..3c3812f 100644
--- a/CustomerProfiles/create-customer-payment-profile.php
+++ b/CustomerProfiles/create-customer-payment-profile.php
@@ -1,67 +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(\SampleCodeConstants::MERCHANT_LOGIN_ID);
+ $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY);
+
+ // Set the transaction's refId
+ $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);
- $paymentCreditCard = new AnetAPI\PaymentType();
- $paymentCreditCard->setCreditCard($creditCard);
+ // 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
- // 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");
+ // 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 a new Customer Payment Profile
- $paymentprofile = new AnetAPI\CustomerPaymentProfileType();
- $paymentprofile->setCustomerType('individual');
- $paymentprofile->setBillTo($billto);
- $paymentprofile->setPayment($paymentCreditCard);
+ // 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");
- $paymentprofiles[] = $paymentprofile;
+ // Create a new Customer Payment Profile object
+ $paymentprofile = new AnetAPI\CustomerPaymentProfileType();
+ $paymentprofile->setCustomerType('individual');
+ $paymentprofile->setBillTo($billto);
+ $paymentprofile->setPayment($paymentCreditCard);
+ $paymentprofile->setDefaultPaymentProfile(true);
- // 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(\SampleCode\Constants::CUSTOMER_PROFILE_ID,"000-000-0009");
+ $paymentprofiles[] = $paymentprofile;
+
+ // Assemble the complete transaction request
+ $paymentprofilerequest = new AnetAPI\CreateCustomerPaymentProfileRequest();
+ $paymentprofilerequest->setMerchantAuthentication($merchantAuthentication);
+
+ // Add an existing profile id to the request
+ $paymentprofilerequest->setCustomerProfileId($existingcustomerprofileid);
+ $paymentprofilerequest->setPaymentProfile($paymentprofile);
+ $paymentprofilerequest->setValidationMode("liveMode");
+
+ // Create the controller and get the response
+ $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("1929905607", "000-000-0009");
+}
?>
diff --git a/CustomerProfiles/create-customer-profile-from-transaction.php b/CustomerProfiles/create-customer-profile-from-transaction.php
index f7232fd..fa9c002 100644
--- a/CustomerProfiles/create-customer-profile-from-transaction.php
+++ b/CustomerProfiles/create-customer-profile-from-transaction.php
@@ -1,48 +1,54 @@
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(\SampleCodeConstants::MERCHANT_LOGIN_ID);
+ $merchantAuthentication->setTransactionKey(\SampleCodeConstants::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);
+
+ $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");
+}
- 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(\SampleCode\Constants::TRANS_ID_TO_CREATE_CUSTOMER_PROFILE);
?>
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..abce577
--- /dev/null
+++ b/CustomerProfiles/create-customer-profile-with-accept-nonce.php
@@ -0,0 +1,90 @@
+setName(\SampleCodeConstants::MERCHANT_LOGIN_ID);
+ $merchantAuthentication->setTransactionKey(\SampleCodeConstants::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(123-123-1234);
+ $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 a new CustomerProfileType and add the payment profile object
+ $customerprofile = new AnetAPI\CustomerProfileType();
+ $customerprofile->setDescription("Customer Test PHP Accept Test");
+
+ $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);
+
+ // 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;
+}
+
+if (!defined('DONT_RUN_SAMPLES')) {
+ createCustomerProfileWithAcceptNonce("test123@test.com");
+}
+?>
diff --git a/CustomerProfiles/create-customer-profile.php b/CustomerProfiles/create-customer-profile.php
index 9f54d8b..49fb43f 100644
--- a/CustomerProfiles/create-customer-profile.php
+++ b/CustomerProfiles/create-customer-profile.php
@@ -1,75 +1,106 @@
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(\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( \SampleCode\Constants::CREDIT_CARD_NUMBER);
- $creditCard->setExpirationDate( \SampleCode\Constants::EXPIRY_DATE);
- $paymentCreditCard = new AnetAPI\PaymentType();
- $paymentCreditCard->setCreditCard($creditCard);
+ // 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
- // 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
+ // 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);
- $paymentprofile = new AnetAPI\CustomerPaymentProfileType();
+ // 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");
- $paymentprofile->setCustomerType('individual');
- $paymentprofile->setBillTo($billto);
- $paymentprofile->setPayment($paymentCreditCard);
- $paymentprofiles[] = $paymentprofile;
- $customerprofile = new AnetAPI\CustomerProfileType();
- $customerprofile->setDescription("Customer 2 Test PHP");
+ // 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");
- $customerprofile->setMerchantCustomerId("M_".$email);
- $customerprofile->setEmail($email);
- $customerprofile->setPaymentProfiles($paymentprofiles);
+ // Create an array of any shipping addresses
+ $shippingProfiles[] = $customerShippingAddress;
- $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( \SampleCode\Constants::TEST_CUSTOMER_EMAIL);
-?>
+
+ // Create a new CustomerPaymentProfile object
+ $paymentProfile = new AnetAPI\CustomerPaymentProfileType();
+ $paymentProfile->setCustomerType('individual');
+ $paymentProfile->setBillTo($billTo);
+ $paymentProfile->setPayment($paymentCreditCard);
+ $paymentProfiles[] = $paymentProfile;
+
+
+ // Create a new CustomerProfileType and add the payment profile object
+ $customerProfile = new AnetAPI\CustomerProfileType();
+ $customerProfile->setDescription("Customer 2 Test PHP");
+ $customerProfile->setMerchantCustomerId("M_" . time());
+ $customerProfile->setEmail($email);
+ $customerProfile->setpaymentProfiles($paymentProfiles);
+ $customerProfile->setShipToList($shippingProfiles);
+
+
+ // Assemble the complete transaction request
+ $request = new AnetAPI\CreateCustomerProfileRequest();
+ $request->setMerchantAuthentication($merchantAuthentication);
+ $request->setRefId($refId);
+ $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")) {
+ 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;
+}
+
+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 51151dd..3044353 100644
--- a/CustomerProfiles/create-customer-shipping-address.php
+++ b/CustomerProfiles/create-customer-shipping-address.php
@@ -1,53 +1,56 @@
setName(\SampleCode\Constants::MERCHANT_LOGIN_ID);
- $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY);
+function createCustomerShippingAddress($existingcustomerprofileid = "1929905607",
+ $phoneNumber="000-000-0000"
+) {
+ /* Create a merchantAuthenticationType object with authentication details
+ retrieved from the constants file */
+ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
+ $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID);
+ $merchantAuthentication->setTransactionKey(\SampleCodeConstants::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/CustomerProfiles/delete-customer-payment-profile.php b/CustomerProfiles/delete-customer-payment-profile.php
index 23238bd..ce3e6ca 100644
--- a/CustomerProfiles/delete-customer-payment-profile.php
+++ b/CustomerProfiles/delete-customer-payment-profile.php
@@ -1,17 +1,22 @@
-]setName(\SampleCode\Constants::MERCHANT_LOGIN_ID);
- $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY);
+function deleteCustomerPaymentProfile($customerProfileId= "1929905607",
+ $customerpaymentprofileid = "1842074814"
+) {
+ /* Create a merchantAuthenticationType object with authentication details
+ retrieved from the constants file */
+ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
+ $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID);
+ $merchantAuthentication->setTransactionKey(\SampleCodeConstants::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 b253064..ee918cc 100644
--- a/CustomerProfiles/delete-customer-profile.php
+++ b/CustomerProfiles/delete-customer-profile.php
@@ -1,17 +1,21 @@
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(\SampleCodeConstants::MERCHANT_LOGIN_ID);
+ $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY);
+
+ // Set the transaction's refId
+ $refId = 'ref' . time();
// Delete an existing customer profile
$request = new AnetAPI\DeleteCustomerProfileRequest();
@@ -35,5 +39,5 @@ function deleteCustomerProfile($customerProfileId)
}
if(!defined('DONT_RUN_SAMPLES'))
- deleteCustomerProfile( \SampleCode\Constants::CUSTOMER_PAYMENT_PROFILE_ID_DELETE);
+ deleteCustomerProfile("1929905651");
?>
diff --git a/CustomerProfiles/delete-customer-shipping-address.php b/CustomerProfiles/delete-customer-shipping-address.php
index 127bfa1..d3f2ccc 100644
--- a/CustomerProfiles/delete-customer-shipping-address.php
+++ b/CustomerProfiles/delete-customer-shipping-address.php
@@ -1,17 +1,21 @@
setName(\SampleCode\Constants::MERCHANT_LOGIN_ID);
- $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY);
+function deleteCustomerShippingAddress($customerprofileid = "1929905607", $customeraddressid = "901116911")
+{
+ /* Create a merchantAuthenticationType object with authentication details
+ retrieved from the constants file */
+ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
+ $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID);
+ $merchantAuthentication->setTransactionKey(\SampleCodeConstants::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-customer-payment-profile-list.php b/CustomerProfiles/get-customer-payment-profile-list.php
index 1e337e9..51da3b3 100644
--- a/CustomerProfiles/get-customer-payment-profile-list.php
+++ b/CustomerProfiles/get-customer-payment-profile-list.php
@@ -1,77 +1,76 @@
setName(\SampleCode\Constants::MERCHANT_LOGIN_ID);
- $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY);
- $refId = 'ref' . time();
-
- //Setting the paging
- $paging = new AnetAPI\PagingType();
- $paging->setLimit("1000");
- $paging->setOffset("1");
-
- //Setting the sorting
- $sorting = new AnetAPI\CustomerPaymentProfileSortingType();
- $sorting->setOrderBy("id");
- $sorting->setOrderDescending("false");
-
- //Creating the request with the required parameters
- $request = new AnetAPI\GetCustomerPaymentProfileListRequest();
- $request->setMerchantAuthentication($merchantAuthentication);
- $request->setRefId($refId);
- $request->setPaging($paging);
- $request->setSorting($sorting);
- $request->setSearchType("cardsExpiringInMonth");
- $request->setMonth("2020-12");
-
- // 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();
-?>
+function getCustomerPaymentProfileList()
+{
+ /* Create a merchantAuthenticationType object with authentication details
+ retrieved from the constants file */
+ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
+ $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID);
+ $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY);
+
+ // Set the transaction's refId
+ $refId = 'ref' . time();
+
+ //Setting the paging
+ $paging = new AnetAPI\PagingType();
+ $paging->setLimit("1000");
+ $paging->setOffset("1");
+
+ //Setting the sorting
+ $sorting = new AnetAPI\CustomerPaymentProfileSortingType();
+ $sorting->setOrderBy("id");
+ $sorting->setOrderDescending(false);
+
+ //Creating the request with the required parameters
+ $request = new AnetAPI\GetCustomerPaymentProfileListRequest();
+ $request->setMerchantAuthentication($merchantAuthentication);
+ $request->setRefId($refId);
+ $request->setPaging($paging);
+ $request->setSorting($sorting);
+ $request->setSearchType("cardsExpiringInMonth");
+ $request->setMonth("2020-12");
+
+ // 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/CustomerProfiles/get-customer-payment-profile.php b/CustomerProfiles/get-customer-payment-profile.php
index 7323653..6e056a5 100644
--- a/CustomerProfiles/get-customer-payment-profile.php
+++ b/CustomerProfiles/get-customer-payment-profile.php
@@ -1,20 +1,23 @@
setName(\SampleCode\Constants::MERCHANT_LOGIN_ID);
- $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY);
- $refId = 'ref' . time();
+function getCustomerPaymentProfile($customerProfileId="1929905607",
+ $customerPaymentProfileId= "1842074814"
+) {
+ /* Create a merchantAuthenticationType object with authentication details
+ retrieved from the constants file */
+ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
+ $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID);
+ $merchantAuthentication->setTransactionKey(\SampleCodeConstants::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..20b68a0 100644
--- a/CustomerProfiles/get-customer-profile-ids.php
+++ b/CustomerProfiles/get-customer-profile-ids.php
@@ -1,16 +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();
// Get all existing customer profile ID's
diff --git a/CustomerProfiles/get-customer-profile.php b/CustomerProfiles/get-customer-profile.php
index 6af433a..c69efc6 100644
--- a/CustomerProfiles/get-customer-profile.php
+++ b/CustomerProfiles/get-customer-profile.php
@@ -1,22 +1,26 @@
setName(\SampleCodeConstants::MERCHANT_LOGIN_ID);
+ $merchantAuthentication->setTransactionKey(\SampleCodeConstants::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();
$creditCard->setCardNumber( "4111111111111111" );
- $creditCard->setExpirationDate( "2038-12");
+ $creditCard->setExpirationDate("2038-12");
$paymentCreditCard = new AnetAPI\PaymentType();
$paymentCreditCard->setCreditCard($creditCard);
diff --git a/CustomerProfiles/get-customer-shipping-address.php b/CustomerProfiles/get-customer-shipping-address.php
index 9abeff5..1e1b541 100644
--- a/CustomerProfiles/get-customer-shipping-address.php
+++ b/CustomerProfiles/get-customer-shipping-address.php
@@ -1,16 +1,21 @@
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(\SampleCodeConstants::MERCHANT_LOGIN_ID);
+ $merchantAuthentication->setTransactionKey(\SampleCodeConstants::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;
@@ -60,6 +65,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/update-customer-payment-profile.php b/CustomerProfiles/update-customer-payment-profile.php
index b497807..484d5e5 100644
--- a/CustomerProfiles/update-customer-payment-profile.php
+++ b/CustomerProfiles/update-customer-payment-profile.php
@@ -1,100 +1,95 @@
setName(\SampleCode\Constants::MERCHANT_LOGIN_ID);
- $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY);
- $refId = 'ref' . time();
+function updateCustomerPaymentProfile($customerProfileId = "1916322670",
+ $customerPaymentProfileId = "1829639667")
+{
+ /* Create a merchantAuthenticationType object with authentication details
+ retrieved from the constants file */
+ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
+ $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( "0718");
- $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 87e61ac..4a2c708 100644
--- a/CustomerProfiles/update-customer-profile.php
+++ b/CustomerProfiles/update-customer-profile.php
@@ -1,21 +1,26 @@
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();
// 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-shipping-address.php b/CustomerProfiles/update-customer-shipping-address.php
index ea8295e..36ad6ad 100644
--- a/CustomerProfiles/update-customer-shipping-address.php
+++ b/CustomerProfiles/update-customer-shipping-address.php
@@ -1,16 +1,21 @@
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(\SampleCodeConstants::MERCHANT_LOGIN_ID);
+ $merchantAuthentication->setTransactionKey(\SampleCodeConstants::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;
@@ -49,6 +54,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( "1929905607","901116911");
?>
diff --git a/CustomerProfiles/validate-customer-payment-profile.php b/CustomerProfiles/validate-customer-payment-profile.php
index 33288cb..ca57209 100644
--- a/CustomerProfiles/validate-customer-payment-profile.php
+++ b/CustomerProfiles/validate-customer-payment-profile.php
@@ -1,17 +1,22 @@
setName(\SampleCode\Constants::MERCHANT_LOGIN_ID);
- $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY);
+function validateCustomerPaymentProfile($customerProfileId= "1929905607",
+ $customerPaymentProfileId= "1842074814"
+) {
+ /* Create a merchantAuthenticationType object with authentication details
+ retrieved from the constants file */
+ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
+ $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID);
+ $merchantAuthentication->setTransactionKey(\SampleCodeConstants::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
new file mode 100644
index 0000000..c3e6df5
--- /dev/null
+++ b/FraudManagement/approve-or-decline-held-transaction.php
@@ -0,0 +1,82 @@
+setName(\SampleCodeConstants::MERCHANT_LOGIN_ID);
+ $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY);
+
+ // Set the transaction's refId
+ $refId = 'ref' . time();
+
+ //create a transaction
+ $transactionRequestType = new AnetAPI\HeldTransactionRequestType();
+ $transactionRequestType->setAction("approve"); //other possible value: decline
+ $transactionRequestType->setRefTransId("60012148205");
+
+
+ $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'))
+ approveOrDeclineHeldTransaction();
+?>
diff --git a/FraudManagement/get-held-transaction-list.php b/FraudManagement/get-held-transaction-list.php
new file mode 100644
index 0000000..9405614
--- /dev/null
+++ b/FraudManagement/get-held-transaction-list.php
@@ -0,0 +1,56 @@
+setName(\SampleCodeConstants::MERCHANT_LOGIN_ID);
+ $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY);
+
+ // Set the transaction's refId
+ $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'))
+ getHeldTransactionList();
+
+?>
diff --git a/MobileInAppTransactions/create-an-accept-transaction.php b/MobileInAppTransactions/create-an-accept-transaction.php
new file mode 100644
index 0000000..ea7650e
--- /dev/null
+++ b/MobileInAppTransactions/create-an-accept-transaction.php
@@ -0,0 +1,120 @@
+setName(\SampleCodeConstants::MERCHANT_LOGIN_ID);
+ $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY);
+
+ // Set the transaction's refId
+ $refId = 'ref' . time();
+
+ // Create the payment object for a payment nonce
+ $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);
+
+ // Create order information
+ $order = new AnetAPI\OrderType();
+ $order->invoiceNumber("10101");
+ $order->setDescription("Golf Shirts");
+
+ // 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 and add the previous objects to it
+ $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);
+
+ // Assemble the complete transaction request
+ $request = new AnetAPI\CreateTransactionRequest();
+ $request->setMerchantAuthentication($merchantAuthentication);
+ $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);
+
+
+ if ($response != null) {
+ // Check to see if the API request was successfully received and acted upon
+ 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();
+
+ 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";
+ }
+
+ return $response;
+}
+
+if (!defined('DONT_RUN_SAMPLES')) {
+ CreateAnAcceptTransaction("2.23");
+}
+?>
diff --git a/MobileInAppTransactions/create-an-android-pay-transaction.php b/MobileInAppTransactions/create-an-android-pay-transaction.php
new file mode 100644
index 0000000..175a0a4
--- /dev/null
+++ b/MobileInAppTransactions/create-an-android-pay-transaction.php
@@ -0,0 +1,90 @@
+setName(\SampleCodeConstants::MERCHANT_LOGIN_ID);
+ $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY);
+
+ // Set the transaction's refId
+ $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)
+ {
+ 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'))
+ createAnAndroidPayTransaction();
+?>
diff --git a/ApplePayTransactions/create-an-apple-pay-transaction.php b/MobileInAppTransactions/create-an-apple-pay-transaction.php
similarity index 69%
rename from ApplePayTransactions/create-an-apple-pay-transaction.php
rename to MobileInAppTransactions/create-an-apple-pay-transaction.php
index b01dbcd..4a8006a 100644
--- a/ApplePayTransactions/create-an-apple-pay-transaction.php
+++ b/MobileInAppTransactions/create-an-apple-pay-transaction.php
@@ -1,15 +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();
$op = new AnetAPI\OpaqueDataType();
@@ -32,26 +37,52 @@ function createAnApplePayTransaction(){
$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->getResponseCode()=="1") )
+
+ 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 " 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-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
new file mode 100644
index 0000000..6ef77cd
--- /dev/null
+++ b/PayPalExpressCheckout/authorization-and-capture-continued.php
@@ -0,0 +1,78 @@
+setName(\SampleCodeConstants::MERCHANT_LOGIN_ID);
+ $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY);
+
+ // Set the transaction's refId
+ $refId = 'ref' . time();
+
+ // Set PayPal compatible merchant credentials
+ $payPalType=new AnetAPI\PayPalType();
+ $payPalType->setPayerID($payerID);
+
+ $paymentOne = new AnetAPI\PaymentType();
+ $paymentOne->setPayPal($payPalType);
+
+ // 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);
+
+ if ($response != null) {
+ if ($response->getMessages()->getResultCode() == "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;
+}
+
+if (!defined('DONT_RUN_SAMPLES')) {
+ payPalAuthorizeCaptureContinued("2241708986", "6ZSCSYG33VP8Q");
+}
diff --git a/PayPalExpressCheckout/authorization-and-capture.php b/PayPalExpressCheckout/authorization-and-capture.php
new file mode 100644
index 0000000..5252c27
--- /dev/null
+++ b/PayPalExpressCheckout/authorization-and-capture.php
@@ -0,0 +1,93 @@
+setName(\SampleCodeConstants::MERCHANT_LOGIN_ID);
+ $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY);
+
+ // Set the transaction's refId
+ $refId = 'ref' . time();
+
+ $payPalType=new AnetAPI\PayPalType();
+ $payPalType->setCancelUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
+ $payPalType->setSuccessUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
+
+ $paymentOne = new AnetAPI\PaymentType();
+ $paymentOne->setPayPal($payPalType);
+
+ // Create an authorize and capture transaction
+ $transactionRequestType = new AnetAPI\TransactionRequestType();
+ $transactionRequestType->setTransactionType( "authCaptureTransaction");
+ $transactionRequestType->setPayment($paymentOne);
+ $transactionRequestType->setAmount($amount);
+
+ $request = new AnetAPI\CreateTransactionRequest();
+ $request->setMerchantAuthentication($merchantAuthentication);
+ $request->setTransactionRequest( $transactionRequestType);
+ $controller = new AnetController\CreateTransactionController($request);
+ $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);
+
+ if ($response != null)
+ {
+ if($response->getMessages()->getResultCode() == "Ok")
+ {
+ $tresponse = $response->getTransactionResponse();
+
+ if ($tresponse != null && $tresponse->getMessages() != null)
+ {
+ 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;
+ }
+
+ if(!defined('DONT_RUN_SAMPLES'))
+ payPalAuthorizeCapture(12.322);
+?>
diff --git a/PayPalExpressCheckout/authorization-only-continued.php b/PayPalExpressCheckout/authorization-only-continued.php
new file mode 100644
index 0000000..20422d7
--- /dev/null
+++ b/PayPalExpressCheckout/authorization-only-continued.php
@@ -0,0 +1,85 @@
+setName(\SampleCodeConstants::MERCHANT_LOGIN_ID);
+ $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY);
+
+ // Set the transaction's refId
+ $refId = 'ref' . time();
+
+ // 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");
+
+ $payment_type = new AnetAPI\PaymentType();
+ $payment_type->setPayPal($paypal_type);
+
+ //create a transaction
+ $transactionRequestType = new AnetAPI\TransactionRequestType();
+ $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);
+
+ $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 "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 "No response returned \n";
+ }
+
+ return $response;
+}
+
+if (!defined('DONT_RUN_SAMPLES')) {
+ payPalAuthorizeOnlyContinued("2241711631", "JJLRRB29QC7RU");
+}
diff --git a/PayPalExpressCheckout/authorization-only.php b/PayPalExpressCheckout/authorization-only.php
new file mode 100644
index 0000000..32fd18e
--- /dev/null
+++ b/PayPalExpressCheckout/authorization-only.php
@@ -0,0 +1,93 @@
+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 paypal account
+ $payPalType = new AnetAPI\PayPalType();
+ $payPalType->setCancelUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
+ $payPalType->setSuccessUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
+ $paymentOne = new AnetAPI\PaymentType();
+ $paymentOne->setPayPal($payPalType);
+
+ //create a auth-only transaction
+ $transactionRequestType = new AnetAPI\TransactionRequestType();
+ $transactionRequestType->setTransactionType( "authOnlyTransaction");
+ $transactionRequestType->setAmount($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 "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 "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'))
+ payPalAuthorizeOnly(23.34);
+
+?>
diff --git a/PaypalExpressCheckout/credit.php b/PayPalExpressCheckout/credit.php
similarity index 50%
rename from PaypalExpressCheckout/credit.php
rename to PayPalExpressCheckout/credit.php
index 8e84885..498eba8 100644
--- a/PaypalExpressCheckout/credit.php
+++ b/PayPalExpressCheckout/credit.php
@@ -1,20 +1,23 @@
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();
- //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
@@ -42,21 +45,47 @@ function payPalCredit($transactionId) {
if ($response != null)
{
+ if($response->getMessages()->getResultCode() == "Ok")
+ {
$tresponse = $response->getTransactionResponse();
-
- if (($tresponse != null)&& ($response->getMessages()->getResultCode()=="Ok"))
+
+ 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";
+ 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
new file mode 100644
index 0000000..4a81b70
--- /dev/null
+++ b/PayPalExpressCheckout/get-details.php
@@ -0,0 +1,116 @@
+setName(\SampleCodeConstants::MERCHANT_LOGIN_ID);
+ $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY);
+
+ // Set the transaction's refId
+ $refId = 'ref' . time();
+
+ //create a transaction of type get details
+ $transactionRequestType = new AnetAPI\TransactionRequestType();
+ $transactionRequestType->setTransactionType( "getDetailsTransaction");
+
+ //replace following transaction ID with your transaction ID for which the details are required
+ $transactionRequestType->setRefTransId($transactionId);
+
+ // Create the payment data for a paypal account
+ $payPalType = new AnetAPI\PayPalType();
+ $payPalType->setCancelUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
+ $payPalType->setSuccessUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
+ $paymentOne = new AnetAPI\PaymentType();
+ $paymentOne->setPayPal($payPalType);
+
+ $transactionRequestType->setPayment($paymentOne);
+
+ //create a transaction request
+ $request = new AnetAPI\CreateTransactionRequest();
+ $request->setMerchantAuthentication($merchantAuthentication);
+ $request->setRefId( $refId);
+ $request->setTransactionRequest( $transactionRequestType);
+
+ $controller = new AnetController\CreateTransactionController($request);
+
+ //execute the api call to get transaction details
+ $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 "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 "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'))
+ payPalGetDetails("60007107304");
+
+?>
\ No newline at end of file
diff --git a/PayPalExpressCheckout/prior-authorization-capture.php b/PayPalExpressCheckout/prior-authorization-capture.php
new file mode 100644
index 0000000..432d0fe
--- /dev/null
+++ b/PayPalExpressCheckout/prior-authorization-capture.php
@@ -0,0 +1,93 @@
+setName(\SampleCodeConstants::MERCHANT_LOGIN_ID);
+ $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY);
+
+ // Set the transaction's refId
+ $refId = 'ref' . time();
+
+ $payPalType = new AnetAPI\PayPalType();
+ $payPalType->setSuccessUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
+ $payPalType->setCancelUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
+
+ $paymentType = new AnetAPI\PaymentType();
+ $paymentType->setPayPal($payPalType);
+
+ $transactionRequest = new AnetAPI\TransactionRequestType();
+ $transactionRequest->setTransactionType("priorAuthCaptureTransaction");
+ $transactionRequest->setPayment($paymentType);
+ $transactionRequest->setAmount(floatval(19.45));
+ $transactionRequest->setRefTransId($transactionId);
+
+ $request = new AnetAPI\CreateTransactionRequest();
+ $request->setMerchantAuthentication($merchantAuthentication);
+ $request->setRefId( $refId);
+ $request->setTransactionRequest($transactionRequest);
+
+ $controller = new AnetController\CreateTransactionController($request);
+
+ $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);
+
+ if ($response != null)
+ {
+ if($response->getMessages()->getResultCode() == "Ok")
+ {
+ $tresponse = $response->getTransactionResponse();
+
+ 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";
+ }
+ 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'))
+ {
+ payPalPriorAuthorizationCapture("2249863278");
+ }
+?>
\ No newline at end of file
diff --git a/PayPalExpressCheckout/void.php b/PayPalExpressCheckout/void.php
new file mode 100644
index 0000000..bb6e242
--- /dev/null
+++ b/PayPalExpressCheckout/void.php
@@ -0,0 +1,91 @@
+setName(\SampleCodeConstants::MERCHANT_LOGIN_ID);
+ $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY);
+
+ // Set the transaction's refId
+ $refId = 'ref' . time();
+
+ $payPalType = new AnetAPI\PayPalType();
+ $payPalType->setSuccessUrl("");
+ $payPalType->setCancelUrl("");
+
+ $paymentType = new AnetAPI\PaymentType();
+ $paymentType->setPayPal($payPalType);
+
+ $transactionRequest = new AnetAPI\TransactionRequestType();
+ $transactionRequest->setTransactionType("voidTransaction");
+ $transactionRequest->setPayment($paymentType);
+ $transactionRequest->setRefTransId($transactionId);
+
+ $request = new AnetAPI\CreateTransactionRequest();
+ $request->setMerchantAuthentication($merchantAuthentication);
+ $request->setRefId( $refId);
+ $request->setTransactionRequest($transactionRequest);
+
+ $controller = new AnetController\CreateTransactionController($request);
+
+ $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);
+
+ if ($response != null)
+ {
+ if($response->getMessages()->getResultCode() == "Ok")
+ {
+ $tresponse = $response->getTransactionResponse();
+
+ 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";
+ }
+ 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'))
+ payPalVoid("2241706281");
+
+ ?>
\ No newline at end of file
diff --git a/PaymentTransactions/authorize-credit-card.php b/PaymentTransactions/authorize-credit-card.php
index 4179620..10c8198 100644
--- a/PaymentTransactions/authorize-credit-card.php
+++ b/PaymentTransactions/authorize-credit-card.php
@@ -1,61 +1,133 @@
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();
// 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
$paymentOne = new AnetAPI\PaymentType();
$paymentOne->setCreditCard($creditCard);
- //create a transaction
+ // Create order information
+ $order = new AnetAPI\OrderType();
+ $order->setInvoiceNumber("10101");
+ $order->setDescription("Golf Shirts");
+
+ // 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("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();
- $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);
-
- if ($response != null)
- {
- $tresponse = $response->getTransactionResponse();
-
- if (($tresponse != null) && ($tresponse->getResponseCode()== \SampleCode\Constants::RESPONSE_OK) )
- {
- echo " AUTH CODE : " . $tresponse->getAuthCode() . "\n";
- echo " TRANS ID : " . $tresponse->getTransId() . "\n";
- }
- else
- {
- echo "ERROR : " . $tresponse->getResponseCode() . "\n";
- }
-
- }
- else
- {
- echo "No response returned";
+ $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() == "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->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'))
- authorizeCreditCard( \SampleCode\Constants::SAMPLE_AMOUNT);
+}
+
+if (!defined('DONT_RUN_SAMPLES')) {
+ 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 0062e0b..8879a05 100644
--- a/PaymentTransactions/capture-funds-authorized-through-another-channel.php
+++ b/PaymentTransactions/capture-funds-authorized-through-another-channel.php
@@ -1,20 +1,25 @@
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();
$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,8 +30,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();
$request->setMerchantAuthentication($merchantAuthentication);
@@ -37,25 +41,51 @@ function captureFundsAuthorizedThroughAnotherChannel($amount){
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 "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->getResponseCode()== \SampleCode\Constants::RESPONSE_OK) )
+ if($tresponse != null && $tresponse->getErrors() != null)
{
- echo "Successful." . "\n";
- echo "Capture funds authorized through another channel TRANS ID : " . $tresponse->getTransId() . " Amount : $amount \n";
+ 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, \SampleCode\Constants::MAX_AMOUNT)/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 763f1c6..de19ffd 100644
--- a/PaymentTransactions/capture-previously-authorized-amount.php
+++ b/PaymentTransactions/capture-previously-authorized-amount.php
@@ -1,15 +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();
// Now capture the previously authorized amount
@@ -28,23 +33,51 @@ function capturePreviouslyAuthorizedAmount($transactionid){
if ($response != null)
{
- $tresponse = $response->getTransactionResponse();
- if (($tresponse != null) && ($tresponse->getResponseCode()== \SampleCode\Constants::RESPONSE_OK) )
+ if($response->getMessages()->getResultCode() == "Ok")
{
- echo "Successful." . "\n";
- echo "Capture Previously Authorized Amount, Trans ID : " . $tresponse->getRefTransId() . "\n";
+ $tresponse = $response->getTransactionResponse();
+
+ 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";
+ 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(\SampleCode\Constants::TRANS_ID_PREVIOUSLY_AUTHORIZED);
+ capturePreviouslyAuthorizedAmount(60007076002);
?>
diff --git a/PaymentTransactions/charge-credit-card.php b/PaymentTransactions/charge-credit-card.php
index 759c3f0..c05df53 100644
--- a/PaymentTransactions/charge-credit-card.php
+++ b/PaymentTransactions/charge-credit-card.php
@@ -1,64 +1,132 @@
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($amount);
- $transactionRequestType->setOrder($order);
- $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()== \SampleCode\Constants::RESPONSE_OK) )
- {
- echo "Charge Credit Card AUTH CODE : " . $tresponse->getAuthCode() . "\n";
- echo "Charge Credit Card TRANS ID : " . $tresponse->getTransId() . "\n";
- }
- else
- {
- echo "Charge Credit Card ERROR : Invalid response\n";
- }
+function chargeCreditCard($amount)
+{
+ /* Create a merchantAuthenticationType object with authentication details
+ retrieved from the constants file */
+ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
+ $merchantAuthentication->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("123");
+
+ // Add the payment data to a paymentType object
+ $paymentOne = new AnetAPI\PaymentType();
+ $paymentOne->setCreditCard($creditCard);
+
+ // Create order information
+ $order = new AnetAPI\OrderType();
+ $order->setInvoiceNumber("10101");
+ $order->setDescription("Golf Shirts");
+
+ // 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("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();
+ $transactionRequestType->setTransactionType("authCaptureTransaction");
+ $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);
+
+ // Create the controller and get the 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() == "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();
- }
- else
- {
- echo "Charge Credit card Null response returned";
- }
- return $response;
- }
- if(!defined('DONT_RUN_SAMPLES'))
- chargeCreditCard(\SampleCode\Constants::SAMPLE_AMOUNT);
-?>
+ 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";
+ }
+
+ return $response;
+}
+
+if (!defined('DONT_RUN_SAMPLES')) {
+ chargeCreditCard("2.23");
+}
diff --git a/PaymentTransactions/charge-customer-profile.php b/PaymentTransactions/charge-customer-profile.php
index 0cb8dfd..7482001 100644
--- a/PaymentTransactions/charge-customer-profile.php
+++ b/PaymentTransactions/charge-customer-profile.php
@@ -1,15 +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();
$profileToCharge = new AnetAPI\CustomerProfilePaymentType();
@@ -18,7 +23,6 @@ function chargeCustomerProfile($profileid, $paymentprofileid, $amount){
$paymentProfile->setPaymentProfileId($paymentprofileid);
$profileToCharge->setPaymentProfile($paymentProfile);
-
$transactionRequestType = new AnetAPI\TransactionRequestType();
$transactionRequestType->setTransactionType( "authCaptureTransaction");
$transactionRequestType->setAmount($amount);
@@ -30,31 +34,56 @@ 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() == "Ok")
{
- echo "ERROR" . "\n";
+ $tresponse = $response->getTransactionResponse();
+
+ 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";
+ 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(\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..7b11b1d 100644
--- a/PaymentTransactions/charge-tokenized-credit-card.php
+++ b/PaymentTransactions/charge-tokenized-credit-card.php
@@ -1,23 +1,29 @@
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();
// 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);
- //Set the cryptogram
- $creditCard->setCryptogram( \SampleCode\Constants::CRYPTOGRAM);
+ $creditCard->setCardNumber("4111111111111111");
+ $creditCard->setExpirationDate("2038-12");
+ // Set the token specific info
+ $creditCard->setIsPaymentToken(true);
+ $creditCard->setCryptogram("EjRWeJASNFZ4kBI0VniQEjRWeJA=");
$paymentOne = new AnetAPI\PaymentType();
$paymentOne->setCreditCard($creditCard);
@@ -38,23 +44,51 @@ function chargeTokenizedCreditCard($amount){
if ($response != null)
{
- $tresponse = $response->getTransactionResponse();
- if (($tresponse != null) && ($tresponse->getResponseCode()== \SampleCode\Constants::RESPONSE_OK) )
+ if($response->getMessages()->getResultCode() == "Ok")
{
- echo "Charge Tokenized Credit Card AUTH CODE : " . $tresponse->getAuthCode() . "\n";
- echo "Charge Tokenized Credit Card TRANS ID : " . $tresponse->getTransId() . "\n";
+ $tresponse = $response->getTransactionResponse();
+
+ if ($tresponse != null && $tresponse->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 "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'))
- chargeTokenizedCreditCard( \SampleCode\Constants::SAMPLE_AMOUNT);
+ chargeTokenizedCreditCard(12.23);
?>
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 69ce174..b68f771 100644
--- a/PaymentTransactions/credit-bank-account.php
+++ b/PaymentTransactions/credit-bank-account.php
@@ -1,67 +1,94 @@
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->setRoutingNumber(\SampleCode\Constants::ROUTING_NUMBER);
- $bankAccount->setAccountNumber(\SampleCode\Constants::ACCOUNT_NUMBER);
- $bankAccount->setNameOnAccount(\SampleCode\Constants::NAME_ON_ACCOUNT);
+ $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($randomAccountNumber);
+ $bankAccount->setNameOnAccount('John Doe');
+ $bankAccount->setBankName('Wells Fargo Bank NA');
$paymentBank= new AnetAPI\PaymentType();
$paymentBank->setBankAccount($bankAccount);
- // Order info
+ // 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
+ //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);
- 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") )
- {
- echo "Credit Bank Account ERROR : DECLINED" . "\n";
- }
- elseif (($tresponse != null) && ($tresponse->getResponseCode()=="4") )
- {
- echo "Credit Bank Account ERROR: HELD FOR REVIEW:" . "\n";
- }
- }
- else
- {
- echo "Credit Bank Account No response returned";
+ $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 "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 "No response returned \n";
}
+
return $response;
- }
- if(!defined('DONT_RUN_SAMPLES'))
- creditBankAccount( \SampleCode\Constants::SAMPLE_AMOUNT);
-?>
+}
+
+if (!defined('DONT_RUN_SAMPLES')) {
+ creditBankAccount(5.29);
+}
+
diff --git a/PaymentTransactions/debit-bank-account.php b/PaymentTransactions/debit-bank-account.php
index 85a9caf..6d50388 100644
--- a/PaymentTransactions/debit-bank-account.php
+++ b/PaymentTransactions/debit-bank-account.php
@@ -1,73 +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();
+ //Generate random bank account number
+ $randomAccountNumber= rand(100000000,9999999999);
+
// Create the payment data for a Bank Account
$bankAccount = new AnetAPI\BankAccountType();
- //$bankAccount->setAccountType('CHECKING');
+ $bankAccount->setAccountType('checking');
+ // see eCheck documentation for proper echeck type to use for each situation
$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('122000661');
+
+ $bankAccount->setAccountNumber(rand(10000,999999999999));
+
+ $bankAccount->setNameOnAccount('John Doe');
+ $bankAccount->setBankName('Wells Fargo Bank NA');
$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);
- 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") )
- {
- 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";
- }
- else
- {
- echo "Debit Bank Account 3 response returned";
- }
- }
- else
- {
- echo "Debit Bank Account Null response returned";
+ $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 " 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 "No response returned \n";
}
+
return $response;
- }
- if(!defined('DONT_RUN_SAMPLES'))
- debitBankAccount( \SampleCode\Constants::SAMPLE_AMOUNT);
-?>
+}
+
+if (!defined('DONT_RUN_SAMPLES')) {
+ debitBankAccount(5.29);
+}
diff --git a/PaymentTransactions/refund-transaction.php b/PaymentTransactions/refund-transaction.php
index b30380b..7171066 100644
--- a/PaymentTransactions/refund-transaction.php
+++ b/PaymentTransactions/refund-transaction.php
@@ -1,16 +1,21 @@
setName(\SampleCode\Constants::MERCHANT_LOGIN_ID);
- $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY);
- $refId = 'ref' . time();
+ $merchantAuthentication->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();
@@ -23,6 +28,7 @@ function refundTransaction($amount){
$transactionRequest->setTransactionType( "refundTransaction");
$transactionRequest->setAmount($amount);
$transactionRequest->setPayment($paymentOne);
+ $transactionRequest->setRefTransId($refTransId);
$request = new AnetAPI\CreateTransactionRequest();
@@ -31,25 +37,53 @@ 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() == "Ok")
{
- echo "Refund SUCCESS: " . $tresponse->getTransId() . "\n";
+ $tresponse = $response->getTransactionResponse();
+
+ 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";
+ }
+ 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'))
- refundTransaction( \SampleCode\Constants::SAMPLE_AMOUNT_REFUND);
-?>
\ No newline at end of file
+ refundTransaction( "2.23");
+?>
diff --git a/PaymentTransactions/update-split-tender-group.php b/PaymentTransactions/update-split-tender-group.php
index 338ac09..e386750 100644
--- a/PaymentTransactions/update-split-tender-group.php
+++ b/PaymentTransactions/update-split-tender-group.php
@@ -1,22 +1,27 @@
setName( \SampleCode\Constants::MERCHANT_LOGIN_ID);
- $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY);
- $refId = 'ref' . time();
+ $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->setSplitTenderId(\SampleCode\Constants::SPLIT_TENDER_ID);
- $request->setSplitTenderStatus(\SampleCode\Constants::STATUS_VOID);
+ $request->setRefId($refId);
+ $request->setSplitTenderId("115901");
+ $request->setSplitTenderStatus("voided");
$controller = new AnetController\UpdateSplitTenderGroupController($request);
@@ -38,4 +43,4 @@ function updateSplitTenderGroup(){
if(!defined('DONT_RUN_SAMPLES'))
updateSplitTenderGroup();
- ?>
\ No newline at end of file
+ ?>
diff --git a/PaymentTransactions/void-transaction.php b/PaymentTransactions/void-transaction.php
index e4e9405..c2a4d3b 100644
--- a/PaymentTransactions/void-transaction.php
+++ b/PaymentTransactions/void-transaction.php
@@ -1,57 +1,81 @@
setName(\SampleCode\Constants::MERCHANT_LOGIN_ID);
- $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY);
- $refId = 'ref' . time();
+ $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID);
+ $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY);
- // 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);
- $paymentOne = new AnetAPI\PaymentType();
- $paymentOne->setCreditCard($creditCard);
+ // Set the transaction's refId
+ $refId = 'ref' . time();
+
//create a transaction
$transactionRequestType = new AnetAPI\TransactionRequestType();
$transactionRequestType->setTransactionType( "voidTransaction");
- $transactionRequestType->setPayment($paymentOne);
$transactionRequestType->setRefTransId($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() == "Ok")
{
- echo "Void transaction SUCCESS AUTH CODE: " . $tresponse->getAuthCode() . "\n";
- echo "Void transaction SUCCESS TRANS ID : " . $tresponse->getTransId() . "\n";
+ $tresponse = $response->getTransactionResponse();
+
+ if ($tresponse != null && $tresponse->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";
+ 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'))
- voidTransaction(\SampleCode\Constants::TRANS_ID_VOID);
+ voidTransaction("60009605785");
?>
diff --git a/PaypalExpressCheckout/authorization-and-capture-continue.php b/PaypalExpressCheckout/authorization-and-capture-continue.php
deleted file mode 100644
index ade134b..0000000
--- a/PaypalExpressCheckout/authorization-and-capture-continue.php
+++ /dev/null
@@ -1,66 +0,0 @@
-setName(\SampleCode\Constants::MERCHANT_LOGIN_ID);
- $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY);
-
- $payPalType=new AnetAPI\PayPalType();
- $payPalType->setPayerID($payerID);
-
- $paymentOne = new AnetAPI\PaymentType();
- $paymentOne->setPayPal($payPalType);
-
- // Create an authorize and capture continue transaction
- $transactionRequestType = new AnetAPI\TransactionRequestType();
- $transactionRequestType->setTransactionType( "authCaptureContinueTransaction");
- $transactionRequestType->setPayment($paymentOne);
- $transactionRequestType->setRefTransId($refTransId);
-
- $request = new AnetAPI\CreateTransactionRequest();
- $request->setMerchantAuthentication($merchantAuthentication);
- $request->setTransactionRequest( $transactionRequestType);
- $controller = new AnetController\CreateTransactionController($request);
- $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);
-
- if ($response != null)
- {
- $tresponse = $response->getTransactionResponse();
- if (($tresponse != null))
- {
- echo "Transaction Response...\n";
- echo "Received response code: ".$tresponse->getResponseCode()."\n";
- //Valid response codes: 1=Approved, 2=Declined, 3=Error, 5=Need Payer Consent
- echo "Secure acceptance URL: ".$tresponse->getSecureAcceptance()->getSecureAcceptanceUrl()."\n";
- echo "Transaction ID: ".$tresponse->getTransId()."\n";
- }
- else
- echo "NULL transactionResponse Error\n";
- $messages=$response->getMessages();
- if (($messages != null))
- {
- 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";
-
- return $response;
- }
-
- if(!defined('DONT_RUN_SAMPLES'))
- payPalAuthorizeCaptureContinue(\SampleCode\Constants::TRANS_ID_PAYPAL,
- \SampleCode\Constants::PAYER_ID);
-?>
diff --git a/PaypalExpressCheckout/authorization-and-capture.php b/PaypalExpressCheckout/authorization-and-capture.php
deleted file mode 100644
index 5d73cb8..0000000
--- a/PaypalExpressCheckout/authorization-and-capture.php
+++ /dev/null
@@ -1,55 +0,0 @@
-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");
-
- $paymentOne = new AnetAPI\PaymentType();
- $paymentOne->setPayPal($payPalType);
-
- // Create an authorize and capture transaction
- $transactionRequestType = new AnetAPI\TransactionRequestType();
- $transactionRequestType->setTransactionType( "authCaptureTransaction");
- $transactionRequestType->setPayment($paymentOne);
- $transactionRequestType->setAmount($amount);
-
- $request = new AnetAPI\CreateTransactionRequest();
- $request->setMerchantAuthentication($merchantAuthentication);
- $request->setTransactionRequest( $transactionRequestType);
- $controller = new AnetController\CreateTransactionController($request);
- $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);
-
- if ($response != null)
- {
- $tresponse = $response->getTransactionResponse();
- if (($tresponse != null))
- {
- echo "Received response code: ".$tresponse->getResponseCode()."\n";
- //Valid response codes: 1=Approved, 2=Declined, 3=Error, 5=Need Payer Consent
- echo "Secure acceptance URL: ".$tresponse->getSecureAcceptance()->getSecureAcceptanceUrl()."\n";
- echo "Transaction ID: ".$tresponse->getTransId()."\n";
- }
- else
- echo "NULL transactionResponse Error\n";
- }
- else
- echo "NULL response Error\n";
-
- return $response;
- }
-
- if(!defined('DONT_RUN_SAMPLES'))
- payPalAuthorizeCapture(\SampleCode\Constants::SAMPLE_AMOUNT);
-?>
diff --git a/PaypalExpressCheckout/authorization-only-continued.php b/PaypalExpressCheckout/authorization-only-continued.php
deleted file mode 100644
index e5c2711..0000000
--- a/PaypalExpressCheckout/authorization-only-continued.php
+++ /dev/null
@@ -1,70 +0,0 @@
-setName(\SampleCode\Constants::MERCHANT_LOGIN_ID);
- $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY);
- $refId = 'ref' . time();
-
- $paypal_type = new AnetAPI\PayPalType();
- $paypal_type->setPayerID($payerId);
- $paypal_type->setSuccessUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
- $paypal_type->setCancelUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
-
- $payment_type = new AnetAPI\PaymentType();
- $payment_type->setPayPal($paypal_type);
-
- //create a transaction
- $transactionRequestType = new AnetAPI\TransactionRequestType();
- $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);
-
- $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 " RESULT CODE : " . $response->getResultCode() . "\n";
- echo " TRANS ID : " . $tresponse->getTransId() . "\n";
- echo "Payer ID : " . $tresponse->getSecureAcceptance()->getPayerID();
- }
- else
- {
- //print_r($tresponse);
- echo "ERROR : " . $tresponse->getResponseCode() . "\n";
- }
-
- }
- else
- {
- echo "No response returned";
- }
-
- return $response;
- }
-
- if(!defined('DONT_RUN_SAMPLES'))
- payPalAuthorizeOnlyContinue("2241711631", "JJLRRB29QC7RU");
-
-?>
diff --git a/PaypalExpressCheckout/authorization-only.php b/PaypalExpressCheckout/authorization-only.php
deleted file mode 100644
index 3928890..0000000
--- a/PaypalExpressCheckout/authorization-only.php
+++ /dev/null
@@ -1,59 +0,0 @@
-setName(\SampleCode\Constants::MERCHANT_LOGIN_ID);
- $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY);
- $refId = 'ref' . time();
-
- // Create the payment data for a paypal account
- $payPalType = new AnetAPI\PayPalType();
- $payPalType->setCancelUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
- $payPalType->setSuccessUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
- $paymentOne = new AnetAPI\PaymentType();
- $paymentOne->setPayPal($payPalType);
-
- //create a auth-only transaction
- $transactionRequestType = new AnetAPI\TransactionRequestType();
- $transactionRequestType->setTransactionType( "authOnlyTransaction");
- $transactionRequestType->setAmount($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))
- {
- $tresponse = $response->getTransactionResponse();
- if (($tresponse != null)&& ($response->getMessages()->getResultCode()=="Ok"))
- {
- echo "Received response code: ".$tresponse->getResponseCode()."\n";
- //Valid response codes: 1=Approved, 2=Declined, 3=Error, 5=Need Payer Consent\n";
- echo "Secure acceptance URL: ".$tresponse->getSecureAcceptance()->getSecureAcceptanceUrl()."\n";
- }
- else{
- echo "ERROR : " . $tresponse->getResponseCode() . "\n";
- }
- }
- else
- echo "NULL response Error\n";
-
- return $response;
-}
-
-if(!defined('DONT_RUN_SAMPLES'))
- payPalAuthorizeOnly(23.34);
-
-?>
diff --git a/PaypalExpressCheckout/get-details.php b/PaypalExpressCheckout/get-details.php
deleted file mode 100644
index 199d2b6..0000000
--- a/PaypalExpressCheckout/get-details.php
+++ /dev/null
@@ -1,100 +0,0 @@
-setName(\SampleCode\Constants::MERCHANT_LOGIN_ID);
- $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY);
-
- $refId = 'ref' . time();
-
- //create a transaction of type get details
- $transactionRequestType = new AnetAPI\TransactionRequestType();
- $transactionRequestType->setTransactionType( "getDetailsTransaction");
-
- //replace following transaction ID with your transaction ID for which the details are required
- $transactionRequestType->setRefTransId($transactionId);
-
- // Create the payment data for a paypal account
- $payPalType = new AnetAPI\PayPalType();
- $payPalType->setCancelUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
- $payPalType->setSuccessUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
- $paymentOne = new AnetAPI\PaymentType();
- $paymentOne->setPayPal($payPalType);
-
- $transactionRequestType->setPayment($paymentOne);
-
- //create a transaction request
- $request = new AnetAPI\CreateTransactionRequest();
- $request->setMerchantAuthentication($merchantAuthentication);
- $request->setRefId( $refId);
- $request->setTransactionRequest( $transactionRequestType);
-
- $controller = new AnetController\CreateTransactionController($request);
-
- //execute the api call to get transaction details
- $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);
-
- if ($response != null)
- {
- $tresponse = $response->getTransactionResponse();
-
- if($tresponse != null)
- {
- 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";
- }
- else
- {
- echo "No response returned";
- }
- }
- else
- {
- echo "No response returned";
- }
-
- return $response;
- }
-
-if(!defined('DONT_RUN_SAMPLES'))
- payPalGetDetails( \SampleCode\Constants::TRANS_ID_PAYPAL_GET);
-
-?>
\ No newline at end of file
diff --git a/PaypalExpressCheckout/prior-authorization-capture.php b/PaypalExpressCheckout/prior-authorization-capture.php
deleted file mode 100644
index fb8b0d8..0000000
--- a/PaypalExpressCheckout/prior-authorization-capture.php
+++ /dev/null
@@ -1,62 +0,0 @@
-setName(\SampleCode\Constants::MERCHANT_LOGIN_ID);
- $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY);
- $refId = 'ref' . time();
-
- $payPalType = new AnetAPI\PayPalType();
- $payPalType->setSuccessUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
- $payPalType->setCancelUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
-
- $paymentType = new AnetAPI\PaymentType();
- $paymentType->setPayPal($payPalType);
-
- $transactionRequest = new AnetAPI\TransactionRequestType();
- $transactionRequest->setTransactionType("priorAuthCaptureTransaction");
- $transactionRequest->setPayment($paymentType);
- $transactionRequest->setAmount(floatval(19.45));
- $transactionRequest->setRefTransId($transactionId);
-
- $request = new AnetAPI\CreateTransactionRequest();
- $request->setMerchantAuthentication($merchantAuthentication);
- $request->setRefId( $refId);
- $request->setTransactionRequest($transactionRequest);
-
- $controller = new AnetController\CreateTransactionController($request);
-
- $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);
-
- if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") )
- {
- $tresponse = $response->getTransactionResponse();
- if (($tresponse != null) && ($tresponse->getResponseCode()=="1") )
- {
- echo "Prior Authorization capture AUTH CODE : " . $tresponse->getAuthCode() . "\n";
- }
- else
- {
- echo "Prior Authorization capture ERROR : Invalid response\n";
- }
- }
- else
- {
- echo "PriorAuthorizationCapture ERROR : Invalid response\n";
- }
-
- return $response;
- }
-
- if(!defined('DONT_RUN_SAMPLES'))
- {
- payPalPriorAuthorizationCapture( \SampleCode\Constants::TRANS_ID_PAYPAL_GET);
- }
-?>
\ No newline at end of file
diff --git a/PaypalExpressCheckout/void.php b/PaypalExpressCheckout/void.php
deleted file mode 100644
index 4509e14..0000000
--- a/PaypalExpressCheckout/void.php
+++ /dev/null
@@ -1,60 +0,0 @@
-setName(\SampleCode\Constants::MERCHANT_LOGIN_ID);
- $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY);
- $refId = 'ref' . time();
-
- $payPalType = new AnetAPI\PayPalType();
- $payPalType->setSuccessUrl("");
- $payPalType->setCancelUrl("");
-
- $paymentType = new AnetAPI\PaymentType();
- $paymentType->setPayPal($payPalType);
-
- $transactionRequest = new AnetAPI\TransactionRequestType();
- $transactionRequest->setTransactionType("voidTransaction");
- $transactionRequest->setPayment($paymentType);
- $transactionRequest->setRefTransId($transactionId);
-
- $request = new AnetAPI\CreateTransactionRequest();
- $request->setMerchantAuthentication($merchantAuthentication);
- $request->setRefId( $refId);
- $request->setTransactionRequest($transactionRequest);
-
- $controller = new AnetController\CreateTransactionController($request);
-
- $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);
-
- if ($response != null)
- {
- $tresponse = $response->getTransactionResponse();
- if (($tresponse != null) && ($tresponse->getResponseCode()=="1") )
- {
- echo "Void transaction SUCCESS TRANS ID : " . $tresponse->getTransId() . "\n";
- }
- else
- {
- echo "Void transaction ERROR : " . $tresponse->getResponseCode() . "\n";
- }
- }
- else
- {
- echo "Void transaction Null esponse returned";
- }
-
- return $response;
- }
-
- if(!defined('DONT_RUN_SAMPLES'))
- payPalVoid("2241706281");
-
- ?>
\ No newline at end of file
diff --git a/README.md b/README.md
index f171dca..e929b5c 100644
--- a/README.md
+++ b/README.md
@@ -1,23 +1,49 @@
-# Sample PHP Code for Authorize.Net
+# PHP Sample Code for the Authorize.Net SDK
+[](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
+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 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
-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.
+## Using the Sample Code
-##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
-````
+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.
-##What if I'm not using Composer?
-We provide a custom `SPL` autoloader, just [download the SDK.](https://github.com/AuthorizeNet/sdk-php/releases):
+You can also run each sample directly from the command line.
+
+## Running the Samples From the Command Line
+* 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 by name. For example:
+```
+ $ php PaymentTransactions/[CodeSampleName]
+```
+e.g.
+```
+ $ php PaymentTransactions/authorize-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
+extension=php_curl.dll
+```
+On Windows systems, you also have to uncomment:
+```
+extension_dir = "ext"
+```
+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) and point to its `autoload.php` file:
```php
require 'path/to/anet_php_sdk/autoload.php';
diff --git a/RecurringBilling/cancel-subscription.php b/RecurringBilling/cancel-subscription.php
index cb7205b..59f8553 100644
--- a/RecurringBilling/cancel-subscription.php
+++ b/RecurringBilling/cancel-subscription.php
@@ -1,16 +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();
$request = new AnetAPI\ARBCancelSubscriptionRequest();
@@ -41,6 +45,6 @@ function cancelSubscription($subscriptionId) {
}
if(!defined('DONT_RUN_SAMPLES'))
- cancelSubscription(\SampleCode\Constants::SUBSCRIPTION_ID_CANCEL);
+ cancelSubscription("7087965");
?>
diff --git a/RecurringBilling/create-subscription-from-customer-profile.php b/RecurringBilling/create-subscription-from-customer-profile.php
index 33c7419..8681182 100644
--- a/RecurringBilling/create-subscription-from-customer-profile.php
+++ b/RecurringBilling/create-subscription-from-customer-profile.php
@@ -1,18 +1,22 @@
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();
// Subscription Type Info
@@ -25,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 bca64d0..1bf6fba 100644
--- a/RecurringBilling/create-subscription.php
+++ b/RecurringBilling/create-subscription.php
@@ -1,18 +1,21 @@
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();
// Subscription Type Info
@@ -25,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");
@@ -35,13 +38,17 @@ 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);
-
$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");
@@ -71,6 +78,6 @@ function createSubscription($intervalLength) {
}
if(!defined('DONT_RUN_SAMPLES'))
- createSubscription( \SampleCode\Constants::SUBSCRIPTION_INTERVAL_DAYS);
+ createSubscription(23);
?>
diff --git a/RecurringBilling/get-list-of-subscriptions.php b/RecurringBilling/get-list-of-subscriptions.php
index 74fdab8..72330e8 100644
--- a/RecurringBilling/get-list-of-subscriptions.php
+++ b/RecurringBilling/get-list-of-subscriptions.php
@@ -1,25 +1,28 @@
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();
$sorting = new AnetAPI\ARBGetSubscriptionListSortingType();
$sorting->setOrderBy("id");
- $sorting->setOrderDescending("false");
+ $sorting->setOrderDescending(false);
$paging = new AnetAPI\PagingType();
- $paging->setLimit("1000");
+ $paging->setLimit("10");
$paging->setOffset("1");
$request = new AnetAPI\ARBGetSubscriptionListRequest();
@@ -32,23 +35,25 @@ 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";
echo "Total Number In Results:" . $response->getTotalNumInResultSet() . "\n";
- }
- else
- {
+ 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();
echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n";
}
return $response;
- }
+}
- if(!defined('DONT_RUN_SAMPLES'))
+if (!defined('DONT_RUN_SAMPLES')) {
getListOfSubscriptions();
-?>
+}
diff --git a/RecurringBilling/get-subscription-status.php b/RecurringBilling/get-subscription-status.php
index 1b71589..52796b0 100644
--- a/RecurringBilling/get-subscription-status.php
+++ b/RecurringBilling/get-subscription-status.php
@@ -1,17 +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();
$request = new AnetAPI\ARBGetSubscriptionStatusRequest();
@@ -38,6 +41,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..23b0409 100644
--- a/RecurringBilling/get-subscription.php
+++ b/RecurringBilling/get-subscription.php
@@ -1,62 +1,72 @@
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(\SampleCodeConstants::MERCHANT_LOGIN_ID);
+ $merchantAuthentication->setTransactionKey(\SampleCodeConstants::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();
- $request->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);
+ $request->setIncludeTransactions(true);
+
+ // 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";
- }
- 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";
+ $transactions = $response->getSubscription()->getArbTransactions();
+ if($transactions != null){
+ foreach ($transactions as $transaction) {
+ echo "Transaction ID : ".$transaction->getTransId()." -- ".$transaction->getResponse()." -- Pay Number : ".$transaction->getPayNum()."\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'))
- getSubscription( \SampleCode\Constants::SUBSCRIPTION_ID_GET);
+ getSubscription("2942461");
?>
diff --git a/RecurringBilling/update-subscription.php b/RecurringBilling/update-subscription.php
index cd58a43..6729445 100644
--- a/RecurringBilling/update-subscription.php
+++ b/RecurringBilling/update-subscription.php
@@ -1,24 +1,27 @@
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();
$subscription = new AnetAPI\ARBSubscriptionType();
$creditCard = new AnetAPI\CreditCardType();
$creditCard->setCardNumber("4111111111111111");
- $creditCard->setExpirationDate("2020-12");
+ $creditCard->setExpirationDate("2038-12");
$payment = new AnetAPI\PaymentType();
$payment->setCreditCard($creditCard);
@@ -61,5 +64,5 @@ function updateSubscription($subscriptionId) {
}
if(!defined('DONT_RUN_SAMPLES'))
- updateSubscription( \SampleCode\Constants::SUBSCRIPTION_ID_UPDATE);
+ updateSubscription("3056948");
?>
diff --git a/SampleCodeList.txt b/SampleCodeList.txt
index 1148f89..5119f91 100644
--- a/SampleCodeList.txt
+++ b/SampleCodeList.txt
@@ -5,8 +5,10 @@ CreateSubscriptionFromCustomerProfile,1,1
GetCustomerPaymentProfileList,0,1
GetTransactionList,0,1
CreateAnApplePayTransaction,0,0
-DecryptVisaCheckoutData,0,1
-CreateVisaCheckoutTransaction,0,0
+CreateAnAcceptTransaction,0,0
+CreateAnAndroidPayTransaction,0,0
+decryptVisaSrcData,0,0
+createVisaSrcTransaction,0,0
CaptureFundsAuthorizedThroughAnotherChannel,1,1
AuthorizeCreditCard,1,1
DebitBankAccount,1,1
@@ -14,16 +16,16 @@ 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
UpdateCustomerPaymentProfile,1,1
GetCustomerShippingAddress,1,1
-GetCustomerProfileIds,0,1
+GetCustomerProfileIds,0,0
GetCustomerProfile,1,1
-GetHostedProfilePage,1,1
+GetAcceptCustomerProfilePage,1,1
GetCustomerPaymentProfile,1,1
DeleteCustomerShippingAddress,1,1
DeleteCustomerProfile,1,1
@@ -38,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
@@ -49,4 +51,8 @@ GetSubscription,1,1
UpdateSubscription,1,1
CreateCustomerProfile,1,1
CreateCustomerPaymentProfile,1,1
-ValidateCustomerPaymentProfile,1,0
\ No newline at end of file
+ValidateCustomerPaymentProfile,1,0
+GetMerchantDetails,0,1
+UpdateHeldTransaction,1,0
+GetAnAcceptPaymentPage,0,1
+CreateAnAcceptPaymentTransaction,0,0
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/TestRunner.php b/TestRunner.php
new file mode 100644
index 0000000..61c981c
--- /dev/null
+++ b/TestRunner.php
@@ -0,0 +1,471 @@
+');
+}
+$dirPath = $_SERVER['argv'][2];
+echo $dirPath;
+if (substr($dirPath, -1) != "/") {
+ $dirPath = $dirPath."/";
+}
+
+$directories = array(
+ 'CustomerProfiles/',
+ 'RecurringBilling/',
+ 'PayPalExpressCheckout/',
+ 'PaymentTransactions/',
+ 'TransactionReporting/',
+ 'MobileInappTransactions/',
+ 'VisaCheckout/',
+ 'AcceptSuite/'
+);
+
+$errorlevel=error_reporting();
+error_reporting($errorlevel & ~E_NOTICE); //turn off constant re-defined and other notices
+foreach ($directories as $directory) {
+ foreach (glob($dirPath.$directory . "*.php") as $sample) {
+ require_once $sample;
+ //echo $sample;
+ }
+}
+
+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, 9000)/10);
+ }
+ //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";
+ 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 " . $apiName . "\n";
+ } else {
+ //Try the request twice
+ 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";
+
+ 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;
+ }
+ }
+
+ //response must be successful
+ $this->assertNotNull($response);
+ $this->assertEquals($response->getMessages()->getResultCode(), "Ok");
+ echo $sampleMethodName . " - OK \n";
+ $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());
+ }
+
+
+ // ****ARB Subscription methods******
+ 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;
+ }
+
+ // *******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;
+ }
+ //*****Accept - Accept Customer Profile Page********
+ public static function runGetAcceptCustomerProfilePage()
+ {
+ $response = createCustomerProfile(self::getEmail());
+ $profileResponse = GetAcceptCustomerProfilePage($response->getCustomerProfileId());
+ deleteCustomerProfile($response->getCustomerProfileId());
+
+ return $profileResponse;
+ }
+
+ // *****Transaction Reporting methods********
+ public static function runGetTransactionDetails()
+ {
+ $response = authorizeCreditCard(self::getAmount());
+ return getTransactionDetails($response->getTransactionResponse()->getTransId());
+ }
+
+ public static function runGetSettledBatchList()
+ {
+ $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, $lastSettlementDate);
+ }
+
+ public static function runGetBatchStatistics()
+ {
+ $response = getBatchStatistics(self::runGetSettledBatchList()->getBatchList()[0]->getBatchId());
+ return $response;
+ }
+}
diff --git a/TransactionReporting/get-account-updater-job-details.php b/TransactionReporting/get-account-updater-job-details.php
new file mode 100644
index 0000000..0d26eb5
--- /dev/null
+++ b/TransactionReporting/get-account-updater-job-details.php
@@ -0,0 +1,84 @@
+setName(\SampleCodeConstants::MERCHANT_LOGIN_ID);
+ $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY);
+
+ // Set the request's refId
+ $refId = 'ref' . time();
+
+ // Set a valid month (and other parameters) for the request
+ $month = "2017-07";
+ $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) : " . $update->getUpdateTimeUTC() . "\n";
+ echo " Reason Code : " . $update->getAuReasonCode() . "\n";
+ echo " Reason Description : " . $update->getReasonDescription() . "\n";
+ echo "\n";
+ }
+ echo "\nDeletes:\n";
+ foreach ($details->getAuDelete() as $delete) {
+ 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";
+ 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..444e894
--- /dev/null
+++ b/TransactionReporting/get-account-updater-job-summary.php
@@ -0,0 +1,57 @@
+setName(\SampleCodeConstants::MERCHANT_LOGIN_ID);
+ $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY);
+
+ // Set the request's refId
+ $refId = 'ref' . time();
+
+ // Set a valid month for the request
+ $month = "2017-07";
+
+ // Build tbe request object
+ $request = new AnetAPI\GetAUJobSummaryRequest();
+ $request->setMerchantAuthentication($merchantAuthentication);
+ $request->setMonth($month);
+
+ $controller = new AnetController\GetAUJobSummaryController($request);
+
+ // 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")) {
+ 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 " # of 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();
+}
diff --git a/TransactionReporting/get-batch-statistics.php b/TransactionReporting/get-batch-statistics.php
index a5cf7b0..9a161c6 100644
--- a/TransactionReporting/get-batch-statistics.php
+++ b/TransactionReporting/get-batch-statistics.php
@@ -1,20 +1,21 @@
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();
-
- //Setting a valid batch Id for the Merchant
- $batchId = \SampleCode\Constants::BATCH_ID;
// Creating a request
$request = new AnetAPI\GetBatchStatisticsRequest();
@@ -61,4 +62,4 @@ function getBatchStatistics() {
if(!defined('DONT_RUN_SAMPLES'))
getBatchStatistics();
-?>
\ No newline at end of file
+?>
diff --git a/TransactionReporting/get-customer-profile-transaction-list.php b/TransactionReporting/get-customer-profile-transaction-list.php
new file mode 100644
index 0000000..69eb20c
--- /dev/null
+++ b/TransactionReporting/get-customer-profile-transaction-list.php
@@ -0,0 +1,53 @@
+setName(\SampleCodeConstants::MERCHANT_LOGIN_ID);
+ $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY);
+
+ // Set the transaction's refId
+ $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
diff --git a/TransactionReporting/get-merchant-details.php b/TransactionReporting/get-merchant-details.php
new file mode 100644
index 0000000..1b20655
--- /dev/null
+++ b/TransactionReporting/get-merchant-details.php
@@ -0,0 +1,52 @@
+setName(\SampleCodeConstants::MERCHANT_LOGIN_ID);
+ $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY);
+
+ // Set the transaction's refId
+ $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 "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 "ERROR : Invalid response\n";
+ $errorMessages = $response->getMessages()->getMessage();
+ echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n";
+ }
+
+ return $response;
+ }
+
+ if(!defined('DONT_RUN_SAMPLES'))
+ getMerchantDetails();
+?>
diff --git a/TransactionReporting/get-settled-batch-list.php b/TransactionReporting/get-settled-batch-list.php
index 150512b..89292af 100644
--- a/TransactionReporting/get-settled-batch-list.php
+++ b/TransactionReporting/get-settled-batch-list.php
@@ -1,31 +1,29 @@
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\GetSettledBatchListRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setIncludeStatistics(true);
- // both the first and last dates must be in the same time zone
- $firstSettlementDate=new DateTime("2015-08-25T06:00:00Z");
- // a date constructed from an ISO8601 format date string
+ // 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);
-
- // 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);
@@ -39,7 +37,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";
@@ -65,8 +63,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);
?>
diff --git a/TransactionReporting/get-transaction-details.php b/TransactionReporting/get-transaction-details.php
index 1ed8ede..1822d78 100644
--- a/TransactionReporting/get-transaction-details.php
+++ b/TransactionReporting/get-transaction-details.php
@@ -1,17 +1,23 @@
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();
@@ -39,5 +45,5 @@ function getTransactionDetails($transactionId) {
}
if(!defined('DONT_RUN_SAMPLES'))
- getTransactionDetails( \SampleCode\Constants::TRANS_ID);
-?>
\ No newline at end of file
+ getTransactionDetails("2238968786");
+?>
diff --git a/TransactionReporting/get-transaction-list.php b/TransactionReporting/get-transaction-list.php
index db83004..ccf86c1 100644
--- a/TransactionReporting/get-transaction-list.php
+++ b/TransactionReporting/get-transaction-list.php
@@ -1,16 +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 request's refId
$refId = 'ref' . time();
//Setting a valid batch Id for the Merchant
@@ -26,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 dispaly in this Batch.";
- return ;
- }
- //Displaying the details of each transaction in the list
- foreach ($response->getTransactions() as $transaction) {
- echo " ->Transaction Id : " . $transaction->getTransId() . "\n";
- echo " Submitted on (Local) : " . date_format($transaction->getSubmitTimeLocal(), 'Y-m-d H:i:s') . "\n";
- echo " Status : " . $transaction->getTransactionStatus() . "\n";
- echo " Settle amount : " . number_format($transaction->getSettleAmount(), 2, '.', '') . "\n";
- }
- }
+ 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 4301421..45e9db8 100644
--- a/TransactionReporting/get-unsettled-transaction-list.php
+++ b/TransactionReporting/get-unsettled-transaction-list.php
@@ -1,16 +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();
@@ -24,12 +28,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";
diff --git a/VisaCheckout/create-visa-checkout-transaction.php b/VisaCheckout/create-visa-checkout-transaction.php
deleted file mode 100644
index 926e8bf..0000000
--- a/VisaCheckout/create-visa-checkout-transaction.php
+++ /dev/null
@@ -1,63 +0,0 @@
-setName(\SampleCode\Constants::MERCHANT_LOGIN_ID);
- $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY);
- $refId = 'ref' . time();
-
- // Create the payment data from a Visa Checkout blob
- $op = new AnetAPI\OpaqueDataType();
- $op->setDataDescriptor(\SampleCode\Constants::VC_DATA_DESCRIPTOR);
- $op->setDataValue(\SampleCode\Constants::VC_DATA_VALUE);
- $op->setDataKey(\SampleCode\Constants::VC_DATA_KEY);
- $paymentOne = new AnetAPI\PaymentType();
- $paymentOne->setOpaqueData($op);
-
- //create a transaction
- $transactionRequestType = new AnetAPI\TransactionRequestType();
- $transactionRequestType->setTransactionType( "authCaptureTransaction");
- $transactionRequestType->setAmount(151);
- $transactionRequestType->setCallId("9004180129978687101");
- $transactionRequestType->setPayment($paymentOne);
-
- $request = new AnetAPI\CreateTransactionRequest();
- $request->setMerchantAuthentication($merchantAuthentication);
- $request->setRefId( $refId);
- $request->setTransactionRequest( $transactionRequestType);
-
- $controller = new AnetController\CreateTransactionController($request);
- $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);
-
- if ($response != null)
- {
- $tresponse = $response->getTransactionResponse();
-
- if (($tresponse != null) && ($tresponse->getResponseCode()=="1") )
- {
- echo " AUTH CODE : " . $tresponse->getAuthCode() . "\n";
- echo " TRANS ID : " . $tresponse->getTransId() . "\n";
- }
- else
- {
- echo "BAD NEWS : " . $tresponse->getResponseCode() . "\n";
- }
- }
- else
- {
- echo "REALLY BAD NEWS : ";
- }
- return $response;
- }
-
- if(!defined('DONT_RUN_SAMPLES'))
- createVisaCheckoutTransaction();
-
-?>
diff --git a/VisaCheckout/create-visa-src-transaction.php b/VisaCheckout/create-visa-src-transaction.php
new file mode 100644
index 0000000..1edcf11
--- /dev/null
+++ b/VisaCheckout/create-visa-src-transaction.php
@@ -0,0 +1,93 @@
+setName(\SampleCodeConstants::MERCHANT_LOGIN_ID);
+ $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY);
+
+ // Set the transaction's refId
+ $refId = 'ref' . time();
+
+ // Create the payment data from a Visa Checkout blob
+ $op = new AnetAPI\OpaqueDataType();
+ $op->setDataDescriptor("COMMON.VCO.ONLINE.PAYMENT");
+ $op->setDataValue("4Ng5pzJ6DXfAvLSzVauN9KTufx5lTHhFlnuIr248N3fjtyHrHqMuhOkB1BLiSjKWeTM9+BNj3+9nY56d7CsUfIuvVSTaJRhQQSex1dS2Y2Y+/cA5U+3D1pg5YtTmDVUGlsu1simAd3huwPnwD+CG6O8Ml0AmXvYHntmL3vFaJomadMQBy27k8Dbh5eplPBwyawKUVJ7GqTyKLe8aOYkBUHT5ANWkq2hlGps44BOoDHZ26JWjHdorBZtVIqMK1SIyW4Dih5c/Y//w2toA8WBTPILIvt4h6HPPvWZMZCHCqom9D2k4WGH5+BCEY2jHI7gfYV6xRx54i5vitsYTKm3CyA0C5+l0FNDkfUFHDvVUG9FVzRWVd0TXYhDwfa2pcfI68eYvkEfeT+ZNJ24ZXKPrJo6KZ3x6eZAhzgAMFiC+tPsiygb2zQy5PVoYoBIGj/NGNRqmhZTOEajcO3ZjWxfAnLZAmvMi+pEwJCMmuIY4qRU3RfcaXhAoaUPpDxqrSxR1m+CUKYVdt3nnnQeVaVqf+RaeV9cyFJvILeBPXTBVC50AckVLS37UuBWgWaWcchjRPk9mriDu2KlHQwdR4zu0jnLh4i3tbxV416QBcYLO6AF2Ixlm3GzqGE6QcVssgFCUAhklBWGNLP62O1jtyV4NgTD36QhvHEHby7o4XBB+mjlY6xSEXR+IW9u64AzfDCsTxWiAOE65le6cSk4NDV8DrtYeIozILivWu6wFSpy1gMfiDot4Ndv3C9xCFvH0Bzlky7NoZrvSolKTVNTs8W8UqMFV19qGl6SRaNUEhCqgso/FkdO0eGXFMdQPuP11wQzK/9F3yB9gS2rpXi9sy8DrCqnJ9EXMmliSstKuQl5+yfGc8K3Urot3t+BmNoOvzM9Aha/PzmbLnuKBN6/DUbIw5mhNMCvIA1ByispKpjeV682jl4uslkRsitGLcIOBREFXvGaLxRb37HJkXCHk+jorpDz7LUQhVkClN+hW0vXtgdHQFCIOL7uREdbvk6BZbQlFsuVEKGZxPbKPEJfqMbH54B4a4P5XNQHm4Yt4haH4T0JuYgzoSo76uuXD3g5IuUvy7x8Ykuja1rwW/k//SZAiGaZraRIIAEnzHiUP8dcufb/RonHGnJcYXIEWeIF1lX980bDA+H4vlO8/nN/Mj+EL6tT95MfRDiQHUW69qkqotQd7FJ5uWT+NtetzqDsN5s3sIhwkLKIn9EDLIav5v4SXKxkG+ycMJmGFcfhs7Td9O6hl+Om/JD3he3rgfClaFi/ZR7AVY6fWbAAm9QftKijQ6rskPDYL9Y3gVSA9rdduSg97fUHC+FdfyQXGH552cDLs2ZgzYw6KluXHEuwhACgNotxToPYTTdZxxNr1vPoqYCqHDL2dL8dkuO59/sbZE1m4ektKvUC2wz0UdTDVbHN8HSrLPn2hf/xQp5bKeDDjYkWvNKuwy+aug9H+Uu/m1LuPK/YdogVv9l25y/c2Qbj3dAJ9xTuKjmiJLKlRh4SUI9+05HjDF+i84AoUZ8LuC7LGtrN8ReYIktLhaXq9+XDh5fv4NYhnuYgWkUioKtx1dmfOMHjpLm4aE8Ra1gpJQcZAgwnqYubQvnYy0nY4VaykNix7m3vZwItpKOLqxDYxa3q0qUw25X9zafAM61kPW6EP+4idPzHNww6r1FD4Ihq644dCnCXwoSQ531DW6oAPot8iLZ/xXwoWwrW05k9t2RHjjLbw1L5r1CKgShJQfX7nkJxfGyuw1RmqoQDuNt/tj9M/dHOnoPnOYZZN0JX+Al8PI5zs+LLajw1imu9YcSpwMz3ZlfQqTfI0fjSCc8Is6qVYDMvKD0TweY4hiIxkzs+RyQmPgIeIWqf7Su5+RcnXitb3OuFibBGCjdDeG0ESG8qeiBQKZ3wEyZG09eDAfhuUR5kfZCG4Q01u2YDoRzObxLd8Ruf7HNvtefucFLubciWvOSzbDUisoz0wwOSgJGHucC3IR+1mb/4gz/dI2wvWFInhKcQz4ivkuHaFj8XwvZMcpkwPKtg3pRGTleX/gfjbHcx2VcWRcMPdlDMgTgst9ouN763TZUHHLxjECyB9pkLrR1nhG0cS/aig8Bq1+AH7tvl1wLVxm1Z77DVX4aUIxBH2YUcOgpe6mrWFi6LK3im4/grZECsL/XC4tsTEHjO/U3SazUuhP+6LiCYqp50+3zZf3RpWlxZoYjm5SJ9VIWabocO/Ef26G38lKottW1XsSQUan7myYFFyeyon2hnufzMuxpyXTJ7TLekXCi2gLYbGjldgiRmGShPXzSar+hC2");
+ $op->setDataKey("JxAB39A9yUsf6wMD0jwGKCuY7mmzWaeEj85MH02AfKGUxOkJ00JK+o8vGG55cUF9voYU4QQ1Jec4p6nKmsxXmTREEaJwmQErotD4fpcFOyoqWTLMZfslrkHgiqbwru/V");
+ $paymentOne = new AnetAPI\PaymentType();
+ $paymentOne->setOpaqueData($op);
+
+ //create a transaction
+ $transactionRequestType = new AnetAPI\TransactionRequestType();
+ $transactionRequestType->setTransactionType( "authCaptureTransaction");
+ $transactionRequestType->setAmount(76);
+ $transactionRequestType->setCallId("9004180129978687101");
+ $transactionRequestType->setPayment($paymentOne);
+
+ $request = new AnetAPI\CreateTransactionRequest();
+ $request->setMerchantAuthentication($merchantAuthentication);
+ $request->setRefId( $refId);
+ $request->setTransactionRequest( $transactionRequestType);
+
+ $controller = new AnetController\CreateTransactionController($request);
+ $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);
+
+ if ($response != null)
+ {
+ 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'))
+ createVisaSrcTransaction();
+
+?>
diff --git a/VisaCheckout/decrypt-visa-checkout-data.php b/VisaCheckout/decrypt-visa-checkout-data.php
deleted file mode 100644
index 890d2ca..0000000
--- a/VisaCheckout/decrypt-visa-checkout-data.php
+++ /dev/null
@@ -1,47 +0,0 @@
-setName(\SampleCode\Constants::MERCHANT_LOGIN_ID);
- $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY);
- $refId = 'ref' . time();
-
- // Create the payment data from a Visa Checkout blob
- $op = new AnetAPI\OpaqueDataType();
- $op->setDataDescriptor(\SampleCode\Constants::VC_DATA_DESCRIPTOR);
- $op->setDataValue( \SampleCode\Constants::VC_DATA_VALUE);
- $op->setDataKey( \SampleCode\Constants::VC_DATA_KEY);
-
- //create a decrypt request
- $decryptRequest = new AnetAPI\DecryptPaymentDataRequest();
- $decryptRequest->setRefId( $refId);
- $decryptRequest->setMerchantAuthentication($merchantAuthentication);
- $decryptRequest->setOpaqueData($op);
- $decryptRequest->setCallId("9004180129978687101");
-
-
- $controller = new AnetController\DecryptPaymentDataController($decryptRequest);
- $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);
-
- if ($response != null)
- {
- if ($response->getMessages()->getResultCode() == "Ok")
- {
- echo "Card Number : " . $response->getCardInfo()->getCardNumber() . "\n";
- echo "Amount : " . $response->getPaymentDetails()->getAmount() . "\n";
- }
- }
- return $response;
- }
-
- if(!defined('DONT_RUN_SAMPLES'))
- decryptVisaCheckoutData();
-
-?>
diff --git a/VisaCheckout/decrypt-visa-src-data.php b/VisaCheckout/decrypt-visa-src-data.php
new file mode 100644
index 0000000..2b2b791
--- /dev/null
+++ b/VisaCheckout/decrypt-visa-src-data.php
@@ -0,0 +1,51 @@
+setName(\SampleCodeConstants::MERCHANT_LOGIN_ID);
+ $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY);
+
+ // Set the transaction's refId
+ $refId = 'ref' . time();
+
+ // Create the payment data from a Visa Checkout blob
+ $op = new AnetAPI\OpaqueDataType();
+ $op->setDataDescriptor("COMMON.VCO.ONLINE.PAYMENT");
+ $op->setDataValue("4Ng5pzJ6DXfAvLSzVauN9KTufx5lTHhFlnuIr248N3fjtyHrHqMuhOkB1BLiSjKWeTM9+BNj3+9nY56d7CsUfIuvVSTaJRhQQSex1dS2Y2Y+/cA5U+3D1pg5YtTmDVUGlsu1simAd3huwPnwD+CG6O8Ml0AmXvYHntmL3vFaJomadMQBy27k8Dbh5eplPBwyawKUVJ7GqTyKLe8aOYkBUHT5ANWkq2hlGps44BOoDHZ26JWjHdorBZtVIqMK1SIyW4Dih5c/Y//w2toA8WBTPILIvt4h6HPPvWZMZCHCqom9D2k4WGH5+BCEY2jHI7gfYV6xRx54i5vitsYTKm3CyA0C5+l0FNDkfUFHDvVUG9FVzRWVd0TXYhDwfa2pcfI68eYvkEfeT+ZNJ24ZXKPrJo6KZ3x6eZAhzgAMFiC+tPsiygb2zQy5PVoYoBIGj/NGNRqmhZTOEajcO3ZjWxfAnLZAmvMi+pEwJCMmuIY4qRU3RfcaXhAoaUPpDxqrSxR1m+CUKYVdt3nnnQeVaVqf+RaeV9cyFJvILeBPXTBVC50AckVLS37UuBWgWaWcchjRPk9mriDu2KlHQwdR4zu0jnLh4i3tbxV416QBcYLO6AF2Ixlm3GzqGE6QcVssgFCUAhklBWGNLP62O1jtyV4NgTD36QhvHEHby7o4XBB+mjlY6xSEXR+IW9u64AzfDCsTxWiAOE65le6cSk4NDV8DrtYeIozILivWu6wFSpy1gMfiDot4Ndv3C9xCFvH0Bzlky7NoZrvSolKTVNTs8W8UqMFV19qGl6SRaNUEhCqgso/FkdO0eGXFMdQPuP11wQzK/9F3yB9gS2rpXi9sy8DrCqnJ9EXMmliSstKuQl5+yfGc8K3Urot3t+BmNoOvzM9Aha/PzmbLnuKBN6/DUbIw5mhNMCvIA1ByispKpjeV682jl4uslkRsitGLcIOBREFXvGaLxRb37HJkXCHk+jorpDz7LUQhVkClN+hW0vXtgdHQFCIOL7uREdbvk6BZbQlFsuVEKGZxPbKPEJfqMbH54B4a4P5XNQHm4Yt4haH4T0JuYgzoSo76uuXD3g5IuUvy7x8Ykuja1rwW/k//SZAiGaZraRIIAEnzHiUP8dcufb/RonHGnJcYXIEWeIF1lX980bDA+H4vlO8/nN/Mj+EL6tT95MfRDiQHUW69qkqotQd7FJ5uWT+NtetzqDsN5s3sIhwkLKIn9EDLIav5v4SXKxkG+ycMJmGFcfhs7Td9O6hl+Om/JD3he3rgfClaFi/ZR7AVY6fWbAAm9QftKijQ6rskPDYL9Y3gVSA9rdduSg97fUHC+FdfyQXGH552cDLs2ZgzYw6KluXHEuwhACgNotxToPYTTdZxxNr1vPoqYCqHDL2dL8dkuO59/sbZE1m4ektKvUC2wz0UdTDVbHN8HSrLPn2hf/xQp5bKeDDjYkWvNKuwy+aug9H+Uu/m1LuPK/YdogVv9l25y/c2Qbj3dAJ9xTuKjmiJLKlRh4SUI9+05HjDF+i84AoUZ8LuC7LGtrN8ReYIktLhaXq9+XDh5fv4NYhnuYgWkUioKtx1dmfOMHjpLm4aE8Ra1gpJQcZAgwnqYubQvnYy0nY4VaykNix7m3vZwItpKOLqxDYxa3q0qUw25X9zafAM61kPW6EP+4idPzHNww6r1FD4Ihq644dCnCXwoSQ531DW6oAPot8iLZ/xXwoWwrW05k9t2RHjjLbw1L5r1CKgShJQfX7nkJxfGyuw1RmqoQDuNt/tj9M/dHOnoPnOYZZN0JX+Al8PI5zs+LLajw1imu9YcSpwMz3ZlfQqTfI0fjSCc8Is6qVYDMvKD0TweY4hiIxkzs+RyQmPgIeIWqf7Su5+RcnXitb3OuFibBGCjdDeG0ESG8qeiBQKZ3wEyZG09eDAfhuUR5kfZCG4Q01u2YDoRzObxLd8Ruf7HNvtefucFLubciWvOSzbDUisoz0wwOSgJGHucC3IR+1mb/4gz/dI2wvWFInhKcQz4ivkuHaFj8XwvZMcpkwPKtg3pRGTleX/gfjbHcx2VcWRcMPdlDMgTgst9ouN763TZUHHLxjECyB9pkLrR1nhG0cS/aig8Bq1+AH7tvl1wLVxm1Z77DVX4aUIxBH2YUcOgpe6mrWFi6LK3im4/grZECsL/XC4tsTEHjO/U3SazUuhP+6LiCYqp50+3zZf3RpWlxZoYjm5SJ9VIWabocO/Ef26G38lKottW1XsSQUan7myYFFyeyon2hnufzMuxpyXTJ7TLekXCi2gLYbGjldgiRmGShPXzSar+hC2");
+ $op->setDataKey("JxAB39A9yUsf6wMD0jwGKCuY7mmzWaeEj85MH02AfKGUxOkJ00JK+o8vGG55cUF9voYU4QQ1Jec4p6nKmsxXmTREEaJwmQErotD4fpcFOyoqWTLMZfslrkHgiqbwru/V");
+
+ //create a decrypt request
+ $decryptRequest = new AnetAPI\DecryptPaymentDataRequest();
+ $decryptRequest->setRefId( $refId);
+ $decryptRequest->setMerchantAuthentication($merchantAuthentication);
+ $decryptRequest->setOpaqueData($op);
+ $decryptRequest->setCallId("9004180129978687101");
+
+
+ $controller = new AnetController\DecryptPaymentDataController($decryptRequest);
+ $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);
+
+ if ($response != null)
+ {
+ if ($response->getMessages()->getResultCode() == "Ok")
+ {
+ echo "Card Number : " . $response->getCardInfo()->getCardNumber() . "\n";
+ echo "Amount : " . $response->getPaymentDetails()->getAmount() . "\n";
+ }
+ }
+ return $response;
+ }
+
+ if(!defined('DONT_RUN_SAMPLES'))
+ decryptVisaSrcData();
+
+?>
diff --git a/composer.json b/composer.json
index 269c7a6..08f03a6 100644
--- a/composer.json
+++ b/composer.json
@@ -1,20 +1,7 @@
{
"require": {
- "php": ">=5.2.0",
+ "php": ">=5.6",
"ext-curl": "*",
- "authorizenet/authorizenet": "1.8.8",
- "jms/serializer": "xsd2php-dev as 0.18.0"
- },
- "require-dev": {
- "phpunit/phpunit": "~4.0",
- "goetas/xsd2php": "2.0.x-dev#fdc2ab0bb3f2b3ab796ca567cf8c0f3446a7ea3a",
- "goetas/xsd-reader": "2.*@dev"
- },
- "repositories": [{
- "type": "vcs",
- "url": "https://github.com/goetas/serializer.git"
- }],
- "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 e612aab..0000000
--- a/constants/Constants.php
+++ /dev/null
@@ -1,85 +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/phpunit.xml.dist b/phpunit.xml.dist
index 4d61151..19a10f4 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -26,7 +26,7 @@
-
+
diff --git a/test-runner.php b/test-runner.php
deleted file mode 100644
index b1acc10..0000000
--- a/test-runner.php
+++ /dev/null
@@ -1,406 +0,0 @@
-');
-}
-$dirPath = $_SERVER['argv'][2];
-echo $dirPath;
-if(substr($dirPath, -1) != "/")
- $dirPath = $dirPath."/";
-
-$directories = array(
- 'CustomerProfiles/',
- 'RecurringBilling/',
- 'PaypalExpressCheckout/',
- 'PaymentTransactions/',
- 'TransactionReporting/',
- 'ApplePayTransactions/',
- 'VisaCheckout/'
-);
-
-$errorlevel=error_reporting();
-error_reporting($errorlevel & ~E_NOTICE); //turn off constant re-defined and other notices
-foreach ($directories as $directory) {
- foreach(glob($dirPath.$directory . "*.php") as $sample) {
- require_once $sample;
- //echo $sample;
- }
-}
-
-error_reporting($errorlevel);
-class TestRunner extends PHPUnit_Framework_TestCase
-{
- public static $apiLoginId = "5KP3u95bQpv";
- public static $transactionKey = "4Ktq966gC55GAX7S";
- 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());
- }
-
- public static function runChargeTokenizedCreditCard()
- {
- return chargeTokenizedCreditCard(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 runPayPalAuthorizeCaptureContinue()
- {
- $response = payPalAuthorizeCapture(self::getAmount());
- return payPalAuthorizeCaptureContinue($response->getTransactionResponse()->getTransId(), self::$payerID);
- }
-
- public static function runPayPalAuthorizeOnlyContinue()
- {
- return payPalAuthorizeOnlyContinue(self::$transactionID, self::$payerID);
- }
-
- public static function runPayPalCredit() {
- return payPalCredit(self::$transactionID);
- }
-
- public static function 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 runGetHostedProfilePage()
- {
- $response = createCustomerProfile(self::getEmail());
- $profileResponse = getHostedProfilePage($response->getCustomerProfileId());
- deleteCustomerProfile($response->getCustomerProfileId());
-
- return $profileResponse;
- }
-}