From c802b92adbf92b26b43a87045b457e7d9af4461d Mon Sep 17 00:00:00 2001 From: Kaushik Mahato Date: Mon, 19 Oct 2015 18:46:15 +0530 Subject: [PATCH 001/176] Added call request to GetCustomerProfileIds --- src/main/java/net/authorize/sample/SampleCode.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index 233fae1d..39b53986 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -97,6 +97,7 @@ private static void ShowMethods() System.out.println(" GetUnsettledTransactionList"); System.out.println(" GetTransactionDetails"); System.out.println(" CreateCustomerProfile"); + System.out.println(" CreateCustomerProfileIds"); System.out.println(" CreateCustomerPaymentProfile"); System.out.println(" CreateCustomerShippingAddress"); System.out.println(" DeleteCustomerPaymentProfile"); @@ -223,6 +224,9 @@ private static void RunMethod(String methodName) case "GetCustomerProfile": GetCustomerProfile.run(apiLoginId, transactionKey); break; + case "GetCustomerProfileIds": + GetCustomerProfileIds.run(apiLoginId, transactionKey); + break; case "GetCustomerShippingAddress": GetCustomerShippingAddress.run(apiLoginId, transactionKey); break; From 9d471ddb1c06304b9f1a2b08e8110dfee2b333ff Mon Sep 17 00:00:00 2001 From: Kaushik Mahato Date: Mon, 19 Oct 2015 18:46:15 +0530 Subject: [PATCH 002/176] Added call request to GetCustomerProfileIds --- src/main/java/net/authorize/sample/SampleCode.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index 233fae1d..f0b2ae99 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -104,6 +104,7 @@ private static void ShowMethods() System.out.println(" DeleteCustomerShippingAddress"); System.out.println(" GetCustomerPaymentProfile"); System.out.println(" GetCustomerProfile"); + System.out.println(" GetCustomerProfileIds"); System.out.println(" GetCustomerShippingAddress"); System.out.println(" GetHostedProfilePage"); System.out.println(" UpdateCustomerPaymentProfile"); @@ -223,6 +224,9 @@ private static void RunMethod(String methodName) case "GetCustomerProfile": GetCustomerProfile.run(apiLoginId, transactionKey); break; + case "GetCustomerProfileIds": + GetCustomerProfileIds.run(apiLoginId, transactionKey); + break; case "GetCustomerShippingAddress": GetCustomerShippingAddress.run(apiLoginId, transactionKey); break; From 843f0fc728c6ce3241464f0d83078f190b35cbf6 Mon Sep 17 00:00:00 2001 From: sapta89 Date: Tue, 20 Oct 2015 17:51:32 +0530 Subject: [PATCH 003/176] updated CreateSubscription.java Minor issue in converting amount to BigDecimal with double constructor, resulting in invalid amount error. Changed input parameter to string. --- .../sample/RecurringBilling/CreateSubscription.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscription.java b/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscription.java index d7144570..5eca930f 100644 --- a/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscription.java +++ b/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscription.java @@ -50,8 +50,8 @@ public static void run(String apiLoginId, String transactionKey) { ARBSubscriptionType arbSubscriptionType = new ARBSubscriptionType(); arbSubscriptionType.setPaymentSchedule(schedule); - arbSubscriptionType.setAmount(new BigDecimal(10.29)); - arbSubscriptionType.setTrialAmount(new BigDecimal(0.00)); + arbSubscriptionType.setAmount(new BigDecimal("10.29")); + arbSubscriptionType.setTrialAmount(new BigDecimal("0.00")); arbSubscriptionType.setPayment(paymentType); NameAndAddressType name = new NameAndAddressType(); @@ -80,4 +80,4 @@ public static void run(String apiLoginId, String transactionKey) { } } } -} \ No newline at end of file +} From cd7c93726f6e182dfe65a069b8326a42ac05da21 Mon Sep 17 00:00:00 2001 From: gnongsie Date: Tue, 27 Oct 2015 14:21:35 +0530 Subject: [PATCH 004/176] Committed to master of AuthorizeNet Changed the dependency to use the Error100 continue fix --- pom.xml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 0ffcef66..20560f28 100644 --- a/pom.xml +++ b/pom.xml @@ -7,13 +7,6 @@ 1.0 SampleCode http://maven.apache.org - - - net.authorize - anet-java-sdk - 1.8.4 - - @@ -46,4 +39,11 @@ + + + net.authorize + anet-java-sdk + 1.8.6-SNAPSHOT + + From bdbfe0e66cacfaf6754b4c8ddfbaf06131689cc4 Mon Sep 17 00:00:00 2001 From: gnongsie Date: Tue, 27 Oct 2015 15:54:08 +0530 Subject: [PATCH 005/176] Changed dependencies in pom.xml Added sample code for UpdateSplitTenderGroup Added function call in SampleCode --- pom.xml | 14 ++--- .../UpdateSplitTenderGroup.java | 52 +++++++++++++++++++ .../java/net/authorize/sample/SampleCode.java | 14 +++-- 3 files changed, 68 insertions(+), 12 deletions(-) create mode 100644 src/main/java/net/authorize/sample/PaymentTransactions/UpdateSplitTenderGroup.java diff --git a/pom.xml b/pom.xml index 20560f28..0ffcef66 100644 --- a/pom.xml +++ b/pom.xml @@ -7,6 +7,13 @@ 1.0 SampleCode http://maven.apache.org + + + net.authorize + anet-java-sdk + 1.8.4 + + @@ -39,11 +46,4 @@ - - - net.authorize - anet-java-sdk - 1.8.6-SNAPSHOT - - diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/UpdateSplitTenderGroup.java b/src/main/java/net/authorize/sample/PaymentTransactions/UpdateSplitTenderGroup.java new file mode 100644 index 00000000..e5468cff --- /dev/null +++ b/src/main/java/net/authorize/sample/PaymentTransactions/UpdateSplitTenderGroup.java @@ -0,0 +1,52 @@ + +package net.authorize.sample.PaymentTransactions; + +import net.authorize.Environment; +import net.authorize.api.contract.v1.*; +import net.authorize.api.controller.base.ApiOperationBase; +import net.authorize.api.controller.UpdateSplitTenderGroupController; + +/** + * + * @author gnongsie + */ +public class UpdateSplitTenderGroup { + public static void run(String apiLoginId, String transactionKey) { + System.out.println("Update Split Tender Group Sample Code"); + + //Common code to set for all requests + ApiOperationBase.setEnvironment(Environment.SANDBOX); + + MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; + merchantAuthenticationType.setName(apiLoginId); + merchantAuthenticationType.setTransactionKey(transactionKey); + ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); + + // Provide a split tender Id + // To get a split Tender ID in sandbox, authorize any transaction with amount = 462.25 [if card present] and set allowPartialAuth = true + String splitTenderId = "SPLIT_TENDER_ID"; + + // Create a request + UpdateSplitTenderGroupRequest request = new UpdateSplitTenderGroupRequest(); + request.setMerchantAuthentication(merchantAuthenticationType); + request.setSplitTenderId(splitTenderId); + + // Set the Split Tender Status (VOIDED or HELD or COMPLETED) + request.setSplitTenderStatus(SplitTenderStatusEnum.VOIDED); + + UpdateSplitTenderGroupController controller = new UpdateSplitTenderGroupController(request); + controller.execute(); + + UpdateSplitTenderGroupResponse response = controller.getApiResponse(); + + if (response.getMessages().getResultCode() == MessageTypeEnum.OK){ + System.out.println(response.getMessages().getMessage().get(0).getCode()); + System.out.println(response.getMessages().getMessage().get(0).getText()); + } + + else { + System.out.println("Error: " + response.getMessages().getMessage().get(0).getCode() + + " " + response.getMessages().getMessage().get(0).getText()); + } + } +} diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index 233fae1d..053dcbc4 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -113,9 +113,10 @@ private static void ShowMethods() System.out.println(" PayPalAuthorizationOnly"); System.out.println(" PayPalAuthorizeCaptureContinue"); System.out.println(" PayPalGetDetails"); - System.out.println(" PayPalPriorAuthorizationCapture"); - System.out.println(" PayPalAuthorizeOnlyContinue"); + System.out.println(" PayPalPriorAuthorizationCapture"); + System.out.println(" PayPalAuthorizeOnlyContinue"); System.out.println(" PayPalCredit"); + System.out.println(" UpdateSplitTenderGroup"); } private static void RunMethod(String methodName) @@ -251,14 +252,17 @@ private static void RunMethod(String methodName) AuthorizationOnlyContinued.run(apiLoginId, transactionKey, transactionId, payerId); break; case "PayPalCredit": - Credit.run(apiLoginId, transactionKey, transactionId); - break; + Credit.run(apiLoginId, transactionKey, transactionId); + break; case "PayPalGetDetails": GetDetails.run(apiLoginId, transactionKey); - case "PaypalPriorAuthorizationCapture": + case "PaypalPriorAuthorizationCapture": transactionId = "2241801682"; // Use a valid transaction ID here PriorAuthorizationCapture.run(apiLoginId, transactionKey, transactionId); break; + case "UpdateSplitTenderGroup": + UpdateSplitTenderGroup.run(apiLoginId, transactionKey); + break; default: ShowUsage(); break; From 01021596d4625ed2b3b54faa468841aa5c602027 Mon Sep 17 00:00:00 2001 From: kaumahat Date: Mon, 9 Nov 2015 15:23:18 +0530 Subject: [PATCH 006/176] Fixed GetSettledBatchList Sample Code --- .../java/net/authorize/sample/SampleCode.java | 6 +++--- .../GetSettledBatchList.java | 21 +++++++++++++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index f0b2ae99..bce4e115 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -92,7 +92,7 @@ private static void ShowMethods() System.out.println(" UpdateSubscription"); System.out.println(" GetListOfSubscriptions"); System.out.println(" GetBatchStatistics"); - //System.out.println(" GetSettledBatchList"); + System.out.println(" GetSettledBatchList"); System.out.println(" GetTransactionList"); System.out.println(" GetUnsettledTransactionList"); System.out.println(" GetTransactionDetails"); @@ -188,9 +188,9 @@ private static void RunMethod(String methodName) case "GetBatchStatistics": GetBatchStatistics.run(apiLoginId, transactionKey); break; - /*case "GetSettledBatchList": + case "GetSettledBatchList": GetSettledBatchList.run(apiLoginId, transactionKey); - break;*/ + break; case "GetTransactionList": GetTransactionList.run(apiLoginId, transactionKey); break; diff --git a/src/main/java/net/authorize/sample/TransactionReporting/GetSettledBatchList.java b/src/main/java/net/authorize/sample/TransactionReporting/GetSettledBatchList.java index b420cac2..b67985bf 100644 --- a/src/main/java/net/authorize/sample/TransactionReporting/GetSettledBatchList.java +++ b/src/main/java/net/authorize/sample/TransactionReporting/GetSettledBatchList.java @@ -1,11 +1,13 @@ package net.authorize.sample.TransactionReporting; +import com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl; +import java.util.GregorianCalendar; import net.authorize.Environment; import net.authorize.api.contract.v1.*; import net.authorize.api.controller.GetSettledBatchListController; import net.authorize.api.controller.base.ApiOperationBase; -//author @krgupta +//author @krgupta modified @kikmak42 public class GetSettledBatchList { public static void run(String apiLoginId, String transactionKey) { @@ -19,15 +21,30 @@ public static void run(String apiLoginId, String transactionKey) { GetSettledBatchListRequest getRequest = new GetSettledBatchListRequest(); getRequest.setMerchantAuthentication(merchantAuthenticationType); + + // Set first settlement date in format (year, month, day) + getRequest.setFirstSettlementDate(new XMLGregorianCalendarImpl(new GregorianCalendar(2015, 10, 8))); + + // Set last settlement date in format (year, month, day) (should not be greater that 31 days since first settlement date) + getRequest.setLastSettlementDate(new XMLGregorianCalendarImpl(new GregorianCalendar(2015, 11, 8))); + GetSettledBatchListController controller = new GetSettledBatchListController(getRequest); controller.execute(); - GetSettledBatchListResponse getResponse = new GetSettledBatchListResponse(); + GetSettledBatchListResponse getResponse = controller.getApiResponse(); if (getResponse!=null) { if (getResponse.getMessages().getResultCode() == MessageTypeEnum.OK) { System.out.println(getResponse.getMessages().getMessage().get(0).getCode()); System.out.println(getResponse.getMessages().getMessage().get(0).getText()); + + ArrayOfBatchDetailsType batchList = getResponse.getBatchList(); + if(batchList != null){ + System.out.println("List of Settled Transaction :"); + for (BatchDetailsType batch : batchList.getBatch()) { + System.out.println(batch.getBatchId() + " - " + batch.getMarketType() + " - " + batch.getPaymentMethod() + " - " + batch.getProduct() + " - " + batch.getSettlementState()); + } + } } else { From 9e13b3f8601259de1ca91376f6b488aed89f45b7 Mon Sep 17 00:00:00 2001 From: kaumahat Date: Mon, 9 Nov 2015 15:51:47 +0530 Subject: [PATCH 007/176] GetSettledBatchList display detailed error message --- .../sample/TransactionReporting/GetSettledBatchList.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/net/authorize/sample/TransactionReporting/GetSettledBatchList.java b/src/main/java/net/authorize/sample/TransactionReporting/GetSettledBatchList.java index b67985bf..e6fbafd3 100644 --- a/src/main/java/net/authorize/sample/TransactionReporting/GetSettledBatchList.java +++ b/src/main/java/net/authorize/sample/TransactionReporting/GetSettledBatchList.java @@ -49,6 +49,7 @@ public static void run(String apiLoginId, String transactionKey) { else { System.out.println("Failed to get settled batch list: " + getResponse.getMessages().getResultCode()); + System.out.println(getResponse.getMessages().getMessage().get(0).getText()); } } } From 20ac7a99c4fddd9850f28d37946c39e0918c6dfd Mon Sep 17 00:00:00 2001 From: Kaushik Date: Fri, 13 Nov 2015 16:11:20 +0530 Subject: [PATCH 008/176] Removed Hard Coded first & last settlement date. --- .../sample/TransactionReporting/GetSettledBatchList.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/authorize/sample/TransactionReporting/GetSettledBatchList.java b/src/main/java/net/authorize/sample/TransactionReporting/GetSettledBatchList.java index e6fbafd3..e0b7bd31 100644 --- a/src/main/java/net/authorize/sample/TransactionReporting/GetSettledBatchList.java +++ b/src/main/java/net/authorize/sample/TransactionReporting/GetSettledBatchList.java @@ -1,6 +1,7 @@ package net.authorize.sample.TransactionReporting; import com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl; +import java.time.ZonedDateTime; import java.util.GregorianCalendar; import net.authorize.Environment; import net.authorize.api.contract.v1.*; @@ -22,11 +23,13 @@ public static void run(String apiLoginId, String transactionKey) { GetSettledBatchListRequest getRequest = new GetSettledBatchListRequest(); getRequest.setMerchantAuthentication(merchantAuthenticationType); - // Set first settlement date in format (year, month, day) - getRequest.setFirstSettlementDate(new XMLGregorianCalendarImpl(new GregorianCalendar(2015, 10, 8))); + // Set first settlement date in format (year, month, day)(should not be less that 31 days since last settlement date) + GregorianCalendar pastDate = GregorianCalendar.from(ZonedDateTime.now().minusDays(30)); + getRequest.setFirstSettlementDate(new XMLGregorianCalendarImpl(pastDate)); // Set last settlement date in format (year, month, day) (should not be greater that 31 days since first settlement date) - getRequest.setLastSettlementDate(new XMLGregorianCalendarImpl(new GregorianCalendar(2015, 11, 8))); + GregorianCalendar currentDate = GregorianCalendar.from(ZonedDateTime.now()); + getRequest.setLastSettlementDate(new XMLGregorianCalendarImpl(currentDate)); GetSettledBatchListController controller = new GetSettledBatchListController(getRequest); controller.execute(); From 8db3cd1cee36f8198dae31eb2311e01a06c19285 Mon Sep 17 00:00:00 2001 From: Kaushik Date: Mon, 16 Nov 2015 17:32:23 +0530 Subject: [PATCH 009/176] XMLGeorgianCalendar object created using DataFactory -> GetSettledBatchList --- .../GetSettledBatchList.java | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/main/java/net/authorize/sample/TransactionReporting/GetSettledBatchList.java b/src/main/java/net/authorize/sample/TransactionReporting/GetSettledBatchList.java index e0b7bd31..67c98e65 100644 --- a/src/main/java/net/authorize/sample/TransactionReporting/GetSettledBatchList.java +++ b/src/main/java/net/authorize/sample/TransactionReporting/GetSettledBatchList.java @@ -1,12 +1,12 @@ package net.authorize.sample.TransactionReporting; -import com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl; import java.time.ZonedDateTime; import java.util.GregorianCalendar; import net.authorize.Environment; import net.authorize.api.contract.v1.*; import net.authorize.api.controller.GetSettledBatchListController; import net.authorize.api.controller.base.ApiOperationBase; +import javax.xml.datatype.DatatypeFactory; //author @krgupta modified @kikmak42 public class GetSettledBatchList { @@ -23,13 +23,19 @@ public static void run(String apiLoginId, String transactionKey) { GetSettledBatchListRequest getRequest = new GetSettledBatchListRequest(); getRequest.setMerchantAuthentication(merchantAuthenticationType); - // Set first settlement date in format (year, month, day)(should not be less that 31 days since last settlement date) - GregorianCalendar pastDate = GregorianCalendar.from(ZonedDateTime.now().minusDays(30)); - getRequest.setFirstSettlementDate(new XMLGregorianCalendarImpl(pastDate)); - - // Set last settlement date in format (year, month, day) (should not be greater that 31 days since first settlement date) - GregorianCalendar currentDate = GregorianCalendar.from(ZonedDateTime.now()); - getRequest.setLastSettlementDate(new XMLGregorianCalendarImpl(currentDate)); + try { + // Set first settlement date in format (year, month, day)(should not be less that 31 days since last settlement date) + GregorianCalendar pastDate = GregorianCalendar.from(ZonedDateTime.now().minusDays(30)); + getRequest.setFirstSettlementDate(DatatypeFactory.newInstance().newXMLGregorianCalendar(pastDate)); + + // Set last settlement date in format (year, month, day) (should not be greater that 31 days since first settlement date) + GregorianCalendar currentDate = GregorianCalendar.from(ZonedDateTime.now()); + getRequest.setLastSettlementDate(DatatypeFactory.newInstance().newXMLGregorianCalendar(currentDate)); + + } catch (Exception ex) { + System.out.println("Error : while setting dates"); + ex.printStackTrace(); + } GetSettledBatchListController controller = new GetSettledBatchListController(getRequest); controller.execute(); From 381b95717b94c02d349245471826eee5a67acfad Mon Sep 17 00:00:00 2001 From: Kaushik Date: Mon, 16 Nov 2015 18:01:56 +0530 Subject: [PATCH 010/176] Removed ZonedDateTime --- .../GetSettledBatchList.java | 35 +++++++++---------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/src/main/java/net/authorize/sample/TransactionReporting/GetSettledBatchList.java b/src/main/java/net/authorize/sample/TransactionReporting/GetSettledBatchList.java index 67c98e65..3a7fd72c 100644 --- a/src/main/java/net/authorize/sample/TransactionReporting/GetSettledBatchList.java +++ b/src/main/java/net/authorize/sample/TransactionReporting/GetSettledBatchList.java @@ -1,6 +1,6 @@ package net.authorize.sample.TransactionReporting; -import java.time.ZonedDateTime; +import java.util.Calendar; import java.util.GregorianCalendar; import net.authorize.Environment; import net.authorize.api.contract.v1.*; @@ -11,57 +11,54 @@ //author @krgupta modified @kikmak42 public class GetSettledBatchList { - public static void run(String apiLoginId, String transactionKey) { + public static void run(String apiLoginId, String transactionKey) { ApiOperationBase.setEnvironment(Environment.SANDBOX); - MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; + MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType(); merchantAuthenticationType.setName(apiLoginId); merchantAuthenticationType.setTransactionKey(transactionKey); ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); - + GetSettledBatchListRequest getRequest = new GetSettledBatchListRequest(); getRequest.setMerchantAuthentication(merchantAuthenticationType); - + try { // Set first settlement date in format (year, month, day)(should not be less that 31 days since last settlement date) - GregorianCalendar pastDate = GregorianCalendar.from(ZonedDateTime.now().minusDays(30)); + GregorianCalendar pastDate = new GregorianCalendar(); + pastDate.add(Calendar.DAY_OF_YEAR, -7); getRequest.setFirstSettlementDate(DatatypeFactory.newInstance().newXMLGregorianCalendar(pastDate)); // Set last settlement date in format (year, month, day) (should not be greater that 31 days since first settlement date) - GregorianCalendar currentDate = GregorianCalendar.from(ZonedDateTime.now()); + GregorianCalendar currentDate = new GregorianCalendar(); getRequest.setLastSettlementDate(DatatypeFactory.newInstance().newXMLGregorianCalendar(currentDate)); } catch (Exception ex) { System.out.println("Error : while setting dates"); ex.printStackTrace(); } - + GetSettledBatchListController controller = new GetSettledBatchListController(getRequest); controller.execute(); GetSettledBatchListResponse getResponse = controller.getApiResponse(); - if (getResponse!=null) { + if (getResponse != null) { - if (getResponse.getMessages().getResultCode() == MessageTypeEnum.OK) { + if (getResponse.getMessages().getResultCode() == MessageTypeEnum.OK) { System.out.println(getResponse.getMessages().getMessage().get(0).getCode()); System.out.println(getResponse.getMessages().getMessage().get(0).getText()); - + ArrayOfBatchDetailsType batchList = getResponse.getBatchList(); - if(batchList != null){ + if (batchList != null) { System.out.println("List of Settled Transaction :"); for (BatchDetailsType batch : batchList.getBatch()) { System.out.println(batch.getBatchId() + " - " + batch.getMarketType() + " - " + batch.getPaymentMethod() + " - " + batch.getProduct() + " - " + batch.getSettlementState()); } - } - } - else - { + } + } else { System.out.println("Failed to get settled batch list: " + getResponse.getMessages().getResultCode()); System.out.println(getResponse.getMessages().getMessage().get(0).getText()); } } + } } -} - - From 32a184ee6de85b0028a6b41b86a5be86381173c3 Mon Sep 17 00:00:00 2001 From: zhaque Date: Thu, 19 Nov 2015 16:43:00 +0530 Subject: [PATCH 011/176] - Added sample code for GetSubscription and GetCustomerPaymentProfileList. --- .../GetCustomerPaymentProfileList.java | 87 +++++++++++++++++++ .../RecurringBilling/GetSubscription.java | 68 +++++++++++++++ .../java/net/authorize/sample/SampleCode.java | 12 ++- 3 files changed, 165 insertions(+), 2 deletions(-) create mode 100644 src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerPaymentProfileList.java create mode 100644 src/main/java/net/authorize/sample/RecurringBilling/GetSubscription.java diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerPaymentProfileList.java b/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerPaymentProfileList.java new file mode 100644 index 00000000..1cc8b547 --- /dev/null +++ b/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerPaymentProfileList.java @@ -0,0 +1,87 @@ +package net.authorize.sample.CustomerProfiles; + +import java.util.ArrayList; +import java.util.List; +import net.authorize.Environment; +import net.authorize.api.contract.v1.*; +import net.authorize.api.controller.base.ApiOperationBase; +import net.authorize.api.controller.*; + +public class GetCustomerPaymentProfileList +{ + public static void run(String apiLoginId,String transactionKey) + { + ApiOperationBase.setEnvironment(Environment.SANDBOX); + + // Giving the merchant authentication information + MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; + merchantAuthenticationType.setName(apiLoginId); + merchantAuthenticationType.setTransactionKey(transactionKey); + ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); + + //Setting the paging + Paging paging = new Paging(); + paging.setLimit(100); + paging.setOffset(1); + + // Setting the sorting order + CustomerPaymentProfileSorting sorting = new CustomerPaymentProfileSorting(); + CustomerPaymentProfileOrderFieldEnum orderByEnum = CustomerPaymentProfileOrderFieldEnum.ID; + sorting.setOrderBy(orderByEnum); + sorting.setOrderDescending(false); + + // Setting the searchType + CustomerPaymentProfileSearchTypeEnum searchType = CustomerPaymentProfileSearchTypeEnum.CARDS_EXPIRING_IN_MONTH; + + // Making the API request + GetCustomerPaymentProfileListRequest apiRequest = new GetCustomerPaymentProfileListRequest(); + apiRequest.setPaging(paging); + apiRequest.setSearchType(searchType); + apiRequest.setSorting(sorting); + apiRequest.setMonth("2020-12"); + + // Calling the controller + GetCustomerPaymentProfileListController controller = new GetCustomerPaymentProfileListController(apiRequest); + controller.execute(); + // Getting the response + GetCustomerPaymentProfileListResponse response = new GetCustomerPaymentProfileListResponse(); + response = controller.getApiResponse(); + // Checking id the response is not null then printing the details + if(response != null) + { + if(response.getMessages().getResultCode() == MessageTypeEnum.OK) + { + System.out.println("Successfully got customer payment profile list"); + System.out.println("Message Code:" + response.getMessages().getMessage().get(0).getCode()); + System.out.println("Message Text:" + response.getMessages().getMessage().get(0).getText()); + System.out.println("Total Number of Results in the Results Set:" + response.getTotalNumInResultSet()); + List arr = response.getPaymentProfiles().getPaymentProfile(); + + for(CustomerPaymentProfileListItemType element : arr) + { + System.out.println(); + if(element.getBillTo()!=null) + System.out.println("Customer name : "+element.getBillTo().getFirstName()+" "+element.getBillTo().getLastName()); + System.out.println("Credit card number: "+element.getPayment().getCreditCard().getCardNumber()); + System.out.println("Customer Profile ID : "+element.getCustomerProfileId()); + System.out.println("Customer Payment Profile ID : "+element.getCustomerPaymentProfileId()); + } + } + else + { + // When the error occurs + System.out.println("Failed to get customer payment profile list"); + if(!response.getMessages().getMessage().isEmpty()) + System.out.println("Error: "+response.getMessages().getMessage().get(0).getCode()+" "+ response.getMessages().getMessage().get(0).getText()); + } + } + else + { + // Displaying the error code and message when response is null + ANetApiResponse errorResponse = controller.getErrorResponse(); + System.out.println("Failed to get response"); + if(!errorResponse.getMessages().getMessage().isEmpty()) + System.out.println("Error: "+errorResponse.getMessages().getMessage().get(0).getCode()+" \n"+ errorResponse.getMessages().getMessage().get(0).getText()); + } + } +} diff --git a/src/main/java/net/authorize/sample/RecurringBilling/GetSubscription.java b/src/main/java/net/authorize/sample/RecurringBilling/GetSubscription.java new file mode 100644 index 00000000..9cac8b97 --- /dev/null +++ b/src/main/java/net/authorize/sample/RecurringBilling/GetSubscription.java @@ -0,0 +1,68 @@ +package net.authorize.sample.RecurringBilling; + +import net.authorize.Environment; +import net.authorize.api.contract.v1.ANetApiResponse; +import net.authorize.api.contract.v1.ARBGetSubscriptionRequest; +import net.authorize.api.contract.v1.ARBGetSubscriptionResponse; +import net.authorize.api.contract.v1.ErrorResponse; +import net.authorize.api.contract.v1.MerchantAuthenticationType; +import net.authorize.api.contract.v1.MessageTypeEnum; +import net.authorize.api.controller.ARBGetSubscriptionController; +import net.authorize.api.controller.base.ApiOperationBase; + +public class GetSubscription +{ + public static void run(String apiLoginId,String transactionKey) + { + ApiOperationBase.setEnvironment(Environment.SANDBOX); + // Giving the merchant authentication information + MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; + merchantAuthenticationType.setName(apiLoginId); + merchantAuthenticationType.setTransactionKey(transactionKey); + ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); + // Making the API request + ARBGetSubscriptionRequest apiRequest = new ARBGetSubscriptionRequest(); + apiRequest.setRefId("Sample"); + apiRequest.setSubscriptionId("2930242"); + // Calling the controller + ARBGetSubscriptionController controller = new ARBGetSubscriptionController(apiRequest); + controller.execute(); + // Getting the response + ARBGetSubscriptionResponse response = controller.getApiResponse(); + + if(response!=null) + { + if(response.getMessages().getResultCode() == MessageTypeEnum.OK) + { + if(response.getSubscription() != null) + { + // Displaying the subscription details + System.out.println("Successfully got ARB Subscription"); + System.out.println("Subscription Details:"); + System.out.println("Subscription Name: " + response.getSubscription().getName()); + System.out.println("Subscription start date: " + response.getSubscription().getPaymentSchedule().getStartDate()); + System.out.println("Subscription amount: " + response.getSubscription().getAmount()); + System.out.println("Subscription status: " + response.getSubscription().getStatus()); + System.out.println("Subscription Description: "+response.getSubscription().getProfile().getDescription()); + System.out.println("Customer Profile ID: "+ response.getSubscription().getProfile().getCustomerProfileId()); + } + } + else + { + // Displaying the error code and message when error occurs + System.out.println("Failed to get ARB Subscription"); + if(!response.getMessages().getMessage().isEmpty()) + System.out.println("Error: "+response.getMessages().getMessage().get(0).getCode()+" "+ response.getMessages().getMessage().get(0).getText()); + } + } + else + { + // Displaying the error code and message when response is null + ANetApiResponse errorResponse = controller.getErrorResponse(); + + System.out.println("Failed to get response"); + if(!errorResponse.getMessages().getMessage().isEmpty()) + System.out.println("Error: "+errorResponse.getMessages().getMessage().get(0).getCode()+" \n"+ errorResponse.getMessages().getMessage().get(0).getText()); + } + } +} diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index 8a20904d..796defe4 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -11,7 +11,7 @@ import net.authorize.sample.RecurringBilling.*; import net.authorize.sample.TransactionReporting.*; import net.authorize.sample.CustomerProfiles.*; -import net.authorize.sample.PaypalExpressCheckout.*; + /** * Created by anetdeveloper on 8/5/15. @@ -88,6 +88,7 @@ private static void ShowMethods() System.out.println(" ChargeTokenizedCreditCard"); System.out.println(" ChargeCustomerProfile"); System.out.println(" CreateSubscription"); + System.out.println(" GetSubscription"); System.out.println(" GetSubscriptionStatus"); System.out.println(" CancelSubscription"); System.out.println(" UpdateSubscription"); @@ -104,6 +105,7 @@ private static void ShowMethods() System.out.println(" DeleteCustomerProfile"); System.out.println(" DeleteCustomerShippingAddress"); System.out.println(" GetCustomerPaymentProfile"); + System.out.println(" GetCustomerPaymentProfileList"); System.out.println(" GetCustomerProfile"); System.out.println(" GetCustomerShippingAddress"); System.out.println(" GetHostedProfilePage"); @@ -114,7 +116,7 @@ private static void ShowMethods() System.out.println(" PayPalAuthorizationOnly"); System.out.println(" PayPalAuthorizeCaptureContinue"); System.out.println(" PayPalGetDetails"); - System.out.println(" PayPalPriorAuthorizationCapture"); + System.out.println(" PayPalPriorAuthorizationCapture"); } private static void RunMethod(String methodName) @@ -171,6 +173,9 @@ private static void RunMethod(String methodName) case "CreateSubscription": CreateSubscription.run(apiLoginId, transactionKey); break; + case "GetSubscription": + GetSubscription.run(apiLoginId, transactionKey); + break; case "GetSubscriptionStatus": GetSubscriptionStatus.run(apiLoginId, transactionKey); break; @@ -219,6 +224,9 @@ private static void RunMethod(String methodName) case "GetCustomerPaymentProfile": GetCustomerPaymentProfile.run(apiLoginId, transactionKey); break; + case "GetCustomerPaymentProfileList": + GetCustomerPaymentProfileList.run(apiLoginId, transactionKey); + break; case "GetCustomerProfile": GetCustomerProfile.run(apiLoginId, transactionKey); break; From e0ba9e289b3de6b3450368e22c9f3fe4f7cbe3a7 Mon Sep 17 00:00:00 2001 From: zhaque Date: Thu, 19 Nov 2015 17:43:35 +0530 Subject: [PATCH 012/176] Sample code changed --- src/main/java/net/authorize/sample/SampleCode.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index 91440991..b63a06d2 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -87,6 +87,7 @@ private static void ShowMethods() System.out.println(" ChargeTokenizedCreditCard"); System.out.println(" ChargeCustomerProfile"); System.out.println(" CreateSubscription"); + System.out.println(" GetSubscription"); System.out.println(" GetSubscriptionStatus"); System.out.println(" CancelSubscription"); System.out.println(" UpdateSubscription"); @@ -103,6 +104,7 @@ private static void ShowMethods() System.out.println(" DeleteCustomerProfile"); System.out.println(" DeleteCustomerShippingAddress"); System.out.println(" GetCustomerPaymentProfile"); + System.out.println(" GetCustomerPaymentProfileList"); System.out.println(" GetCustomerProfile"); System.out.println(" GetCustomerProfileIds"); System.out.println(" GetCustomerShippingAddress"); @@ -174,6 +176,9 @@ private static void RunMethod(String methodName) case "CreateSubscription": CreateSubscription.run(apiLoginId, transactionKey); break; + case "GetSubscription": + GetSubscription.run(apiLoginId, transactionKey); + break; case "GetSubscriptionStatus": GetSubscriptionStatus.run(apiLoginId, transactionKey); break; @@ -222,6 +227,9 @@ private static void RunMethod(String methodName) case "GetCustomerPaymentProfile": GetCustomerPaymentProfile.run(apiLoginId, transactionKey); break; + case "GetCustomerPaymentProfileList": + GetCustomerPaymentProfileList.run(apiLoginId, transactionKey); + break; case "GetCustomerProfile": GetCustomerProfile.run(apiLoginId, transactionKey); break; @@ -272,4 +280,4 @@ private static void RunMethod(String methodName) break; } } -} \ No newline at end of file +} From 3437cefc20c8486bdeb7bc7cd6714b652e871e7c Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Sun, 22 Nov 2015 22:16:12 -0800 Subject: [PATCH 013/176] Update pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0ffcef66..dc4c0c44 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ net.authorize anet-java-sdk - 1.8.4 + 1.8.6 From 1714fc4b143f829e3acf5ee3b3a703f23bffb732 Mon Sep 17 00:00:00 2001 From: zhaque Date: Wed, 25 Nov 2015 23:28:17 +0530 Subject: [PATCH 014/176] Added CreateAnApplePayTransaction sample code and modified SampleCode --- pom.xml | 2 +- .../CreateAnApplePayTransaction.java | 65 +++++++++++++++++++ .../java/net/authorize/sample/SampleCode.java | 7 +- 3 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 src/main/java/net/authorize/sample/ApplePayTransactions/CreateAnApplePayTransaction.java diff --git a/pom.xml b/pom.xml index 0ffcef66..dc4c0c44 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ net.authorize anet-java-sdk - 1.8.4 + 1.8.6 diff --git a/src/main/java/net/authorize/sample/ApplePayTransactions/CreateAnApplePayTransaction.java b/src/main/java/net/authorize/sample/ApplePayTransactions/CreateAnApplePayTransaction.java new file mode 100644 index 00000000..959b2e83 --- /dev/null +++ b/src/main/java/net/authorize/sample/ApplePayTransactions/CreateAnApplePayTransaction.java @@ -0,0 +1,65 @@ +package net.authorize.sample.ApplePayTransactions; + +import java.math.BigDecimal; +import net.authorize.Environment; +import net.authorize.TransactionType; +import net.authorize.api.contract.v1.*; +import net.authorize.api.controller.CreateTransactionController; +import net.authorize.api.controller.base.ApiOperationBase; + +public class CreateAnApplePayTransaction +{ + public static void run(String apiLoginId, String transactionKey) + { + ApiOperationBase.setEnvironment(Environment.SANDBOX); + + // Giving the merchant authentication information + MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; + merchantAuthenticationType.setName(apiLoginId); + merchantAuthenticationType.setTransactionKey(transactionKey); + ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); + // Setting the payment + OpaqueDataType op = new OpaqueDataType(); + op.setDataDescriptor("COMMON.APPLE.INAPP.PAYMENT"); + op.setDataValue("eyJkYXRhIjoiQkRQTldTdE1tR2V3UVVXR2c0bzdFXC9qKzFjcTFUNzhxeVU4NGI2N2l0amNZSTh3UFlBT2hzaGpoWlBycWRVcjRYd1BNYmo0emNHTWR5KysxSDJWa1BPWStCT01GMjV1YjE5Y1g0bkN2a1hVVU9UakRsbEIxVGdTcjhKSFp4Z3A5ckNnc1NVZ2JCZ0tmNjBYS3V0WGY2YWpcL284WkliS25yS1E4U2gwb3VMQUtsb1VNbit2UHU0K0E3V0tycXJhdXo5SnZPUXA2dmhJcStIS2pVY1VOQ0lUUHlGaG1PRXRxK0grdzB2UmExQ0U2V2hGQk5uQ0hxenpXS2NrQlwvMG5xTFpSVFliRjBwK3Z5QmlWYVdIZWdoRVJmSHhSdGJ6cGVjelJQUHVGc2ZwSFZzNDhvUExDXC9rXC8xTU5kNDdrelwvcEhEY1JcL0R5NmFVTStsTmZvaWx5XC9RSk4rdFMzbTBIZk90SVNBUHFPbVhlbXZyNnhKQ2pDWmxDdXcwQzltWHpcL29iSHBvZnVJRVM4cjljcUdHc1VBUERwdzdnNjQybTRQendLRitIQnVZVW5lV0RCTlNEMnU2amJBRzMiLCJ2ZXJzaW9uIjoiRUNfdjEiLCJoZWFkZXIiOnsiYXBwbGljYXRpb25EYXRhIjoiOTRlZTA1OTMzNWU1ODdlNTAxY2M0YmY5MDYxM2UwODE0ZjAwYTdiMDhiYzdjNjQ4ZmQ4NjVhMmFmNmEyMmNjMiIsInRyYW5zYWN0aW9uSWQiOiJjMWNhZjVhZTcyZjAwMzlhODJiYWQ5MmI4MjgzNjM3MzRmODViZjJmOWNhZGYxOTNkMWJhZDlkZGNiNjBhNzk1IiwiZXBoZW1lcmFsUHVibGljS2V5IjoiTUlJQlN6Q0NBUU1HQnlxR1NNNDlBZ0V3Z2ZjQ0FRRXdMQVlIS29aSXpqMEJBUUloQVBcL1wvXC9cLzhBQUFBQkFBQUFBQUFBQUFBQUFBQUFcL1wvXC9cL1wvXC9cL1wvXC9cL1wvXC9cL1wvXC9cL01Gc0VJUFwvXC9cL1wvOEFBQUFCQUFBQUFBQUFBQUFBQUFBQVwvXC9cL1wvXC9cL1wvXC9cL1wvXC9cL1wvXC9cLzhCQ0JheGpYWXFqcVQ1N1BydlZWMm1JYThaUjBHc014VHNQWTd6ancrSjlKZ1N3TVZBTVNkTmdpRzV3U1RhbVo0NFJPZEpyZUJuMzZRQkVFRWF4ZlI4dUVzUWtmNHZPYmxZNlJBOG5jRGZZRXQ2ek9nOUtFNVJkaVl3cFpQNDBMaVwvaHBcL200N242MHA4RDU0V0s4NHpWMnN4WHM3THRrQm9ONzlSOVFJaEFQXC9cL1wvXC84QUFBQUFcL1wvXC9cL1wvXC9cL1wvXC9cLys4NXZxdHB4ZWVoUE81eXNMOFl5VlJBZ0VCQTBJQUJHbStnc2wwUFpGVFwva0RkVVNreHd5Zm84SnB3VFFRekJtOWxKSm5tVGw0REdVdkFENEdzZUdqXC9wc2hCWjBLM1RldXFEdFwvdERMYkUrOFwvbTB5Q21veHc9IiwicHVibGljS2V5SGFzaCI6IlwvYmI5Q05DMzZ1QmhlSEZQYm1vaEI3T28xT3NYMkora0pxdjQ4ek9WVmlRPSJ9LCJzaWduYXR1cmUiOiJNSUlEUWdZSktvWklodmNOQVFjQ29JSURNekNDQXk4Q0FRRXhDekFKQmdVckRnTUNHZ1VBTUFzR0NTcUdTSWIzRFFFSEFhQ0NBaXN3Z2dJbk1JSUJsS0FEQWdFQ0FoQmNsK1BmMytVNHBrMTNuVkQ5bndRUU1Ba0dCU3NPQXdJZEJRQXdKekVsTUNNR0ExVUVBeDRjQUdNQWFBQnRBR0VBYVFCQUFIWUFhUUJ6QUdFQUxnQmpBRzhBYlRBZUZ3MHhOREF4TURFd05qQXdNREJhRncweU5EQXhNREV3TmpBd01EQmFNQ2N4SlRBakJnTlZCQU1lSEFCakFHZ0FiUUJoQUdrQVFBQjJBR2tBY3dCaEFDNEFZd0J2QUcwd2daOHdEUVlKS29aSWh2Y05BUUVCQlFBRGdZMEFNSUdKQW9HQkFOQzgra2d0Z212V0YxT3pqZ0ROcmpURUJSdW9cLzVNS3ZsTTE0NnBBZjdHeDQxYmxFOXc0ZklYSkFEN0ZmTzdRS2pJWFlOdDM5ckx5eTd4RHdiXC81SWtaTTYwVFoyaUkxcGo1NVVjOGZkNGZ6T3BrM2Z0WmFRR1hOTFlwdEcxZDlWN0lTODJPdXA5TU1vMUJQVnJYVFBITmNzTTk5RVBVblBxZGJlR2M4N20wckFnTUJBQUdqWERCYU1GZ0dBMVVkQVFSUk1FK0FFSFpXUHJXdEpkN1laNDMxaENnN1lGU2hLVEFuTVNVd0l3WURWUVFESGh3QVl3Qm9BRzBBWVFCcEFFQUFkZ0JwQUhNQVlRQXVBR01BYndCdGdoQmNsK1BmMytVNHBrMTNuVkQ5bndRUU1Ba0dCU3NPQXdJZEJRQURnWUVBYlVLWUNrdUlLUzlRUTJtRmNNWVJFSW0ybCtYZzhcL0pYditHQlZRSmtPS29zY1k0aU5ERkFcL2JRbG9nZjlMTFU4NFRId05SbnN2VjNQcnY3UlRZODFncTBkdEM4elljQWFBa0NISUkzeXFNbko0QU91NkVPVzlrSmsyMzJnU0U3V2xDdEhiZkxTS2Z1U2dRWDhLWFFZdVpMazJScjYzTjhBcFhzWHdCTDNjSjB4Z2VBd2dkMENBUUV3T3pBbk1TVXdJd1lEVlFRREhod0FZd0JvQUcwQVlRQnBBRUFBZGdCcEFITUFZUUF1QUdNQWJ3QnRBaEJjbCtQZjMrVTRwazEzblZEOW53UVFNQWtHQlNzT0F3SWFCUUF3RFFZSktvWklodmNOQVFFQkJRQUVnWUJhSzNFbE9zdGJIOFdvb3NlREFCZitKZ1wvMTI5SmNJYXdtN2M2VnhuN1phc05iQXEzdEF0OFB0eSt1UUNnc3NYcVprTEE3a3oyR3pNb2xOdHY5d1ltdTlVandhcjFQSFlTK0JcL29Hbm96NTkxd2phZ1hXUnowbk1vNXkzTzFLelgwZDhDUkhBVmE4OFNyVjFhNUpJaVJldjNvU3RJcXd2NXh1WmxkYWc2VHI4dz09In0="); + PaymentType paymentOne = new PaymentType(); + paymentOne.setOpaqueData(op); + // Setting the transaction + TransactionRequestType transactionRequest = new TransactionRequestType(); + transactionRequest.setAmount(new BigDecimal("131")); + transactionRequest.setTransactionType(TransactionTypeEnum.AUTH_CAPTURE_TRANSACTION.value()); + transactionRequest.setPayment(paymentOne); + // Making the api request + CreateTransactionRequest apiRequest = new CreateTransactionRequest(); + apiRequest.setTransactionRequest(transactionRequest); + // Creating the controller + CreateTransactionController controller = new CreateTransactionController(apiRequest); + controller.execute(); + // Getting the response + CreateTransactionResponse response = controller.getApiResponse(); + if(response!=null) + { + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) + { + if (response.getTransactionResponse() != null) + { + TransactionResponse result = response.getTransactionResponse(); + System.out.println("Successful: Create an ApplePay Transaction"); + System.out.println("Response Code : " + result.getResponseCode()); + System.out.println("Transaction ID : " + result.getTransId()); + System.out.println("Auth code : " + result.getAuthCode()); + } + } + else + { + System.out.println("Failed: Create ApplePay Transaction"); + if(!response.getMessages().getMessage().isEmpty()) + System.out.println("Error: " + response.getMessages().getMessage().get(0).getCode() + " " + response.getMessages().getMessage().get(0).getText()); + + if (response.getTransactionResponse() != null) + if(!response.getTransactionResponse().getErrors().getError().isEmpty()) + System.out.println("Transaction Error : " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode() + " " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + } + } +} diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index b63a06d2..f5b3960e 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -3,6 +3,7 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; +import net.authorize.sample.ApplePayTransactions.CreateAnApplePayTransaction; import net.authorize.sample.VisaCheckout.*; import net.authorize.sample.PaymentTransactions.*; @@ -11,7 +12,7 @@ import net.authorize.sample.RecurringBilling.*; import net.authorize.sample.TransactionReporting.*; import net.authorize.sample.CustomerProfiles.*; - +import net.authorize.sample.ApplePayTransactions.*; /** * Created by anetdeveloper on 8/5/15. */ @@ -85,6 +86,7 @@ private static void ShowMethods() System.out.println(" DebitBankAccount"); System.out.println(" CreditBankAccount"); System.out.println(" ChargeTokenizedCreditCard"); + System.out.println(" CreateAnApplePayTransaction"); System.out.println(" ChargeCustomerProfile"); System.out.println(" CreateSubscription"); System.out.println(" GetSubscription"); @@ -170,6 +172,9 @@ private static void RunMethod(String methodName) case "ChargeTokenizedCreditCard": ChargeTokenizedCreditCard.run(apiLoginId, transactionKey); break; + case "CreateAnApplePayTransaction": + CreateAnApplePayTransaction.run(apiLoginId, transactionKey); + break; case "ChargeCustomerProfile": ChargeCustomerProfile.run(apiLoginId, transactionKey); break; From 70ed0afa3aea56fd383b6d6edf7acf655ee6c599 Mon Sep 17 00:00:00 2001 From: brianmc Date: Sun, 29 Nov 2015 06:24:41 -0800 Subject: [PATCH 015/176] Updated sample to use a profile ID --- .../ChargeCustomerProfile.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCustomerProfile.java b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCustomerProfile.java index 0ba35171..a2bd6032 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCustomerProfile.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCustomerProfile.java @@ -24,21 +24,20 @@ public static void run(String apiLoginId, String transactionKey) { merchantAuthenticationType.setTransactionKey(transactionKey); ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); - // Populate the payment data - PaymentType paymentType = new PaymentType(); - CreditCardType creditCard = new CreditCardType(); - creditCard.setCardNumber("4242424242424242"); - creditCard.setExpirationDate("0822"); - paymentType.setCreditCard(creditCard); + + // Set the profile ID to charge + CustomerProfilePaymentType profileToCharge = new CustomerProfilePaymentType(); + profileToCharge.setCustomerProfileId("36731856"); + PaymentProfile paymentProfile = new PaymentProfile(); + paymentProfile.setPaymentProfileId("33211899"); + profileToCharge.setPaymentProfile(paymentProfile); // Create the payment transaction request TransactionRequestType txnRequest = new TransactionRequestType(); txnRequest.setTransactionType(TransactionTypeEnum.AUTH_CAPTURE_TRANSACTION.value()); - txnRequest.setPayment(paymentType); + txnRequest.setProfile(profileToCharge); txnRequest.setAmount(new BigDecimal(500.00)); - PaymentProfile paymentProfile = new PaymentProfile(); - paymentProfile.setPaymentProfileId("25000332"); CreateTransactionRequest apiRequest = new CreateTransactionRequest(); apiRequest.setTransactionRequest(txnRequest); From 24b9403f55969debdd4b804f088e0dccfc77d400 Mon Sep 17 00:00:00 2001 From: zhaque Date: Mon, 30 Nov 2015 16:39:44 +0530 Subject: [PATCH 016/176] Modified the SampleCode.java for running Visa Checkout sample codes --- src/main/java/net/authorize/sample/SampleCode.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index f5b3960e..ff485a42 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -136,10 +136,10 @@ private static void RunMethod(String methodName) String transactionId = ""; switch (methodName) { - case "VisaCheckoutDecrypt": + case "DecryptVisaCheckoutData": DecryptVisaCheckoutData.run(apiLoginId, transactionKey); break; - case "VisaCheckoutTransaction": + case "CreateVisaCheckoutTransaction": CreateVisaCheckoutTransaction.run(apiLoginId, transactionKey); break; case "ChargeCreditCard": From 37b8c56ea9fa4d562fe88563da0cd8732e2162d8 Mon Sep 17 00:00:00 2001 From: zhaque Date: Wed, 23 Dec 2015 12:09:34 +0530 Subject: [PATCH 017/176] Added ValidateCustomerPaymentProfile to the list of displayed sample code names and also added the case expression for it. --- src/main/java/net/authorize/sample/SampleCode.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index ff485a42..4e755295 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -113,6 +113,7 @@ private static void ShowMethods() System.out.println(" GetHostedProfilePage"); System.out.println(" UpdateCustomerPaymentProfile"); System.out.println(" UpdateCustomerShippingAddress"); + System.out.println(" ValidateCustomerPaymentProfile"); System.out.println(" PayPalAuthorizeCapture"); System.out.println(" PayPalVoid"); System.out.println(" PayPalAuthorizationOnly"); @@ -253,6 +254,9 @@ private static void RunMethod(String methodName) case "UpdateCustomerShippingAddress": UpdateCustomerShippingAddress.run(apiLoginId, transactionKey); break; + case "ValidateCustomerPaymentProfile": + ValidateCustomerPaymentProfile.run(apiLoginId, transactionKey); + break; case "PayPalAuthorizeCapture": AuthorizationAndCapture.run(apiLoginId, transactionKey); break; From b0e58e7d1cfdd7f19cea6366276648268562ffe9 Mon Sep 17 00:00:00 2001 From: brianmc Date: Sun, 27 Dec 2015 21:21:52 -0800 Subject: [PATCH 018/176] Updated Sample for Refund --- .../PaymentTransactions/RefundTransaction.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/RefundTransaction.java b/src/main/java/net/authorize/sample/PaymentTransactions/RefundTransaction.java index 6c51ea1d..b7eea0aa 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/RefundTransaction.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/RefundTransaction.java @@ -23,10 +23,19 @@ public static void run(String apiLoginId, String transactionKey) { merchantAuthenticationType.setTransactionKey(transactionKey); ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); + // Create a payment object, last 4 of the credit card and expiration date are required + PaymentType paymentType = new PaymentType(); + CreditCardType creditCard = new CreditCardType(); + creditCard.setCardNumber("0015"); + creditCard.setExpirationDate("1220"); + paymentType.setCreditCard(creditCard); + // Create the payment transaction request TransactionRequestType txnRequest = new TransactionRequestType(); txnRequest.setTransactionType(TransactionTypeEnum.REFUND_TRANSACTION.value()); - txnRequest.setRefTransId("2238786428"); + txnRequest.setRefTransId("2245803597"); + txnRequest.setAmount(new BigDecimal(1.00)); + txnRequest.setPayment(paymentType); // Make the API Request CreateTransactionRequest apiRequest = new CreateTransactionRequest(); @@ -57,6 +66,12 @@ public static void run(String apiLoginId, String transactionKey) { else { System.out.println("Failed Transaction: "+response.getMessages().getResultCode()); + if(!response.getMessages().getMessage().isEmpty()) + System.out.println("Error: " + response.getMessages().getMessage().get(0).getCode() + " " + response.getMessages().getMessage().get(0).getText()); + + if (response.getTransactionResponse() != null) + if(!response.getTransactionResponse().getErrors().getError().isEmpty()) + System.out.println("Transaction Error : " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode() + " " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } } From c0488f48a6db878dca0d11a6ec664a336aaba58c Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Mon, 28 Dec 2015 07:40:26 -0800 Subject: [PATCH 019/176] Rename CaptureOnly.java to CaptureFundsAuthorizedThroughAnotherChannel.java --- ...Only.java => CaptureFundsAuthorizedThroughAnotherChannel.java} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/java/net/authorize/sample/PaymentTransactions/{CaptureOnly.java => CaptureFundsAuthorizedThroughAnotherChannel.java} (100%) diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/CaptureOnly.java b/src/main/java/net/authorize/sample/PaymentTransactions/CaptureFundsAuthorizedThroughAnotherChannel.java similarity index 100% rename from src/main/java/net/authorize/sample/PaymentTransactions/CaptureOnly.java rename to src/main/java/net/authorize/sample/PaymentTransactions/CaptureFundsAuthorizedThroughAnotherChannel.java From 0d02b59b967488b03a341adf9c504da81f8dc3ae Mon Sep 17 00:00:00 2001 From: akankari Date: Tue, 29 Dec 2015 13:49:22 +0530 Subject: [PATCH 020/176] Correcting the class name in order to fix build --- .../CaptureFundsAuthorizedThroughAnotherChannel.java | 2 +- src/main/java/net/authorize/sample/SampleCode.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/CaptureFundsAuthorizedThroughAnotherChannel.java b/src/main/java/net/authorize/sample/PaymentTransactions/CaptureFundsAuthorizedThroughAnotherChannel.java index 23a50f12..dd43ba75 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/CaptureFundsAuthorizedThroughAnotherChannel.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/CaptureFundsAuthorizedThroughAnotherChannel.java @@ -7,7 +7,7 @@ import net.authorize.api.controller.base.ApiOperationBase; import net.authorize.api.controller.CreateTransactionController; -public class CaptureOnly { +public class CaptureFundsAuthorizedThroughAnotherChannel { // // Run this sample from command line with: diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index 4e755295..70a1d1f3 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -81,7 +81,7 @@ private static void ShowMethods() System.out.println(" RefundTransaction"); System.out.println(" VoidTransaction"); System.out.println(" CreateCustomerProfileFromTransaction"); - System.out.println(" CaptureOnly"); + System.out.println(" CaptureFundsAuthorizedThroughAnotherChannel"); System.out.println(" CapturePreviouslyAuthorizedAmount"); System.out.println(" DebitBankAccount"); System.out.println(" CreditBankAccount"); @@ -158,8 +158,8 @@ private static void RunMethod(String methodName) case "CreateCustomerProfileFromTransaction": CreateCustomerProfileFromTransaction.run(apiLoginId, transactionKey); break; - case "CaptureOnly": - CaptureOnly.run(apiLoginId, transactionKey); + case "CaptureFundsAuthorizedThroughAnotherChannel": + CaptureFundsAuthorizedThroughAnotherChannel.run(apiLoginId, transactionKey); break; case "CapturePreviouslyAuthorizedAmount": CapturePreviouslyAuthorizedAmount.run(apiLoginId, transactionKey); From e39c1767feeef68398212012e3ea7c55d7e07efb Mon Sep 17 00:00:00 2001 From: srathod Date: Mon, 11 Jan 2016 16:45:44 +0530 Subject: [PATCH 021/176] - Implemented testrunner for java. - Updated sample codes to return ANetApiResponse so that output can be validated by TestRunner. --- .gitignore | 1 + .../CreateAnApplePayTransaction.java | 3 +- .../CreateCustomerPaymentProfile.java | 24 +- .../CreateCustomerProfile.java | 14 +- .../CreateCustomerProfileFromTransaction.java | 5 +- .../CreateCustomerShippingAddress.java | 5 +- .../DeleteCustomerPaymentProfile.java | 8 +- .../DeleteCustomerProfile.java | 5 +- .../DeleteCustomerShippingAddress.java | 8 +- .../GetCustomerPaymentProfile.java | 8 +- .../GetCustomerPaymentProfileList.java | 3 +- .../CustomerProfiles/GetCustomerProfile.java | 5 +- .../GetCustomerProfileIds.java | 3 +- .../GetCustomerShippingAddress.java | 8 +- .../GetHostedProfilePage.java | 5 +- .../UpdateCustomerPaymentProfile.java | 7 +- .../UpdateCustomerProfile.java | 5 +- .../UpdateCustomerShippingAddress.java | 7 +- .../ValidateCustomerPaymentProfile.java | 16 +- .../AuthorizeCreditCard.java | 5 +- ...eFundsAuthorizedThroughAnotherChannel.java | 3 +- .../CapturePreviouslyAuthorizedAmount.java | 5 +- .../PaymentTransactions/ChargeCreditCard.java | 5 +- .../ChargeCustomerProfile.java | 8 +- .../ChargeTokenizedCreditCard.java | 3 +- .../CreditBankAccount.java | 5 +- .../PaymentTransactions/DebitBankAccount.java | 3 +- .../RefundTransaction.java | 7 +- .../UpdateSplitTenderGroup.java | 3 +- .../PaymentTransactions/VoidTransaction.java | 5 +- .../AuthorizationAndCapture.java | 6 +- .../AuthorizationAndCaptureContinue.java | 11 +- .../AuthorizationOnly.java | 5 +- .../AuthorizationOnlyContinued.java | 5 +- .../sample/PaypalExpressCheckout/Credit.java | 3 +- .../PaypalExpressCheckout/GetDetails.java | 5 +- .../PriorAuthorizationCapture.java | 3 +- .../sample/PaypalExpressCheckout/Void.java | 6 +- .../RecurringBilling/CancelSubscription.java | 5 +- .../RecurringBilling/CreateSubscription.java | 11 +- .../GetListOfSubscriptions.java | 11 +- .../RecurringBilling/GetSubscription.java | 5 +- .../GetSubscriptionStatus.java | 53 +- .../RecurringBilling/UpdateSubscription.java | 5 +- .../java/net/authorize/sample/SampleCode.java | 73 +-- .../sample/SampleCodeTest/Constants.java | 9 + .../sample/SampleCodeTest/SampleCodeList.txt | 51 ++ .../sample/SampleCodeTest/TestRunner.java | 478 ++++++++++++++++++ .../GetBatchStatistics.java | 3 +- .../GetSettledBatchList.java | 3 +- .../GetTransactionDetails.java | 8 +- .../GetTransactionList.java | 3 +- .../GetUnsettledTransactionList.java | 3 +- .../CreateVisaCheckoutTransaction.java | 4 +- .../VisaCheckout/DecryptVisaCheckoutData.java | 4 +- 55 files changed, 781 insertions(+), 184 deletions(-) create mode 100644 src/main/java/net/authorize/sample/SampleCodeTest/Constants.java create mode 100644 src/main/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt create mode 100644 src/main/java/net/authorize/sample/SampleCodeTest/TestRunner.java diff --git a/.gitignore b/.gitignore index dca07322..68546a7a 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ hs_err_pid* /logs/ /target/ +/bin/ diff --git a/src/main/java/net/authorize/sample/ApplePayTransactions/CreateAnApplePayTransaction.java b/src/main/java/net/authorize/sample/ApplePayTransactions/CreateAnApplePayTransaction.java index 959b2e83..d3b797ec 100644 --- a/src/main/java/net/authorize/sample/ApplePayTransactions/CreateAnApplePayTransaction.java +++ b/src/main/java/net/authorize/sample/ApplePayTransactions/CreateAnApplePayTransaction.java @@ -9,7 +9,7 @@ public class CreateAnApplePayTransaction { - public static void run(String apiLoginId, String transactionKey) + public static ANetApiResponse run(String apiLoginId, String transactionKey) { ApiOperationBase.setEnvironment(Environment.SANDBOX); @@ -61,5 +61,6 @@ public static void run(String apiLoginId, String transactionKey) System.out.println("Transaction Error : " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode() + " " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } } + return response; } } diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerPaymentProfile.java b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerPaymentProfile.java index 23a1263d..d3169b35 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerPaymentProfile.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerPaymentProfile.java @@ -18,7 +18,7 @@ //author @krgupta public class CreateCustomerPaymentProfile { - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey, String customerProfileId) { ApiOperationBase.setEnvironment(Environment.SANDBOX); @@ -27,13 +27,10 @@ public static void run(String apiLoginId, String transactionKey) { merchantAuthenticationType.setTransactionKey(transactionKey); ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); - String customerprofileId = "36374423" ; - - //private String getPaymentDetails(MerchantAuthenticationType merchantAuthentication, String customerprofileId, ValidationModeEnum validationMode) { CreateCustomerPaymentProfileRequest apiRequest = new CreateCustomerPaymentProfileRequest(); apiRequest.setMerchantAuthentication(merchantAuthenticationType); - apiRequest.setCustomerProfileId(customerprofileId); + apiRequest.setCustomerProfileId(customerProfileId); //customer address CustomerAddressType customerAddress = new CustomerAddressType(); @@ -50,7 +47,7 @@ public static void run(String apiLoginId, String transactionKey) { CreditCardType creditCard = new CreditCardType(); creditCard.setCardNumber("4111111111111111"); creditCard.setExpirationDate("2023-12"); - creditCard.setCardCode(""); + creditCard.setCardCode("122"); CustomerPaymentProfileType profile = new CustomerPaymentProfileType(); profile.setBillTo(customerAddress); @@ -60,26 +57,27 @@ public static void run(String apiLoginId, String transactionKey) { profile.setPayment(payment); apiRequest.setPaymentProfile(profile); - - CreateCustomerPaymentProfileController controller = new CreateCustomerPaymentProfileController(apiRequest); - controller.execute(); + + CreateCustomerPaymentProfileController controller = new CreateCustomerPaymentProfileController(apiRequest); + controller.execute(); CreateCustomerPaymentProfileResponse response = new CreateCustomerPaymentProfileResponse(); response = controller.getApiResponse(); - if (response!=null) { - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { - + System.out.println(response.getCustomerPaymentProfileId()); System.out.println(response.getMessages().getMessage().get(0).getCode()); System.out.println(response.getMessages().getMessage().get(0).getText()); - System.out.println(response.getValidationDirectResponse()); + if(response.getValidationDirectResponse() != null) + System.out.println(response.getValidationDirectResponse()); } else { System.out.println("Failed to create customer payment profile: " + response.getMessages().getResultCode()); } } + + return response; } } diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfile.java b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfile.java index be3168c0..54b96a4f 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfile.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfile.java @@ -8,7 +8,7 @@ public class CreateCustomerProfile { - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey, String eMail) { ApiOperationBase.setEnvironment(Environment.SANDBOX); @@ -31,7 +31,7 @@ public static void run(String apiLoginId, String transactionKey) { CustomerProfileType customerProfileType = new CustomerProfileType(); customerProfileType.setMerchantCustomerId("Merchant_Customer_ID"); customerProfileType.setDescription("Profile description here"); - customerProfileType.setEmail("customer-profile-email@here.com"); + customerProfileType.setEmail(eMail); customerProfileType.getPaymentProfiles().add(customerPaymentProfileType); CreateCustomerProfileRequest apiRequest = new CreateCustomerProfileRequest(); @@ -45,15 +45,19 @@ public static void run(String apiLoginId, String transactionKey) { if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { System.out.println(response.getCustomerProfileId()); - System.out.println(response.getCustomerPaymentProfileIdList().getNumericString().get(0)); - System.out.println(response.getCustomerShippingAddressIdList().getNumericString().get(0)); - System.out.println(response.getValidationDirectResponseList().getString().get(0)); + if(!response.getCustomerPaymentProfileIdList().getNumericString().isEmpty()) + System.out.println(response.getCustomerPaymentProfileIdList().getNumericString().get(0)); + if(!response.getCustomerShippingAddressIdList().getNumericString().isEmpty()) + System.out.println(response.getCustomerShippingAddressIdList().getNumericString().get(0)); + if(!response.getValidationDirectResponseList().getString().isEmpty()) + System.out.println(response.getValidationDirectResponseList().getString().get(0)); } else { System.out.println("Failed to create customer profile: " + response.getMessages().getResultCode()); } } + return response; } } \ No newline at end of file diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfileFromTransaction.java b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfileFromTransaction.java index 33da4ac1..29e74139 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfileFromTransaction.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfileFromTransaction.java @@ -10,7 +10,7 @@ public class CreateCustomerProfileFromTransaction { - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey) { ApiOperationBase.setEnvironment(Environment.SANDBOX); @@ -19,8 +19,6 @@ public static void run(String apiLoginId, String transactionKey) { merchantAuthenticationType.setTransactionKey(transactionKey); ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); - String customerprofileId = "36374423" ; - CreditCardType creditCard = new CreditCardType(); creditCard.setCardNumber("4111111111111111"); creditCard.setExpirationDate("0616"); @@ -54,5 +52,6 @@ public static void run(String apiLoginId, String transactionKey) { if(customer_response != null) { System.out.println(transaction_request.getTransId()); } + return customer_response; } } diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerShippingAddress.java b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerShippingAddress.java index b4f339e1..b3187096 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerShippingAddress.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerShippingAddress.java @@ -8,7 +8,7 @@ public class CreateCustomerShippingAddress { - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey, String customerProfileId) { ApiOperationBase.setEnvironment(Environment.SANDBOX); @@ -28,7 +28,7 @@ public static void run(String apiLoginId, String transactionKey) { customerAddressType.setPhoneNumber("000-000-0000"); CreateCustomerShippingAddressRequest apiRequest = new CreateCustomerShippingAddressRequest(); - apiRequest.setCustomerProfileId("10000"); + apiRequest.setCustomerProfileId(customerProfileId); apiRequest.setAddress(customerAddressType); CreateCustomerShippingAddressController controller = new CreateCustomerShippingAddressController(apiRequest); @@ -48,6 +48,7 @@ public static void run(String apiLoginId, String transactionKey) { System.out.println("Failed to create customer shipping address: " + response.getMessages().getResultCode()); } } + return response; } } \ No newline at end of file diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/DeleteCustomerPaymentProfile.java b/src/main/java/net/authorize/sample/CustomerProfiles/DeleteCustomerPaymentProfile.java index 3a501d68..684206a6 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/DeleteCustomerPaymentProfile.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/DeleteCustomerPaymentProfile.java @@ -10,7 +10,8 @@ public class DeleteCustomerPaymentProfile { - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey, String customerProfileId, + String customerPaymentProfileId) { ApiOperationBase.setEnvironment(Environment.SANDBOX); @@ -20,8 +21,8 @@ public static void run(String apiLoginId, String transactionKey) { ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); DeleteCustomerPaymentProfileRequest apiRequest = new DeleteCustomerPaymentProfileRequest(); - apiRequest.setCustomerProfileId("10000"); - apiRequest.setCustomerPaymentProfileId("20000"); + apiRequest.setCustomerProfileId(customerProfileId); + apiRequest.setCustomerPaymentProfileId(customerPaymentProfileId); DeleteCustomerPaymentProfileController controller = new DeleteCustomerPaymentProfileController(apiRequest); controller.execute(); @@ -41,5 +42,6 @@ public static void run(String apiLoginId, String transactionKey) { System.out.println("Failed to delete customer payment profile: " + response.getMessages().getResultCode()); } } + return response; } } \ No newline at end of file diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/DeleteCustomerProfile.java b/src/main/java/net/authorize/sample/CustomerProfiles/DeleteCustomerProfile.java index 54d04601..6eb49847 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/DeleteCustomerProfile.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/DeleteCustomerProfile.java @@ -10,7 +10,7 @@ public class DeleteCustomerProfile { - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey, String customerProfileId) { ApiOperationBase.setEnvironment(Environment.SANDBOX); @@ -20,7 +20,7 @@ public static void run(String apiLoginId, String transactionKey) { ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); DeleteCustomerProfileRequest apiRequest = new DeleteCustomerProfileRequest(); - apiRequest.setCustomerProfileId("10000"); + apiRequest.setCustomerProfileId(customerProfileId); DeleteCustomerProfileController controller = new DeleteCustomerProfileController(apiRequest); controller.execute(); @@ -40,5 +40,6 @@ public static void run(String apiLoginId, String transactionKey) { System.out.println("Failed to delete customer profile: " + response.getMessages().getResultCode()); } } + return response; } } \ No newline at end of file diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/DeleteCustomerShippingAddress.java b/src/main/java/net/authorize/sample/CustomerProfiles/DeleteCustomerShippingAddress.java index fe0e5510..2f5c4ead 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/DeleteCustomerShippingAddress.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/DeleteCustomerShippingAddress.java @@ -10,7 +10,8 @@ public class DeleteCustomerShippingAddress { - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey, String customerProfileId, + String customerAddressId) { ApiOperationBase.setEnvironment(Environment.SANDBOX); @@ -20,8 +21,8 @@ public static void run(String apiLoginId, String transactionKey) { ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); DeleteCustomerShippingAddressRequest apiRequest = new DeleteCustomerShippingAddressRequest(); - apiRequest.setCustomerProfileId("10000"); - apiRequest.setCustomerAddressId("30000"); + apiRequest.setCustomerProfileId(customerProfileId); + apiRequest.setCustomerAddressId(customerAddressId); DeleteCustomerShippingAddressController controller = new DeleteCustomerShippingAddressController(apiRequest); controller.execute(); @@ -41,5 +42,6 @@ public static void run(String apiLoginId, String transactionKey) { System.out.println("Failed to delete customer shipping address: " + response.getMessages().getResultCode()); } } + return response; } } \ No newline at end of file diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerPaymentProfile.java b/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerPaymentProfile.java index c945ff62..57e7f5bb 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerPaymentProfile.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerPaymentProfile.java @@ -10,7 +10,8 @@ public class GetCustomerPaymentProfile { - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey, String customerProfileId, + String customerPaymentProfileId) { ApiOperationBase.setEnvironment(Environment.SANDBOX); @@ -20,8 +21,8 @@ public static void run(String apiLoginId, String transactionKey) { ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); GetCustomerPaymentProfileRequest apiRequest = new GetCustomerPaymentProfileRequest(); - apiRequest.setCustomerProfileId("10000"); - apiRequest.setCustomerPaymentProfileId("20000"); + apiRequest.setCustomerProfileId(customerProfileId); + apiRequest.setCustomerPaymentProfileId(customerPaymentProfileId); GetCustomerPaymentProfileController controller = new GetCustomerPaymentProfileController(apiRequest); controller.execute(); @@ -57,5 +58,6 @@ public static void run(String apiLoginId, String transactionKey) { System.out.println("Failed to get customer payment profile: " + response.getMessages().getResultCode()); } } + return response; } } \ No newline at end of file diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerPaymentProfileList.java b/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerPaymentProfileList.java index 1cc8b547..1633abc8 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerPaymentProfileList.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerPaymentProfileList.java @@ -9,7 +9,7 @@ public class GetCustomerPaymentProfileList { - public static void run(String apiLoginId,String transactionKey) + public static ANetApiResponse run(String apiLoginId,String transactionKey) { ApiOperationBase.setEnvironment(Environment.SANDBOX); @@ -83,5 +83,6 @@ public static void run(String apiLoginId,String transactionKey) if(!errorResponse.getMessages().getMessage().isEmpty()) System.out.println("Error: "+errorResponse.getMessages().getMessage().get(0).getCode()+" \n"+ errorResponse.getMessages().getMessage().get(0).getText()); } + return response; } } diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerProfile.java b/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerProfile.java index b4d9d12b..34961d7b 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerProfile.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerProfile.java @@ -10,7 +10,7 @@ public class GetCustomerProfile { - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey, String customerProfileId) { ApiOperationBase.setEnvironment(Environment.SANDBOX); @@ -20,7 +20,7 @@ public static void run(String apiLoginId, String transactionKey) { ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); GetCustomerProfileRequest apiRequest = new GetCustomerProfileRequest(); - apiRequest.setCustomerProfileId("10000"); + apiRequest.setCustomerProfileId(customerProfileId); GetCustomerProfileController controller = new GetCustomerProfileController(apiRequest); controller.execute(); @@ -72,5 +72,6 @@ public static void run(String apiLoginId, String transactionKey) { System.out.println("Failed to get customer profile: " + response.getMessages().getResultCode()); } } + return response; } } \ No newline at end of file diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerProfileIds.java b/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerProfileIds.java index cf08aa12..e2666fee 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerProfileIds.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerProfileIds.java @@ -10,7 +10,7 @@ public class GetCustomerProfileIds { - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey) { ApiOperationBase.setEnvironment(Environment.SANDBOX); @@ -44,5 +44,6 @@ public static void run(String apiLoginId, String transactionKey) { System.out.println("Failed to get customer payment profile: " + response.getMessages().getResultCode()); } } + return response; } } diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerShippingAddress.java b/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerShippingAddress.java index 06a36a8c..39b33be4 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerShippingAddress.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerShippingAddress.java @@ -10,7 +10,8 @@ public class GetCustomerShippingAddress { - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey, String customerProfileId, + String customerAddressId) { ApiOperationBase.setEnvironment(Environment.SANDBOX); @@ -20,8 +21,8 @@ public static void run(String apiLoginId, String transactionKey) { ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); GetCustomerShippingAddressRequest apiRequest = new GetCustomerShippingAddressRequest(); - apiRequest.setCustomerProfileId("10000"); - apiRequest.setCustomerAddressId("30000"); + apiRequest.setCustomerProfileId(customerProfileId); + apiRequest.setCustomerAddressId(customerAddressId); GetCustomerShippingAddressController controller = new GetCustomerShippingAddressController(apiRequest); controller.execute(); @@ -54,5 +55,6 @@ public static void run(String apiLoginId, String transactionKey) { System.out.println("Failed to get customer shipping address: " + response.getMessages().getResultCode()); } } + return response; } } \ No newline at end of file diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/GetHostedProfilePage.java b/src/main/java/net/authorize/sample/CustomerProfiles/GetHostedProfilePage.java index 258f6801..5e1b7fd6 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/GetHostedProfilePage.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/GetHostedProfilePage.java @@ -10,7 +10,7 @@ public class GetHostedProfilePage { - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey, String customerProfileId) { ApiOperationBase.setEnvironment(Environment.SANDBOX); @@ -27,7 +27,7 @@ public static void run(String apiLoginId, String transactionKey) { alist.getSetting().add(setting); GetHostedProfilePageRequest apiRequest = new GetHostedProfilePageRequest(); - apiRequest.setCustomerProfileId("YourProfileID"); + apiRequest.setCustomerProfileId(customerProfileId); apiRequest.setHostedProfileSettings(alist); GetHostedProfilePageController controller = new GetHostedProfilePageController(apiRequest); @@ -50,5 +50,6 @@ public static void run(String apiLoginId, String transactionKey) { System.out.println("Failed to get hosted profile page: " + response.getMessages().getResultCode()); } } + return response; } } \ No newline at end of file diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/UpdateCustomerPaymentProfile.java b/src/main/java/net/authorize/sample/CustomerProfiles/UpdateCustomerPaymentProfile.java index 4aab3ddf..d4ea1554 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/UpdateCustomerPaymentProfile.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/UpdateCustomerPaymentProfile.java @@ -7,7 +7,7 @@ public class UpdateCustomerPaymentProfile { - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey, String customerProfileId, String customerPaymentProfileId) { ApiOperationBase.setEnvironment(Environment.SANDBOX); @@ -37,11 +37,11 @@ public static void run(String apiLoginId, String transactionKey) { CustomerPaymentProfileExType customer = new CustomerPaymentProfileExType(); customer.setPayment(paymentType); - customer.setCustomerPaymentProfileId("20000"); + customer.setCustomerPaymentProfileId(customerPaymentProfileId); customer.setBillTo(customerAddress); UpdateCustomerPaymentProfileRequest apiRequest = new UpdateCustomerPaymentProfileRequest(); - apiRequest.setCustomerProfileId("10000"); + apiRequest.setCustomerProfileId(customerProfileId); apiRequest.setPaymentProfile(customer); apiRequest.setValidationMode(ValidationModeEnum.LIVE_MODE); @@ -63,5 +63,6 @@ public static void run(String apiLoginId, String transactionKey) { System.out.println("Failed to update customer payment profile: " + response.getMessages().getResultCode()); } } + return response; } } \ No newline at end of file diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/UpdateCustomerProfile.java b/src/main/java/net/authorize/sample/CustomerProfiles/UpdateCustomerProfile.java index b37613bc..e03bbf79 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/UpdateCustomerProfile.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/UpdateCustomerProfile.java @@ -7,7 +7,7 @@ public class UpdateCustomerProfile { - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey, String customerProfileId) { ApiOperationBase.setEnvironment(Environment.SANDBOX); @@ -20,7 +20,7 @@ public static void run(String apiLoginId, String transactionKey) { customer.setMerchantCustomerId("custId123"); customer.setDescription("some description"); customer.setEmail("newaddress@example.com"); - customer.setCustomerProfileId("10000"); + customer.setCustomerProfileId(customerProfileId); UpdateCustomerProfileRequest apiRequest = new UpdateCustomerProfileRequest(); apiRequest.setProfile(customer); @@ -43,5 +43,6 @@ public static void run(String apiLoginId, String transactionKey) { System.out.println("Failed to update customer profile: " + response.getMessages().getResultCode()); } } + return response; } } \ No newline at end of file diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/UpdateCustomerShippingAddress.java b/src/main/java/net/authorize/sample/CustomerProfiles/UpdateCustomerShippingAddress.java index 3ca064cb..a266df5e 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/UpdateCustomerShippingAddress.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/UpdateCustomerShippingAddress.java @@ -7,7 +7,7 @@ public class UpdateCustomerShippingAddress { - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey, String customerProfileID, String customerAddressId) { ApiOperationBase.setEnvironment(Environment.SANDBOX); @@ -25,10 +25,10 @@ public static void run(String apiLoginId, String transactionKey) { customer.setZip("98004"); customer.setCountry("USA"); customer.setPhoneNumber("000-000-0000"); - customer.setCustomerAddressId("30000"); + customer.setCustomerAddressId(customerAddressId); UpdateCustomerShippingAddressRequest apiRequest = new UpdateCustomerShippingAddressRequest(); - apiRequest.setCustomerProfileId("10000"); + apiRequest.setCustomerProfileId(customerProfileID); apiRequest.setAddress(customer); UpdateCustomerShippingAddressController controller = new UpdateCustomerShippingAddressController(apiRequest); @@ -49,5 +49,6 @@ public static void run(String apiLoginId, String transactionKey) { System.out.println("Failed to update customer shipping address: " + response.getMessages().getResultCode()); } } + return response; } } \ No newline at end of file diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/ValidateCustomerPaymentProfile.java b/src/main/java/net/authorize/sample/CustomerProfiles/ValidateCustomerPaymentProfile.java index 4700fb01..55e70e1a 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/ValidateCustomerPaymentProfile.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/ValidateCustomerPaymentProfile.java @@ -7,8 +7,8 @@ public class ValidateCustomerPaymentProfile { - public static void run(String apiLoginId, String transactionKey) { - + public static ANetApiResponse run(String apiLoginId, String transactionKey, String customerProfileId, String customerPaymentProfileId) { + ApiOperationBase.setEnvironment(Environment.SANDBOX); MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; @@ -17,13 +17,16 @@ public static void run(String apiLoginId, String transactionKey) { ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); ValidateCustomerPaymentProfileRequest apiRequest = new ValidateCustomerPaymentProfileRequest(); - apiRequest.setCustomerProfileId("10000"); - apiRequest.setCustomerPaymentProfileId("20000"); + apiRequest.setCustomerProfileId(customerProfileId); + apiRequest.setCustomerPaymentProfileId(customerPaymentProfileId); apiRequest.setValidationMode(ValidationModeEnum.LIVE_MODE); + apiRequest.setCardCode("122"); + apiRequest.setCustomerShippingAddressId("1"); + - ValidateCustomerPaymentProfileController controller = new ValidateCustomerPaymentProfileController(apiRequest); + ValidateCustomerPaymentProfileController controller = new ValidateCustomerPaymentProfileController(apiRequest); controller.execute(); - + ValidateCustomerPaymentProfileResponse response = new ValidateCustomerPaymentProfileResponse(); response = controller.getApiResponse(); @@ -40,5 +43,6 @@ public static void run(String apiLoginId, String transactionKey) { System.out.println("Failed to validate customer payment profile: " + response.getMessages().getResultCode()); } } + return response; } } \ No newline at end of file diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/AuthorizeCreditCard.java b/src/main/java/net/authorize/sample/PaymentTransactions/AuthorizeCreditCard.java index a20750f9..d5a04263 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/AuthorizeCreditCard.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/AuthorizeCreditCard.java @@ -13,7 +13,7 @@ public class AuthorizeCreditCard { // Run this sample from command line with: // java -jar target/ChargeCreditCard-jar-with-dependencies.jar // - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey, Double amount) { //Common code to set for all requests @@ -35,7 +35,7 @@ public static void run(String apiLoginId, String transactionKey) { TransactionRequestType txnRequest = new TransactionRequestType(); txnRequest.setTransactionType(TransactionTypeEnum.AUTH_ONLY_TRANSACTION.value()); txnRequest.setPayment(paymentType); - txnRequest.setAmount(new BigDecimal(500.00)); + txnRequest.setAmount(new BigDecimal(amount)); // Make the API Request CreateTransactionRequest apiRequest = new CreateTransactionRequest(); @@ -68,6 +68,7 @@ public static void run(String apiLoginId, String transactionKey) { System.out.println("Failed Transaction: "+response.getMessages().getResultCode()); } } + return response; } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/CaptureFundsAuthorizedThroughAnotherChannel.java b/src/main/java/net/authorize/sample/PaymentTransactions/CaptureFundsAuthorizedThroughAnotherChannel.java index dd43ba75..97dc144b 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/CaptureFundsAuthorizedThroughAnotherChannel.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/CaptureFundsAuthorizedThroughAnotherChannel.java @@ -13,7 +13,7 @@ public class CaptureFundsAuthorizedThroughAnotherChannel { // Run this sample from command line with: // java -jar target/ChargeCreditCard-jar-with-dependencies.jar // - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey) { //Common code to set for all requests ApiOperationBase.setEnvironment(Environment.SANDBOX); @@ -59,6 +59,7 @@ public static void run(String apiLoginId, String transactionKey) { System.out.println("Failed Transaction: "+response.getMessages().getResultCode()); } } + return response; } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/CapturePreviouslyAuthorizedAmount.java b/src/main/java/net/authorize/sample/PaymentTransactions/CapturePreviouslyAuthorizedAmount.java index a222d4b4..e923fd39 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/CapturePreviouslyAuthorizedAmount.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/CapturePreviouslyAuthorizedAmount.java @@ -13,7 +13,7 @@ public class CapturePreviouslyAuthorizedAmount { // Run this sample from command line with: // java -jar target/ChargeCreditCard-jar-with-dependencies.jar // - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey, String transactionID) { //Common code to set for all requests ApiOperationBase.setEnvironment(Environment.SANDBOX); @@ -26,7 +26,7 @@ public static void run(String apiLoginId, String transactionKey) { // Create the payment transaction request TransactionRequestType txnRequest = new TransactionRequestType(); txnRequest.setTransactionType(TransactionTypeEnum.PRIOR_AUTH_CAPTURE_TRANSACTION.value()); - txnRequest.setRefTransId("2238786428"); + txnRequest.setRefTransId(transactionID); // Make the API Request CreateTransactionRequest apiRequest = new CreateTransactionRequest(); @@ -59,6 +59,7 @@ public static void run(String apiLoginId, String transactionKey) { System.out.println("Failed Transaction: "+response.getMessages().getResultCode()); } } + return response; } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCreditCard.java b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCreditCard.java index 3a9d1e4f..f8bf4bc3 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCreditCard.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCreditCard.java @@ -13,7 +13,7 @@ public class ChargeCreditCard { // Run this sample from command line with: // java -jar target/ChargeCreditCard-jar-with-dependencies.jar // - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey, Double amount) { //Common code to set for all requests @@ -35,7 +35,7 @@ public static void run(String apiLoginId, String transactionKey) { TransactionRequestType txnRequest = new TransactionRequestType(); txnRequest.setTransactionType(TransactionTypeEnum.AUTH_CAPTURE_TRANSACTION.value()); txnRequest.setPayment(paymentType); - txnRequest.setAmount(new BigDecimal(500.00)); + txnRequest.setAmount(new BigDecimal(amount)); // Make the API Request CreateTransactionRequest apiRequest = new CreateTransactionRequest(); @@ -68,6 +68,7 @@ public static void run(String apiLoginId, String transactionKey) { System.out.println("Failed Transaction: "+response.getMessages().getResultCode()); } } + return response; } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCustomerProfile.java b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCustomerProfile.java index a2bd6032..b49dd4c3 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCustomerProfile.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCustomerProfile.java @@ -13,7 +13,8 @@ public class ChargeCustomerProfile { // Run this sample from command line with: // java -jar target/ChargeCreditCard-jar-with-dependencies.jar // - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey, String customerProfileId, + String customerPaymentProfileId) { //Common code to set for all requests @@ -27,9 +28,9 @@ public static void run(String apiLoginId, String transactionKey) { // Set the profile ID to charge CustomerProfilePaymentType profileToCharge = new CustomerProfilePaymentType(); - profileToCharge.setCustomerProfileId("36731856"); + profileToCharge.setCustomerProfileId(customerProfileId); PaymentProfile paymentProfile = new PaymentProfile(); - paymentProfile.setPaymentProfileId("33211899"); + paymentProfile.setPaymentProfileId(customerPaymentProfileId); profileToCharge.setPaymentProfile(paymentProfile); // Create the payment transaction request @@ -69,5 +70,6 @@ public static void run(String apiLoginId, String transactionKey) { System.out.println("Failed Transaction: "+response.getMessages().getResultCode()); } } + return response; } } \ No newline at end of file diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeTokenizedCreditCard.java b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeTokenizedCreditCard.java index c24e4029..38bd4faa 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeTokenizedCreditCard.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeTokenizedCreditCard.java @@ -13,7 +13,7 @@ public class ChargeTokenizedCreditCard { // Run this sample from command line with: // java -jar target/ChargeCreditCard-jar-with-dependencies.jar // - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey) { //Common code to set for all requests @@ -69,6 +69,7 @@ public static void run(String apiLoginId, String transactionKey) { System.out.println("Failed Transaction: "+response.getMessages().getResultCode()); } } + return response; } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java b/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java index a4331de5..36932c87 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java @@ -13,7 +13,7 @@ public class CreditBankAccount { // Run this sample from command line with: // java -jar target/ChargeCreditCard-jar-with-dependencies.jar // - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey, String transactionID) { //Common code to set for all requests @@ -36,7 +36,7 @@ public static void run(String apiLoginId, String transactionKey) { // Create the payment transaction request TransactionRequestType txnRequest = new TransactionRequestType(); txnRequest.setTransactionType(TransactionTypeEnum.REFUND_TRANSACTION.value()); - txnRequest.setRefTransId("2148889729"); + txnRequest.setRefTransId(transactionID); txnRequest.setPayment(paymentType); txnRequest.setAmount(new BigDecimal(500.00)); @@ -71,5 +71,6 @@ public static void run(String apiLoginId, String transactionKey) { System.out.println("Failed Transaction: "+response.getMessages().getResultCode()); } } + return response; } } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java b/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java index 7d1b277e..f80a141d 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java @@ -13,7 +13,7 @@ public class DebitBankAccount { // Run this sample from command line with: // java -jar target/ChargeCreditCard-jar-with-dependencies.jar // - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey) { //Common code to set for all requests @@ -70,5 +70,6 @@ public static void run(String apiLoginId, String transactionKey) { System.out.println("Failed Transaction: "+response.getMessages().getResultCode()); } } + return response; } } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/RefundTransaction.java b/src/main/java/net/authorize/sample/PaymentTransactions/RefundTransaction.java index b7eea0aa..e0d89b91 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/RefundTransaction.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/RefundTransaction.java @@ -13,7 +13,7 @@ public class RefundTransaction { // Run this sample from command line with: // java -jar target/ChargeCreditCard-jar-with-dependencies.jar // - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey, Double transactionAmount, String transactionID) { //Common code to set for all requests ApiOperationBase.setEnvironment(Environment.SANDBOX); @@ -33,8 +33,8 @@ public static void run(String apiLoginId, String transactionKey) { // Create the payment transaction request TransactionRequestType txnRequest = new TransactionRequestType(); txnRequest.setTransactionType(TransactionTypeEnum.REFUND_TRANSACTION.value()); - txnRequest.setRefTransId("2245803597"); - txnRequest.setAmount(new BigDecimal(1.00)); + txnRequest.setRefTransId(transactionID); + txnRequest.setAmount(new BigDecimal(transactionAmount)); txnRequest.setPayment(paymentType); // Make the API Request @@ -74,6 +74,7 @@ public static void run(String apiLoginId, String transactionKey) { System.out.println("Transaction Error : " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode() + " " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } } + return response; } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/UpdateSplitTenderGroup.java b/src/main/java/net/authorize/sample/PaymentTransactions/UpdateSplitTenderGroup.java index e5468cff..be9cbf18 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/UpdateSplitTenderGroup.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/UpdateSplitTenderGroup.java @@ -11,7 +11,7 @@ * @author gnongsie */ public class UpdateSplitTenderGroup { - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey) { System.out.println("Update Split Tender Group Sample Code"); //Common code to set for all requests @@ -48,5 +48,6 @@ public static void run(String apiLoginId, String transactionKey) { System.out.println("Error: " + response.getMessages().getMessage().get(0).getCode() + " " + response.getMessages().getMessage().get(0).getText()); } + return response; } } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/VoidTransaction.java b/src/main/java/net/authorize/sample/PaymentTransactions/VoidTransaction.java index 10c3145d..b870f845 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/VoidTransaction.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/VoidTransaction.java @@ -13,7 +13,7 @@ public class VoidTransaction { // Run this sample from command line with: // java -jar target/ChargeCreditCard-jar-with-dependencies.jar // - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey, String transactionID) { //Common code to set for all requests ApiOperationBase.setEnvironment(Environment.SANDBOX); @@ -26,7 +26,7 @@ public static void run(String apiLoginId, String transactionKey) { // Create the payment transaction request TransactionRequestType txnRequest = new TransactionRequestType(); txnRequest.setTransactionType(TransactionTypeEnum.VOID_TRANSACTION.value()); - txnRequest.setRefTransId("2238786428"); + txnRequest.setRefTransId(transactionID); // Make the API Request CreateTransactionRequest apiRequest = new CreateTransactionRequest(); @@ -59,6 +59,7 @@ public static void run(String apiLoginId, String transactionKey) { System.out.println("Failed Transaction: "+response.getMessages().getResultCode()); } } + return response; } diff --git a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCapture.java b/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCapture.java index bd541a2e..d77d7c10 100644 --- a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCapture.java +++ b/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCapture.java @@ -3,6 +3,7 @@ import java.math.BigDecimal; import net.authorize.Environment; +import net.authorize.api.contract.v1.ANetApiResponse; import net.authorize.api.contract.v1.CreateTransactionRequest; import net.authorize.api.contract.v1.CreateTransactionResponse; import net.authorize.api.contract.v1.MerchantAuthenticationType; @@ -17,7 +18,7 @@ public class AuthorizationAndCapture { - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey, Double amount) { System.out.println("PayPal Authorize Capture Transaction"); @@ -42,7 +43,7 @@ public static void run(String apiLoginId, String transactionKey) { transactionRequest.setTransactionType(TransactionTypeEnum.AUTH_CAPTURE_TRANSACTION.value()); transactionRequest.setPayment(paymentType); - transactionRequest.setAmount(new BigDecimal("123.89")); + transactionRequest.setAmount(new BigDecimal(amount)); // Make the API Request CreateTransactionRequest apiRequest = new CreateTransactionRequest(); @@ -74,5 +75,6 @@ public static void run(String apiLoginId, String transactionKey) { if(!response.getTransactionResponse().getErrors().getError().isEmpty()) System.out.println("Transaction Error : " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode() + " " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } + return response; } } diff --git a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCaptureContinue.java b/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCaptureContinue.java index 03a88ec3..9e4ace29 100644 --- a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCaptureContinue.java +++ b/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCaptureContinue.java @@ -4,6 +4,7 @@ import net.authorize.Environment; import net.authorize.TransactionType; +import net.authorize.api.contract.v1.ANetApiResponse; import net.authorize.api.contract.v1.CreateTransactionRequest; import net.authorize.api.contract.v1.CreateTransactionResponse; import net.authorize.api.contract.v1.MerchantAuthenticationType; @@ -18,7 +19,7 @@ public class AuthorizationAndCaptureContinue { - public static void run(String apiLoginId, String transactionKey, String TransactionID, String payerID){ + public static ANetApiResponse run(String apiLoginId, String transactionKey, String TransactionID, String payerID , Double amount){ System.out.println("PayPal Authorize Capture-Continue Transaction"); @@ -47,7 +48,7 @@ public static void run(String apiLoginId, String transactionKey, String Transact TransactionRequestType transactionRequest = new TransactionRequestType(); transactionRequest.setTransactionType(TransactionTypeEnum.AUTH_CAPTURE_CONTINUE_TRANSACTION.value().toString()); transactionRequest.setPayment(paymentType); - transactionRequest.setAmount(new BigDecimal("19.45")); + transactionRequest.setAmount(new BigDecimal(amount.toString())); transactionRequest.setRefTransId(TransactionID); CreateTransactionRequest request = new CreateTransactionRequest(); @@ -63,7 +64,8 @@ public static void run(String apiLoginId, String transactionKey, String Transact //validate if(response.getMessages().getResultCode() == MessageTypeEnum.OK){ if(response.getTransactionResponse() != null){ - System.out.println("Success, \nMessage : "+response.getTransactionResponse().getMessages().getMessage().get(0).getDescription() ); + if(!response.getTransactionResponse().getMessages().getMessage().isEmpty()) + System.out.println("Success, \nMessage : "+response.getTransactionResponse().getMessages().getMessage().get(0).getDescription() ); // Get Auth Code By : response.getTransactionResponse().getAuthCode() } } @@ -72,6 +74,7 @@ public static void run(String apiLoginId, String transactionKey, String Transact if(response.getTransactionResponse() != null){ System.out.println("Transaction Error : "+ response.getTransactionResponse().getErrors().getError().get(0).getErrorCode() + " " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } - } + } + return response; } } diff --git a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationOnly.java b/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationOnly.java index a9018a90..64965ad2 100644 --- a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationOnly.java +++ b/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationOnly.java @@ -8,7 +8,7 @@ public class AuthorizationOnly { - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey, Double amount) { System.out.println("PayPal Authorize Only Transaction"); //Common code to set for all requests @@ -30,7 +30,7 @@ public static void run(String apiLoginId, String transactionKey) { TransactionRequestType transactionRequest = new TransactionRequestType(); transactionRequest.setTransactionType(TransactionTypeEnum.AUTH_ONLY_TRANSACTION.value()); transactionRequest.setPayment(paymentType); - transactionRequest.setAmount(new BigDecimal("19.44")); + transactionRequest.setAmount(new BigDecimal(amount.toString())); CreateTransactionRequest request = new CreateTransactionRequest(); request.setTransactionRequest(transactionRequest); @@ -57,5 +57,6 @@ public static void run(String apiLoginId, String transactionKey) { System.out.println("Transaction Error : " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode() + " : " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } } + return response; } } \ No newline at end of file diff --git a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationOnlyContinued.java b/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationOnlyContinued.java index 6bdcc52d..ff300193 100644 --- a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationOnlyContinued.java +++ b/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationOnlyContinued.java @@ -10,7 +10,7 @@ public class AuthorizationOnlyContinued { - public static void run(String apiLoginId, String transactionKey, String transactionId, String payerId) { + public static ANetApiResponse run(String apiLoginId, String transactionKey, String transactionId, String payerId, Double amount) { System.out.println("PayPal Authorize Only-Continue Transaction"); //Common code to set for all requests @@ -34,7 +34,7 @@ public static void run(String apiLoginId, String transactionKey, String transact TransactionRequestType txnRequest = new TransactionRequestType(); txnRequest.setTransactionType(TransactionTypeEnum.AUTH_ONLY_CONTINUE_TRANSACTION.value()); txnRequest.setPayment(paymentType); - txnRequest.setAmount(new BigDecimal(500.00)); + txnRequest.setAmount(new BigDecimal(amount.toString())); txnRequest.setRefTransId(transactionId); // Make the API Request @@ -70,6 +70,7 @@ public static void run(String apiLoginId, String transactionKey, String transact System.out.println("Error Code: "+response.getMessages().getMessage().get(0).getCode()); } } + return response; } diff --git a/src/main/java/net/authorize/sample/PaypalExpressCheckout/Credit.java b/src/main/java/net/authorize/sample/PaypalExpressCheckout/Credit.java index 9a17ccdc..4b84d8a6 100644 --- a/src/main/java/net/authorize/sample/PaypalExpressCheckout/Credit.java +++ b/src/main/java/net/authorize/sample/PaypalExpressCheckout/Credit.java @@ -9,7 +9,7 @@ public class Credit { - public static void run(String apiLoginId, String transactionKey, String transactionId) { + public static ANetApiResponse run(String apiLoginId, String transactionKey, String transactionId) { System.out.println("PayPal Credit Transaction"); //Common code to set for all requests @@ -68,6 +68,7 @@ public static void run(String apiLoginId, String transactionKey, String transact } } + return response; } diff --git a/src/main/java/net/authorize/sample/PaypalExpressCheckout/GetDetails.java b/src/main/java/net/authorize/sample/PaypalExpressCheckout/GetDetails.java index 76d46f41..2f21e778 100644 --- a/src/main/java/net/authorize/sample/PaypalExpressCheckout/GetDetails.java +++ b/src/main/java/net/authorize/sample/PaypalExpressCheckout/GetDetails.java @@ -7,7 +7,7 @@ public class GetDetails { - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey, String transactionID) { //Common code to set for all requests ApiOperationBase.setEnvironment(Environment.SANDBOX); MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; @@ -26,7 +26,7 @@ public static void run(String apiLoginId, String transactionKey) { TransactionRequestType transactionRequestType = new TransactionRequestType(); transactionRequestType.setTransactionType(TransactionTypeEnum.GET_DETAILS_TRANSACTION.value()); transactionRequestType.setPayment(paymentType); - transactionRequestType.setRefTransId("2241936095"); + transactionRequestType.setRefTransId(transactionID); CreateTransactionRequest apiRequest = new CreateTransactionRequest(); apiRequest.setTransactionRequest(transactionRequestType); @@ -54,6 +54,7 @@ public static void run(String apiLoginId, String transactionKey) { { System.out.println("Failed Transaction: "+response.getMessages().getMessage().get(0).getCode()+ " " + response.getMessages().getMessage().get(0).getText()); } + return response; } diff --git a/src/main/java/net/authorize/sample/PaypalExpressCheckout/PriorAuthorizationCapture.java b/src/main/java/net/authorize/sample/PaypalExpressCheckout/PriorAuthorizationCapture.java index b41e1378..9e86cb22 100644 --- a/src/main/java/net/authorize/sample/PaypalExpressCheckout/PriorAuthorizationCapture.java +++ b/src/main/java/net/authorize/sample/PaypalExpressCheckout/PriorAuthorizationCapture.java @@ -17,7 +17,7 @@ * @author gnongsie */ public class PriorAuthorizationCapture { - public static void run(String apiLoginId, String apiTransactionKey, String transactionId){ + public static ANetApiResponse run(String apiLoginId, String apiTransactionKey, String transactionId){ System.out.println("Paypal Prior Authorization Transaction"); //Common code to set for all requests @@ -65,5 +65,6 @@ public static void run(String apiLoginId, String apiTransactionKey, String trans System.out.println("Error: " + response.getMessages().getMessage().get(0).getCode() + " " + response.getMessages().getMessage().get(0).getText()); } + return response; } } diff --git a/src/main/java/net/authorize/sample/PaypalExpressCheckout/Void.java b/src/main/java/net/authorize/sample/PaypalExpressCheckout/Void.java index 01f200fc..f4fdbfad 100644 --- a/src/main/java/net/authorize/sample/PaypalExpressCheckout/Void.java +++ b/src/main/java/net/authorize/sample/PaypalExpressCheckout/Void.java @@ -1,6 +1,7 @@ package net.authorize.sample.PaypalExpressCheckout; import net.authorize.Environment; +import net.authorize.api.contract.v1.ANetApiResponse; import net.authorize.api.contract.v1.CreateTransactionRequest; import net.authorize.api.contract.v1.CreateTransactionResponse; import net.authorize.api.contract.v1.MerchantAuthenticationType; @@ -14,7 +15,7 @@ import net.authorize.api.controller.base.ApiOperationBase; public class Void { - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey, String transactionID) { System.out.println("PayPal Void Transaction"); @@ -39,7 +40,7 @@ public static void run(String apiLoginId, String transactionKey) { transactionRequest.setTransactionType(TransactionTypeEnum.VOID_TRANSACTION.value()); transactionRequest.setPayment(paymentType); - transactionRequest.setRefTransId("2241708879"); + transactionRequest.setRefTransId(transactionID); // Make the API Request CreateTransactionRequest apiRequest = new CreateTransactionRequest(); @@ -69,6 +70,7 @@ public static void run(String apiLoginId, String transactionKey) { if(!response.getTransactionResponse().getErrors().getError().isEmpty()) System.out.println("Transaction Error : " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode() + " " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } + return response; } } diff --git a/src/main/java/net/authorize/sample/RecurringBilling/CancelSubscription.java b/src/main/java/net/authorize/sample/RecurringBilling/CancelSubscription.java index 75f692e1..95746019 100644 --- a/src/main/java/net/authorize/sample/RecurringBilling/CancelSubscription.java +++ b/src/main/java/net/authorize/sample/RecurringBilling/CancelSubscription.java @@ -11,7 +11,7 @@ public class CancelSubscription { - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey, String subscriptionId) { //Common code to set for all requests ApiOperationBase.setEnvironment(Environment.SANDBOX); MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; @@ -21,7 +21,7 @@ public static void run(String apiLoginId, String transactionKey) { // Make the API Request ARBCancelSubscriptionRequest apiRequest = new ARBCancelSubscriptionRequest(); - apiRequest.setSubscriptionId("100748"); + apiRequest.setSubscriptionId(subscriptionId); ARBCancelSubscriptionController controller = new ARBCancelSubscriptionController(apiRequest); controller.execute(); ARBCancelSubscriptionResponse response = controller.getApiResponse(); @@ -37,5 +37,6 @@ public static void run(String apiLoginId, String transactionKey) { System.out.println("Failed to cancel Subscription: " + response.getMessages().getResultCode()); } } + return response; } } \ No newline at end of file diff --git a/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscription.java b/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscription.java index 5eca930f..1f928ce5 100644 --- a/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscription.java +++ b/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscription.java @@ -12,7 +12,7 @@ public class CreateSubscription { - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey, short intervalLength, Double amount) { //Common code to set for all requests ApiOperationBase.setEnvironment(Environment.SANDBOX); MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; @@ -23,8 +23,8 @@ public static void run(String apiLoginId, String transactionKey) { // Set up payment schedule PaymentScheduleType schedule = new PaymentScheduleType(); PaymentScheduleType.Interval interval = new PaymentScheduleType.Interval(); - interval.setLength( (short)1); - interval.setUnit(ARBSubscriptionUnitEnum.MONTHS); + interval.setLength(intervalLength); + interval.setUnit(ARBSubscriptionUnitEnum.DAYS); schedule.setInterval(interval); try { @@ -50,7 +50,7 @@ public static void run(String apiLoginId, String transactionKey) { ARBSubscriptionType arbSubscriptionType = new ARBSubscriptionType(); arbSubscriptionType.setPaymentSchedule(schedule); - arbSubscriptionType.setAmount(new BigDecimal("10.29")); + arbSubscriptionType.setAmount(new BigDecimal(amount.toString())); arbSubscriptionType.setTrialAmount(new BigDecimal("0.00")); arbSubscriptionType.setPayment(paymentType); @@ -77,7 +77,10 @@ public static void run(String apiLoginId, String transactionKey) { else { System.out.println("Failed to create Subscription: " + response.getMessages().getResultCode()); + System.out.println(response.getMessages().getMessage().get(0).getText()); } } + + return response; } } diff --git a/src/main/java/net/authorize/sample/RecurringBilling/GetListOfSubscriptions.java b/src/main/java/net/authorize/sample/RecurringBilling/GetListOfSubscriptions.java index 66d6669b..70c57e12 100644 --- a/src/main/java/net/authorize/sample/RecurringBilling/GetListOfSubscriptions.java +++ b/src/main/java/net/authorize/sample/RecurringBilling/GetListOfSubscriptions.java @@ -1,17 +1,13 @@ package net.authorize.sample.RecurringBilling; -import net.authorize.data.arb.*; -import java.math.BigDecimal; import net.authorize.Environment; -import net.authorize.data.Customer; import net.authorize.api.contract.v1.*; import net.authorize.api.controller.base.ApiOperationBase; import net.authorize.api.controller.ARBGetSubscriptionListController; -import javax.xml.datatype.XMLGregorianCalendar; public class GetListOfSubscriptions { - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey) { //Common code to set for all requests ApiOperationBase.setEnvironment(Environment.SANDBOX); MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; @@ -41,14 +37,15 @@ public static void run(String apiLoginId, String transactionKey) { if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { System.out.println(response.getTotalNumInResultSet()); - System.out.println(response.getSubscriptionDetails().getSubscriptionDetail()); System.out.println(response.getMessages().getMessage().get(0).getCode()); System.out.println(response.getMessages().getMessage().get(0).getText()); } else { - System.out.println("Failed to create Subscription: " + response.getMessages().getResultCode()); + System.out.println("Failed to get Subscription list: " + response.getMessages().getResultCode()); } } + + return response; } } diff --git a/src/main/java/net/authorize/sample/RecurringBilling/GetSubscription.java b/src/main/java/net/authorize/sample/RecurringBilling/GetSubscription.java index 9cac8b97..6b1ebc41 100644 --- a/src/main/java/net/authorize/sample/RecurringBilling/GetSubscription.java +++ b/src/main/java/net/authorize/sample/RecurringBilling/GetSubscription.java @@ -12,7 +12,7 @@ public class GetSubscription { - public static void run(String apiLoginId,String transactionKey) + public static ANetApiResponse run(String apiLoginId,String transactionKey, String subscriptionId) { ApiOperationBase.setEnvironment(Environment.SANDBOX); // Giving the merchant authentication information @@ -23,7 +23,7 @@ public static void run(String apiLoginId,String transactionKey) // Making the API request ARBGetSubscriptionRequest apiRequest = new ARBGetSubscriptionRequest(); apiRequest.setRefId("Sample"); - apiRequest.setSubscriptionId("2930242"); + apiRequest.setSubscriptionId(subscriptionId); // Calling the controller ARBGetSubscriptionController controller = new ARBGetSubscriptionController(apiRequest); controller.execute(); @@ -64,5 +64,6 @@ public static void run(String apiLoginId,String transactionKey) if(!errorResponse.getMessages().getMessage().isEmpty()) System.out.println("Error: "+errorResponse.getMessages().getMessage().get(0).getCode()+" \n"+ errorResponse.getMessages().getMessage().get(0).getText()); } + return response; } } diff --git a/src/main/java/net/authorize/sample/RecurringBilling/GetSubscriptionStatus.java b/src/main/java/net/authorize/sample/RecurringBilling/GetSubscriptionStatus.java index 48001b23..14c89f8b 100644 --- a/src/main/java/net/authorize/sample/RecurringBilling/GetSubscriptionStatus.java +++ b/src/main/java/net/authorize/sample/RecurringBilling/GetSubscriptionStatus.java @@ -10,32 +10,33 @@ import javax.xml.datatype.XMLGregorianCalendar; public class GetSubscriptionStatus { - - public static void run(String apiLoginId, String transactionKey) { - //Common code to set for all requests - ApiOperationBase.setEnvironment(Environment.SANDBOX); - MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; - merchantAuthenticationType.setName(apiLoginId); - merchantAuthenticationType.setTransactionKey(transactionKey); - ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); - ARBGetSubscriptionStatusRequest apiRequest = new ARBGetSubscriptionStatusRequest(); - apiRequest.setSubscriptionId("100748"); - ARBGetSubscriptionStatusController controller = new ARBGetSubscriptionStatusController(apiRequest); - controller.execute(); - ARBGetSubscriptionStatusResponse response = controller.getApiResponse(); - if (response!=null) { + public static ANetApiResponse run(String apiLoginId, String transactionKey, String subscriptionId) { + //Common code to set for all requests + ApiOperationBase.setEnvironment(Environment.SANDBOX); + MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; + merchantAuthenticationType.setName(apiLoginId); + merchantAuthenticationType.setTransactionKey(transactionKey); + ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { - - System.out.println(response.getStatus()); - System.out.println(response.getMessages().getMessage().get(0).getCode()); - System.out.println(response.getMessages().getMessage().get(0).getText()); - } - else - { - System.out.println("Failed to update Subscription: " + response.getMessages().getResultCode()); - } - } - } + ARBGetSubscriptionStatusRequest apiRequest = new ARBGetSubscriptionStatusRequest(); + apiRequest.setSubscriptionId(subscriptionId); + ARBGetSubscriptionStatusController controller = new ARBGetSubscriptionStatusController(apiRequest); + controller.execute(); + ARBGetSubscriptionStatusResponse response = controller.getApiResponse(); + if (response!=null) { + + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + + System.out.println(response.getStatus()); + System.out.println(response.getMessages().getMessage().get(0).getCode()); + System.out.println(response.getMessages().getMessage().get(0).getText()); + } + else + { + System.out.println("Failed to update Subscription: " + response.getMessages().getResultCode()); + } + } + return response; + } } \ No newline at end of file diff --git a/src/main/java/net/authorize/sample/RecurringBilling/UpdateSubscription.java b/src/main/java/net/authorize/sample/RecurringBilling/UpdateSubscription.java index d72fc1f0..98f49a69 100644 --- a/src/main/java/net/authorize/sample/RecurringBilling/UpdateSubscription.java +++ b/src/main/java/net/authorize/sample/RecurringBilling/UpdateSubscription.java @@ -11,7 +11,7 @@ public class UpdateSubscription { - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey, String subscriptionId) { //Common code to set for all requests ApiOperationBase.setEnvironment(Environment.SANDBOX); MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; @@ -31,7 +31,7 @@ public static void run(String apiLoginId, String transactionKey) { // Make the API Request ARBUpdateSubscriptionRequest apiRequest = new ARBUpdateSubscriptionRequest(); - apiRequest.setSubscriptionId("100748"); + apiRequest.setSubscriptionId(subscriptionId); apiRequest.setSubscription(arbSubscriptionType); ARBUpdateSubscriptionController controller = new ARBUpdateSubscriptionController(apiRequest); controller.execute(); @@ -48,5 +48,6 @@ public static void run(String apiLoginId, String transactionKey) { System.out.println("Failed to update Subscription: " + response.getMessages().getResultCode()); } } + return response; } } \ No newline at end of file diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index 70a1d1f3..20b95fdd 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -68,7 +68,7 @@ private static void SelectMethod() try{ RunMethod(br.readLine()); }catch(Exception ex){ - System.out.print("Error no such method"); + System.out.println(ex.toString()); } } @@ -132,9 +132,11 @@ private static void RunMethod(String methodName) String apiLoginId = "5KP3u95bQpv"; String transactionKey = "4Ktq966gC55GAX7S"; //Update the payedId with which you want to run the sample code - String payerId = ""; + String payerId = "6ZSCSYG33VP8Q"; //Update the transactionId with which you want to run the sample code - String transactionId = ""; + String transactionId = "123456"; + + Double amount = 123.45; switch (methodName) { case "DecryptVisaCheckoutData": @@ -144,16 +146,16 @@ private static void RunMethod(String methodName) CreateVisaCheckoutTransaction.run(apiLoginId, transactionKey); break; case "ChargeCreditCard": - ChargeCreditCard.run(apiLoginId, transactionKey); + ChargeCreditCard.run(apiLoginId, transactionKey, amount); break; case "VoidTransaction": - VoidTransaction.run(apiLoginId, transactionKey); + VoidTransaction.run(apiLoginId, transactionKey, transactionId); break; case "AuthorizeCreditCard": - AuthorizeCreditCard.run(apiLoginId, transactionKey); + AuthorizeCreditCard.run(apiLoginId, transactionKey, amount); break; case "RefundTransaction": - RefundTransaction.run(apiLoginId, transactionKey); + RefundTransaction.run(apiLoginId, transactionKey , amount, transactionId); break; case "CreateCustomerProfileFromTransaction": CreateCustomerProfileFromTransaction.run(apiLoginId, transactionKey); @@ -162,13 +164,13 @@ private static void RunMethod(String methodName) CaptureFundsAuthorizedThroughAnotherChannel.run(apiLoginId, transactionKey); break; case "CapturePreviouslyAuthorizedAmount": - CapturePreviouslyAuthorizedAmount.run(apiLoginId, transactionKey); + CapturePreviouslyAuthorizedAmount.run(apiLoginId, transactionKey, transactionId); break; case "DebitBankAccount": DebitBankAccount.run(apiLoginId, transactionKey); break; case "CreditBankAccount": - CreditBankAccount.run(apiLoginId, transactionKey); + CreditBankAccount.run(apiLoginId, transactionKey, transactionId); break; case "ChargeTokenizedCreditCard": ChargeTokenizedCreditCard.run(apiLoginId, transactionKey); @@ -177,22 +179,22 @@ private static void RunMethod(String methodName) CreateAnApplePayTransaction.run(apiLoginId, transactionKey); break; case "ChargeCustomerProfile": - ChargeCustomerProfile.run(apiLoginId, transactionKey); + ChargeCustomerProfile.run(apiLoginId, transactionKey, "36731856", "33211899"); break; case "CreateSubscription": - CreateSubscription.run(apiLoginId, transactionKey); + CreateSubscription.run(apiLoginId, transactionKey, (short)12, 10.21); break; case "GetSubscription": - GetSubscription.run(apiLoginId, transactionKey); + GetSubscription.run(apiLoginId, transactionKey, "2930242"); break; case "GetSubscriptionStatus": - GetSubscriptionStatus.run(apiLoginId, transactionKey); + GetSubscriptionStatus.run(apiLoginId, transactionKey, "100748"); break; case "CancelSubscription": - CancelSubscription.run(apiLoginId, transactionKey); + CancelSubscription.run(apiLoginId, transactionKey, "100748"); break; case "UpdateSubscription": - UpdateSubscription.run(apiLoginId, transactionKey); + UpdateSubscription.run(apiLoginId, transactionKey, "100748"); break; case "GetListOfSubscriptions": GetListOfSubscriptions.run(apiLoginId, transactionKey); @@ -210,75 +212,74 @@ private static void RunMethod(String methodName) GetUnsettledTransactionList.run(apiLoginId, transactionKey); break; case "GetTransactionDetails": - GetTransactionDetails.run(apiLoginId, transactionKey); + GetTransactionDetails.run(apiLoginId, transactionKey, transactionId); break; case "CreateCustomerProfile": - CreateCustomerProfile.run(apiLoginId, transactionKey); + CreateCustomerProfile.run(apiLoginId, transactionKey, "test@te.com"); break; case "CreateCustomerPaymentProfile": - CreateCustomerPaymentProfile.run(apiLoginId, transactionKey); + CreateCustomerPaymentProfile.run(apiLoginId, transactionKey, "38854744"); break; case "CreateCustomerShippingAddress": - CreateCustomerShippingAddress.run(apiLoginId, transactionKey); + CreateCustomerShippingAddress.run(apiLoginId, transactionKey, "10000"); break; case "DeleteCustomerPaymentProfile": - DeleteCustomerPaymentProfile.run(apiLoginId, transactionKey); + DeleteCustomerPaymentProfile.run(apiLoginId, transactionKey, "10000", "20000"); break; case "DeleteCustomerProfile": - DeleteCustomerProfile.run(apiLoginId, transactionKey); + DeleteCustomerProfile.run(apiLoginId, transactionKey, "10000"); break; case "DeleteCustomerShippingAddress": - DeleteCustomerShippingAddress.run(apiLoginId, transactionKey); + DeleteCustomerShippingAddress.run(apiLoginId, transactionKey, "10000", "30000"); break; case "GetCustomerPaymentProfile": - GetCustomerPaymentProfile.run(apiLoginId, transactionKey); + GetCustomerPaymentProfile.run(apiLoginId, transactionKey, "10000", "20000"); break; case "GetCustomerPaymentProfileList": GetCustomerPaymentProfileList.run(apiLoginId, transactionKey); break; case "GetCustomerProfile": - GetCustomerProfile.run(apiLoginId, transactionKey); + GetCustomerProfile.run(apiLoginId, transactionKey, "10000"); break; case "GetCustomerProfileIds": GetCustomerProfileIds.run(apiLoginId, transactionKey); break; case "GetCustomerShippingAddress": - GetCustomerShippingAddress.run(apiLoginId, transactionKey); + GetCustomerShippingAddress.run(apiLoginId, transactionKey, "10000", "30000"); break; case "GetHostedProfilePage": - GetHostedProfilePage.run(apiLoginId, transactionKey); + GetHostedProfilePage.run(apiLoginId, transactionKey, "10000"); break; case "UpdateCustomerPaymentProfile": - UpdateCustomerPaymentProfile.run(apiLoginId, transactionKey); + UpdateCustomerPaymentProfile.run(apiLoginId, transactionKey, "10000", "20000"); break; case "UpdateCustomerShippingAddress": - UpdateCustomerShippingAddress.run(apiLoginId, transactionKey); + UpdateCustomerShippingAddress.run(apiLoginId, transactionKey, "10000", "30000"); break; case "ValidateCustomerPaymentProfile": - ValidateCustomerPaymentProfile.run(apiLoginId, transactionKey); + ValidateCustomerPaymentProfile.run(apiLoginId, transactionKey, "10000", "20000"); break; case "PayPalAuthorizeCapture": - AuthorizationAndCapture.run(apiLoginId, transactionKey); + AuthorizationAndCapture.run(apiLoginId, transactionKey, amount); break; case "PayPalVoid": - Void.run(apiLoginId, transactionKey); + Void.run(apiLoginId, transactionKey, transactionId); break; case "PayPalAuthorizationOnly": - AuthorizationOnly.run(apiLoginId, transactionKey); + AuthorizationOnly.run(apiLoginId, transactionKey, 12.23); break; case "PayPalAuthorizeCaptureContinue": - AuthorizationAndCaptureContinue.run(apiLoginId, transactionKey, transactionId, payerId); + AuthorizationAndCaptureContinue.run(apiLoginId, transactionKey, "2248647898", payerId, 12.12); break; case "PayPalAuthorizeOnlyContinue": - AuthorizationOnlyContinued.run(apiLoginId, transactionKey, transactionId, payerId); + AuthorizationOnlyContinued.run(apiLoginId, transactionKey, transactionId, payerId, 34.56); break; case "PayPalCredit": Credit.run(apiLoginId, transactionKey, transactionId); break; case "PayPalGetDetails": - GetDetails.run(apiLoginId, transactionKey); + GetDetails.run(apiLoginId, transactionKey, transactionId); case "PaypalPriorAuthorizationCapture": - transactionId = "2241801682"; // Use a valid transaction ID here PriorAuthorizationCapture.run(apiLoginId, transactionKey, transactionId); break; case "UpdateSplitTenderGroup": diff --git a/src/main/java/net/authorize/sample/SampleCodeTest/Constants.java b/src/main/java/net/authorize/sample/SampleCodeTest/Constants.java new file mode 100644 index 00000000..838c63d2 --- /dev/null +++ b/src/main/java/net/authorize/sample/SampleCodeTest/Constants.java @@ -0,0 +1,9 @@ +package net.authorize.sample.SampleCodeTest; + +public final class Constants { + public static final String API_LOGIN_ID = "5KP3u95bQpv"; + public static final String TRANSACTION_KEY = "4Ktq966gC55GAX7S"; + public static final String TRANSACTION_ID = "123456"; + public static final String PAYER_ID = "6ZSCSYG33VP8Q"; + public static final String CONFIG_FILE = "./src/main/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt"; +} diff --git a/src/main/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt b/src/main/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt new file mode 100644 index 00000000..03a3b00d --- /dev/null +++ b/src/main/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt @@ -0,0 +1,51 @@ +SampleCode IsDependent RunApi +RecurringBilling.CreateSubscription 1 1 +RecurringBilling.GetListOfSubscriptions 0 1 +RecurringBilling.CancelSubscription 1 1 +RecurringBilling.GetSubscriptionStatus 1 1 +RecurringBilling.GetSubscription 1 1 +RecurringBilling.UpdateSubscription 1 1 +CustomerProfiles.ValidateCustomerPaymentProfile 1 0 +CustomerProfiles.UpdateCustomerShippingAddress 1 1 +CustomerProfiles.UpdateCustomerProfile 1 1 +CustomerProfiles.UpdateCustomerPaymentProfile 1 1 +CustomerProfiles.GetCustomerShippingAddress 1 1 +CustomerProfiles.GetCustomerProfileIds 0 1 +CustomerProfiles.GetCustomerProfile 1 1 +CustomerProfiles.GetHostedProfilePage 1 1 +CustomerProfiles.GetCustomerPaymentProfile 1 1 +CustomerProfiles.DeleteCustomerShippingAddress 1 1 +CustomerProfiles.DeleteCustomerProfile 1 1 +CustomerProfiles.DeleteCustomerPaymentProfile 1 1 +CustomerProfiles.CreateCustomerShippingAddress 1 1 +CustomerProfiles.CreateCustomerProfileFromTransaction 0 1 +CustomerProfiles.GetCustomerPaymentProfileList 0 1 +CustomerProfiles.CreateCustomerProfile 1 1 +CustomerProfiles.CreateCustomerPaymentProfile 1 1 +PaypalExpressCheckout.PayPalAuthorizationOnly 1 1 +PaypalExpressCheckout.PayPalVoid 1 0 +PaypalExpressCheckout.PayPalAuthorizationAndCapture 1 1 +PaypalExpressCheckout.PayPalAuthorizationAndCaptureContinue 1 1 +PaypalExpressCheckout.PayPalAuthorizationOnlyContinued 1 0 +PaypalExpressCheckout.PayPalCredit 1 0 +PaypalExpressCheckout.PayPalGetDetails 1 1 +PaypalExpressCheckout.PayPalPriorAuthorizationCapture 1 0 +PaymentTransactions.ChargeCreditCard 1 1 +PaymentTransactions.CapturePreviouslyAuthorizedAmount 1 1 +PaymentTransactions.RefundTransaction 1 0 +PaymentTransactions.VoidTransaction 1 1 +PaymentTransactions.CreditBankAccount 1 0 +PaymentTransactions.ChargeCustomerProfile 1 0 +PaymentTransactions.CaptureFundsAuthorizedThroughAnotherChannel 0 0 +PaymentTransactions.AuthorizeCreditCard 1 0 +PaymentTransactions.DebitBankAccount 0 1 +PaymentTransactions.ChargeTokenizedCreditCard 0 1 +PaymentTransactions.UpdateSplitTenderGroup 0 0 +TransactionReporting.GetTransactionList 0 1 +TransactionReporting.GetUnsettledTransactionList 0 1 +TransactionReporting.GetBatchStatistics 0 1 +TransactionReporting.GetSettledBatchList 0 1 +TransactionReporting.GetTransactionDetails 1 1 +ApplePayTransactions.CreateAnApplePayTransaction 0 0 +VisaCheckout.DecryptVisaCheckoutData 0 1 +VisaCheckout.CreateVisaCheckoutTransaction 0 0 diff --git a/src/main/java/net/authorize/sample/SampleCodeTest/TestRunner.java b/src/main/java/net/authorize/sample/SampleCodeTest/TestRunner.java new file mode 100644 index 00000000..092b953a --- /dev/null +++ b/src/main/java/net/authorize/sample/SampleCodeTest/TestRunner.java @@ -0,0 +1,478 @@ +package net.authorize.sample.SampleCodeTest; + +import java.io.BufferedReader; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.security.SecureRandom; + +import org.junit.Test; + +import junit.framework.Assert; +import net.authorize.api.contract.v1.ANetApiResponse; +import net.authorize.api.contract.v1.ARBCreateSubscriptionResponse; +import net.authorize.api.contract.v1.ARBGetSubscriptionResponse; +import net.authorize.api.contract.v1.ARBGetSubscriptionStatusResponse; +import net.authorize.api.contract.v1.ARBUpdateSubscriptionResponse; +import net.authorize.api.contract.v1.CreateCustomerPaymentProfileResponse; +import net.authorize.api.contract.v1.CreateCustomerProfileResponse; +import net.authorize.api.contract.v1.CreateCustomerShippingAddressResponse; +import net.authorize.api.contract.v1.CreateTransactionResponse; +import net.authorize.api.contract.v1.DeleteCustomerPaymentProfileResponse; +import net.authorize.api.contract.v1.DeleteCustomerShippingAddressResponse; +import net.authorize.api.contract.v1.GetCustomerPaymentProfileResponse; +import net.authorize.api.contract.v1.GetCustomerProfileResponse; +import net.authorize.api.contract.v1.GetCustomerShippingAddressResponse; +import net.authorize.api.contract.v1.GetHostedProfilePageResponse; +import net.authorize.api.contract.v1.MessageTypeEnum; +import net.authorize.api.contract.v1.UpdateCustomerPaymentProfileResponse; +import net.authorize.api.contract.v1.UpdateCustomerProfileResponse; +import net.authorize.api.contract.v1.UpdateCustomerShippingAddressResponse; +import net.authorize.api.contract.v1.ValidateCustomerPaymentProfileResponse; +import net.authorize.sample.CustomerProfiles.CreateCustomerPaymentProfile; +import net.authorize.sample.CustomerProfiles.CreateCustomerProfile; +import net.authorize.sample.CustomerProfiles.CreateCustomerShippingAddress; +import net.authorize.sample.CustomerProfiles.DeleteCustomerPaymentProfile; +import net.authorize.sample.CustomerProfiles.DeleteCustomerProfile; +import net.authorize.sample.CustomerProfiles.DeleteCustomerShippingAddress; +import net.authorize.sample.CustomerProfiles.GetCustomerPaymentProfile; +import net.authorize.sample.CustomerProfiles.GetCustomerProfile; +import net.authorize.sample.CustomerProfiles.GetCustomerShippingAddress; +import net.authorize.sample.CustomerProfiles.GetHostedProfilePage; +import net.authorize.sample.CustomerProfiles.UpdateCustomerPaymentProfile; +import net.authorize.sample.CustomerProfiles.UpdateCustomerProfile; +import net.authorize.sample.CustomerProfiles.UpdateCustomerShippingAddress; +import net.authorize.sample.CustomerProfiles.ValidateCustomerPaymentProfile; +import net.authorize.sample.PaymentTransactions.AuthorizeCreditCard; +import net.authorize.sample.PaymentTransactions.CapturePreviouslyAuthorizedAmount; +import net.authorize.sample.PaymentTransactions.ChargeCreditCard; +import net.authorize.sample.PaymentTransactions.ChargeCustomerProfile; +import net.authorize.sample.PaymentTransactions.CreditBankAccount; +import net.authorize.sample.PaymentTransactions.RefundTransaction; +import net.authorize.sample.PaymentTransactions.VoidTransaction; +import net.authorize.sample.PaypalExpressCheckout.AuthorizationAndCapture; +import net.authorize.sample.PaypalExpressCheckout.AuthorizationAndCaptureContinue; +import net.authorize.sample.PaypalExpressCheckout.AuthorizationOnly; +import net.authorize.sample.PaypalExpressCheckout.AuthorizationOnlyContinued; +import net.authorize.sample.PaypalExpressCheckout.Credit; +import net.authorize.sample.PaypalExpressCheckout.GetDetails; +import net.authorize.sample.PaypalExpressCheckout.PriorAuthorizationCapture; +import net.authorize.sample.RecurringBilling.CancelSubscription; +import net.authorize.sample.RecurringBilling.CreateSubscription; +import net.authorize.sample.RecurringBilling.GetSubscription; +import net.authorize.sample.RecurringBilling.GetSubscriptionStatus; +import net.authorize.sample.RecurringBilling.UpdateSubscription; +import net.authorize.sample.TransactionReporting.GetTransactionDetails; + +public class TestRunner { + + String apiLoginId = Constants.API_LOGIN_ID; + String transactionKey = Constants.TRANSACTION_KEY; + String TransactionID = Constants.TRANSACTION_ID; + String payerID = Constants.PAYER_ID; + + static SecureRandom rgenerator = new SecureRandom(); + + private static String getEmail() + { + return rgenerator.nextInt(10000) + "@test.com"; + } + + private static Double getAmount() + { + return (double)(rgenerator.nextInt(1000)); + } + + private static short getDays() + { + return (short) (rgenerator.nextInt(358) + 7); + } + + @Test + public void TestAllSampleCodes() + { + String fileName = Constants.CONFIG_FILE; + + BufferedReader reader = null; + + try { + reader = new BufferedReader(new FileReader(fileName)); + } catch (FileNotFoundException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + TestRunner tr = new TestRunner(); + int cnt = 0; + String line; + try { + + while ((line = reader.readLine()) != null) + { + String[] items = line.split("\t"); + + String apiName = items[0]; + String isDependent = items[1]; + String shouldApiRun = items[2]; + + System.out.println(apiName); + + if (!shouldApiRun.equals("1")) + continue; + + try + { + cnt++; + ANetApiResponse response = null; + if (isDependent.equals("0")) + { + response = InvokeRunMethod(apiName); + } + else + { + String[] namespace = apiName.split("\\."); + + String className = namespace[1]; + Class classType = this.getClass(); + response = (ANetApiResponse)classType.getMethod("Test" + className).invoke(tr); + } + + Assert.assertNotNull(response); + Assert.assertEquals(response.getMessages().getResultCode(), MessageTypeEnum.OK); + } + catch (Exception e) + { + System.out.println("Exception in " + apiName + " " + e.toString()); + System.out.println(e.getMessage()); + } + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + System.out.println("Total Sample Runs: " + cnt); + } + + public ANetApiResponse InvokeRunMethod(String className) + { + String fqClassName = "net.authorize.sample." + className; + + Class classType = null; + try { + classType = Class.forName(fqClassName); + } catch (ClassNotFoundException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + Method runMethod = null; + try { + runMethod = classType.getMethod("run",String.class, String.class); + } catch (NoSuchMethodException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (SecurityException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + try { + return (ANetApiResponse)runMethod.invoke(null, Constants.API_LOGIN_ID, Constants.TRANSACTION_KEY); + } catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalArgumentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InvocationTargetException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + public ANetApiResponse TestValidateCustomerPaymentProfile() + { + CreateCustomerProfileResponse response = (CreateCustomerProfileResponse) CreateCustomerProfile.run(apiLoginId, transactionKey, getEmail()); + CreateCustomerPaymentProfileResponse customerPaymentProfile = (CreateCustomerPaymentProfileResponse)CreateCustomerPaymentProfile.run(apiLoginId, transactionKey, response.getCustomerProfileId()); + System.out.println(response.getCustomerProfileId()); + System.out.println(customerPaymentProfile.getCustomerPaymentProfileId()); + ValidateCustomerPaymentProfileResponse validateResponse = (ValidateCustomerPaymentProfileResponse) ValidateCustomerPaymentProfile.run(apiLoginId, transactionKey, response.getCustomerProfileId(), customerPaymentProfile.getCustomerPaymentProfileId()); + DeleteCustomerProfile.run(apiLoginId, transactionKey, response.getCustomerProfileId()); + + return validateResponse; + } + + + public ANetApiResponse TestUpdateCustomerShippingAddress() + { + CreateCustomerProfileResponse response = (CreateCustomerProfileResponse)CreateCustomerProfile.run(apiLoginId, transactionKey, getEmail()); + CreateCustomerShippingAddressResponse shippingResponse = (CreateCustomerShippingAddressResponse)CreateCustomerShippingAddress.run(apiLoginId, transactionKey, response.getCustomerProfileId()); + UpdateCustomerShippingAddressResponse updateResponse = (UpdateCustomerShippingAddressResponse) UpdateCustomerShippingAddress.run(apiLoginId, transactionKey, response.getCustomerProfileId(), shippingResponse.getCustomerAddressId()); + DeleteCustomerProfile.run(apiLoginId, transactionKey, response.getCustomerProfileId()); + + return updateResponse; + } + + public ANetApiResponse TestUpdateCustomerProfile() + { + CreateCustomerProfileResponse response = (CreateCustomerProfileResponse)CreateCustomerProfile.run(apiLoginId, transactionKey, getEmail()); + UpdateCustomerProfileResponse updateResponse = (UpdateCustomerProfileResponse) UpdateCustomerProfile.run(apiLoginId, transactionKey, response.getCustomerProfileId()); + DeleteCustomerProfile.run(apiLoginId, transactionKey, response.getCustomerProfileId()); + + return updateResponse; + } + + public ANetApiResponse TestUpdateCustomerPaymentProfile() + { + CreateCustomerProfileResponse response = (CreateCustomerProfileResponse)CreateCustomerProfile.run(apiLoginId, transactionKey, getEmail()); + CreateCustomerPaymentProfileResponse paymentProfileResponse = (CreateCustomerPaymentProfileResponse)CreateCustomerPaymentProfile.run(apiLoginId, transactionKey, response.getCustomerProfileId()); + UpdateCustomerPaymentProfileResponse updateResponse = (UpdateCustomerPaymentProfileResponse) UpdateCustomerPaymentProfile.run(apiLoginId, transactionKey, + response.getCustomerProfileId(), paymentProfileResponse.getCustomerPaymentProfileId()); + DeleteCustomerProfile.run(apiLoginId, transactionKey, response.getCustomerProfileId()); + + return updateResponse; + } + + public ANetApiResponse TestGetCustomerShippingAddress() + { + CreateCustomerProfileResponse response = (CreateCustomerProfileResponse)CreateCustomerProfile.run(apiLoginId, transactionKey, getEmail()); + CreateCustomerShippingAddressResponse shippingResponse = (CreateCustomerShippingAddressResponse)CreateCustomerShippingAddress.run(apiLoginId, transactionKey, response.getCustomerProfileId()); + + GetCustomerShippingAddressResponse getResponse = (GetCustomerShippingAddressResponse) GetCustomerShippingAddress.run(apiLoginId, transactionKey, + response.getCustomerProfileId(), shippingResponse.getCustomerAddressId()); + + DeleteCustomerProfile.run(apiLoginId, transactionKey, response.getCustomerProfileId()); + return getResponse; + } + + // public ANetApiResponse TestGetCustomerProfileIds() + // { + // return GetCustomerProfileIds.run(apiLoginId, transactionKey); + // } + + public ANetApiResponse TestGetCustomerProfile() + { + CreateCustomerProfileResponse response = (CreateCustomerProfileResponse)CreateCustomerProfile.run(apiLoginId, transactionKey, getEmail()); + GetCustomerProfileResponse profileResponse = (GetCustomerProfileResponse) GetCustomerProfile.run(apiLoginId, transactionKey, response.getCustomerProfileId()); + DeleteCustomerProfile.run(apiLoginId, transactionKey, response.getCustomerProfileId()); + + return profileResponse; + } + + public ANetApiResponse TestGetHostedProfilePage() + { + CreateCustomerProfileResponse response = (CreateCustomerProfileResponse)CreateCustomerProfile.run(apiLoginId, transactionKey, getEmail()); + GetHostedProfilePageResponse profileResponse = (GetHostedProfilePageResponse) GetHostedProfilePage.run(apiLoginId, transactionKey, response.getCustomerProfileId()); + DeleteCustomerProfile.run(apiLoginId, transactionKey, response.getCustomerProfileId()); + + return profileResponse; + } + + public ANetApiResponse TestGetCustomerPaymentProfile() + { + CreateCustomerProfileResponse response = (CreateCustomerProfileResponse)CreateCustomerProfile.run(apiLoginId, transactionKey, getEmail()); + CreateCustomerPaymentProfileResponse paymentProfileResponse = (CreateCustomerPaymentProfileResponse)CreateCustomerPaymentProfile.run(apiLoginId, transactionKey, response.getCustomerProfileId()); + GetCustomerPaymentProfileResponse getResponse = (GetCustomerPaymentProfileResponse) GetCustomerPaymentProfile.run(apiLoginId, transactionKey, + response.getCustomerProfileId(), paymentProfileResponse.getCustomerPaymentProfileId()); + + DeleteCustomerProfile.run(apiLoginId, transactionKey, response.getCustomerProfileId()); + return getResponse; + } + + public ANetApiResponse TestDeleteCustomerShippingAddress() + { + CreateCustomerProfileResponse response = (CreateCustomerProfileResponse)CreateCustomerProfile.run(apiLoginId, transactionKey, getEmail()); + CreateCustomerShippingAddressResponse shippingResponse = (CreateCustomerShippingAddressResponse)CreateCustomerShippingAddress.run(apiLoginId, transactionKey, response.getCustomerProfileId()); + DeleteCustomerShippingAddressResponse deleteResponse = (DeleteCustomerShippingAddressResponse) DeleteCustomerShippingAddress.run(apiLoginId, transactionKey, + response.getCustomerProfileId(), shippingResponse.getCustomerAddressId()); + DeleteCustomerProfile.run(apiLoginId, transactionKey, response.getCustomerProfileId()); + + return deleteResponse; + } + + public ANetApiResponse TestDeleteCustomerProfile() + { + CreateCustomerProfileResponse response = (CreateCustomerProfileResponse)CreateCustomerProfile.run(apiLoginId, transactionKey, getEmail()); + return DeleteCustomerProfile.run(apiLoginId, transactionKey, response.getCustomerProfileId()); + } + + public ANetApiResponse TestDeleteCustomerPaymentProfile() + { + CreateCustomerProfileResponse response = (CreateCustomerProfileResponse)CreateCustomerProfile.run(apiLoginId, transactionKey, getEmail()); + CreateCustomerPaymentProfileResponse paymentProfileResponse = (CreateCustomerPaymentProfileResponse)CreateCustomerPaymentProfile.run(apiLoginId, transactionKey, response.getCustomerProfileId()); + DeleteCustomerPaymentProfileResponse deleteResponse = (DeleteCustomerPaymentProfileResponse) DeleteCustomerPaymentProfile.run(apiLoginId, transactionKey, + response.getCustomerProfileId(), paymentProfileResponse.getCustomerPaymentProfileId()); + DeleteCustomerProfile.run(apiLoginId, transactionKey, response.getCustomerProfileId()); + + return deleteResponse; + } + + public ANetApiResponse TestCreateCustomerShippingAddress() + { + CreateCustomerProfileResponse response = (CreateCustomerProfileResponse)CreateCustomerProfile.run(apiLoginId, transactionKey, getEmail()); + CreateCustomerShippingAddressResponse shippingResponse = (CreateCustomerShippingAddressResponse)CreateCustomerShippingAddress.run(apiLoginId, transactionKey, response.getCustomerProfileId()); + DeleteCustomerProfile.run(apiLoginId, transactionKey, response.getCustomerProfileId()); + + return shippingResponse; + } + + public ANetApiResponse TestAuthorizeCreditCard() + { + CreateTransactionResponse response = (CreateTransactionResponse)AuthorizeCreditCard.run(apiLoginId, transactionKey, getAmount()); + return response; + } + + // public ANetApiResponse TestCreateCustomerProfileFromTransaction() + // { + // CreateTransactionResponse response = (CreateTransactionResponse)AuthorizeCreditCard.run(apiLoginId, transactionKey, getAmount()); + // CreateCustomerProfileResponse profileResponse = (CreateCustomerProfileResponse)CreateCustomerProfileFromTransaction.run(apiLoginId, transactionKey, response.getTransactionResponse().getTransId()); + // DeleteCustomerProfile.run(apiLoginId, transactionKey, profileResponse.getCustomerProfileId()); + // + // return profileResponse; + // } + + public ANetApiResponse TestGetTransactionDetails() + { + CreateTransactionResponse response = (CreateTransactionResponse)AuthorizeCreditCard.run(apiLoginId, transactionKey, getAmount()); + return GetTransactionDetails.run(apiLoginId, transactionKey, response.getTransactionResponse().getTransId()); + } + + public ANetApiResponse TestChargeCreditCard() + { + return ChargeCreditCard.run(apiLoginId, transactionKey, getAmount()); + } + + public ANetApiResponse TestCapturePreviouslyAuthorizedAmount() + { + CreateTransactionResponse response = (CreateTransactionResponse)AuthorizeCreditCard.run(apiLoginId, transactionKey, getAmount()); + return CapturePreviouslyAuthorizedAmount.run(apiLoginId, transactionKey, response.getTransactionResponse().getTransId()); + } + + public ANetApiResponse TestRefundTransaction() + { + CreateTransactionResponse response = (CreateTransactionResponse)AuthorizeCreditCard.run(apiLoginId, transactionKey, getAmount()); + response = (CreateTransactionResponse)CapturePreviouslyAuthorizedAmount.run(apiLoginId, transactionKey, response.getTransactionResponse().getTransId()); + return RefundTransaction.run(apiLoginId, transactionKey, getAmount(), response.getTransactionResponse().getTransId()); + } + + public ANetApiResponse TestVoidTransaction() + { + CreateTransactionResponse response = (CreateTransactionResponse)AuthorizeCreditCard.run(apiLoginId, transactionKey, getAmount()); + return VoidTransaction.run(apiLoginId, transactionKey, response.getTransactionResponse().getTransId()); + } + + public ANetApiResponse TestCreditBankAccount() + { + return CreditBankAccount.run(apiLoginId, transactionKey, TransactionID); + } + + public ANetApiResponse TestChargeCustomerProfile() + { + CreateCustomerProfileResponse response = (CreateCustomerProfileResponse)CreateCustomerProfile.run(apiLoginId, transactionKey, getEmail()); + CreateCustomerPaymentProfileResponse paymentProfileResponse = (CreateCustomerPaymentProfileResponse)CreateCustomerPaymentProfile.run(apiLoginId, transactionKey, response.getCustomerProfileId()); + CreateTransactionResponse chargeResponse = (CreateTransactionResponse) ChargeCustomerProfile.run(apiLoginId, transactionKey, + response.getCustomerProfileId(), paymentProfileResponse.getCustomerPaymentProfileId()); + DeleteCustomerProfile.run(apiLoginId, transactionKey, response.getCustomerProfileId()); + + return chargeResponse; + } + + public ANetApiResponse TestPayPalVoid() + { + CreateTransactionResponse response = (CreateTransactionResponse)AuthorizationAndCapture.run(apiLoginId, transactionKey, getAmount()); + return net.authorize.sample.PaypalExpressCheckout.Void.run(apiLoginId, transactionKey, response.getTransactionResponse().getTransId()); + } + + public ANetApiResponse TestPayPalAuthorizationAndCapture() + { + return AuthorizationAndCapture.run(apiLoginId, transactionKey, getAmount()); + } + + public ANetApiResponse TestPayPalAuthorizationAndCaptureContinue() + { + CreateTransactionResponse response = (CreateTransactionResponse)AuthorizationAndCapture.run(apiLoginId, transactionKey, getAmount()); + return AuthorizationAndCaptureContinue.run(apiLoginId, transactionKey, response.getTransactionResponse().getTransId(), payerID, getAmount()); + } + + public ANetApiResponse TestPayPalAuthorizationOnly() + { + return AuthorizationOnly.run(apiLoginId, transactionKey, getAmount()); + } + + public ANetApiResponse TestPayPalAuthorizationOnlyContinued() + { + CreateTransactionResponse response = (CreateTransactionResponse)AuthorizationAndCapture.run(apiLoginId, transactionKey, getAmount()); + return AuthorizationOnlyContinued.run(apiLoginId, transactionKey, response.getTransactionResponse().getTransId(), payerID, getAmount()); + } + + public ANetApiResponse TestPayPalCredit() + { + return Credit.run(apiLoginId, transactionKey, TransactionID); + } + + public ANetApiResponse TestPayPalGetDetails() + { + CreateTransactionResponse response = (CreateTransactionResponse)AuthorizationAndCapture.run(apiLoginId, transactionKey, getAmount()); + return GetDetails.run(apiLoginId, transactionKey, response.getTransactionResponse().getTransId()); + } + + public ANetApiResponse TestPayPalPriorAuthorizationCapture() + { + CreateTransactionResponse response = (CreateTransactionResponse)AuthorizationAndCapture.run(apiLoginId, transactionKey, getAmount()); + return PriorAuthorizationCapture.run(apiLoginId, transactionKey, response.getTransactionResponse().getTransId()); + } + + public ANetApiResponse TestCancelSubscription() + { + ARBCreateSubscriptionResponse response = (ARBCreateSubscriptionResponse)CreateSubscription.run(apiLoginId, transactionKey, getDays(), getAmount()); + return CancelSubscription.run(apiLoginId, transactionKey, response.getSubscriptionId()); + } + + public ANetApiResponse TestCreateSubscription() + { + ARBCreateSubscriptionResponse response = (ARBCreateSubscriptionResponse)CreateSubscription.run(apiLoginId, transactionKey, getDays(), getAmount()); + CancelSubscription.run(apiLoginId, transactionKey, response.getSubscriptionId()); + + return response; + } + + public ANetApiResponse TestGetSubscriptionStatus() + { + ARBCreateSubscriptionResponse response = (ARBCreateSubscriptionResponse)CreateSubscription.run(apiLoginId, transactionKey, getDays(), getAmount()); + ARBGetSubscriptionStatusResponse subscriptionResponse = (ARBGetSubscriptionStatusResponse) GetSubscriptionStatus.run(apiLoginId, transactionKey, response.getSubscriptionId()); + + + return subscriptionResponse; + } + + public ANetApiResponse TestGetSubscription() + { + ARBCreateSubscriptionResponse response = (ARBCreateSubscriptionResponse)CreateSubscription.run(apiLoginId, transactionKey, getDays(), getAmount()); + ARBGetSubscriptionResponse getResponse = (ARBGetSubscriptionResponse) GetSubscription.run(apiLoginId, transactionKey, response.getSubscriptionId()); + CancelSubscription.run(apiLoginId, transactionKey, response.getSubscriptionId()); + return getResponse; + } + + public ANetApiResponse TestUpdateSubscription() + { + ARBCreateSubscriptionResponse response = (ARBCreateSubscriptionResponse)CreateSubscription.run(apiLoginId, transactionKey, getDays(), getAmount()); + ARBUpdateSubscriptionResponse updateResponse = (ARBUpdateSubscriptionResponse) UpdateSubscription.run(apiLoginId, transactionKey, response.getSubscriptionId()); + CancelSubscription.run(apiLoginId, transactionKey, response.getSubscriptionId()); + + return updateResponse; + } + + public ANetApiResponse TestCreateCustomerProfile() + { + return CreateCustomerProfile.run(apiLoginId, transactionKey, getEmail()); + } + + public ANetApiResponse TestCreateCustomerPaymentProfile() + { + CreateCustomerProfileResponse response = (CreateCustomerProfileResponse)CreateCustomerProfile.run(apiLoginId, transactionKey, getEmail()); + return CreateCustomerPaymentProfile.run(apiLoginId, transactionKey, response.getCustomerProfileId()); + } +} diff --git a/src/main/java/net/authorize/sample/TransactionReporting/GetBatchStatistics.java b/src/main/java/net/authorize/sample/TransactionReporting/GetBatchStatistics.java index 96968239..ce1408c5 100644 --- a/src/main/java/net/authorize/sample/TransactionReporting/GetBatchStatistics.java +++ b/src/main/java/net/authorize/sample/TransactionReporting/GetBatchStatistics.java @@ -8,7 +8,7 @@ //author @krgupta public class GetBatchStatistics { - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey) { ApiOperationBase.setEnvironment(Environment.SANDBOX); MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; @@ -37,5 +37,6 @@ public static void run(String apiLoginId, String transactionKey) { System.out.println("Failed to get batch statistics: " + getResponse.getMessages().getResultCode()); } } + return getResponse; } } \ No newline at end of file diff --git a/src/main/java/net/authorize/sample/TransactionReporting/GetSettledBatchList.java b/src/main/java/net/authorize/sample/TransactionReporting/GetSettledBatchList.java index 3a7fd72c..db690d65 100644 --- a/src/main/java/net/authorize/sample/TransactionReporting/GetSettledBatchList.java +++ b/src/main/java/net/authorize/sample/TransactionReporting/GetSettledBatchList.java @@ -11,7 +11,7 @@ //author @krgupta modified @kikmak42 public class GetSettledBatchList { - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey) { ApiOperationBase.setEnvironment(Environment.SANDBOX); @@ -60,5 +60,6 @@ public static void run(String apiLoginId, String transactionKey) { System.out.println(getResponse.getMessages().getMessage().get(0).getText()); } } + return getResponse; } } diff --git a/src/main/java/net/authorize/sample/TransactionReporting/GetTransactionDetails.java b/src/main/java/net/authorize/sample/TransactionReporting/GetTransactionDetails.java index 157638ec..a4fb6ca6 100644 --- a/src/main/java/net/authorize/sample/TransactionReporting/GetTransactionDetails.java +++ b/src/main/java/net/authorize/sample/TransactionReporting/GetTransactionDetails.java @@ -9,7 +9,7 @@ //author @krgupta public class GetTransactionDetails { - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey, String transactionId) { ApiOperationBase.setEnvironment(Environment.SANDBOX); @@ -18,12 +18,9 @@ public static void run(String apiLoginId, String transactionKey) { merchantAuthenticationType.setTransactionKey(transactionKey); ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); - //need valid transacaction Id to run - String transId = "2238248926"; - GetTransactionDetailsRequest getRequest = new GetTransactionDetailsRequest(); getRequest.setMerchantAuthentication(merchantAuthenticationType); - getRequest.setTransId(transId); + getRequest.setTransId(transactionId); GetTransactionDetailsController controller = new GetTransactionDetailsController(getRequest); controller.execute(); @@ -41,6 +38,7 @@ public static void run(String apiLoginId, String transactionKey) { System.out.println("Failed to get transaction details: " + getResponse.getMessages().getResultCode()); } } + return getResponse; } } diff --git a/src/main/java/net/authorize/sample/TransactionReporting/GetTransactionList.java b/src/main/java/net/authorize/sample/TransactionReporting/GetTransactionList.java index 07334ecc..7de38531 100644 --- a/src/main/java/net/authorize/sample/TransactionReporting/GetTransactionList.java +++ b/src/main/java/net/authorize/sample/TransactionReporting/GetTransactionList.java @@ -8,7 +8,7 @@ //author @krgupta public class GetTransactionList{ - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey) { ApiOperationBase.setEnvironment(Environment.SANDBOX); MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; @@ -37,6 +37,7 @@ public static void run(String apiLoginId, String transactionKey) { System.out.println("Failed to get transaction list: " + getResponse.getMessages().getResultCode()); } } + return getResponse; } } diff --git a/src/main/java/net/authorize/sample/TransactionReporting/GetUnsettledTransactionList.java b/src/main/java/net/authorize/sample/TransactionReporting/GetUnsettledTransactionList.java index a88aa944..ea42f806 100644 --- a/src/main/java/net/authorize/sample/TransactionReporting/GetUnsettledTransactionList.java +++ b/src/main/java/net/authorize/sample/TransactionReporting/GetUnsettledTransactionList.java @@ -11,7 +11,7 @@ //author @krgupta public class GetUnsettledTransactionList{ - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey) { ApiOperationBase.setEnvironment(Environment.SANDBOX); MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; @@ -40,6 +40,7 @@ public static void run(String apiLoginId, String transactionKey) { System.out.println("Failed to get unsettled transaction list: " + getResponse.getMessages().getResultCode()); } } + return getResponse; } } diff --git a/src/main/java/net/authorize/sample/VisaCheckout/CreateVisaCheckoutTransaction.java b/src/main/java/net/authorize/sample/VisaCheckout/CreateVisaCheckoutTransaction.java index 138ca2a8..c6b40700 100644 --- a/src/main/java/net/authorize/sample/VisaCheckout/CreateVisaCheckoutTransaction.java +++ b/src/main/java/net/authorize/sample/VisaCheckout/CreateVisaCheckoutTransaction.java @@ -4,6 +4,7 @@ import net.authorize.Environment; import net.authorize.api.controller.base.ApiOperationBase; +import net.authorize.api.contract.v1.ANetApiResponse; import net.authorize.api.contract.v1.CreateTransactionRequest; import net.authorize.api.contract.v1.CreateTransactionResponse; import net.authorize.api.contract.v1.MerchantAuthenticationType; @@ -23,7 +24,7 @@ // public class CreateVisaCheckoutTransaction { - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey) { //Common code to set for all requests @@ -74,6 +75,7 @@ public static void run(String apiLoginId, String transactionKey) { } } } + return response; } } diff --git a/src/main/java/net/authorize/sample/VisaCheckout/DecryptVisaCheckoutData.java b/src/main/java/net/authorize/sample/VisaCheckout/DecryptVisaCheckoutData.java index ae54145a..c9a09763 100644 --- a/src/main/java/net/authorize/sample/VisaCheckout/DecryptVisaCheckoutData.java +++ b/src/main/java/net/authorize/sample/VisaCheckout/DecryptVisaCheckoutData.java @@ -2,6 +2,7 @@ import net.authorize.Environment; import net.authorize.api.controller.base.ApiOperationBase; +import net.authorize.api.contract.v1.ANetApiResponse; import net.authorize.api.contract.v1.DecryptPaymentDataRequest; import net.authorize.api.contract.v1.DecryptPaymentDataResponse; import net.authorize.api.contract.v1.MerchantAuthenticationType; @@ -11,7 +12,7 @@ public class DecryptVisaCheckoutData { - public static void run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey) { //Common code to set for all requests ApiOperationBase.setEnvironment(Environment.SANDBOX); @@ -52,6 +53,7 @@ public static void run(String apiLoginId, String transactionKey) { System.out.println("Error : " + response.getMessages().getMessage().get(0).getText()); } } + return response; } } From 28d41aea79f36a5bf86c5accb21b985c7a4a4997 Mon Sep 17 00:00:00 2001 From: srathod Date: Mon, 11 Jan 2016 21:41:07 +0530 Subject: [PATCH 022/176] - Added junit dependency in pom.xml. - Fixed some samplecodes. --- pom.xml | 112 ++++++++++-------- ...eFundsAuthorizedThroughAnotherChannel.java | 13 +- .../ChargeCustomerProfile.java | 4 +- .../UpdateSplitTenderGroup.java | 2 +- .../java/net/authorize/sample/SampleCode.java | 4 +- .../sample/SampleCodeTest/SampleCodeList.txt | 10 +- .../sample/SampleCodeTest/TestRunner.java | 8 +- 7 files changed, 93 insertions(+), 60 deletions(-) diff --git a/pom.xml b/pom.xml index dc4c0c44..382b3dd0 100644 --- a/pom.xml +++ b/pom.xml @@ -1,49 +1,67 @@ - 4.0.0 - net.authorize.sample - SampleCode - jar - 1.0 - SampleCode - http://maven.apache.org - - - net.authorize - anet-java-sdk - 1.8.6 - - - - - - maven-compiler-plugin - - 1.7 - 1.7 - - - - org.apache.maven.plugins - maven-shade-plugin - 2.4.1 - - - package - - shade - - - SampleCode - - - net.authorize.sample.SampleCode - - - - - - - - + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + 4.0.0 + net.authorize.sample + SampleCode + jar + 1.0 + SampleCode + + + + net.authorize + anet-java-sdk + 1.8.6 + + + junit + junit + 4.8.1 + test + + + + + + maven-compiler-plugin + + 1.7 + 1.7 + + + + org.apache.maven.plugins + maven-shade-plugin + 2.4.1 + + + package + + shade + + + SampleCode + + + net.authorize.sample.SampleCode + + + + + + + + + diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/CaptureFundsAuthorizedThroughAnotherChannel.java b/src/main/java/net/authorize/sample/PaymentTransactions/CaptureFundsAuthorizedThroughAnotherChannel.java index 97dc144b..35a0c21b 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/CaptureFundsAuthorizedThroughAnotherChannel.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/CaptureFundsAuthorizedThroughAnotherChannel.java @@ -13,7 +13,7 @@ public class CaptureFundsAuthorizedThroughAnotherChannel { // Run this sample from command line with: // java -jar target/ChargeCreditCard-jar-with-dependencies.jar // - public static ANetApiResponse run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey, Double amount) { //Common code to set for all requests ApiOperationBase.setEnvironment(Environment.SANDBOX); @@ -22,11 +22,20 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) { merchantAuthenticationType.setName(apiLoginId); merchantAuthenticationType.setTransactionKey(transactionKey); ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); + + CreditCardType cc = new CreditCardType(); + cc.setCardNumber("4111111111111111"); + cc.setExpirationDate("2020-12"); + + PaymentType payment = new PaymentType(); + payment.setCreditCard(cc); // Create the payment transaction request TransactionRequestType txnRequest = new TransactionRequestType(); txnRequest.setTransactionType(TransactionTypeEnum.CAPTURE_ONLY_TRANSACTION.value()); - txnRequest.setRefTransId("2238786428"); + txnRequest.setAmount(new BigDecimal(amount.toString())); + txnRequest.setPayment(payment); + txnRequest.setAuthCode("ROHNFQ"); // Make the API Request CreateTransactionRequest apiRequest = new CreateTransactionRequest(); diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCustomerProfile.java b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCustomerProfile.java index b49dd4c3..5ee87d07 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCustomerProfile.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCustomerProfile.java @@ -14,7 +14,7 @@ public class ChargeCustomerProfile { // java -jar target/ChargeCreditCard-jar-with-dependencies.jar // public static ANetApiResponse run(String apiLoginId, String transactionKey, String customerProfileId, - String customerPaymentProfileId) { + String customerPaymentProfileId, Double amount) { //Common code to set for all requests @@ -37,7 +37,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri TransactionRequestType txnRequest = new TransactionRequestType(); txnRequest.setTransactionType(TransactionTypeEnum.AUTH_CAPTURE_TRANSACTION.value()); txnRequest.setProfile(profileToCharge); - txnRequest.setAmount(new BigDecimal(500.00)); + txnRequest.setAmount(new BigDecimal(amount.toString())); CreateTransactionRequest apiRequest = new CreateTransactionRequest(); diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/UpdateSplitTenderGroup.java b/src/main/java/net/authorize/sample/PaymentTransactions/UpdateSplitTenderGroup.java index be9cbf18..a6bccc94 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/UpdateSplitTenderGroup.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/UpdateSplitTenderGroup.java @@ -24,7 +24,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) { // Provide a split tender Id // To get a split Tender ID in sandbox, authorize any transaction with amount = 462.25 [if card present] and set allowPartialAuth = true - String splitTenderId = "SPLIT_TENDER_ID"; + String splitTenderId = "115901"; // Create a request UpdateSplitTenderGroupRequest request = new UpdateSplitTenderGroupRequest(); diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index 20b95fdd..840a73eb 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -161,7 +161,7 @@ private static void RunMethod(String methodName) CreateCustomerProfileFromTransaction.run(apiLoginId, transactionKey); break; case "CaptureFundsAuthorizedThroughAnotherChannel": - CaptureFundsAuthorizedThroughAnotherChannel.run(apiLoginId, transactionKey); + CaptureFundsAuthorizedThroughAnotherChannel.run(apiLoginId, transactionKey, 12.34); break; case "CapturePreviouslyAuthorizedAmount": CapturePreviouslyAuthorizedAmount.run(apiLoginId, transactionKey, transactionId); @@ -179,7 +179,7 @@ private static void RunMethod(String methodName) CreateAnApplePayTransaction.run(apiLoginId, transactionKey); break; case "ChargeCustomerProfile": - ChargeCustomerProfile.run(apiLoginId, transactionKey, "36731856", "33211899"); + ChargeCustomerProfile.run(apiLoginId, transactionKey, "36731856", "33211899" , 10.23); break; case "CreateSubscription": CreateSubscription.run(apiLoginId, transactionKey, (short)12, 10.21); diff --git a/src/main/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt b/src/main/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt index 03a3b00d..ea801203 100644 --- a/src/main/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt +++ b/src/main/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt @@ -35,12 +35,12 @@ PaymentTransactions.CapturePreviouslyAuthorizedAmount 1 1 PaymentTransactions.RefundTransaction 1 0 PaymentTransactions.VoidTransaction 1 1 PaymentTransactions.CreditBankAccount 1 0 -PaymentTransactions.ChargeCustomerProfile 1 0 -PaymentTransactions.CaptureFundsAuthorizedThroughAnotherChannel 0 0 -PaymentTransactions.AuthorizeCreditCard 1 0 +PaymentTransactions.ChargeCustomerProfile 1 1 +PaymentTransactions.CaptureFundsAuthorizedThroughAnotherChannel 1 1 +PaymentTransactions.AuthorizeCreditCard 1 1 PaymentTransactions.DebitBankAccount 0 1 PaymentTransactions.ChargeTokenizedCreditCard 0 1 -PaymentTransactions.UpdateSplitTenderGroup 0 0 +PaymentTransactions.UpdateSplitTenderGroup 0 1 TransactionReporting.GetTransactionList 0 1 TransactionReporting.GetUnsettledTransactionList 0 1 TransactionReporting.GetBatchStatistics 0 1 @@ -48,4 +48,4 @@ TransactionReporting.GetSettledBatchList 0 1 TransactionReporting.GetTransactionDetails 1 1 ApplePayTransactions.CreateAnApplePayTransaction 0 0 VisaCheckout.DecryptVisaCheckoutData 0 1 -VisaCheckout.CreateVisaCheckoutTransaction 0 0 +VisaCheckout.CreateVisaCheckoutTransaction 0 0 \ No newline at end of file diff --git a/src/main/java/net/authorize/sample/SampleCodeTest/TestRunner.java b/src/main/java/net/authorize/sample/SampleCodeTest/TestRunner.java index 092b953a..f2e42596 100644 --- a/src/main/java/net/authorize/sample/SampleCodeTest/TestRunner.java +++ b/src/main/java/net/authorize/sample/SampleCodeTest/TestRunner.java @@ -46,6 +46,7 @@ import net.authorize.sample.CustomerProfiles.UpdateCustomerShippingAddress; import net.authorize.sample.CustomerProfiles.ValidateCustomerPaymentProfile; import net.authorize.sample.PaymentTransactions.AuthorizeCreditCard; +import net.authorize.sample.PaymentTransactions.CaptureFundsAuthorizedThroughAnotherChannel; import net.authorize.sample.PaymentTransactions.CapturePreviouslyAuthorizedAmount; import net.authorize.sample.PaymentTransactions.ChargeCreditCard; import net.authorize.sample.PaymentTransactions.ChargeCustomerProfile; @@ -374,7 +375,7 @@ public ANetApiResponse TestChargeCustomerProfile() CreateCustomerProfileResponse response = (CreateCustomerProfileResponse)CreateCustomerProfile.run(apiLoginId, transactionKey, getEmail()); CreateCustomerPaymentProfileResponse paymentProfileResponse = (CreateCustomerPaymentProfileResponse)CreateCustomerPaymentProfile.run(apiLoginId, transactionKey, response.getCustomerProfileId()); CreateTransactionResponse chargeResponse = (CreateTransactionResponse) ChargeCustomerProfile.run(apiLoginId, transactionKey, - response.getCustomerProfileId(), paymentProfileResponse.getCustomerPaymentProfileId()); + response.getCustomerProfileId(), paymentProfileResponse.getCustomerPaymentProfileId(), getAmount()); DeleteCustomerProfile.run(apiLoginId, transactionKey, response.getCustomerProfileId()); return chargeResponse; @@ -469,6 +470,11 @@ public ANetApiResponse TestCreateCustomerProfile() { return CreateCustomerProfile.run(apiLoginId, transactionKey, getEmail()); } + + public ANetApiResponse TestCaptureFundsAuthorizedThroughAnotherChannel() + { + return CaptureFundsAuthorizedThroughAnotherChannel.run(apiLoginId, transactionKey, getAmount()); + } public ANetApiResponse TestCreateCustomerPaymentProfile() { From e468af42f87a49360b6f8136877fea106ce19193 Mon Sep 17 00:00:00 2001 From: srathod Date: Mon, 11 Jan 2016 21:47:09 +0530 Subject: [PATCH 023/176] - Fixed junit dependency. --- pom.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 382b3dd0..0565d10f 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ jar 1.0 SampleCode - + http://maven.apache.org net.authorize @@ -17,7 +17,6 @@ junit junit 4.8.1 - test From 73f9231b437a3ee49ea88cd839a50d7f902bcfa0 Mon Sep 17 00:00:00 2001 From: srathod Date: Mon, 11 Jan 2016 22:21:28 +0530 Subject: [PATCH 024/176] - Moved SampleCodeTest package to src/test/java. --- pom.xml | 7 +++---- .../net/authorize/sample/SampleCodeTest/Constants.java | 2 +- .../net/authorize/sample/SampleCodeTest/SampleCodeList.txt | 0 .../net/authorize/sample/SampleCodeTest/TestRunner.java | 0 4 files changed, 4 insertions(+), 5 deletions(-) rename src/{main => test}/java/net/authorize/sample/SampleCodeTest/Constants.java (85%) rename src/{main => test}/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt (100%) rename src/{main => test}/java/net/authorize/sample/SampleCodeTest/TestRunner.java (100%) diff --git a/pom.xml b/pom.xml index 0565d10f..05df367b 100644 --- a/pom.xml +++ b/pom.xml @@ -50,17 +50,16 @@ - + diff --git a/src/main/java/net/authorize/sample/SampleCodeTest/Constants.java b/src/test/java/net/authorize/sample/SampleCodeTest/Constants.java similarity index 85% rename from src/main/java/net/authorize/sample/SampleCodeTest/Constants.java rename to src/test/java/net/authorize/sample/SampleCodeTest/Constants.java index 838c63d2..672c6b1e 100644 --- a/src/main/java/net/authorize/sample/SampleCodeTest/Constants.java +++ b/src/test/java/net/authorize/sample/SampleCodeTest/Constants.java @@ -5,5 +5,5 @@ public final class Constants { public static final String TRANSACTION_KEY = "4Ktq966gC55GAX7S"; public static final String TRANSACTION_ID = "123456"; public static final String PAYER_ID = "6ZSCSYG33VP8Q"; - public static final String CONFIG_FILE = "./src/main/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt"; + public static final String CONFIG_FILE = "./src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt"; } diff --git a/src/main/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt b/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt similarity index 100% rename from src/main/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt rename to src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt diff --git a/src/main/java/net/authorize/sample/SampleCodeTest/TestRunner.java b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java similarity index 100% rename from src/main/java/net/authorize/sample/SampleCodeTest/TestRunner.java rename to src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java From 1d6789c66a8f7e636e7d1c5fd3fd6e9b3a82cea3 Mon Sep 17 00:00:00 2001 From: srathod Date: Mon, 11 Jan 2016 22:29:58 +0530 Subject: [PATCH 025/176] - Fixed DebitBankAccount.java. Different values of amount required to run the test multiple times. --- .../PaymentTransactions/DebitBankAccount.java | 4 ++-- .../java/net/authorize/sample/SampleCode.java | 2 +- .../sample/SampleCodeTest/SampleCodeList.txt | 2 +- .../sample/SampleCodeTest/TestRunner.java | 16 +++++++--------- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java b/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java index f80a141d..c204056d 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java @@ -13,7 +13,7 @@ public class DebitBankAccount { // Run this sample from command line with: // java -jar target/ChargeCreditCard-jar-with-dependencies.jar // - public static ANetApiResponse run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey, Double amount) { //Common code to set for all requests @@ -37,7 +37,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) { TransactionRequestType txnRequest = new TransactionRequestType(); txnRequest.setTransactionType(TransactionTypeEnum.AUTH_CAPTURE_TRANSACTION.value()); txnRequest.setPayment(paymentType); - txnRequest.setAmount(new BigDecimal(500.00)); + txnRequest.setAmount(new BigDecimal(amount.toString())); // Make the API Request CreateTransactionRequest apiRequest = new CreateTransactionRequest(); diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index 840a73eb..8531b983 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -167,7 +167,7 @@ private static void RunMethod(String methodName) CapturePreviouslyAuthorizedAmount.run(apiLoginId, transactionKey, transactionId); break; case "DebitBankAccount": - DebitBankAccount.run(apiLoginId, transactionKey); + DebitBankAccount.run(apiLoginId, transactionKey, 12.93); break; case "CreditBankAccount": CreditBankAccount.run(apiLoginId, transactionKey, transactionId); diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt b/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt index ea801203..cc4003c4 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt +++ b/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt @@ -38,7 +38,7 @@ PaymentTransactions.CreditBankAccount 1 0 PaymentTransactions.ChargeCustomerProfile 1 1 PaymentTransactions.CaptureFundsAuthorizedThroughAnotherChannel 1 1 PaymentTransactions.AuthorizeCreditCard 1 1 -PaymentTransactions.DebitBankAccount 0 1 +PaymentTransactions.DebitBankAccount 1 1 PaymentTransactions.ChargeTokenizedCreditCard 0 1 PaymentTransactions.UpdateSplitTenderGroup 0 1 TransactionReporting.GetTransactionList 0 1 diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java index f2e42596..2b33587f 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java +++ b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java @@ -51,6 +51,7 @@ import net.authorize.sample.PaymentTransactions.ChargeCreditCard; import net.authorize.sample.PaymentTransactions.ChargeCustomerProfile; import net.authorize.sample.PaymentTransactions.CreditBankAccount; +import net.authorize.sample.PaymentTransactions.DebitBankAccount; import net.authorize.sample.PaymentTransactions.RefundTransaction; import net.authorize.sample.PaymentTransactions.VoidTransaction; import net.authorize.sample.PaypalExpressCheckout.AuthorizationAndCapture; @@ -325,15 +326,12 @@ public ANetApiResponse TestAuthorizeCreditCard() CreateTransactionResponse response = (CreateTransactionResponse)AuthorizeCreditCard.run(apiLoginId, transactionKey, getAmount()); return response; } - - // public ANetApiResponse TestCreateCustomerProfileFromTransaction() - // { - // CreateTransactionResponse response = (CreateTransactionResponse)AuthorizeCreditCard.run(apiLoginId, transactionKey, getAmount()); - // CreateCustomerProfileResponse profileResponse = (CreateCustomerProfileResponse)CreateCustomerProfileFromTransaction.run(apiLoginId, transactionKey, response.getTransactionResponse().getTransId()); - // DeleteCustomerProfile.run(apiLoginId, transactionKey, profileResponse.getCustomerProfileId()); - // - // return profileResponse; - // } + + public ANetApiResponse TestDebitBankAccount() + { + CreateTransactionResponse response = (CreateTransactionResponse)DebitBankAccount.run(apiLoginId, transactionKey, getAmount()); + return response; + } public ANetApiResponse TestGetTransactionDetails() { From 1b6adc89c5b0cefbbeb1e633e6142b0e48ec421c Mon Sep 17 00:00:00 2001 From: srathod Date: Mon, 11 Jan 2016 22:34:38 +0530 Subject: [PATCH 026/176] - Amount fix for ChargeTokenizedCreditCard.java. --- .../PaymentTransactions/ChargeTokenizedCreditCard.java | 4 ++-- src/main/java/net/authorize/sample/SampleCode.java | 2 +- .../net/authorize/sample/SampleCodeTest/SampleCodeList.txt | 2 +- .../net/authorize/sample/SampleCodeTest/TestRunner.java | 7 +++++++ 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeTokenizedCreditCard.java b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeTokenizedCreditCard.java index 38bd4faa..ef2bb25d 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeTokenizedCreditCard.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeTokenizedCreditCard.java @@ -13,7 +13,7 @@ public class ChargeTokenizedCreditCard { // Run this sample from command line with: // java -jar target/ChargeCreditCard-jar-with-dependencies.jar // - public static ANetApiResponse run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey, Double amount) { //Common code to set for all requests @@ -36,7 +36,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) { TransactionRequestType txnRequest = new TransactionRequestType(); txnRequest.setTransactionType(TransactionTypeEnum.AUTH_CAPTURE_TRANSACTION.value()); txnRequest.setPayment(paymentType); - txnRequest.setAmount(new BigDecimal(500.00)); + txnRequest.setAmount(new BigDecimal(amount.toString())); // Make the API Request CreateTransactionRequest apiRequest = new CreateTransactionRequest(); diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index 8531b983..6a039725 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -173,7 +173,7 @@ private static void RunMethod(String methodName) CreditBankAccount.run(apiLoginId, transactionKey, transactionId); break; case "ChargeTokenizedCreditCard": - ChargeTokenizedCreditCard.run(apiLoginId, transactionKey); + ChargeTokenizedCreditCard.run(apiLoginId, transactionKey, 12.89); break; case "CreateAnApplePayTransaction": CreateAnApplePayTransaction.run(apiLoginId, transactionKey); diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt b/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt index cc4003c4..79f7b4e3 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt +++ b/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt @@ -39,7 +39,7 @@ PaymentTransactions.ChargeCustomerProfile 1 1 PaymentTransactions.CaptureFundsAuthorizedThroughAnotherChannel 1 1 PaymentTransactions.AuthorizeCreditCard 1 1 PaymentTransactions.DebitBankAccount 1 1 -PaymentTransactions.ChargeTokenizedCreditCard 0 1 +PaymentTransactions.ChargeTokenizedCreditCard 1 1 PaymentTransactions.UpdateSplitTenderGroup 0 1 TransactionReporting.GetTransactionList 0 1 TransactionReporting.GetUnsettledTransactionList 0 1 diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java index 2b33587f..6a230a0e 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java +++ b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java @@ -50,6 +50,7 @@ import net.authorize.sample.PaymentTransactions.CapturePreviouslyAuthorizedAmount; import net.authorize.sample.PaymentTransactions.ChargeCreditCard; import net.authorize.sample.PaymentTransactions.ChargeCustomerProfile; +import net.authorize.sample.PaymentTransactions.ChargeTokenizedCreditCard; import net.authorize.sample.PaymentTransactions.CreditBankAccount; import net.authorize.sample.PaymentTransactions.DebitBankAccount; import net.authorize.sample.PaymentTransactions.RefundTransaction; @@ -332,6 +333,12 @@ public ANetApiResponse TestDebitBankAccount() CreateTransactionResponse response = (CreateTransactionResponse)DebitBankAccount.run(apiLoginId, transactionKey, getAmount()); return response; } + + public ANetApiResponse TestChargeTokenizedCreditCard() + { + CreateTransactionResponse response = (CreateTransactionResponse)ChargeTokenizedCreditCard.run(apiLoginId, transactionKey, getAmount()); + return response; + } public ANetApiResponse TestGetTransactionDetails() { From 38dc93083c7def41a0057b41ae99e5bdd3e60e65 Mon Sep 17 00:00:00 2001 From: srathod Date: Tue, 12 Jan 2016 09:17:37 +0530 Subject: [PATCH 027/176] - Fixed amount to string conversion. Required for use in BigDecimal. --- .../sample/PaymentTransactions/AuthorizeCreditCard.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/AuthorizeCreditCard.java b/src/main/java/net/authorize/sample/PaymentTransactions/AuthorizeCreditCard.java index d5a04263..6eaad727 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/AuthorizeCreditCard.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/AuthorizeCreditCard.java @@ -35,7 +35,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub TransactionRequestType txnRequest = new TransactionRequestType(); txnRequest.setTransactionType(TransactionTypeEnum.AUTH_ONLY_TRANSACTION.value()); txnRequest.setPayment(paymentType); - txnRequest.setAmount(new BigDecimal(amount)); + txnRequest.setAmount(new BigDecimal(amount.toString())); // Make the API Request CreateTransactionRequest apiRequest = new CreateTransactionRequest(); From 6d9dbace38e8d2ee513f0b07c257089bb66ccf8e Mon Sep 17 00:00:00 2001 From: srathod Date: Tue, 12 Jan 2016 10:01:54 +0530 Subject: [PATCH 028/176] - Fixed amount to string conversion for AuthorizationAndCapture. --- .../sample/PaypalExpressCheckout/AuthorizationAndCapture.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCapture.java b/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCapture.java index d77d7c10..97d3d96b 100644 --- a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCapture.java +++ b/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCapture.java @@ -43,7 +43,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub transactionRequest.setTransactionType(TransactionTypeEnum.AUTH_CAPTURE_TRANSACTION.value()); transactionRequest.setPayment(paymentType); - transactionRequest.setAmount(new BigDecimal(amount)); + transactionRequest.setAmount(new BigDecimal(amount.toString())); // Make the API Request CreateTransactionRequest apiRequest = new CreateTransactionRequest(); From 12f4de10cc6d9344b9a0f375bbc38ee92458f947 Mon Sep 17 00:00:00 2001 From: srathod Date: Tue, 12 Jan 2016 10:06:00 +0530 Subject: [PATCH 029/176] - Fixed amount to string for ChargeCreditCard. --- .../authorize/sample/PaymentTransactions/ChargeCreditCard.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCreditCard.java b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCreditCard.java index f8bf4bc3..18ce3918 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCreditCard.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCreditCard.java @@ -35,7 +35,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub TransactionRequestType txnRequest = new TransactionRequestType(); txnRequest.setTransactionType(TransactionTypeEnum.AUTH_CAPTURE_TRANSACTION.value()); txnRequest.setPayment(paymentType); - txnRequest.setAmount(new BigDecimal(amount)); + txnRequest.setAmount(new BigDecimal(amount.toString())); // Make the API Request CreateTransactionRequest apiRequest = new CreateTransactionRequest(); From 1bf5bebd313995c4d2850735e6b19a87407d3233 Mon Sep 17 00:00:00 2001 From: srathod Date: Tue, 12 Jan 2016 10:13:06 +0530 Subject: [PATCH 030/176] - Updating random amount generator function. --- .../java/net/authorize/sample/SampleCodeTest/TestRunner.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java index 6a230a0e..4254bef9 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java +++ b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java @@ -85,7 +85,7 @@ private static String getEmail() private static Double getAmount() { - return (double)(rgenerator.nextInt(1000)); + return (double)(rgenerator.nextInt(1000) + rgenerator.nextDouble()); } private static short getDays() From 3d956d39378cd582424132702e6ca522e23aeb50 Mon Sep 17 00:00:00 2001 From: srathod Date: Tue, 12 Jan 2016 10:18:26 +0530 Subject: [PATCH 031/176] - Another fix for random double generator. --- .../java/net/authorize/sample/SampleCodeTest/TestRunner.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java index 4254bef9..d5104e2b 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java +++ b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java @@ -85,7 +85,7 @@ private static String getEmail() private static Double getAmount() { - return (double)(rgenerator.nextInt(1000) + rgenerator.nextDouble()); + return (double)(1.05 + (15.0 *rgenerator.nextDouble())); } private static short getDays() From d0c71a8898615ca8266f4a85d8e7693a44bb7ba6 Mon Sep 17 00:00:00 2001 From: srathod Date: Tue, 12 Jan 2016 10:25:19 +0530 Subject: [PATCH 032/176] - Fixed decimal format for amount. --- .../net/authorize/sample/SampleCodeTest/TestRunner.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java index d5104e2b..ac5149bf 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java +++ b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java @@ -7,6 +7,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.security.SecureRandom; +import java.text.DecimalFormat; import org.junit.Test; @@ -85,7 +86,11 @@ private static String getEmail() private static Double getAmount() { - return (double)(1.05 + (15.0 *rgenerator.nextDouble())); + double d = (double)(1.05 + (15.0 * rgenerator.nextDouble())); + DecimalFormat df = new DecimalFormat("#.##"); + d = Double.valueOf(df.format(d)); + System.out.println("Amount : " + d); + return d; } private static short getDays() From a04e4e9dfb5ca6dac0d1d7099cd4f1bce219d120 Mon Sep 17 00:00:00 2001 From: srathod Date: Tue, 12 Jan 2016 10:29:17 +0530 Subject: [PATCH 033/176] - Changed random getAmount function. --- .../java/net/authorize/sample/SampleCodeTest/TestRunner.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java index ac5149bf..e5483170 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java +++ b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java @@ -86,7 +86,7 @@ private static String getEmail() private static Double getAmount() { - double d = (double)(1.05 + (15.0 * rgenerator.nextDouble())); + double d = (double)(1.05 + (450.0 * rgenerator.nextDouble())); DecimalFormat df = new DecimalFormat("#.##"); d = Double.valueOf(df.format(d)); System.out.println("Amount : " + d); From 3d4748c98c848dabfedce1e4546d3329f3377dcc Mon Sep 17 00:00:00 2001 From: srathod Date: Tue, 12 Jan 2016 10:42:39 +0530 Subject: [PATCH 034/176] - Added amount and email as parameter in CreateCustomerProfileFromTransaction. --- .../CreateCustomerProfileFromTransaction.java | 6 +++--- src/main/java/net/authorize/sample/SampleCode.java | 2 +- .../net/authorize/sample/SampleCodeTest/SampleCodeList.txt | 2 +- .../net/authorize/sample/SampleCodeTest/TestRunner.java | 6 ++++++ 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfileFromTransaction.java b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfileFromTransaction.java index 29e74139..0c2aed9f 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfileFromTransaction.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfileFromTransaction.java @@ -10,7 +10,7 @@ public class CreateCustomerProfileFromTransaction { - public static ANetApiResponse run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey, Double amount, String email) { ApiOperationBase.setEnvironment(Environment.SANDBOX); @@ -29,10 +29,10 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) { TransactionRequestType requestInternal = new TransactionRequestType(); requestInternal.setTransactionType("authOnlyTransaction"); requestInternal.setPayment(paymentType); - requestInternal.setAmount(new BigDecimal(System.currentTimeMillis() % 100)); + requestInternal.setAmount(new BigDecimal(amount.toString())); CustomerDataType customer = new CustomerDataType(); - customer.setEmail(System.currentTimeMillis()+"@b.bla"); + customer.setEmail(email); requestInternal.setCustomer(customer); CreateTransactionRequest request = new CreateTransactionRequest(); diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index 6a039725..123c13f6 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -158,7 +158,7 @@ private static void RunMethod(String methodName) RefundTransaction.run(apiLoginId, transactionKey , amount, transactionId); break; case "CreateCustomerProfileFromTransaction": - CreateCustomerProfileFromTransaction.run(apiLoginId, transactionKey); + CreateCustomerProfileFromTransaction.run(apiLoginId, transactionKey, 12.34, "test@test.com"); break; case "CaptureFundsAuthorizedThroughAnotherChannel": CaptureFundsAuthorizedThroughAnotherChannel.run(apiLoginId, transactionKey, 12.34); diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt b/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt index 79f7b4e3..94aea5ff 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt +++ b/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt @@ -18,7 +18,7 @@ CustomerProfiles.DeleteCustomerShippingAddress 1 1 CustomerProfiles.DeleteCustomerProfile 1 1 CustomerProfiles.DeleteCustomerPaymentProfile 1 1 CustomerProfiles.CreateCustomerShippingAddress 1 1 -CustomerProfiles.CreateCustomerProfileFromTransaction 0 1 +CustomerProfiles.CreateCustomerProfileFromTransaction 1 1 CustomerProfiles.GetCustomerPaymentProfileList 0 1 CustomerProfiles.CreateCustomerProfile 1 1 CustomerProfiles.CreateCustomerPaymentProfile 1 1 diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java index e5483170..22ab4f7b 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java +++ b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java @@ -34,6 +34,7 @@ import net.authorize.api.contract.v1.ValidateCustomerPaymentProfileResponse; import net.authorize.sample.CustomerProfiles.CreateCustomerPaymentProfile; import net.authorize.sample.CustomerProfiles.CreateCustomerProfile; +import net.authorize.sample.CustomerProfiles.CreateCustomerProfileFromTransaction; import net.authorize.sample.CustomerProfiles.CreateCustomerShippingAddress; import net.authorize.sample.CustomerProfiles.DeleteCustomerPaymentProfile; import net.authorize.sample.CustomerProfiles.DeleteCustomerProfile; @@ -355,6 +356,11 @@ public ANetApiResponse TestChargeCreditCard() { return ChargeCreditCard.run(apiLoginId, transactionKey, getAmount()); } + + public ANetApiResponse TestCreateCustomerProfileFromTransaction() + { + return CreateCustomerProfileFromTransaction.run(apiLoginId, transactionKey, getAmount(), getEmail()); + } public ANetApiResponse TestCapturePreviouslyAuthorizedAmount() { From 6b50c1741d5d18ea749c33a16c1ed5cb34551a09 Mon Sep 17 00:00:00 2001 From: srathod Date: Tue, 12 Jan 2016 11:02:06 +0530 Subject: [PATCH 035/176] - Added randomness for merchant customer id in CreateCustomerProfile. --- .../sample/CustomerProfiles/CreateCustomerProfile.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfile.java b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfile.java index 54b96a4f..58111dc5 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfile.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfile.java @@ -29,7 +29,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri customerPaymentProfileType.setPayment(paymentType); CustomerProfileType customerProfileType = new CustomerProfileType(); - customerProfileType.setMerchantCustomerId("Merchant_Customer_ID"); + customerProfileType.setMerchantCustomerId("Merchant_Customer_ID_" + System.currentTimeMillis()); customerProfileType.setDescription("Profile description here"); customerProfileType.setEmail(eMail); customerProfileType.getPaymentProfiles().add(customerPaymentProfileType); From 268369eb6fc0f271db3fe0b3be1f610e47c4f5e5 Mon Sep 17 00:00:00 2001 From: srathod Date: Tue, 12 Jan 2016 11:08:58 +0530 Subject: [PATCH 036/176] - Fixed customer id in CreateCustomerProfile. --- .../sample/CustomerProfiles/CreateCustomerProfile.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfile.java b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfile.java index 58111dc5..52aae7b6 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfile.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfile.java @@ -29,7 +29,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri customerPaymentProfileType.setPayment(paymentType); CustomerProfileType customerProfileType = new CustomerProfileType(); - customerProfileType.setMerchantCustomerId("Merchant_Customer_ID_" + System.currentTimeMillis()); + customerProfileType.setMerchantCustomerId("M_" + eMail); customerProfileType.setDescription("Profile description here"); customerProfileType.setEmail(eMail); customerProfileType.getPaymentProfiles().add(customerPaymentProfileType); From a3eb751df752ea36bfbc25af0c0fcf688d572c45 Mon Sep 17 00:00:00 2001 From: srathod Date: Tue, 12 Jan 2016 12:18:39 +0530 Subject: [PATCH 037/176] - Updated sample codes for RefundTransaction and CreditBankAccount. --- .../sample/PaymentTransactions/CreditBankAccount.java | 4 ++-- .../sample/PaymentTransactions/RefundTransaction.java | 2 +- src/main/java/net/authorize/sample/SampleCode.java | 2 +- .../net/authorize/sample/SampleCodeTest/TestRunner.java | 8 +------- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java b/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java index 36932c87..35302ca8 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java @@ -13,7 +13,7 @@ public class CreditBankAccount { // Run this sample from command line with: // java -jar target/ChargeCreditCard-jar-with-dependencies.jar // - public static ANetApiResponse run(String apiLoginId, String transactionKey, String transactionID) { + public static ANetApiResponse run(String apiLoginId, String transactionKey, String transactionID, Double amount) { //Common code to set for all requests @@ -38,7 +38,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri txnRequest.setTransactionType(TransactionTypeEnum.REFUND_TRANSACTION.value()); txnRequest.setRefTransId(transactionID); txnRequest.setPayment(paymentType); - txnRequest.setAmount(new BigDecimal(500.00)); + txnRequest.setAmount(new BigDecimal(amount.toString())); // Make the API Request CreateTransactionRequest apiRequest = new CreateTransactionRequest(); diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/RefundTransaction.java b/src/main/java/net/authorize/sample/PaymentTransactions/RefundTransaction.java index e0d89b91..9e27c07d 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/RefundTransaction.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/RefundTransaction.java @@ -34,7 +34,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub TransactionRequestType txnRequest = new TransactionRequestType(); txnRequest.setTransactionType(TransactionTypeEnum.REFUND_TRANSACTION.value()); txnRequest.setRefTransId(transactionID); - txnRequest.setAmount(new BigDecimal(transactionAmount)); + txnRequest.setAmount(new BigDecimal(transactionAmount.toString())); txnRequest.setPayment(paymentType); // Make the API Request diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index 123c13f6..2b53d7d5 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -170,7 +170,7 @@ private static void RunMethod(String methodName) DebitBankAccount.run(apiLoginId, transactionKey, 12.93); break; case "CreditBankAccount": - CreditBankAccount.run(apiLoginId, transactionKey, transactionId); + CreditBankAccount.run(apiLoginId, transactionKey, transactionId, 12.23); break; case "ChargeTokenizedCreditCard": ChargeTokenizedCreditCard.run(apiLoginId, transactionKey, 12.89); diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java index 22ab4f7b..89b83f52 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java +++ b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java @@ -90,7 +90,6 @@ private static Double getAmount() double d = (double)(1.05 + (450.0 * rgenerator.nextDouble())); DecimalFormat df = new DecimalFormat("#.##"); d = Double.valueOf(df.format(d)); - System.out.println("Amount : " + d); return d; } @@ -257,11 +256,6 @@ public ANetApiResponse TestGetCustomerShippingAddress() return getResponse; } - // public ANetApiResponse TestGetCustomerProfileIds() - // { - // return GetCustomerProfileIds.run(apiLoginId, transactionKey); - // } - public ANetApiResponse TestGetCustomerProfile() { CreateCustomerProfileResponse response = (CreateCustomerProfileResponse)CreateCustomerProfile.run(apiLoginId, transactionKey, getEmail()); @@ -383,7 +377,7 @@ public ANetApiResponse TestVoidTransaction() public ANetApiResponse TestCreditBankAccount() { - return CreditBankAccount.run(apiLoginId, transactionKey, TransactionID); + return CreditBankAccount.run(apiLoginId, transactionKey, TransactionID, getAmount()); } public ANetApiResponse TestChargeCustomerProfile() From 42e76a2062a51ae447c2e554c2d8bd8f4c48293f Mon Sep 17 00:00:00 2001 From: srathod Date: Thu, 28 Jan 2016 15:40:07 +0530 Subject: [PATCH 038/176] - Added necessary constants in SampleCode.java. - Updated setAmount for BigDecimal initialization as suggested by rajeev. --- .../CreateCustomerProfileFromTransaction.java | 16 ++++- .../AuthorizeCreditCard.java | 3 +- ...eFundsAuthorizedThroughAnotherChannel.java | 16 ++++- .../PaymentTransactions/ChargeCreditCard.java | 16 ++++- .../ChargeCustomerProfile.java | 16 ++++- .../ChargeTokenizedCreditCard.java | 16 ++++- .../CreditBankAccount.java | 17 ++++- .../PaymentTransactions/DebitBankAccount.java | 17 ++++- .../AuthorizationAndCapture.java | 3 +- .../AuthorizationAndCaptureContinue.java | 4 +- .../AuthorizationOnly.java | 17 ++++- .../AuthorizationOnlyContinued.java | 16 ++++- .../RecurringBilling/CreateSubscription.java | 27 +++++--- .../java/net/authorize/sample/SampleCode.java | 64 +++++++++++-------- 14 files changed, 181 insertions(+), 67 deletions(-) diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfileFromTransaction.java b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfileFromTransaction.java index 0c2aed9f..58049354 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfileFromTransaction.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfileFromTransaction.java @@ -1,9 +1,19 @@ package net.authorize.sample.CustomerProfiles; -import net.authorize.Environment; -import net.authorize.api.contract.v1.*; import java.math.BigDecimal; +import java.math.RoundingMode; +import net.authorize.Environment; +import net.authorize.api.contract.v1.ANetApiResponse; +import net.authorize.api.contract.v1.CreateCustomerProfileFromTransactionRequest; +import net.authorize.api.contract.v1.CreateCustomerProfileResponse; +import net.authorize.api.contract.v1.CreateTransactionRequest; +import net.authorize.api.contract.v1.CreateTransactionResponse; +import net.authorize.api.contract.v1.CreditCardType; +import net.authorize.api.contract.v1.CustomerDataType; +import net.authorize.api.contract.v1.MerchantAuthenticationType; +import net.authorize.api.contract.v1.PaymentType; +import net.authorize.api.contract.v1.TransactionRequestType; import net.authorize.api.controller.CreateCustomerProfileFromTransactionController; import net.authorize.api.controller.CreateTransactionController; import net.authorize.api.controller.base.ApiOperationBase; @@ -29,7 +39,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub TransactionRequestType requestInternal = new TransactionRequestType(); requestInternal.setTransactionType("authOnlyTransaction"); requestInternal.setPayment(paymentType); - requestInternal.setAmount(new BigDecimal(amount.toString())); + requestInternal.setAmount(new BigDecimal(amount).setScale(2, RoundingMode.CEILING)); CustomerDataType customer = new CustomerDataType(); customer.setEmail(email); diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/AuthorizeCreditCard.java b/src/main/java/net/authorize/sample/PaymentTransactions/AuthorizeCreditCard.java index 6eaad727..b8ce7371 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/AuthorizeCreditCard.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/AuthorizeCreditCard.java @@ -1,6 +1,7 @@ package net.authorize.sample.PaymentTransactions; import java.math.BigDecimal; +import java.math.RoundingMode; import net.authorize.Environment; import net.authorize.api.contract.v1.*; @@ -35,7 +36,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub TransactionRequestType txnRequest = new TransactionRequestType(); txnRequest.setTransactionType(TransactionTypeEnum.AUTH_ONLY_TRANSACTION.value()); txnRequest.setPayment(paymentType); - txnRequest.setAmount(new BigDecimal(amount.toString())); + txnRequest.setAmount(new BigDecimal(amount).setScale(2, RoundingMode.CEILING)); // Make the API Request CreateTransactionRequest apiRequest = new CreateTransactionRequest(); diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/CaptureFundsAuthorizedThroughAnotherChannel.java b/src/main/java/net/authorize/sample/PaymentTransactions/CaptureFundsAuthorizedThroughAnotherChannel.java index 35a0c21b..580164fd 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/CaptureFundsAuthorizedThroughAnotherChannel.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/CaptureFundsAuthorizedThroughAnotherChannel.java @@ -1,11 +1,21 @@ package net.authorize.sample.PaymentTransactions; import java.math.BigDecimal; +import java.math.RoundingMode; import net.authorize.Environment; -import net.authorize.api.contract.v1.*; -import net.authorize.api.controller.base.ApiOperationBase; +import net.authorize.api.contract.v1.ANetApiResponse; +import net.authorize.api.contract.v1.CreateTransactionRequest; +import net.authorize.api.contract.v1.CreateTransactionResponse; +import net.authorize.api.contract.v1.CreditCardType; +import net.authorize.api.contract.v1.MerchantAuthenticationType; +import net.authorize.api.contract.v1.MessageTypeEnum; +import net.authorize.api.contract.v1.PaymentType; +import net.authorize.api.contract.v1.TransactionRequestType; +import net.authorize.api.contract.v1.TransactionResponse; +import net.authorize.api.contract.v1.TransactionTypeEnum; import net.authorize.api.controller.CreateTransactionController; +import net.authorize.api.controller.base.ApiOperationBase; public class CaptureFundsAuthorizedThroughAnotherChannel { @@ -33,7 +43,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub // Create the payment transaction request TransactionRequestType txnRequest = new TransactionRequestType(); txnRequest.setTransactionType(TransactionTypeEnum.CAPTURE_ONLY_TRANSACTION.value()); - txnRequest.setAmount(new BigDecimal(amount.toString())); + txnRequest.setAmount(new BigDecimal(amount).setScale(2, RoundingMode.CEILING)); txnRequest.setPayment(payment); txnRequest.setAuthCode("ROHNFQ"); diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCreditCard.java b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCreditCard.java index 18ce3918..31367402 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCreditCard.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCreditCard.java @@ -1,11 +1,21 @@ package net.authorize.sample.PaymentTransactions; import java.math.BigDecimal; +import java.math.RoundingMode; import net.authorize.Environment; -import net.authorize.api.contract.v1.*; -import net.authorize.api.controller.base.ApiOperationBase; +import net.authorize.api.contract.v1.ANetApiResponse; +import net.authorize.api.contract.v1.CreateTransactionRequest; +import net.authorize.api.contract.v1.CreateTransactionResponse; +import net.authorize.api.contract.v1.CreditCardType; +import net.authorize.api.contract.v1.MerchantAuthenticationType; +import net.authorize.api.contract.v1.MessageTypeEnum; +import net.authorize.api.contract.v1.PaymentType; +import net.authorize.api.contract.v1.TransactionRequestType; +import net.authorize.api.contract.v1.TransactionResponse; +import net.authorize.api.contract.v1.TransactionTypeEnum; import net.authorize.api.controller.CreateTransactionController; +import net.authorize.api.controller.base.ApiOperationBase; public class ChargeCreditCard { @@ -35,7 +45,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub TransactionRequestType txnRequest = new TransactionRequestType(); txnRequest.setTransactionType(TransactionTypeEnum.AUTH_CAPTURE_TRANSACTION.value()); txnRequest.setPayment(paymentType); - txnRequest.setAmount(new BigDecimal(amount.toString())); + txnRequest.setAmount(new BigDecimal(amount).setScale(2, RoundingMode.CEILING)); // Make the API Request CreateTransactionRequest apiRequest = new CreateTransactionRequest(); diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCustomerProfile.java b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCustomerProfile.java index 5ee87d07..60c20827 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCustomerProfile.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCustomerProfile.java @@ -1,11 +1,21 @@ package net.authorize.sample.PaymentTransactions; import java.math.BigDecimal; +import java.math.RoundingMode; import net.authorize.Environment; -import net.authorize.api.contract.v1.*; -import net.authorize.api.controller.base.ApiOperationBase; +import net.authorize.api.contract.v1.ANetApiResponse; +import net.authorize.api.contract.v1.CreateTransactionRequest; +import net.authorize.api.contract.v1.CreateTransactionResponse; +import net.authorize.api.contract.v1.CustomerProfilePaymentType; +import net.authorize.api.contract.v1.MerchantAuthenticationType; +import net.authorize.api.contract.v1.MessageTypeEnum; +import net.authorize.api.contract.v1.PaymentProfile; +import net.authorize.api.contract.v1.TransactionRequestType; +import net.authorize.api.contract.v1.TransactionResponse; +import net.authorize.api.contract.v1.TransactionTypeEnum; import net.authorize.api.controller.CreateTransactionController; +import net.authorize.api.controller.base.ApiOperationBase; public class ChargeCustomerProfile { @@ -37,7 +47,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri TransactionRequestType txnRequest = new TransactionRequestType(); txnRequest.setTransactionType(TransactionTypeEnum.AUTH_CAPTURE_TRANSACTION.value()); txnRequest.setProfile(profileToCharge); - txnRequest.setAmount(new BigDecimal(amount.toString())); + txnRequest.setAmount(new BigDecimal(amount).setScale(2, RoundingMode.CEILING)); CreateTransactionRequest apiRequest = new CreateTransactionRequest(); diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeTokenizedCreditCard.java b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeTokenizedCreditCard.java index ef2bb25d..4d9556c5 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeTokenizedCreditCard.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeTokenizedCreditCard.java @@ -1,11 +1,21 @@ package net.authorize.sample.PaymentTransactions; import java.math.BigDecimal; +import java.math.RoundingMode; import net.authorize.Environment; -import net.authorize.api.contract.v1.*; -import net.authorize.api.controller.base.ApiOperationBase; +import net.authorize.api.contract.v1.ANetApiResponse; +import net.authorize.api.contract.v1.CreateTransactionRequest; +import net.authorize.api.contract.v1.CreateTransactionResponse; +import net.authorize.api.contract.v1.CreditCardType; +import net.authorize.api.contract.v1.MerchantAuthenticationType; +import net.authorize.api.contract.v1.MessageTypeEnum; +import net.authorize.api.contract.v1.PaymentType; +import net.authorize.api.contract.v1.TransactionRequestType; +import net.authorize.api.contract.v1.TransactionResponse; +import net.authorize.api.contract.v1.TransactionTypeEnum; import net.authorize.api.controller.CreateTransactionController; +import net.authorize.api.controller.base.ApiOperationBase; public class ChargeTokenizedCreditCard { @@ -36,7 +46,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub TransactionRequestType txnRequest = new TransactionRequestType(); txnRequest.setTransactionType(TransactionTypeEnum.AUTH_CAPTURE_TRANSACTION.value()); txnRequest.setPayment(paymentType); - txnRequest.setAmount(new BigDecimal(amount.toString())); + txnRequest.setAmount(new BigDecimal(amount).setScale(2, RoundingMode.CEILING)); // Make the API Request CreateTransactionRequest apiRequest = new CreateTransactionRequest(); diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java b/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java index 35302ca8..a253cbcb 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java @@ -1,11 +1,22 @@ package net.authorize.sample.PaymentTransactions; import java.math.BigDecimal; +import java.math.RoundingMode; import net.authorize.Environment; -import net.authorize.api.contract.v1.*; -import net.authorize.api.controller.base.ApiOperationBase; +import net.authorize.api.contract.v1.ANetApiResponse; +import net.authorize.api.contract.v1.BankAccountType; +import net.authorize.api.contract.v1.BankAccountTypeEnum; +import net.authorize.api.contract.v1.CreateTransactionRequest; +import net.authorize.api.contract.v1.CreateTransactionResponse; +import net.authorize.api.contract.v1.MerchantAuthenticationType; +import net.authorize.api.contract.v1.MessageTypeEnum; +import net.authorize.api.contract.v1.PaymentType; +import net.authorize.api.contract.v1.TransactionRequestType; +import net.authorize.api.contract.v1.TransactionResponse; +import net.authorize.api.contract.v1.TransactionTypeEnum; import net.authorize.api.controller.CreateTransactionController; +import net.authorize.api.controller.base.ApiOperationBase; public class CreditBankAccount { @@ -38,7 +49,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri txnRequest.setTransactionType(TransactionTypeEnum.REFUND_TRANSACTION.value()); txnRequest.setRefTransId(transactionID); txnRequest.setPayment(paymentType); - txnRequest.setAmount(new BigDecimal(amount.toString())); + txnRequest.setAmount(new BigDecimal(amount).setScale(2, RoundingMode.CEILING)); // Make the API Request CreateTransactionRequest apiRequest = new CreateTransactionRequest(); diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java b/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java index c204056d..06756f3b 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java @@ -1,11 +1,22 @@ package net.authorize.sample.PaymentTransactions; import java.math.BigDecimal; +import java.math.RoundingMode; import net.authorize.Environment; -import net.authorize.api.contract.v1.*; -import net.authorize.api.controller.base.ApiOperationBase; +import net.authorize.api.contract.v1.ANetApiResponse; +import net.authorize.api.contract.v1.BankAccountType; +import net.authorize.api.contract.v1.BankAccountTypeEnum; +import net.authorize.api.contract.v1.CreateTransactionRequest; +import net.authorize.api.contract.v1.CreateTransactionResponse; +import net.authorize.api.contract.v1.MerchantAuthenticationType; +import net.authorize.api.contract.v1.MessageTypeEnum; +import net.authorize.api.contract.v1.PaymentType; +import net.authorize.api.contract.v1.TransactionRequestType; +import net.authorize.api.contract.v1.TransactionResponse; +import net.authorize.api.contract.v1.TransactionTypeEnum; import net.authorize.api.controller.CreateTransactionController; +import net.authorize.api.controller.base.ApiOperationBase; public class DebitBankAccount { @@ -37,7 +48,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub TransactionRequestType txnRequest = new TransactionRequestType(); txnRequest.setTransactionType(TransactionTypeEnum.AUTH_CAPTURE_TRANSACTION.value()); txnRequest.setPayment(paymentType); - txnRequest.setAmount(new BigDecimal(amount.toString())); + txnRequest.setAmount(new BigDecimal(amount).setScale(2, RoundingMode.CEILING)); // Make the API Request CreateTransactionRequest apiRequest = new CreateTransactionRequest(); diff --git a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCapture.java b/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCapture.java index 97d3d96b..12176f7e 100644 --- a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCapture.java +++ b/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCapture.java @@ -1,6 +1,7 @@ package net.authorize.sample.PaypalExpressCheckout; import java.math.BigDecimal; +import java.math.RoundingMode; import net.authorize.Environment; import net.authorize.api.contract.v1.ANetApiResponse; @@ -43,7 +44,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub transactionRequest.setTransactionType(TransactionTypeEnum.AUTH_CAPTURE_TRANSACTION.value()); transactionRequest.setPayment(paymentType); - transactionRequest.setAmount(new BigDecimal(amount.toString())); + transactionRequest.setAmount(new BigDecimal(amount).setScale(2, RoundingMode.CEILING)); // Make the API Request CreateTransactionRequest apiRequest = new CreateTransactionRequest(); diff --git a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCaptureContinue.java b/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCaptureContinue.java index 9e4ace29..58f321de 100644 --- a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCaptureContinue.java +++ b/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCaptureContinue.java @@ -1,9 +1,9 @@ package net.authorize.sample.PaypalExpressCheckout; import java.math.BigDecimal; +import java.math.RoundingMode; import net.authorize.Environment; -import net.authorize.TransactionType; import net.authorize.api.contract.v1.ANetApiResponse; import net.authorize.api.contract.v1.CreateTransactionRequest; import net.authorize.api.contract.v1.CreateTransactionResponse; @@ -48,7 +48,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri TransactionRequestType transactionRequest = new TransactionRequestType(); transactionRequest.setTransactionType(TransactionTypeEnum.AUTH_CAPTURE_CONTINUE_TRANSACTION.value().toString()); transactionRequest.setPayment(paymentType); - transactionRequest.setAmount(new BigDecimal(amount.toString())); + transactionRequest.setAmount(new BigDecimal(amount).setScale(2, RoundingMode.CEILING)); transactionRequest.setRefTransId(TransactionID); CreateTransactionRequest request = new CreateTransactionRequest(); diff --git a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationOnly.java b/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationOnly.java index 64965ad2..e97841e8 100644 --- a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationOnly.java +++ b/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationOnly.java @@ -1,10 +1,21 @@ package net.authorize.sample.PaypalExpressCheckout; import java.math.BigDecimal; +import java.math.RoundingMode; + import net.authorize.Environment; -import net.authorize.api.contract.v1.*; -import net.authorize.api.controller.base.ApiOperationBase; +import net.authorize.api.contract.v1.ANetApiResponse; +import net.authorize.api.contract.v1.CreateTransactionRequest; +import net.authorize.api.contract.v1.CreateTransactionResponse; +import net.authorize.api.contract.v1.MerchantAuthenticationType; +import net.authorize.api.contract.v1.MessageTypeEnum; +import net.authorize.api.contract.v1.MessagesType; +import net.authorize.api.contract.v1.PayPalType; +import net.authorize.api.contract.v1.PaymentType; +import net.authorize.api.contract.v1.TransactionRequestType; +import net.authorize.api.contract.v1.TransactionTypeEnum; import net.authorize.api.controller.CreateTransactionController; +import net.authorize.api.controller.base.ApiOperationBase; public class AuthorizationOnly { @@ -30,7 +41,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub TransactionRequestType transactionRequest = new TransactionRequestType(); transactionRequest.setTransactionType(TransactionTypeEnum.AUTH_ONLY_TRANSACTION.value()); transactionRequest.setPayment(paymentType); - transactionRequest.setAmount(new BigDecimal(amount.toString())); + transactionRequest.setAmount(new BigDecimal(amount).setScale(2, RoundingMode.CEILING)); CreateTransactionRequest request = new CreateTransactionRequest(); request.setTransactionRequest(transactionRequest); diff --git a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationOnlyContinued.java b/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationOnlyContinued.java index ff300193..9c9ba464 100644 --- a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationOnlyContinued.java +++ b/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationOnlyContinued.java @@ -1,11 +1,21 @@ package net.authorize.sample.PaypalExpressCheckout; import java.math.BigDecimal; +import java.math.RoundingMode; import net.authorize.Environment; -import net.authorize.api.contract.v1.*; -import net.authorize.api.controller.base.ApiOperationBase; +import net.authorize.api.contract.v1.ANetApiResponse; +import net.authorize.api.contract.v1.CreateTransactionRequest; +import net.authorize.api.contract.v1.CreateTransactionResponse; +import net.authorize.api.contract.v1.MerchantAuthenticationType; +import net.authorize.api.contract.v1.MessageTypeEnum; +import net.authorize.api.contract.v1.PayPalType; +import net.authorize.api.contract.v1.PaymentType; +import net.authorize.api.contract.v1.TransactionRequestType; +import net.authorize.api.contract.v1.TransactionResponse; +import net.authorize.api.contract.v1.TransactionTypeEnum; import net.authorize.api.controller.CreateTransactionController; +import net.authorize.api.controller.base.ApiOperationBase; public class AuthorizationOnlyContinued { @@ -34,7 +44,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri TransactionRequestType txnRequest = new TransactionRequestType(); txnRequest.setTransactionType(TransactionTypeEnum.AUTH_ONLY_CONTINUE_TRANSACTION.value()); txnRequest.setPayment(paymentType); - txnRequest.setAmount(new BigDecimal(amount.toString())); + txnRequest.setAmount(new BigDecimal(amount).setScale(2, RoundingMode.CEILING)); txnRequest.setRefTransId(transactionId); // Make the API Request diff --git a/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscription.java b/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscription.java index 1f928ce5..19d58ade 100644 --- a/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscription.java +++ b/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscription.java @@ -1,14 +1,25 @@ package net.authorize.sample.RecurringBilling; -import net.authorize.data.arb.*; import java.math.BigDecimal; +import java.math.RoundingMode; + +import javax.xml.datatype.DatatypeFactory; +import javax.xml.datatype.XMLGregorianCalendar; + import net.authorize.Environment; -import net.authorize.data.Customer; -import net.authorize.api.contract.v1.*; -import net.authorize.api.controller.base.ApiOperationBase; +import net.authorize.api.contract.v1.ANetApiResponse; +import net.authorize.api.contract.v1.ARBCreateSubscriptionRequest; +import net.authorize.api.contract.v1.ARBCreateSubscriptionResponse; +import net.authorize.api.contract.v1.ARBSubscriptionType; +import net.authorize.api.contract.v1.ARBSubscriptionUnitEnum; +import net.authorize.api.contract.v1.CreditCardType; +import net.authorize.api.contract.v1.MerchantAuthenticationType; +import net.authorize.api.contract.v1.MessageTypeEnum; +import net.authorize.api.contract.v1.NameAndAddressType; +import net.authorize.api.contract.v1.PaymentScheduleType; +import net.authorize.api.contract.v1.PaymentType; import net.authorize.api.controller.ARBCreateSubscriptionController; -import javax.xml.datatype.*; -import java.lang.Exception.*; +import net.authorize.api.controller.base.ApiOperationBase; public class CreateSubscription { @@ -50,8 +61,8 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, shor ARBSubscriptionType arbSubscriptionType = new ARBSubscriptionType(); arbSubscriptionType.setPaymentSchedule(schedule); - arbSubscriptionType.setAmount(new BigDecimal(amount.toString())); - arbSubscriptionType.setTrialAmount(new BigDecimal("0.00")); + arbSubscriptionType.setAmount(new BigDecimal(amount).setScale(2, RoundingMode.CEILING)); + arbSubscriptionType.setTrialAmount(new BigDecimal(1.23).setScale(2, RoundingMode.CEILING)); arbSubscriptionType.setPayment(paymentType); NameAndAddressType name = new NameAndAddressType(); diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index 2b53d7d5..8a7fcbf2 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -136,7 +136,15 @@ private static void RunMethod(String methodName) //Update the transactionId with which you want to run the sample code String transactionId = "123456"; - Double amount = 123.45; + String customerProfileId = "36731856"; + String customerPaymentProfileId = "33211899"; + String customerAddressId = "123"; + + String emailId = "test@test.com"; + + String subscriptionId = "2930242"; + + Double amount = 123.45; switch (methodName) { case "DecryptVisaCheckoutData": @@ -158,43 +166,43 @@ private static void RunMethod(String methodName) RefundTransaction.run(apiLoginId, transactionKey , amount, transactionId); break; case "CreateCustomerProfileFromTransaction": - CreateCustomerProfileFromTransaction.run(apiLoginId, transactionKey, 12.34, "test@test.com"); + CreateCustomerProfileFromTransaction.run(apiLoginId, transactionKey, amount, emailId); break; case "CaptureFundsAuthorizedThroughAnotherChannel": - CaptureFundsAuthorizedThroughAnotherChannel.run(apiLoginId, transactionKey, 12.34); + CaptureFundsAuthorizedThroughAnotherChannel.run(apiLoginId, transactionKey, amount); break; case "CapturePreviouslyAuthorizedAmount": CapturePreviouslyAuthorizedAmount.run(apiLoginId, transactionKey, transactionId); break; case "DebitBankAccount": - DebitBankAccount.run(apiLoginId, transactionKey, 12.93); + DebitBankAccount.run(apiLoginId, transactionKey, amount); break; case "CreditBankAccount": - CreditBankAccount.run(apiLoginId, transactionKey, transactionId, 12.23); + CreditBankAccount.run(apiLoginId, transactionKey, transactionId, amount); break; case "ChargeTokenizedCreditCard": - ChargeTokenizedCreditCard.run(apiLoginId, transactionKey, 12.89); + ChargeTokenizedCreditCard.run(apiLoginId, transactionKey, amount); break; case "CreateAnApplePayTransaction": CreateAnApplePayTransaction.run(apiLoginId, transactionKey); break; case "ChargeCustomerProfile": - ChargeCustomerProfile.run(apiLoginId, transactionKey, "36731856", "33211899" , 10.23); + ChargeCustomerProfile.run(apiLoginId, transactionKey, customerProfileId, customerPaymentProfileId, amount); break; case "CreateSubscription": - CreateSubscription.run(apiLoginId, transactionKey, (short)12, 10.21); + CreateSubscription.run(apiLoginId, transactionKey, (short)12, amount); break; case "GetSubscription": - GetSubscription.run(apiLoginId, transactionKey, "2930242"); + GetSubscription.run(apiLoginId, transactionKey, subscriptionId); break; case "GetSubscriptionStatus": - GetSubscriptionStatus.run(apiLoginId, transactionKey, "100748"); + GetSubscriptionStatus.run(apiLoginId, transactionKey, subscriptionId); break; case "CancelSubscription": - CancelSubscription.run(apiLoginId, transactionKey, "100748"); + CancelSubscription.run(apiLoginId, transactionKey, subscriptionId); break; case "UpdateSubscription": - UpdateSubscription.run(apiLoginId, transactionKey, "100748"); + UpdateSubscription.run(apiLoginId, transactionKey, subscriptionId); break; case "GetListOfSubscriptions": GetListOfSubscriptions.run(apiLoginId, transactionKey); @@ -215,49 +223,49 @@ private static void RunMethod(String methodName) GetTransactionDetails.run(apiLoginId, transactionKey, transactionId); break; case "CreateCustomerProfile": - CreateCustomerProfile.run(apiLoginId, transactionKey, "test@te.com"); + CreateCustomerProfile.run(apiLoginId, transactionKey, emailId); break; case "CreateCustomerPaymentProfile": - CreateCustomerPaymentProfile.run(apiLoginId, transactionKey, "38854744"); + CreateCustomerPaymentProfile.run(apiLoginId, transactionKey, customerProfileId); break; case "CreateCustomerShippingAddress": - CreateCustomerShippingAddress.run(apiLoginId, transactionKey, "10000"); + CreateCustomerShippingAddress.run(apiLoginId, transactionKey, customerProfileId); break; case "DeleteCustomerPaymentProfile": - DeleteCustomerPaymentProfile.run(apiLoginId, transactionKey, "10000", "20000"); + DeleteCustomerPaymentProfile.run(apiLoginId, transactionKey, customerProfileId, customerPaymentProfileId); break; case "DeleteCustomerProfile": - DeleteCustomerProfile.run(apiLoginId, transactionKey, "10000"); + DeleteCustomerProfile.run(apiLoginId, transactionKey, customerProfileId); break; case "DeleteCustomerShippingAddress": - DeleteCustomerShippingAddress.run(apiLoginId, transactionKey, "10000", "30000"); + DeleteCustomerShippingAddress.run(apiLoginId, transactionKey, customerProfileId, customerAddressId); break; case "GetCustomerPaymentProfile": - GetCustomerPaymentProfile.run(apiLoginId, transactionKey, "10000", "20000"); + GetCustomerPaymentProfile.run(apiLoginId, transactionKey, customerProfileId, customerPaymentProfileId); break; case "GetCustomerPaymentProfileList": GetCustomerPaymentProfileList.run(apiLoginId, transactionKey); break; case "GetCustomerProfile": - GetCustomerProfile.run(apiLoginId, transactionKey, "10000"); + GetCustomerProfile.run(apiLoginId, transactionKey, customerProfileId); break; case "GetCustomerProfileIds": GetCustomerProfileIds.run(apiLoginId, transactionKey); break; case "GetCustomerShippingAddress": - GetCustomerShippingAddress.run(apiLoginId, transactionKey, "10000", "30000"); + GetCustomerShippingAddress.run(apiLoginId, transactionKey, customerProfileId, customerAddressId); break; case "GetHostedProfilePage": - GetHostedProfilePage.run(apiLoginId, transactionKey, "10000"); + GetHostedProfilePage.run(apiLoginId, transactionKey, customerProfileId); break; case "UpdateCustomerPaymentProfile": - UpdateCustomerPaymentProfile.run(apiLoginId, transactionKey, "10000", "20000"); + UpdateCustomerPaymentProfile.run(apiLoginId, transactionKey, customerProfileId, customerPaymentProfileId); break; case "UpdateCustomerShippingAddress": - UpdateCustomerShippingAddress.run(apiLoginId, transactionKey, "10000", "30000"); + UpdateCustomerShippingAddress.run(apiLoginId, transactionKey, customerProfileId, customerAddressId); break; case "ValidateCustomerPaymentProfile": - ValidateCustomerPaymentProfile.run(apiLoginId, transactionKey, "10000", "20000"); + ValidateCustomerPaymentProfile.run(apiLoginId, transactionKey, customerProfileId, customerPaymentProfileId); break; case "PayPalAuthorizeCapture": AuthorizationAndCapture.run(apiLoginId, transactionKey, amount); @@ -266,13 +274,13 @@ private static void RunMethod(String methodName) Void.run(apiLoginId, transactionKey, transactionId); break; case "PayPalAuthorizationOnly": - AuthorizationOnly.run(apiLoginId, transactionKey, 12.23); + AuthorizationOnly.run(apiLoginId, transactionKey, amount); break; case "PayPalAuthorizeCaptureContinue": - AuthorizationAndCaptureContinue.run(apiLoginId, transactionKey, "2248647898", payerId, 12.12); + AuthorizationAndCaptureContinue.run(apiLoginId, transactionKey, transactionId, payerId, amount); break; case "PayPalAuthorizeOnlyContinue": - AuthorizationOnlyContinued.run(apiLoginId, transactionKey, transactionId, payerId, 34.56); + AuthorizationOnlyContinued.run(apiLoginId, transactionKey, transactionId, payerId, amount); break; case "PayPalCredit": Credit.run(apiLoginId, transactionKey, transactionId); From 9e9e96357af3de1c346341af74402653ff18bb47 Mon Sep 17 00:00:00 2001 From: akankari Date: Thu, 10 Mar 2016 15:43:59 +0530 Subject: [PATCH 039/176] Adding new sample code for CreateSubscriptionFromCustomerProfile. Adding corresponding tests in test runner. Updated Sample code to pass CustomerProfileBaseType object in CreateCustomerProfileFromTransaction. To be reviewed by Sunny --- .../CreateCustomerProfileFromTransaction.java | 12 +++ ...CreateSubscriptionFromCustomerProfile.java | 85 +++++++++++++++++++ .../java/net/authorize/sample/SampleCode.java | 4 + .../sample/SampleCodeTest/SampleCodeList.txt | 1 + .../sample/SampleCodeTest/TestRunner.java | 19 +++++ 5 files changed, 121 insertions(+) create mode 100644 src/main/java/net/authorize/sample/RecurringBilling/CreateSubscriptionFromCustomerProfile.java diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfileFromTransaction.java b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfileFromTransaction.java index 58049354..97fc3f22 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfileFromTransaction.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfileFromTransaction.java @@ -11,6 +11,7 @@ import net.authorize.api.contract.v1.CreateTransactionResponse; import net.authorize.api.contract.v1.CreditCardType; import net.authorize.api.contract.v1.CustomerDataType; +import net.authorize.api.contract.v1.CustomerProfileBaseType; import net.authorize.api.contract.v1.MerchantAuthenticationType; import net.authorize.api.contract.v1.PaymentType; import net.authorize.api.contract.v1.TransactionRequestType; @@ -53,8 +54,19 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub CreateTransactionResponse response = controller.getApiResponse(); + CustomerProfileBaseType customerProfile = new CustomerProfileBaseType(); + customerProfile.setMerchantCustomerId("123213"); + customerProfile.setEmail("johnsnow@castleblack.com"); + customerProfile.setDescription("This is a sample customer profile"); + CreateCustomerProfileFromTransactionRequest transaction_request = new CreateCustomerProfileFromTransactionRequest(); transaction_request.setTransId(response.getTransactionResponse().getTransId()); + // You can either specify the customer information in form of customerProfileBaseType object + transaction_request.setCustomer(customerProfile); + // OR + // You can just provide the customer Profile ID + // transaction_request.setCustomerProfileId("1232132"); + CreateCustomerProfileFromTransactionController createProfileController = new CreateCustomerProfileFromTransactionController(transaction_request); createProfileController.execute(); CreateCustomerProfileResponse customer_response = createProfileController.getApiResponse(); diff --git a/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscriptionFromCustomerProfile.java b/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscriptionFromCustomerProfile.java new file mode 100644 index 00000000..136f01a8 --- /dev/null +++ b/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscriptionFromCustomerProfile.java @@ -0,0 +1,85 @@ +package net.authorize.sample.RecurringBilling; + +import java.math.BigDecimal; + +import javax.xml.datatype.DatatypeFactory; +import javax.xml.datatype.XMLGregorianCalendar; + +import net.authorize.Environment; +import net.authorize.api.contract.v1.ANetApiResponse; +import net.authorize.api.contract.v1.ARBCreateSubscriptionRequest; +import net.authorize.api.contract.v1.ARBCreateSubscriptionResponse; +import net.authorize.api.contract.v1.ARBSubscriptionType; +import net.authorize.api.contract.v1.ARBSubscriptionUnitEnum; +import net.authorize.api.contract.v1.CustomerProfileIdType; +import net.authorize.api.contract.v1.MerchantAuthenticationType; +import net.authorize.api.contract.v1.MessageTypeEnum; +import net.authorize.api.contract.v1.PaymentScheduleType; +import net.authorize.api.controller.ARBCreateSubscriptionController; +import net.authorize.api.controller.base.ApiOperationBase; + +public class CreateSubscriptionFromCustomerProfile { + + public static ANetApiResponse run(String apiLoginId, String transactionKey, short intervalLength, Double amount, + String profileId, String paymentProfileId, String customerAddressId) { + //Common code to set for all requests + ApiOperationBase.setEnvironment(Environment.SANDBOX); + MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; + merchantAuthenticationType.setName(apiLoginId); + merchantAuthenticationType.setTransactionKey(transactionKey); + ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); + + // Set up payment schedule + PaymentScheduleType schedule = new PaymentScheduleType(); + PaymentScheduleType.Interval interval = new PaymentScheduleType.Interval(); + interval.setLength(intervalLength); + interval.setUnit(ARBSubscriptionUnitEnum.DAYS); + schedule.setInterval(interval); + + try { + XMLGregorianCalendar startDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(); + startDate.setDay(30); + startDate.setMonth(8); + startDate.setYear(2020); + schedule.setStartDate(startDate); //2020-08-30 + } + catch(Exception e) { } + + schedule.setTotalOccurrences((short)12); + schedule.setTrialOccurrences((short)1); + + CustomerProfileIdType profile = new CustomerProfileIdType(); + profile.setCustomerProfileId(profileId); + profile.setCustomerPaymentProfileId(paymentProfileId); + profile.setCustomerAddressId(customerAddressId); + + ARBSubscriptionType arbSubscriptionType = new ARBSubscriptionType(); + arbSubscriptionType.setPaymentSchedule(schedule); + arbSubscriptionType.setAmount(new BigDecimal("10.29")); + arbSubscriptionType.setTrialAmount(new BigDecimal("0.00")); + arbSubscriptionType.setProfile(profile); + + // Make the API Request + ARBCreateSubscriptionRequest apiRequest = new ARBCreateSubscriptionRequest(); + apiRequest.setSubscription(arbSubscriptionType); + ARBCreateSubscriptionController controller = new ARBCreateSubscriptionController(apiRequest); + controller.execute(); + ARBCreateSubscriptionResponse response = controller.getApiResponse(); + if (response!=null) { + + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + + System.out.println(response.getSubscriptionId()); + System.out.println(response.getMessages().getMessage().get(0).getCode()); + System.out.println(response.getMessages().getMessage().get(0).getText()); + } + else + { + System.out.println("Failed to create Subscription: " + response.getMessages().getResultCode()); + System.out.println(response.getMessages().getMessage().get(0).getText()); + } + } + + return response; + } +} \ No newline at end of file diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index 8a7fcbf2..c9a5a058 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -89,6 +89,7 @@ private static void ShowMethods() System.out.println(" CreateAnApplePayTransaction"); System.out.println(" ChargeCustomerProfile"); System.out.println(" CreateSubscription"); + System.out.println(" CreateSubscriptionFromCustomerProfile"); System.out.println(" GetSubscription"); System.out.println(" GetSubscriptionStatus"); System.out.println(" CancelSubscription"); @@ -192,6 +193,9 @@ private static void RunMethod(String methodName) case "CreateSubscription": CreateSubscription.run(apiLoginId, transactionKey, (short)12, amount); break; + case "CreateSubscriptionFromCustomerProfile": + CreateSubscriptionFromCustomerProfile.run(apiLoginId, transactionKey, (short)12, amount, "123212", "123213", "123213"); + break; case "GetSubscription": GetSubscription.run(apiLoginId, transactionKey, subscriptionId); break; diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt b/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt index 94aea5ff..3ff1927c 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt +++ b/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt @@ -1,5 +1,6 @@ SampleCode IsDependent RunApi RecurringBilling.CreateSubscription 1 1 +RecurringBilling.CreateSubscriptionFromCustomerProfile 1 1 RecurringBilling.GetListOfSubscriptions 0 1 RecurringBilling.CancelSubscription 1 1 RecurringBilling.GetSubscriptionStatus 1 1 diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java index 89b83f52..956816dc 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java +++ b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java @@ -66,6 +66,7 @@ import net.authorize.sample.PaypalExpressCheckout.PriorAuthorizationCapture; import net.authorize.sample.RecurringBilling.CancelSubscription; import net.authorize.sample.RecurringBilling.CreateSubscription; +import net.authorize.sample.RecurringBilling.CreateSubscriptionFromCustomerProfile; import net.authorize.sample.RecurringBilling.GetSubscription; import net.authorize.sample.RecurringBilling.GetSubscriptionStatus; import net.authorize.sample.RecurringBilling.UpdateSubscription; @@ -449,6 +450,24 @@ public ANetApiResponse TestCreateSubscription() return response; } + + public ANetApiResponse TestCreateSubscriptionFromCustomerProfile() + { + CreateCustomerProfileResponse profileResponse = (CreateCustomerProfileResponse)CreateCustomerProfile.run(apiLoginId, transactionKey, getEmail()); + CreateCustomerPaymentProfileResponse paymentResponse = (CreateCustomerPaymentProfileResponse) CreateCustomerPaymentProfile. + run(apiLoginId, transactionKey, profileResponse.getCustomerProfileId()); + + CreateCustomerShippingAddressResponse shippingResponse = (CreateCustomerShippingAddressResponse)CreateCustomerShippingAddress. + run(apiLoginId, transactionKey, profileResponse.getCustomerProfileId()); + + ARBCreateSubscriptionResponse response = (ARBCreateSubscriptionResponse) CreateSubscriptionFromCustomerProfile.run(apiLoginId, transactionKey, getDays(), getAmount(), profileResponse.getCustomerProfileId(), + paymentResponse.getCustomerPaymentProfileId(), shippingResponse.getCustomerAddressId()); + + CancelSubscription.run(apiLoginId, transactionKey, response.getSubscriptionId()); + DeleteCustomerProfile.run(apiLoginId, transactionKey, profileResponse.getCustomerProfileId()); + + return response; + } public ANetApiResponse TestGetSubscriptionStatus() { From 1b9d0f82f523c8e21b222af8f1c78aa2262153b4 Mon Sep 17 00:00:00 2001 From: srathod Date: Thu, 17 Mar 2016 11:13:29 +0530 Subject: [PATCH 040/176] - Updated pom.xml to add sdkVersion property. This has been added so that sample-code-java travis build can work individually using latest jar from remote maven repository and also run from sdk-java travis using the latest built sdk jar. - Minor fixes in sample codes mostly for null checks. --- pom.xml | 5 +- .../CustomerProfiles/GetCustomerProfile.java | 52 +++++++++++-------- .../AuthorizationAndCaptureContinue.java | 31 ++++++----- .../PaypalExpressCheckout/GetDetails.java | 15 ++++-- ...CreateSubscriptionFromCustomerProfile.java | 5 +- .../sample/SampleCodeTest/TestRunner.java | 8 ++- 6 files changed, 71 insertions(+), 45 deletions(-) diff --git a/pom.xml b/pom.xml index 05df367b..ca578120 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,8 @@ + + 1.8.8 + 4.0.0 net.authorize.sample SampleCode @@ -11,7 +14,7 @@ net.authorize anet-java-sdk - 1.8.6 + ${sdkVersion} junit diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerProfile.java b/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerProfile.java index 34961d7b..9136c93a 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerProfile.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerProfile.java @@ -40,32 +40,38 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri System.out.println(response.getProfile().getEmail()); System.out.println(response.getProfile().getCustomerProfileId()); - System.out.println(response.getProfile().getPaymentProfiles().get(0).getBillTo().getFirstName()); - System.out.println(response.getProfile().getPaymentProfiles().get(0).getBillTo().getLastName()); - System.out.println(response.getProfile().getPaymentProfiles().get(0).getBillTo().getCompany()); - System.out.println(response.getProfile().getPaymentProfiles().get(0).getBillTo().getAddress()); - System.out.println(response.getProfile().getPaymentProfiles().get(0).getBillTo().getCity()); - System.out.println(response.getProfile().getPaymentProfiles().get(0).getBillTo().getState()); - System.out.println(response.getProfile().getPaymentProfiles().get(0).getBillTo().getZip()); - System.out.println(response.getProfile().getPaymentProfiles().get(0).getBillTo().getCountry()); - System.out.println(response.getProfile().getPaymentProfiles().get(0).getBillTo().getPhoneNumber()); - System.out.println(response.getProfile().getPaymentProfiles().get(0).getBillTo().getFaxNumber()); + if((!response.getProfile().getPaymentProfiles().isEmpty()) && + (response.getProfile().getPaymentProfiles().get(0).getBillTo() != null)){ + System.out.println(response.getProfile().getPaymentProfiles().get(0).getBillTo().getFirstName()); + System.out.println(response.getProfile().getPaymentProfiles().get(0).getBillTo().getLastName()); + System.out.println(response.getProfile().getPaymentProfiles().get(0).getBillTo().getCompany()); + System.out.println(response.getProfile().getPaymentProfiles().get(0).getBillTo().getAddress()); + System.out.println(response.getProfile().getPaymentProfiles().get(0).getBillTo().getCity()); + System.out.println(response.getProfile().getPaymentProfiles().get(0).getBillTo().getState()); + System.out.println(response.getProfile().getPaymentProfiles().get(0).getBillTo().getZip()); + System.out.println(response.getProfile().getPaymentProfiles().get(0).getBillTo().getCountry()); + System.out.println(response.getProfile().getPaymentProfiles().get(0).getBillTo().getPhoneNumber()); + System.out.println(response.getProfile().getPaymentProfiles().get(0).getBillTo().getFaxNumber()); - System.out.println(response.getProfile().getPaymentProfiles().get(0).getCustomerPaymentProfileId()); + System.out.println(response.getProfile().getPaymentProfiles().get(0).getCustomerPaymentProfileId()); - System.out.println(response.getProfile().getPaymentProfiles().get(0).getPayment().getCreditCard().getCardNumber()); - System.out.println(response.getProfile().getPaymentProfiles().get(0).getPayment().getCreditCard().getExpirationDate()); + System.out.println(response.getProfile().getPaymentProfiles().get(0).getPayment().getCreditCard().getCardNumber()); + System.out.println(response.getProfile().getPaymentProfiles().get(0).getPayment().getCreditCard().getExpirationDate()); + } + + if(!response.getProfile().getShipToList().isEmpty()){ + System.out.println(response.getProfile().getShipToList().get(0).getFirstName()); + System.out.println(response.getProfile().getShipToList().get(0).getLastName()); + System.out.println(response.getProfile().getShipToList().get(0).getCompany()); + System.out.println(response.getProfile().getShipToList().get(0).getAddress()); + System.out.println(response.getProfile().getShipToList().get(0).getCity()); + System.out.println(response.getProfile().getShipToList().get(0).getState()); + System.out.println(response.getProfile().getShipToList().get(0).getZip()); + System.out.println(response.getProfile().getShipToList().get(0).getCountry()); + System.out.println(response.getProfile().getShipToList().get(0).getPhoneNumber()); + System.out.println(response.getProfile().getShipToList().get(0).getFaxNumber()); + } - System.out.println(response.getProfile().getShipToList().get(0).getFirstName()); - System.out.println(response.getProfile().getShipToList().get(0).getLastName()); - System.out.println(response.getProfile().getShipToList().get(0).getCompany()); - System.out.println(response.getProfile().getShipToList().get(0).getAddress()); - System.out.println(response.getProfile().getShipToList().get(0).getCity()); - System.out.println(response.getProfile().getShipToList().get(0).getState()); - System.out.println(response.getProfile().getShipToList().get(0).getZip()); - System.out.println(response.getProfile().getShipToList().get(0).getCountry()); - System.out.println(response.getProfile().getShipToList().get(0).getPhoneNumber()); - System.out.println(response.getProfile().getShipToList().get(0).getFaxNumber()); } else { diff --git a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCaptureContinue.java b/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCaptureContinue.java index 58f321de..b0d067ad 100644 --- a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCaptureContinue.java +++ b/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCaptureContinue.java @@ -61,20 +61,25 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri // get the response from the service (errors contained if any) CreateTransactionResponse response = controller.getApiResponse(); - //validate - if(response.getMessages().getResultCode() == MessageTypeEnum.OK){ - if(response.getTransactionResponse() != null){ - if(!response.getTransactionResponse().getMessages().getMessage().isEmpty()) - System.out.println("Success, \nMessage : "+response.getTransactionResponse().getMessages().getMessage().get(0).getDescription() ); - // Get Auth Code By : response.getTransactionResponse().getAuthCode() - } + //validate + if(response != null){ + if(response.getMessages().getResultCode() == MessageTypeEnum.OK){ + if(response.getTransactionResponse() != null){ + if((response.getTransactionResponse().getMessages() != null) && + (!response.getTransactionResponse().getMessages().getMessage().isEmpty())) { + System.out.println("Success, \nMessage : "+response.getTransactionResponse().getMessages().getMessage().get(0).getDescription() ); + // Get Auth Code By : response.getTransactionResponse().getAuthCode() + } + } + } + else { + System.out.println("Error: " + response.getMessages().getMessage().get(0).getCode()+ " " + response.getMessages().getMessage().get(0).getText() ); + if(response.getTransactionResponse() != null){ + System.out.println("Transaction Error : "+ response.getTransactionResponse().getErrors().getError().get(0).getErrorCode() + " " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + } } - else { - System.out.println("Error: " + response.getMessages().getMessage().get(0).getCode()+ " " + response.getMessages().getMessage().get(0).getText() ); - if(response.getTransactionResponse() != null){ - System.out.println("Transaction Error : "+ response.getTransactionResponse().getErrors().getError().get(0).getErrorCode() + " " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); - } - } + return response; } } diff --git a/src/main/java/net/authorize/sample/PaypalExpressCheckout/GetDetails.java b/src/main/java/net/authorize/sample/PaypalExpressCheckout/GetDetails.java index 2f21e778..3db99653 100644 --- a/src/main/java/net/authorize/sample/PaypalExpressCheckout/GetDetails.java +++ b/src/main/java/net/authorize/sample/PaypalExpressCheckout/GetDetails.java @@ -42,11 +42,16 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri if (result.getResponseCode().equals("1")) { System.out.println("Successful PayPal Get Details Transaction"); System.out.println("Account Type : "+ result.getAccountType()); - System.out.println("PayPal PayerID : "+ result.getSecureAcceptance().getPayerID()); - System.out.println("Shipping Address : "+ result.getShipTo().getFirstName()); - System.out.println(result.getShipTo().getAddress() +" " + result.getShipTo().getCity()); - System.out.println(result.getShipTo().getState() +" "+ result.getShipTo().getZip()); - System.out.println(result.getShipTo().getCountry()); + if(result.getSecureAcceptance() != null) + System.out.println("PayPal PayerID : "+ result.getSecureAcceptance().getPayerID()); + + if(result.getShipTo() != null) { + System.out.println("Shipping Address : "+ result.getShipTo().getFirstName()); + System.out.println(result.getShipTo().getAddress() +" " + result.getShipTo().getCity()); + System.out.println(result.getShipTo().getState() +" "+ result.getShipTo().getZip()); + System.out.println(result.getShipTo().getCountry()); + } + System.out.println("Transaction ID : " + result.getTransId()); } } diff --git a/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscriptionFromCustomerProfile.java b/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscriptionFromCustomerProfile.java index 136f01a8..023724a5 100644 --- a/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscriptionFromCustomerProfile.java +++ b/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscriptionFromCustomerProfile.java @@ -1,6 +1,7 @@ package net.authorize.sample.RecurringBilling; import java.math.BigDecimal; +import java.math.RoundingMode; import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.XMLGregorianCalendar; @@ -55,8 +56,8 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, shor ARBSubscriptionType arbSubscriptionType = new ARBSubscriptionType(); arbSubscriptionType.setPaymentSchedule(schedule); - arbSubscriptionType.setAmount(new BigDecimal("10.29")); - arbSubscriptionType.setTrialAmount(new BigDecimal("0.00")); + arbSubscriptionType.setAmount(new BigDecimal(amount).setScale(2, RoundingMode.CEILING)); + arbSubscriptionType.setTrialAmount(new BigDecimal(0.0).setScale(2, RoundingMode.CEILING)); arbSubscriptionType.setProfile(profile); // Make the API Request diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java index 956816dc..8c424bcd 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java +++ b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java @@ -6,6 +6,8 @@ import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.security.SecureRandom; import java.text.DecimalFormat; @@ -131,10 +133,12 @@ public void TestAllSampleCodes() if (!shouldApiRun.equals("1")) continue; + ANetApiResponse response = null; + try { cnt++; - ANetApiResponse response = null; + if (isDependent.equals("0")) { response = InvokeRunMethod(apiName); @@ -155,6 +159,8 @@ public void TestAllSampleCodes() { System.out.println("Exception in " + apiName + " " + e.toString()); System.out.println(e.getMessage()); + Assert.assertNotNull(response); + Assert.assertEquals(response.getMessages().getResultCode(), MessageTypeEnum.OK); } } } catch (IOException e) { From 18843b64c070dcd88e46b6d8eb338f9d61aa177e Mon Sep 17 00:00:00 2001 From: srathod Date: Mon, 21 Mar 2016 14:06:32 +0530 Subject: [PATCH 041/176] - Updating UpdateSubscription sample code for profile information. - Added prints to subscriptionids in GetCustomerProfile, GetCustomerPaymentProfile and GetCustomerShippingAddress. --- .../CustomerProfiles/GetCustomerPaymentProfile.java | 7 +++++++ .../sample/CustomerProfiles/GetCustomerProfile.java | 7 +++++++ .../CustomerProfiles/GetCustomerShippingAddress.java | 7 +++++++ .../sample/RecurringBilling/UpdateSubscription.java | 8 ++++++++ 4 files changed, 29 insertions(+) diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerPaymentProfile.java b/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerPaymentProfile.java index 57e7f5bb..b8627b2e 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerPaymentProfile.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerPaymentProfile.java @@ -52,6 +52,13 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri System.out.println(response.getPaymentProfile().getPayment().getCreditCard().getCardNumber()); System.out.println(response.getPaymentProfile().getPayment().getCreditCard().getExpirationDate()); + + if((response.getPaymentProfile().getSubscriptionIds() != null) && (response.getPaymentProfile().getSubscriptionIds().getSubscriptionId() != null) && + (!response.getPaymentProfile().getSubscriptionIds().getSubscriptionId().isEmpty())){ + System.out.println("List of subscriptions:"); + for(String subscriptionid : response.getPaymentProfile().getSubscriptionIds().getSubscriptionId()) + System.out.println(subscriptionid); + } } else { diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerProfile.java b/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerProfile.java index 9136c93a..033e3865 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerProfile.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerProfile.java @@ -71,6 +71,13 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri System.out.println(response.getProfile().getShipToList().get(0).getPhoneNumber()); System.out.println(response.getProfile().getShipToList().get(0).getFaxNumber()); } + + if((response.getSubscriptionIds() != null) && (response.getSubscriptionIds().getSubscriptionId() != null) && + (!response.getSubscriptionIds().getSubscriptionId().isEmpty())){ + System.out.println("List of subscriptions:"); + for(String subscriptionid : response.getSubscriptionIds().getSubscriptionId()) + System.out.println(subscriptionid); + } } else diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerShippingAddress.java b/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerShippingAddress.java index 39b33be4..8b245436 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerShippingAddress.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerShippingAddress.java @@ -49,6 +49,13 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri System.out.println(response.getAddress().getFaxNumber()); System.out.println(response.getAddress().getCustomerAddressId()); + + if((response.getSubscriptionIds() != null) && (response.getSubscriptionIds().getSubscriptionId() != null) && + (!response.getSubscriptionIds().getSubscriptionId().isEmpty())){ + System.out.println("List of subscriptions:"); + for(String subscriptionid : response.getSubscriptionIds().getSubscriptionId()) + System.out.println(subscriptionid); + } } else { diff --git a/src/main/java/net/authorize/sample/RecurringBilling/UpdateSubscription.java b/src/main/java/net/authorize/sample/RecurringBilling/UpdateSubscription.java index 98f49a69..04e0c127 100644 --- a/src/main/java/net/authorize/sample/RecurringBilling/UpdateSubscription.java +++ b/src/main/java/net/authorize/sample/RecurringBilling/UpdateSubscription.java @@ -25,9 +25,17 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri creditCard.setCardNumber("4111111111111111"); creditCard.setExpirationDate("1220"); paymentType.setCreditCard(creditCard); + + //set profile information + CustomerProfileIdType profile = new CustomerProfileIdType(); + profile.setCustomerProfileId("121212"); + profile.setCustomerPaymentProfileId("131313"); + profile.setCustomerAddressId("141414"); ARBSubscriptionType arbSubscriptionType = new ARBSubscriptionType(); arbSubscriptionType.setPayment(paymentType); + //to update profile + //arbSubscriptionType.setProfile(profile); // Make the API Request ARBUpdateSubscriptionRequest apiRequest = new ARBUpdateSubscriptionRequest(); From 05c1205d2da5006a8cd697c60ad27bcd1cbcf785 Mon Sep 17 00:00:00 2001 From: brianmc Date: Thu, 21 Apr 2016 13:53:41 -0700 Subject: [PATCH 042/176] Updated Refund sample to demonstrate that full card and expiry are not required to do a linked credit --- .../authorize/sample/PaymentTransactions/RefundTransaction.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/RefundTransaction.java b/src/main/java/net/authorize/sample/PaymentTransactions/RefundTransaction.java index 9e27c07d..49017959 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/RefundTransaction.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/RefundTransaction.java @@ -27,7 +27,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub PaymentType paymentType = new PaymentType(); CreditCardType creditCard = new CreditCardType(); creditCard.setCardNumber("0015"); - creditCard.setExpirationDate("1220"); + creditCard.setExpirationDate("XXXX"); paymentType.setCreditCard(creditCard); // Create the payment transaction request From b29b57c3fb522b85aab6c0a7e847d527a04fdc43 Mon Sep 17 00:00:00 2001 From: srathod Date: Thu, 16 Jun 2016 15:20:44 +0530 Subject: [PATCH 043/176] - Added retries while running a sample in TestRunner. --- .../sample/SampleCodeTest/TestRunner.java | 48 ++++++++++--------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java index 8c424bcd..b295a042 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java +++ b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java @@ -105,6 +105,7 @@ private static short getDays() public void TestAllSampleCodes() { String fileName = Constants.CONFIG_FILE; + int numRetries = 3; BufferedReader reader = null; @@ -132,36 +133,39 @@ public void TestAllSampleCodes() if (!shouldApiRun.equals("1")) continue; - + ANetApiResponse response = null; + + cnt++; - try + for(int i = 0;i Date: Wed, 29 Jun 2016 14:10:46 +0530 Subject: [PATCH 044/176] Updating the transaction key --- .../java/net/authorize/sample/SampleCodeTest/Constants.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/Constants.java b/src/test/java/net/authorize/sample/SampleCodeTest/Constants.java index 672c6b1e..730b8038 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/Constants.java +++ b/src/test/java/net/authorize/sample/SampleCodeTest/Constants.java @@ -2,7 +2,7 @@ public final class Constants { public static final String API_LOGIN_ID = "5KP3u95bQpv"; - public static final String TRANSACTION_KEY = "4Ktq966gC55GAX7S"; + public static final String TRANSACTION_KEY = "346HZ32z3fP4hTG2"; public static final String TRANSACTION_ID = "123456"; public static final String PAYER_ID = "6ZSCSYG33VP8Q"; public static final String CONFIG_FILE = "./src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt"; From a49a47553d94317fb1e488688673fdcb7aa05b18 Mon Sep 17 00:00:00 2001 From: Ashish Kankaria Date: Wed, 29 Jun 2016 14:11:28 +0530 Subject: [PATCH 045/176] Updating the transaction key --- src/main/java/net/authorize/sample/SampleCode.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index c9a5a058..9d058802 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -131,7 +131,7 @@ private static void RunMethod(String methodName) // These are default transaction keys. // You can create your own keys in seconds by signing up for a sandbox account here: https://developer.authorize.net/sandbox/ String apiLoginId = "5KP3u95bQpv"; - String transactionKey = "4Ktq966gC55GAX7S"; + String transactionKey = "346HZ32z3fP4hTG2"; //Update the payedId with which you want to run the sample code String payerId = "6ZSCSYG33VP8Q"; //Update the transactionId with which you want to run the sample code From 2809aad48a159e66c7ea92ed62444ac4f005828a Mon Sep 17 00:00:00 2001 From: akankari Date: Fri, 1 Jul 2016 21:54:48 +0530 Subject: [PATCH 046/176] - Adding sleep to avoid travis build failure - Updating the expiry date --- .../CreateCustomerProfileFromTransaction.java | 2 +- .../sample/SampleCodeTest/TestRunner.java | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfileFromTransaction.java b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfileFromTransaction.java index 97fc3f22..44d674fe 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfileFromTransaction.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfileFromTransaction.java @@ -32,7 +32,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub CreditCardType creditCard = new CreditCardType(); creditCard.setCardNumber("4111111111111111"); - creditCard.setExpirationDate("0616"); + creditCard.setExpirationDate("0621"); PaymentType paymentType = new PaymentType(); paymentType.setCreditCard(creditCard); diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java index b295a042..08802010 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java +++ b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java @@ -6,8 +6,6 @@ import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.math.BigDecimal; -import java.math.RoundingMode; import java.security.SecureRandom; import java.text.DecimalFormat; @@ -134,6 +132,11 @@ public void TestAllSampleCodes() if (!shouldApiRun.equals("1")) continue; + + System.out.println("-------------------"); + System.out.println("Running test case for :: " + apiName); + System.out.println("-------------------"); + ANetApiResponse response = null; cnt++; @@ -470,6 +473,15 @@ public ANetApiResponse TestCreateSubscriptionFromCustomerProfile() CreateCustomerShippingAddressResponse shippingResponse = (CreateCustomerShippingAddressResponse)CreateCustomerShippingAddress. run(apiLoginId, transactionKey, profileResponse.getCustomerProfileId()); + try + { + Thread.sleep(10000); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + ARBCreateSubscriptionResponse response = (ARBCreateSubscriptionResponse) CreateSubscriptionFromCustomerProfile.run(apiLoginId, transactionKey, getDays(), getAmount(), profileResponse.getCustomerProfileId(), paymentResponse.getCustomerPaymentProfileId(), shippingResponse.getCustomerAddressId()); From f64bd13ba769985139307013b59443f9018a3a52 Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Sat, 13 Aug 2016 02:23:03 +0530 Subject: [PATCH 047/176] Update pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ca578120..204219bb 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,7 @@ - 1.8.8 + 1.9.0 4.0.0 net.authorize.sample From 3dd8410dc1fd3da0976f679f6bd8414dd4370c9e Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Wed, 17 Aug 2016 07:56:16 -0700 Subject: [PATCH 048/176] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 454f0095..1d9c7dd5 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,9 @@ The samples are organized just like our API, which you can also try out directly The samples are all completely independent and self-contained so you can look at them to get a gist of how the method works, you can use the snippets to try in your own sample project, or you can run each sample from the command line. ##Running the Samples - Clone this repository. - Run "mvn package" in the root directory to create the SampleCode console app. - Then run a sample directly by name: + 1. Clone this repository. + 2. Run "mvn package" in the root directory to create the SampleCode console app. + 3. Then run a sample directly by name: ```` > java -jar target/SampleCode.jar [CodeSampleName] ```` From a23e62086bf4d193aa8719d4e56c9bfdda411960 Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Wed, 17 Aug 2016 08:05:53 -0700 Subject: [PATCH 049/176] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 1d9c7dd5..300e5f50 100644 --- a/README.md +++ b/README.md @@ -23,4 +23,6 @@ e.g. ```` Running SampleCode without a parameter will give you the list of sample names. Handy or what! +**NOTE You can update to your Sandbox credentials in SampleCode.java** + *PLEASE NOTE THIS PROJECT IS CURRENTLY UNDER DEVELOPMENT* From 47a46c6f4493eb361c5183fc45e33b75d5494dc5 Mon Sep 17 00:00:00 2001 From: Kaushik Date: Mon, 22 Aug 2016 18:50:46 +0530 Subject: [PATCH 050/176] Java env proxy setting eg. in Readme --- README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 300e5f50..fd5000cd 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,15 @@ e.g. ```` Running SampleCode without a parameter will give you the list of sample names. Handy or what! -**NOTE You can update to your Sandbox credentials in SampleCode.java** +**NOTE : You can update to your Sandbox credentials in SampleCode.java** + +**For using behind proxy** + +Please set the JAVA environment proxy using a similar code : +```` + System.setProperty("https.proxyUse", "true"); + System.setProperty("https.proxyHost", "127.0.0.1"); + System.setProperty("https.proxyPort", "3128"); +```` *PLEASE NOTE THIS PROJECT IS CURRENTLY UNDER DEVELOPMENT* From c3f21e486f873fb9fa502f19d6807521ef7168fa Mon Sep 17 00:00:00 2001 From: Kaushik Date: Mon, 22 Aug 2016 19:12:39 +0530 Subject: [PATCH 051/176] Added Sample Accept & AndroidPay --- .../CreateAnAcceptTransaction.java | 67 +++++++++++++++++++ .../CreateAnAndroidPayTransaction.java | 66 ++++++++++++++++++ .../CreateAnApplePayTransaction.java | 4 +- .../java/net/authorize/sample/SampleCode.java | 11 ++- .../sample/SampleCodeTest/SampleCodeList.txt | 4 +- 5 files changed, 147 insertions(+), 5 deletions(-) create mode 100644 src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAcceptTransaction.java create mode 100644 src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAndroidPayTransaction.java rename src/main/java/net/authorize/sample/{ApplePayTransactions => MobileInAppTransactions}/CreateAnApplePayTransaction.java (96%) diff --git a/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAcceptTransaction.java b/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAcceptTransaction.java new file mode 100644 index 00000000..1bb51c69 --- /dev/null +++ b/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAcceptTransaction.java @@ -0,0 +1,67 @@ +package net.authorize.sample.MobileInAppTransactions; + +import java.math.BigDecimal; +import net.authorize.Environment; +import net.authorize.TransactionType; +import net.authorize.api.contract.v1.*; +import net.authorize.api.controller.CreateTransactionController; +import net.authorize.api.controller.base.ApiOperationBase; + +public class CreateAnAcceptTransaction +{ + public static ANetApiResponse run(String apiLoginId, String transactionKey) + { + ApiOperationBase.setEnvironment(Environment.SANDBOX); + + // Giving the merchant authentication information + MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; + merchantAuthenticationType.setName(apiLoginId); + merchantAuthenticationType.setTransactionKey(transactionKey); + ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); + // Setting the payment + OpaqueDataType op = new OpaqueDataType(); + op.setDataDescriptor("COMMON.ACCEPT.INAPP.PAYMENT"); + op.setDataValue("9471471570959063005001"); + PaymentType paymentOne = new PaymentType(); + paymentOne.setOpaqueData(op); + // Setting the transaction + TransactionRequestType transactionRequest = new TransactionRequestType(); + transactionRequest.setAmount(new BigDecimal("131")); + transactionRequest.setTransactionType(TransactionTypeEnum.AUTH_CAPTURE_TRANSACTION.value()); + transactionRequest.setPayment(paymentOne); + // Making the api request + CreateTransactionRequest apiRequest = new CreateTransactionRequest(); + apiRequest.setTransactionRequest(transactionRequest); + // Creating the controller + CreateTransactionController controller = new CreateTransactionController(apiRequest); + controller.execute(); + // Getting the response + CreateTransactionResponse response = controller.getApiResponse(); + if(response!=null) + { + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) + { + if (response.getTransactionResponse() != null) + { + TransactionResponse result = response.getTransactionResponse(); + System.out.println("Successful: Create an Accept Transaction"); + System.out.println("Response Code : " + result.getResponseCode()); + System.out.println("Transaction ID : " + result.getTransId()); + System.out.println("Auth code : " + result.getAuthCode()); + } + } + else + { + + System.out.println("Failed: Create Accept Transaction"); + if(!response.getMessages().getMessage().isEmpty()) + System.out.println("Error: " + response.getMessages().getMessage().get(0).getCode() + " " + response.getMessages().getMessage().get(0).getText()); + + if (response.getTransactionResponse() != null) + if(response.getTransactionResponse().getErrors() != null && !response.getTransactionResponse().getErrors().getError().isEmpty()) + System.out.println("Transaction Error : " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode() + " " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + } + return response; + } +} diff --git a/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAndroidPayTransaction.java b/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAndroidPayTransaction.java new file mode 100644 index 00000000..644f1193 --- /dev/null +++ b/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAndroidPayTransaction.java @@ -0,0 +1,66 @@ +package net.authorize.sample.MobileInAppTransactions; + +import java.math.BigDecimal; +import net.authorize.Environment; +import net.authorize.TransactionType; +import net.authorize.api.contract.v1.*; +import net.authorize.api.controller.CreateTransactionController; +import net.authorize.api.controller.base.ApiOperationBase; + +public class CreateAnAndroidPayTransaction +{ + public static ANetApiResponse run(String apiLoginId, String transactionKey) + { + ApiOperationBase.setEnvironment(Environment.SANDBOX); + + // Giving the merchant authentication information + MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; + merchantAuthenticationType.setName(apiLoginId); + merchantAuthenticationType.setTransactionKey(transactionKey); + ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); + // Setting the payment + OpaqueDataType op = new OpaqueDataType(); + op.setDataDescriptor("COMMON.ANDROID.INAPP.PAYMENT"); + op.setDataValue("eyJkYXRhIjoiQkRQTldTdE1tR2V3UVVXR2c0bzdFXC9qKzFjcTFUNzhxeVU4NGI2N2l0amNZSTh3UFlBT2hzaGpoWlBycWRVcjRYd1BNYmo0emNHTWR5KysxSDJWa1BPWStCT01GMjV1YjE5Y1g0bkN2a1hVVU9UakRsbEIxVGdTcjhKSFp4Z3A5ckNnc1NVZ2JCZ0tmNjBYS3V0WGY2YWpcL284WkliS25yS1E4U2gwb3VMQUtsb1VNbit2UHU0K0E3V0tycXJhdXo5SnZPUXA2dmhJcStIS2pVY1VOQ0lUUHlGaG1PRXRxK0grdzB2UmExQ0U2V2hGQk5uQ0hxenpXS2NrQlwvMG5xTFpSVFliRjBwK3Z5QmlWYVdIZWdoRVJmSHhSdGJ6cGVjelJQUHVGc2ZwSFZzNDhvUExDXC9rXC8xTU5kNDdrelwvcEhEY1JcL0R5NmFVTStsTmZvaWx5XC9RSk4rdFMzbTBIZk90SVNBUHFPbVhlbXZyNnhKQ2pDWmxDdXcwQzltWHpcL29iSHBvZnVJRVM4cjljcUdHc1VBUERwdzdnNjQybTRQendLRitIQnVZVW5lV0RCTlNEMnU2amJBRzMiLCJ2ZXJzaW9uIjoiRUNfdjEiLCJoZWFkZXIiOnsiYXBwbGljYXRpb25EYXRhIjoiOTRlZTA1OTMzNWU1ODdlNTAxY2M0YmY5MDYxM2UwODE0ZjAwYTdiMDhiYzdjNjQ4ZmQ4NjVhMmFmNmEyMmNjMiIsInRyYW5zYWN0aW9uSWQiOiJjMWNhZjVhZTcyZjAwMzlhODJiYWQ5MmI4MjgzNjM3MzRmODViZjJmOWNhZGYxOTNkMWJhZDlkZGNiNjBhNzk1IiwiZXBoZW1lcmFsUHVibGljS2V5IjoiTUlJQlN6Q0NBUU1HQnlxR1NNNDlBZ0V3Z2ZjQ0FRRXdMQVlIS29aSXpqMEJBUUloQVBcL1wvXC9cLzhBQUFBQkFBQUFBQUFBQUFBQUFBQUFcL1wvXC9cL1wvXC9cL1wvXC9cL1wvXC9cL1wvXC9cL01Gc0VJUFwvXC9cL1wvOEFBQUFCQUFBQUFBQUFBQUFBQUFBQVwvXC9cL1wvXC9cL1wvXC9cL1wvXC9cL1wvXC9cLzhCQ0JheGpYWXFqcVQ1N1BydlZWMm1JYThaUjBHc014VHNQWTd6ancrSjlKZ1N3TVZBTVNkTmdpRzV3U1RhbVo0NFJPZEpyZUJuMzZRQkVFRWF4ZlI4dUVzUWtmNHZPYmxZNlJBOG5jRGZZRXQ2ek9nOUtFNVJkaVl3cFpQNDBMaVwvaHBcL200N242MHA4RDU0V0s4NHpWMnN4WHM3THRrQm9ONzlSOVFJaEFQXC9cL1wvXC84QUFBQUFcL1wvXC9cL1wvXC9cL1wvXC9cLys4NXZxdHB4ZWVoUE81eXNMOFl5VlJBZ0VCQTBJQUJHbStnc2wwUFpGVFwva0RkVVNreHd5Zm84SnB3VFFRekJtOWxKSm5tVGw0REdVdkFENEdzZUdqXC9wc2hCWjBLM1RldXFEdFwvdERMYkUrOFwvbTB5Q21veHc9IiwicHVibGljS2V5SGFzaCI6IlwvYmI5Q05DMzZ1QmhlSEZQYm1vaEI3T28xT3NYMkora0pxdjQ4ek9WVmlRPSJ9LCJzaWduYXR1cmUiOiJNSUlEUWdZSktvWklodmNOQVFjQ29JSURNekNDQXk4Q0FRRXhDekFKQmdVckRnTUNHZ1VBTUFzR0NTcUdTSWIzRFFFSEFhQ0NBaXN3Z2dJbk1JSUJsS0FEQWdFQ0FoQmNsK1BmMytVNHBrMTNuVkQ5bndRUU1Ba0dCU3NPQXdJZEJRQXdKekVsTUNNR0ExVUVBeDRjQUdNQWFBQnRBR0VBYVFCQUFIWUFhUUJ6QUdFQUxnQmpBRzhBYlRBZUZ3MHhOREF4TURFd05qQXdNREJhRncweU5EQXhNREV3TmpBd01EQmFNQ2N4SlRBakJnTlZCQU1lSEFCakFHZ0FiUUJoQUdrQVFBQjJBR2tBY3dCaEFDNEFZd0J2QUcwd2daOHdEUVlKS29aSWh2Y05BUUVCQlFBRGdZMEFNSUdKQW9HQkFOQzgra2d0Z212V0YxT3pqZ0ROcmpURUJSdW9cLzVNS3ZsTTE0NnBBZjdHeDQxYmxFOXc0ZklYSkFEN0ZmTzdRS2pJWFlOdDM5ckx5eTd4RHdiXC81SWtaTTYwVFoyaUkxcGo1NVVjOGZkNGZ6T3BrM2Z0WmFRR1hOTFlwdEcxZDlWN0lTODJPdXA5TU1vMUJQVnJYVFBITmNzTTk5RVBVblBxZGJlR2M4N20wckFnTUJBQUdqWERCYU1GZ0dBMVVkQVFSUk1FK0FFSFpXUHJXdEpkN1laNDMxaENnN1lGU2hLVEFuTVNVd0l3WURWUVFESGh3QVl3Qm9BRzBBWVFCcEFFQUFkZ0JwQUhNQVlRQXVBR01BYndCdGdoQmNsK1BmMytVNHBrMTNuVkQ5bndRUU1Ba0dCU3NPQXdJZEJRQURnWUVBYlVLWUNrdUlLUzlRUTJtRmNNWVJFSW0ybCtYZzhcL0pYditHQlZRSmtPS29zY1k0aU5ERkFcL2JRbG9nZjlMTFU4NFRId05SbnN2VjNQcnY3UlRZODFncTBkdEM4elljQWFBa0NISUkzeXFNbko0QU91NkVPVzlrSmsyMzJnU0U3V2xDdEhiZkxTS2Z1U2dRWDhLWFFZdVpMazJScjYzTjhBcFhzWHdCTDNjSjB4Z2VBd2dkMENBUUV3T3pBbk1TVXdJd1lEVlFRREhod0FZd0JvQUcwQVlRQnBBRUFBZGdCcEFITUFZUUF1QUdNQWJ3QnRBaEJjbCtQZjMrVTRwazEzblZEOW53UVFNQWtHQlNzT0F3SWFCUUF3RFFZSktvWklodmNOQVFFQkJRQUVnWUJhSzNFbE9zdGJIOFdvb3NlREFCZitKZ1wvMTI5SmNJYXdtN2M2VnhuN1phc05iQXEzdEF0OFB0eSt1UUNnc3NYcVprTEE3a3oyR3pNb2xOdHY5d1ltdTlVandhcjFQSFlTK0JcL29Hbm96NTkxd2phZ1hXUnowbk1vNXkzTzFLelgwZDhDUkhBVmE4OFNyVjFhNUpJaVJldjNvU3RJcXd2NXh1WmxkYWc2VHI4dz09In0="); + PaymentType paymentOne = new PaymentType(); + paymentOne.setOpaqueData(op); + // Setting the transaction + TransactionRequestType transactionRequest = new TransactionRequestType(); + transactionRequest.setAmount(new BigDecimal("131")); + transactionRequest.setTransactionType(TransactionTypeEnum.AUTH_CAPTURE_TRANSACTION.value()); + transactionRequest.setPayment(paymentOne); + // Making the api request + CreateTransactionRequest apiRequest = new CreateTransactionRequest(); + apiRequest.setTransactionRequest(transactionRequest); + // Creating the controller + CreateTransactionController controller = new CreateTransactionController(apiRequest); + controller.execute(); + // Getting the response + CreateTransactionResponse response = controller.getApiResponse(); + if(response!=null) + { + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) + { + if (response.getTransactionResponse() != null) + { + TransactionResponse result = response.getTransactionResponse(); + System.out.println("Successful: Create an AndroidPay Transaction"); + System.out.println("Response Code : " + result.getResponseCode()); + System.out.println("Transaction ID : " + result.getTransId()); + System.out.println("Auth code : " + result.getAuthCode()); + } + } + else + { + System.out.println("Failed: Create AndroidPay Transaction"); + if(!response.getMessages().getMessage().isEmpty()) + System.out.println("Error: " + response.getMessages().getMessage().get(0).getCode() + " " + response.getMessages().getMessage().get(0).getText()); + + if (response.getTransactionResponse() != null) + if(response.getTransactionResponse().getErrors() != null && !response.getTransactionResponse().getErrors().getError().isEmpty()) + System.out.println("Transaction Error : " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode() + " " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + } + return response; + } +} diff --git a/src/main/java/net/authorize/sample/ApplePayTransactions/CreateAnApplePayTransaction.java b/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnApplePayTransaction.java similarity index 96% rename from src/main/java/net/authorize/sample/ApplePayTransactions/CreateAnApplePayTransaction.java rename to src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnApplePayTransaction.java index d3b797ec..904e1d62 100644 --- a/src/main/java/net/authorize/sample/ApplePayTransactions/CreateAnApplePayTransaction.java +++ b/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnApplePayTransaction.java @@ -1,4 +1,4 @@ -package net.authorize.sample.ApplePayTransactions; +package net.authorize.sample.MobileInAppTransactions; import java.math.BigDecimal; import net.authorize.Environment; @@ -57,7 +57,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) System.out.println("Error: " + response.getMessages().getMessage().get(0).getCode() + " " + response.getMessages().getMessage().get(0).getText()); if (response.getTransactionResponse() != null) - if(!response.getTransactionResponse().getErrors().getError().isEmpty()) + if(response.getTransactionResponse().getErrors() != null && !response.getTransactionResponse().getErrors().getError().isEmpty()) System.out.println("Transaction Error : " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode() + " " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } } diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index 9d058802..6d65fd3f 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -3,7 +3,6 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; -import net.authorize.sample.ApplePayTransactions.CreateAnApplePayTransaction; import net.authorize.sample.VisaCheckout.*; import net.authorize.sample.PaymentTransactions.*; @@ -12,7 +11,7 @@ import net.authorize.sample.RecurringBilling.*; import net.authorize.sample.TransactionReporting.*; import net.authorize.sample.CustomerProfiles.*; -import net.authorize.sample.ApplePayTransactions.*; +import net.authorize.sample.MobileInAppTransactions.*; /** * Created by anetdeveloper on 8/5/15. */ @@ -87,6 +86,8 @@ private static void ShowMethods() System.out.println(" CreditBankAccount"); System.out.println(" ChargeTokenizedCreditCard"); System.out.println(" CreateAnApplePayTransaction"); + System.out.println(" CreateAnAndroidPayTransaction"); + System.out.println(" CreateAnAcceptTransaction"); System.out.println(" ChargeCustomerProfile"); System.out.println(" CreateSubscription"); System.out.println(" CreateSubscriptionFromCustomerProfile"); @@ -187,6 +188,12 @@ private static void RunMethod(String methodName) case "CreateAnApplePayTransaction": CreateAnApplePayTransaction.run(apiLoginId, transactionKey); break; + case "CreateAnAndroidPayTransaction": + CreateAnAndroidPayTransaction.run(apiLoginId, transactionKey); + break; + case "CreateAnAcceptTransaction": + CreateAnAcceptTransaction.run(apiLoginId, transactionKey); + break; case "ChargeCustomerProfile": ChargeCustomerProfile.run(apiLoginId, transactionKey, customerProfileId, customerPaymentProfileId, amount); break; diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt b/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt index 3ff1927c..29a42798 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt +++ b/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt @@ -47,6 +47,8 @@ TransactionReporting.GetUnsettledTransactionList 0 1 TransactionReporting.GetBatchStatistics 0 1 TransactionReporting.GetSettledBatchList 0 1 TransactionReporting.GetTransactionDetails 1 1 -ApplePayTransactions.CreateAnApplePayTransaction 0 0 +MobileInAppTransactions.CreateAnApplePayTransaction 0 0 +MobileInAppTransactions.CreateAnAndroidPayTransaction 0 0 +MobileInAppTransactions.CreateAnAcceptTransaction 0 0 VisaCheckout.DecryptVisaCheckoutData 0 1 VisaCheckout.CreateVisaCheckoutTransaction 0 0 \ No newline at end of file From a57ac03a3733d605543f86e91469b46f2e169017 Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Wed, 24 Aug 2016 18:31:08 +0530 Subject: [PATCH 052/176] Update and rename src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAcceptTransaction.java to src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnAcceptTransaction.java --- .../CreateAnAcceptTransaction.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/main/java/net/authorize/sample/{MobileInAppTransactions => MobileInappTransactions}/CreateAnAcceptTransaction.java (98%) diff --git a/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAcceptTransaction.java b/src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnAcceptTransaction.java similarity index 98% rename from src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAcceptTransaction.java rename to src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnAcceptTransaction.java index 1bb51c69..75621ec2 100644 --- a/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAcceptTransaction.java +++ b/src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnAcceptTransaction.java @@ -1,4 +1,4 @@ -package net.authorize.sample.MobileInAppTransactions; +package net.authorize.sample.MobileInappTransactions; import java.math.BigDecimal; import net.authorize.Environment; From a165f50d2318039797c40fcaf300119e01dc038b Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Wed, 24 Aug 2016 18:31:21 +0530 Subject: [PATCH 053/176] Update and rename src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAndroidPayTransaction.java to src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnAndroidPayTransaction.java --- .../CreateAnAndroidPayTransaction.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/main/java/net/authorize/sample/{MobileInAppTransactions => MobileInappTransactions}/CreateAnAndroidPayTransaction.java (99%) diff --git a/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAndroidPayTransaction.java b/src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnAndroidPayTransaction.java similarity index 99% rename from src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAndroidPayTransaction.java rename to src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnAndroidPayTransaction.java index 644f1193..57d2df3b 100644 --- a/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAndroidPayTransaction.java +++ b/src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnAndroidPayTransaction.java @@ -1,4 +1,4 @@ -package net.authorize.sample.MobileInAppTransactions; +package net.authorize.sample.MobileInappTransactions; import java.math.BigDecimal; import net.authorize.Environment; From c2b8e0b52193ec4f4c362cd07681cd251c281925 Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Wed, 24 Aug 2016 18:31:57 +0530 Subject: [PATCH 054/176] Update and rename src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnApplePayTransaction.java to src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnApplePayTransaction.java --- .../CreateAnApplePayTransaction.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/main/java/net/authorize/sample/{MobileInAppTransactions => MobileInappTransactions}/CreateAnApplePayTransaction.java (99%) diff --git a/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnApplePayTransaction.java b/src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnApplePayTransaction.java similarity index 99% rename from src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnApplePayTransaction.java rename to src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnApplePayTransaction.java index 904e1d62..6babbfd1 100644 --- a/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnApplePayTransaction.java +++ b/src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnApplePayTransaction.java @@ -1,4 +1,4 @@ -package net.authorize.sample.MobileInAppTransactions; +package net.authorize.sample.MobileInappTransactions; import java.math.BigDecimal; import net.authorize.Environment; From 826053d5eb204276a234bc6d328d9fcc23481a7e Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Wed, 24 Aug 2016 18:32:21 +0530 Subject: [PATCH 055/176] Update SampleCode.java --- src/main/java/net/authorize/sample/SampleCode.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index 6d65fd3f..c4514ea5 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -11,7 +11,7 @@ import net.authorize.sample.RecurringBilling.*; import net.authorize.sample.TransactionReporting.*; import net.authorize.sample.CustomerProfiles.*; -import net.authorize.sample.MobileInAppTransactions.*; +import net.authorize.sample.MobileInappTransactions.*; /** * Created by anetdeveloper on 8/5/15. */ From fa8623ac3ec7414001aed1be3143a1d0f721a948 Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Wed, 24 Aug 2016 18:32:41 +0530 Subject: [PATCH 056/176] Update SampleCodeList.txt --- .../authorize/sample/SampleCodeTest/SampleCodeList.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt b/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt index 29a42798..1a855724 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt +++ b/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt @@ -47,8 +47,8 @@ TransactionReporting.GetUnsettledTransactionList 0 1 TransactionReporting.GetBatchStatistics 0 1 TransactionReporting.GetSettledBatchList 0 1 TransactionReporting.GetTransactionDetails 1 1 -MobileInAppTransactions.CreateAnApplePayTransaction 0 0 -MobileInAppTransactions.CreateAnAndroidPayTransaction 0 0 -MobileInAppTransactions.CreateAnAcceptTransaction 0 0 +MobileInappTransactions.CreateAnApplePayTransaction 0 0 +MobileInappTransactions.CreateAnAndroidPayTransaction 0 0 +MobileInappTransactions.CreateAnAcceptTransaction 0 0 VisaCheckout.DecryptVisaCheckoutData 0 1 -VisaCheckout.CreateVisaCheckoutTransaction 0 0 \ No newline at end of file +VisaCheckout.CreateVisaCheckoutTransaction 0 0 From e1e28cd0855d5ef9b818ad87e25a9ac288fc13bc Mon Sep 17 00:00:00 2001 From: srathod Date: Thu, 25 Aug 2016 19:43:46 +0530 Subject: [PATCH 057/176] - updated samples to handle checks for successful transaction. --- .../CreateAnAcceptTransaction.java | 57 +++++---- .../CreateAnAndroidPayTransaction.java | 119 ++++++++++-------- .../CreateAnApplePayTransaction.java | 56 +++++---- .../AuthorizeCreditCard.java | 63 +++++++--- ...eFundsAuthorizedThroughAnotherChannel.java | 52 ++++---- .../CapturePreviouslyAuthorizedAmount.java | 52 ++++---- .../PaymentTransactions/ChargeCreditCard.java | 51 +++++--- .../ChargeCustomerProfile.java | 51 +++++--- .../ChargeTokenizedCreditCard.java | 51 +++++--- .../CreditBankAccount.java | 51 +++++--- .../PaymentTransactions/DebitBankAccount.java | 51 +++++--- .../RefundTransaction.java | 58 +++++---- .../PaymentTransactions/VoidTransaction.java | 52 ++++---- .../AuthorizationAndCapture.java | 56 +++++---- .../AuthorizationAndCaptureContinue.java | 48 ++++--- .../AuthorizationOnly.java | 44 +++++-- .../AuthorizationOnlyContinued.java | 54 ++++---- .../sample/PaypalExpressCheckout/Credit.java | 57 +++++---- .../PaypalExpressCheckout/GetDetails.java | 62 +++++---- .../PriorAuthorizationCapture.java | 39 ++++-- .../sample/PaypalExpressCheckout/Void.java | 52 +++++--- .../CreateVisaCheckoutTransaction.java | 51 +++++--- 22 files changed, 756 insertions(+), 471 deletions(-) diff --git a/src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnAcceptTransaction.java b/src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnAcceptTransaction.java index 75621ec2..c70eb81b 100644 --- a/src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnAcceptTransaction.java +++ b/src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnAcceptTransaction.java @@ -37,31 +37,40 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) controller.execute(); // Getting the response CreateTransactionResponse response = controller.getApiResponse(); - if(response!=null) - { - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) - { - if (response.getTransactionResponse() != null) - { - TransactionResponse result = response.getTransactionResponse(); - System.out.println("Successful: Create an Accept Transaction"); - System.out.println("Response Code : " + result.getResponseCode()); - System.out.println("Transaction ID : " + result.getTransId()); - System.out.println("Auth code : " + result.getAuthCode()); - } - } - else - { - - System.out.println("Failed: Create Accept Transaction"); - if(!response.getMessages().getMessage().isEmpty()) - System.out.println("Error: " + response.getMessages().getMessage().get(0).getCode() + " " + response.getMessages().getMessage().get(0).getText()); - - if (response.getTransactionResponse() != null) - if(response.getTransactionResponse().getErrors() != null && !response.getTransactionResponse().getErrors().getError().isEmpty()) - System.out.println("Transaction Error : " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode() + " " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); - } + + if (response!=null) { + // If API Response is ok, go ahead and check the transaction response + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + TransactionResponse result = response.getTransactionResponse(); + if(result.getMessages() != null){ + System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); + System.out.println("Auth code : " + result.getAuthCode()); + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + } + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + else { + System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); + System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); + } + } } + else { + System.out.println("Null Response."); + } + return response; } } diff --git a/src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnAndroidPayTransaction.java b/src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnAndroidPayTransaction.java index 57d2df3b..b7c9311f 100644 --- a/src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnAndroidPayTransaction.java +++ b/src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnAndroidPayTransaction.java @@ -7,60 +7,71 @@ import net.authorize.api.controller.CreateTransactionController; import net.authorize.api.controller.base.ApiOperationBase; -public class CreateAnAndroidPayTransaction -{ - public static ANetApiResponse run(String apiLoginId, String transactionKey) - { - ApiOperationBase.setEnvironment(Environment.SANDBOX); - - // Giving the merchant authentication information - MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; - merchantAuthenticationType.setName(apiLoginId); - merchantAuthenticationType.setTransactionKey(transactionKey); - ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); - // Setting the payment - OpaqueDataType op = new OpaqueDataType(); - op.setDataDescriptor("COMMON.ANDROID.INAPP.PAYMENT"); - op.setDataValue("eyJkYXRhIjoiQkRQTldTdE1tR2V3UVVXR2c0bzdFXC9qKzFjcTFUNzhxeVU4NGI2N2l0amNZSTh3UFlBT2hzaGpoWlBycWRVcjRYd1BNYmo0emNHTWR5KysxSDJWa1BPWStCT01GMjV1YjE5Y1g0bkN2a1hVVU9UakRsbEIxVGdTcjhKSFp4Z3A5ckNnc1NVZ2JCZ0tmNjBYS3V0WGY2YWpcL284WkliS25yS1E4U2gwb3VMQUtsb1VNbit2UHU0K0E3V0tycXJhdXo5SnZPUXA2dmhJcStIS2pVY1VOQ0lUUHlGaG1PRXRxK0grdzB2UmExQ0U2V2hGQk5uQ0hxenpXS2NrQlwvMG5xTFpSVFliRjBwK3Z5QmlWYVdIZWdoRVJmSHhSdGJ6cGVjelJQUHVGc2ZwSFZzNDhvUExDXC9rXC8xTU5kNDdrelwvcEhEY1JcL0R5NmFVTStsTmZvaWx5XC9RSk4rdFMzbTBIZk90SVNBUHFPbVhlbXZyNnhKQ2pDWmxDdXcwQzltWHpcL29iSHBvZnVJRVM4cjljcUdHc1VBUERwdzdnNjQybTRQendLRitIQnVZVW5lV0RCTlNEMnU2amJBRzMiLCJ2ZXJzaW9uIjoiRUNfdjEiLCJoZWFkZXIiOnsiYXBwbGljYXRpb25EYXRhIjoiOTRlZTA1OTMzNWU1ODdlNTAxY2M0YmY5MDYxM2UwODE0ZjAwYTdiMDhiYzdjNjQ4ZmQ4NjVhMmFmNmEyMmNjMiIsInRyYW5zYWN0aW9uSWQiOiJjMWNhZjVhZTcyZjAwMzlhODJiYWQ5MmI4MjgzNjM3MzRmODViZjJmOWNhZGYxOTNkMWJhZDlkZGNiNjBhNzk1IiwiZXBoZW1lcmFsUHVibGljS2V5IjoiTUlJQlN6Q0NBUU1HQnlxR1NNNDlBZ0V3Z2ZjQ0FRRXdMQVlIS29aSXpqMEJBUUloQVBcL1wvXC9cLzhBQUFBQkFBQUFBQUFBQUFBQUFBQUFcL1wvXC9cL1wvXC9cL1wvXC9cL1wvXC9cL1wvXC9cL01Gc0VJUFwvXC9cL1wvOEFBQUFCQUFBQUFBQUFBQUFBQUFBQVwvXC9cL1wvXC9cL1wvXC9cL1wvXC9cL1wvXC9cLzhCQ0JheGpYWXFqcVQ1N1BydlZWMm1JYThaUjBHc014VHNQWTd6ancrSjlKZ1N3TVZBTVNkTmdpRzV3U1RhbVo0NFJPZEpyZUJuMzZRQkVFRWF4ZlI4dUVzUWtmNHZPYmxZNlJBOG5jRGZZRXQ2ek9nOUtFNVJkaVl3cFpQNDBMaVwvaHBcL200N242MHA4RDU0V0s4NHpWMnN4WHM3THRrQm9ONzlSOVFJaEFQXC9cL1wvXC84QUFBQUFcL1wvXC9cL1wvXC9cL1wvXC9cLys4NXZxdHB4ZWVoUE81eXNMOFl5VlJBZ0VCQTBJQUJHbStnc2wwUFpGVFwva0RkVVNreHd5Zm84SnB3VFFRekJtOWxKSm5tVGw0REdVdkFENEdzZUdqXC9wc2hCWjBLM1RldXFEdFwvdERMYkUrOFwvbTB5Q21veHc9IiwicHVibGljS2V5SGFzaCI6IlwvYmI5Q05DMzZ1QmhlSEZQYm1vaEI3T28xT3NYMkora0pxdjQ4ek9WVmlRPSJ9LCJzaWduYXR1cmUiOiJNSUlEUWdZSktvWklodmNOQVFjQ29JSURNekNDQXk4Q0FRRXhDekFKQmdVckRnTUNHZ1VBTUFzR0NTcUdTSWIzRFFFSEFhQ0NBaXN3Z2dJbk1JSUJsS0FEQWdFQ0FoQmNsK1BmMytVNHBrMTNuVkQ5bndRUU1Ba0dCU3NPQXdJZEJRQXdKekVsTUNNR0ExVUVBeDRjQUdNQWFBQnRBR0VBYVFCQUFIWUFhUUJ6QUdFQUxnQmpBRzhBYlRBZUZ3MHhOREF4TURFd05qQXdNREJhRncweU5EQXhNREV3TmpBd01EQmFNQ2N4SlRBakJnTlZCQU1lSEFCakFHZ0FiUUJoQUdrQVFBQjJBR2tBY3dCaEFDNEFZd0J2QUcwd2daOHdEUVlKS29aSWh2Y05BUUVCQlFBRGdZMEFNSUdKQW9HQkFOQzgra2d0Z212V0YxT3pqZ0ROcmpURUJSdW9cLzVNS3ZsTTE0NnBBZjdHeDQxYmxFOXc0ZklYSkFEN0ZmTzdRS2pJWFlOdDM5ckx5eTd4RHdiXC81SWtaTTYwVFoyaUkxcGo1NVVjOGZkNGZ6T3BrM2Z0WmFRR1hOTFlwdEcxZDlWN0lTODJPdXA5TU1vMUJQVnJYVFBITmNzTTk5RVBVblBxZGJlR2M4N20wckFnTUJBQUdqWERCYU1GZ0dBMVVkQVFSUk1FK0FFSFpXUHJXdEpkN1laNDMxaENnN1lGU2hLVEFuTVNVd0l3WURWUVFESGh3QVl3Qm9BRzBBWVFCcEFFQUFkZ0JwQUhNQVlRQXVBR01BYndCdGdoQmNsK1BmMytVNHBrMTNuVkQ5bndRUU1Ba0dCU3NPQXdJZEJRQURnWUVBYlVLWUNrdUlLUzlRUTJtRmNNWVJFSW0ybCtYZzhcL0pYditHQlZRSmtPS29zY1k0aU5ERkFcL2JRbG9nZjlMTFU4NFRId05SbnN2VjNQcnY3UlRZODFncTBkdEM4elljQWFBa0NISUkzeXFNbko0QU91NkVPVzlrSmsyMzJnU0U3V2xDdEhiZkxTS2Z1U2dRWDhLWFFZdVpMazJScjYzTjhBcFhzWHdCTDNjSjB4Z2VBd2dkMENBUUV3T3pBbk1TVXdJd1lEVlFRREhod0FZd0JvQUcwQVlRQnBBRUFBZGdCcEFITUFZUUF1QUdNQWJ3QnRBaEJjbCtQZjMrVTRwazEzblZEOW53UVFNQWtHQlNzT0F3SWFCUUF3RFFZSktvWklodmNOQVFFQkJRQUVnWUJhSzNFbE9zdGJIOFdvb3NlREFCZitKZ1wvMTI5SmNJYXdtN2M2VnhuN1phc05iQXEzdEF0OFB0eSt1UUNnc3NYcVprTEE3a3oyR3pNb2xOdHY5d1ltdTlVandhcjFQSFlTK0JcL29Hbm96NTkxd2phZ1hXUnowbk1vNXkzTzFLelgwZDhDUkhBVmE4OFNyVjFhNUpJaVJldjNvU3RJcXd2NXh1WmxkYWc2VHI4dz09In0="); - PaymentType paymentOne = new PaymentType(); - paymentOne.setOpaqueData(op); - // Setting the transaction - TransactionRequestType transactionRequest = new TransactionRequestType(); - transactionRequest.setAmount(new BigDecimal("131")); - transactionRequest.setTransactionType(TransactionTypeEnum.AUTH_CAPTURE_TRANSACTION.value()); - transactionRequest.setPayment(paymentOne); - // Making the api request - CreateTransactionRequest apiRequest = new CreateTransactionRequest(); - apiRequest.setTransactionRequest(transactionRequest); - // Creating the controller - CreateTransactionController controller = new CreateTransactionController(apiRequest); - controller.execute(); - // Getting the response - CreateTransactionResponse response = controller.getApiResponse(); - if(response!=null) - { - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) - { - if (response.getTransactionResponse() != null) - { - TransactionResponse result = response.getTransactionResponse(); - System.out.println("Successful: Create an AndroidPay Transaction"); - System.out.println("Response Code : " + result.getResponseCode()); - System.out.println("Transaction ID : " + result.getTransId()); - System.out.println("Auth code : " + result.getAuthCode()); - } - } - else - { - System.out.println("Failed: Create AndroidPay Transaction"); - if(!response.getMessages().getMessage().isEmpty()) - System.out.println("Error: " + response.getMessages().getMessage().get(0).getCode() + " " + response.getMessages().getMessage().get(0).getText()); +public class CreateAnAndroidPayTransaction { + public static ANetApiResponse run(String apiLoginId, String transactionKey) { + ApiOperationBase.setEnvironment(Environment.SANDBOX); + + // Giving the merchant authentication information + MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType(); + merchantAuthenticationType.setName(apiLoginId); + merchantAuthenticationType.setTransactionKey(transactionKey); + ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); + // Setting the payment + OpaqueDataType op = new OpaqueDataType(); + op.setDataDescriptor("COMMON.ANDROID.INAPP.PAYMENT"); + op.setDataValue( + "eyJkYXRhIjoiQkRQTldTdE1tR2V3UVVXR2c0bzdFXC9qKzFjcTFUNzhxeVU4NGI2N2l0amNZSTh3UFlBT2hzaGpoWlBycWRVcjRYd1BNYmo0emNHTWR5KysxSDJWa1BPWStCT01GMjV1YjE5Y1g0bkN2a1hVVU9UakRsbEIxVGdTcjhKSFp4Z3A5ckNnc1NVZ2JCZ0tmNjBYS3V0WGY2YWpcL284WkliS25yS1E4U2gwb3VMQUtsb1VNbit2UHU0K0E3V0tycXJhdXo5SnZPUXA2dmhJcStIS2pVY1VOQ0lUUHlGaG1PRXRxK0grdzB2UmExQ0U2V2hGQk5uQ0hxenpXS2NrQlwvMG5xTFpSVFliRjBwK3Z5QmlWYVdIZWdoRVJmSHhSdGJ6cGVjelJQUHVGc2ZwSFZzNDhvUExDXC9rXC8xTU5kNDdrelwvcEhEY1JcL0R5NmFVTStsTmZvaWx5XC9RSk4rdFMzbTBIZk90SVNBUHFPbVhlbXZyNnhKQ2pDWmxDdXcwQzltWHpcL29iSHBvZnVJRVM4cjljcUdHc1VBUERwdzdnNjQybTRQendLRitIQnVZVW5lV0RCTlNEMnU2amJBRzMiLCJ2ZXJzaW9uIjoiRUNfdjEiLCJoZWFkZXIiOnsiYXBwbGljYXRpb25EYXRhIjoiOTRlZTA1OTMzNWU1ODdlNTAxY2M0YmY5MDYxM2UwODE0ZjAwYTdiMDhiYzdjNjQ4ZmQ4NjVhMmFmNmEyMmNjMiIsInRyYW5zYWN0aW9uSWQiOiJjMWNhZjVhZTcyZjAwMzlhODJiYWQ5MmI4MjgzNjM3MzRmODViZjJmOWNhZGYxOTNkMWJhZDlkZGNiNjBhNzk1IiwiZXBoZW1lcmFsUHVibGljS2V5IjoiTUlJQlN6Q0NBUU1HQnlxR1NNNDlBZ0V3Z2ZjQ0FRRXdMQVlIS29aSXpqMEJBUUloQVBcL1wvXC9cLzhBQUFBQkFBQUFBQUFBQUFBQUFBQUFcL1wvXC9cL1wvXC9cL1wvXC9cL1wvXC9cL1wvXC9cL01Gc0VJUFwvXC9cL1wvOEFBQUFCQUFBQUFBQUFBQUFBQUFBQVwvXC9cL1wvXC9cL1wvXC9cL1wvXC9cL1wvXC9cLzhCQ0JheGpYWXFqcVQ1N1BydlZWMm1JYThaUjBHc014VHNQWTd6ancrSjlKZ1N3TVZBTVNkTmdpRzV3U1RhbVo0NFJPZEpyZUJuMzZRQkVFRWF4ZlI4dUVzUWtmNHZPYmxZNlJBOG5jRGZZRXQ2ek9nOUtFNVJkaVl3cFpQNDBMaVwvaHBcL200N242MHA4RDU0V0s4NHpWMnN4WHM3THRrQm9ONzlSOVFJaEFQXC9cL1wvXC84QUFBQUFcL1wvXC9cL1wvXC9cL1wvXC9cLys4NXZxdHB4ZWVoUE81eXNMOFl5VlJBZ0VCQTBJQUJHbStnc2wwUFpGVFwva0RkVVNreHd5Zm84SnB3VFFRekJtOWxKSm5tVGw0REdVdkFENEdzZUdqXC9wc2hCWjBLM1RldXFEdFwvdERMYkUrOFwvbTB5Q21veHc9IiwicHVibGljS2V5SGFzaCI6IlwvYmI5Q05DMzZ1QmhlSEZQYm1vaEI3T28xT3NYMkora0pxdjQ4ek9WVmlRPSJ9LCJzaWduYXR1cmUiOiJNSUlEUWdZSktvWklodmNOQVFjQ29JSURNekNDQXk4Q0FRRXhDekFKQmdVckRnTUNHZ1VBTUFzR0NTcUdTSWIzRFFFSEFhQ0NBaXN3Z2dJbk1JSUJsS0FEQWdFQ0FoQmNsK1BmMytVNHBrMTNuVkQ5bndRUU1Ba0dCU3NPQXdJZEJRQXdKekVsTUNNR0ExVUVBeDRjQUdNQWFBQnRBR0VBYVFCQUFIWUFhUUJ6QUdFQUxnQmpBRzhBYlRBZUZ3MHhOREF4TURFd05qQXdNREJhRncweU5EQXhNREV3TmpBd01EQmFNQ2N4SlRBakJnTlZCQU1lSEFCakFHZ0FiUUJoQUdrQVFBQjJBR2tBY3dCaEFDNEFZd0J2QUcwd2daOHdEUVlKS29aSWh2Y05BUUVCQlFBRGdZMEFNSUdKQW9HQkFOQzgra2d0Z212V0YxT3pqZ0ROcmpURUJSdW9cLzVNS3ZsTTE0NnBBZjdHeDQxYmxFOXc0ZklYSkFEN0ZmTzdRS2pJWFlOdDM5ckx5eTd4RHdiXC81SWtaTTYwVFoyaUkxcGo1NVVjOGZkNGZ6T3BrM2Z0WmFRR1hOTFlwdEcxZDlWN0lTODJPdXA5TU1vMUJQVnJYVFBITmNzTTk5RVBVblBxZGJlR2M4N20wckFnTUJBQUdqWERCYU1GZ0dBMVVkQVFSUk1FK0FFSFpXUHJXdEpkN1laNDMxaENnN1lGU2hLVEFuTVNVd0l3WURWUVFESGh3QVl3Qm9BRzBBWVFCcEFFQUFkZ0JwQUhNQVlRQXVBR01BYndCdGdoQmNsK1BmMytVNHBrMTNuVkQ5bndRUU1Ba0dCU3NPQXdJZEJRQURnWUVBYlVLWUNrdUlLUzlRUTJtRmNNWVJFSW0ybCtYZzhcL0pYditHQlZRSmtPS29zY1k0aU5ERkFcL2JRbG9nZjlMTFU4NFRId05SbnN2VjNQcnY3UlRZODFncTBkdEM4elljQWFBa0NISUkzeXFNbko0QU91NkVPVzlrSmsyMzJnU0U3V2xDdEhiZkxTS2Z1U2dRWDhLWFFZdVpMazJScjYzTjhBcFhzWHdCTDNjSjB4Z2VBd2dkMENBUUV3T3pBbk1TVXdJd1lEVlFRREhod0FZd0JvQUcwQVlRQnBBRUFBZGdCcEFITUFZUUF1QUdNQWJ3QnRBaEJjbCtQZjMrVTRwazEzblZEOW53UVFNQWtHQlNzT0F3SWFCUUF3RFFZSktvWklodmNOQVFFQkJRQUVnWUJhSzNFbE9zdGJIOFdvb3NlREFCZitKZ1wvMTI5SmNJYXdtN2M2VnhuN1phc05iQXEzdEF0OFB0eSt1UUNnc3NYcVprTEE3a3oyR3pNb2xOdHY5d1ltdTlVandhcjFQSFlTK0JcL29Hbm96NTkxd2phZ1hXUnowbk1vNXkzTzFLelgwZDhDUkhBVmE4OFNyVjFhNUpJaVJldjNvU3RJcXd2NXh1WmxkYWc2VHI4dz09In0="); + PaymentType paymentOne = new PaymentType(); + paymentOne.setOpaqueData(op); + // Setting the transaction + TransactionRequestType transactionRequest = new TransactionRequestType(); + transactionRequest.setAmount(new BigDecimal("131")); + transactionRequest.setTransactionType(TransactionTypeEnum.AUTH_CAPTURE_TRANSACTION.value()); + transactionRequest.setPayment(paymentOne); + // Making the api request + CreateTransactionRequest apiRequest = new CreateTransactionRequest(); + apiRequest.setTransactionRequest(transactionRequest); + // Creating the controller + CreateTransactionController controller = new CreateTransactionController(apiRequest); + controller.execute(); + // Getting the response + CreateTransactionResponse response = controller.getApiResponse(); + + if (response != null) { + // If API Response is ok, go ahead and check the transaction + // response + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + TransactionResponse result = response.getTransactionResponse(); + if (result.getMessages() != null) { + System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); + System.out.println("Auth code : " + result.getAuthCode()); + } else { + System.out.println("Failed Transaction."); + if (response.getTransactionResponse().getErrors() != null) { + System.out.println("Error Code: " + + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + } + } else { + System.out.println("Failed Transaction."); + if (response.getTransactionResponse() != null + && response.getTransactionResponse().getErrors() != null) { + System.out.println("Error Code: " + + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } else { + System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); + System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); + } + } + } else { + System.out.println("Null Response."); + } - if (response.getTransactionResponse() != null) - if(response.getTransactionResponse().getErrors() != null && !response.getTransactionResponse().getErrors().getError().isEmpty()) - System.out.println("Transaction Error : " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode() + " " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); - } - } return response; - } + } } diff --git a/src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnApplePayTransaction.java b/src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnApplePayTransaction.java index 6babbfd1..948c532d 100644 --- a/src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnApplePayTransaction.java +++ b/src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnApplePayTransaction.java @@ -37,30 +37,40 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) controller.execute(); // Getting the response CreateTransactionResponse response = controller.getApiResponse(); - if(response!=null) - { - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) - { - if (response.getTransactionResponse() != null) - { - TransactionResponse result = response.getTransactionResponse(); - System.out.println("Successful: Create an ApplePay Transaction"); - System.out.println("Response Code : " + result.getResponseCode()); - System.out.println("Transaction ID : " + result.getTransId()); - System.out.println("Auth code : " + result.getAuthCode()); - } - } - else - { - System.out.println("Failed: Create ApplePay Transaction"); - if(!response.getMessages().getMessage().isEmpty()) - System.out.println("Error: " + response.getMessages().getMessage().get(0).getCode() + " " + response.getMessages().getMessage().get(0).getText()); - - if (response.getTransactionResponse() != null) - if(response.getTransactionResponse().getErrors() != null && !response.getTransactionResponse().getErrors().getError().isEmpty()) - System.out.println("Transaction Error : " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode() + " " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); - } + + if (response!=null) { + // If API Response is ok, go ahead and check the transaction response + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + TransactionResponse result = response.getTransactionResponse(); + if(result.getMessages() != null){ + System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); + System.out.println("Auth code : " + result.getAuthCode()); + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + } + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + else { + System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); + System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); + } + } } + else { + System.out.println("Null Response."); + } + return response; } } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/AuthorizeCreditCard.java b/src/main/java/net/authorize/sample/PaymentTransactions/AuthorizeCreditCard.java index b8ce7371..7890d2a0 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/AuthorizeCreditCard.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/AuthorizeCreditCard.java @@ -31,12 +31,24 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub creditCard.setCardNumber("4242424242424242"); creditCard.setExpirationDate("0822"); paymentType.setCreditCard(creditCard); + + + CustomerAddressType customerAddressType = new CustomerAddressType(); + customerAddressType.setFirstName("John"); + customerAddressType.setLastName("Doe"); + customerAddressType.setAddress("123 Main St."); + customerAddressType.setCity("Bellevue"); + customerAddressType.setState("WA"); + customerAddressType.setZip("46282"); + customerAddressType.setCountry("USA"); + customerAddressType.setPhoneNumber("000-000-0000"); // Create the payment transaction request TransactionRequestType txnRequest = new TransactionRequestType(); txnRequest.setTransactionType(TransactionTypeEnum.AUTH_ONLY_TRANSACTION.value()); txnRequest.setPayment(paymentType); txnRequest.setAmount(new BigDecimal(amount).setScale(2, RoundingMode.CEILING)); + txnRequest.setBillTo(customerAddressType); // Make the API Request CreateTransactionRequest apiRequest = new CreateTransactionRequest(); @@ -48,27 +60,38 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub CreateTransactionResponse response = controller.getApiResponse(); if (response!=null) { - - // If API Response is ok, go ahead and check the transaction response - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { - - TransactionResponse result = response.getTransactionResponse(); - if (result.getResponseCode().equals("1")) { - System.out.println(result.getResponseCode()); - System.out.println("Successful Credit Card Transaction"); - System.out.println(result.getAuthCode()); - System.out.println(result.getTransId()); - } - else - { - System.out.println("Failed Transaction"+result.getResponseCode()); - } - } - else - { - System.out.println("Failed Transaction: "+response.getMessages().getResultCode()); - } + // If API Response is ok, go ahead and check the transaction response + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + TransactionResponse result = response.getTransactionResponse(); + if(result.getMessages() != null){ + System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); + System.out.println("Auth code: " + result.getAuthCode()); + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + } + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + else { + System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); + System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); + } + } + } + else { + System.out.println("Null Response."); } + return response; } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/CaptureFundsAuthorizedThroughAnotherChannel.java b/src/main/java/net/authorize/sample/PaymentTransactions/CaptureFundsAuthorizedThroughAnotherChannel.java index 580164fd..81079393 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/CaptureFundsAuthorizedThroughAnotherChannel.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/CaptureFundsAuthorizedThroughAnotherChannel.java @@ -55,29 +55,39 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub CreateTransactionResponse response = controller.getApiResponse(); - if (response!=null) { - - // If API Response is ok, go ahead and check the transaction response - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { - - TransactionResponse result = response.getTransactionResponse(); - if (result.getResponseCode().equals("1")) { - System.out.println(result.getResponseCode()); - System.out.println("Successfully Captured Transaction"); - System.out.println(result.getAuthCode()); - System.out.println(result.getTransId()); - } - else - { - System.out.println("Failed Transaction"+result.getResponseCode()); - } - } - else - { - System.out.println("Failed Transaction: "+response.getMessages().getResultCode()); - } + // If API Response is ok, go ahead and check the transaction response + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + TransactionResponse result = response.getTransactionResponse(); + if(result.getMessages() != null){ + System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); + System.out.println("Auth Code: " + result.getAuthCode()); + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + } + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + else { + System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); + System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); + } + } } + else { + System.out.println("Null Response."); + } + return response; } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/CapturePreviouslyAuthorizedAmount.java b/src/main/java/net/authorize/sample/PaymentTransactions/CapturePreviouslyAuthorizedAmount.java index e923fd39..7f584a57 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/CapturePreviouslyAuthorizedAmount.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/CapturePreviouslyAuthorizedAmount.java @@ -36,29 +36,39 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri CreateTransactionResponse response = controller.getApiResponse(); - if (response!=null) { - - // If API Response is ok, go ahead and check the transaction response - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { - - TransactionResponse result = response.getTransactionResponse(); - if (result.getResponseCode().equals("1")) { - System.out.println(result.getResponseCode()); - System.out.println("Successfully Captured Transaction"); - System.out.println(result.getAuthCode()); - System.out.println(result.getTransId()); - } - else - { - System.out.println("Failed Transaction"+result.getResponseCode()); - } - } - else - { - System.out.println("Failed Transaction: "+response.getMessages().getResultCode()); - } + // If API Response is ok, go ahead and check the transaction response + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + TransactionResponse result = response.getTransactionResponse(); + if(result.getMessages() != null){ + System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); + System.out.println("Auth Code: " + result.getAuthCode()); + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + } + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + else { + System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); + System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); + } + } } + else { + System.out.println("Null Response."); + } + return response; } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCreditCard.java b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCreditCard.java index 31367402..728820ab 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCreditCard.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCreditCard.java @@ -57,27 +57,38 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub CreateTransactionResponse response = controller.getApiResponse(); if (response!=null) { - - // If API Response is ok, go ahead and check the transaction response - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { - - TransactionResponse result = response.getTransactionResponse(); - if (result.getResponseCode().equals("1")) { - System.out.println(result.getResponseCode()); - System.out.println("Successful Credit Card Transaction"); - System.out.println(result.getAuthCode()); - System.out.println(result.getTransId()); - } - else - { - System.out.println("Failed Transaction"+result.getResponseCode()); - } - } - else - { - System.out.println("Failed Transaction: "+response.getMessages().getResultCode()); - } + // If API Response is ok, go ahead and check the transaction response + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + TransactionResponse result = response.getTransactionResponse(); + if(result.getMessages() != null){ + System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); + System.out.println("Auth Code: " + result.getAuthCode()); + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + } + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + else { + System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); + System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); + } + } + } + else { + System.out.println("Null Response."); } + return response; } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCustomerProfile.java b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCustomerProfile.java index 60c20827..5281c97f 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCustomerProfile.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCustomerProfile.java @@ -59,27 +59,38 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri CreateTransactionResponse response = controller.getApiResponse(); if (response!=null) { - - // If API Response is ok, go ahead and check the transaction response - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { - - TransactionResponse result = response.getTransactionResponse(); - if (result.getResponseCode().equals("1")) { - System.out.println(result.getResponseCode()); - System.out.println("Successful Transaction"); - System.out.println(result.getAuthCode()); - System.out.println(result.getTransId()); - } - else - { - System.out.println("Failed Transaction"+result.getResponseCode()); - } - } - else - { - System.out.println("Failed Transaction: "+response.getMessages().getResultCode()); - } + // If API Response is ok, go ahead and check the transaction response + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + TransactionResponse result = response.getTransactionResponse(); + if(result.getMessages() != null){ + System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); + System.out.println("Auth Code: " + result.getAuthCode()); + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + } + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + else { + System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); + System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); + } + } + } + else { + System.out.println("Null Response."); } + return response; } } \ No newline at end of file diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeTokenizedCreditCard.java b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeTokenizedCreditCard.java index 4d9556c5..16947723 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeTokenizedCreditCard.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeTokenizedCreditCard.java @@ -58,27 +58,38 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub CreateTransactionResponse response = controller.getApiResponse(); if (response!=null) { - - // If API Response is ok, go ahead and check the transaction response - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { - - TransactionResponse result = response.getTransactionResponse(); - if (result.getResponseCode().equals("1")) { - System.out.println(result.getResponseCode()); - System.out.println("Successful Credit Card Transaction"); - System.out.println(result.getAuthCode()); - System.out.println(result.getTransId()); - } - else - { - System.out.println("Failed Transaction"+result.getResponseCode()); - } - } - else - { - System.out.println("Failed Transaction: "+response.getMessages().getResultCode()); - } + // If API Response is ok, go ahead and check the transaction response + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + TransactionResponse result = response.getTransactionResponse(); + if(result.getMessages() != null){ + System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); + System.out.println("Auth Code: " + result.getAuthCode()); + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + } + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + else { + System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); + System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); + } + } + } + else { + System.out.println("Null Response."); } + return response; } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java b/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java index a253cbcb..5d95e4cc 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java @@ -61,27 +61,38 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri CreateTransactionResponse response = controller.getApiResponse(); if (response!=null) { - - // If API Response is ok, go ahead and check the transaction response - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { - - TransactionResponse result = response.getTransactionResponse(); - if (result.getResponseCode().equals("1")) { - System.out.println(result.getResponseCode()); - System.out.println("Successful Credit Bank Transaction"); - System.out.println(result.getAuthCode()); - System.out.println(result.getTransId()); - } - else - { - System.out.println("Failed Transaction"+result.getResponseCode()); - } - } - else - { - System.out.println("Failed Transaction: "+response.getMessages().getResultCode()); - } + // If API Response is ok, go ahead and check the transaction response + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + TransactionResponse result = response.getTransactionResponse(); + if(result.getMessages() != null){ + System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); + System.out.println("Auth Code: " + result.getAuthCode()); + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + } + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + else { + System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); + System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); + } + } + } + else { + System.out.println("Null Response."); } + return response; } } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java b/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java index 06756f3b..4dd76336 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java @@ -60,27 +60,38 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub CreateTransactionResponse response = controller.getApiResponse(); if (response!=null) { - - // If API Response is ok, go ahead and check the transaction response - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { - - TransactionResponse result = response.getTransactionResponse(); - if (result.getResponseCode().equals("1")) { - System.out.println(result.getResponseCode()); - System.out.println("Successful Debit Bank Transaction"); - System.out.println(result.getAuthCode()); - System.out.println(result.getTransId()); - } - else - { - System.out.println("Failed Transaction: "+result.getResponseCode()); - } - } - else - { - System.out.println("Failed Transaction: "+response.getMessages().getResultCode()); - } + // If API Response is ok, go ahead and check the transaction response + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + TransactionResponse result = response.getTransactionResponse(); + if(result.getMessages() != null){ + System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); + System.out.println("Auth Code: " + result.getAuthCode()); + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + } + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + else { + System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); + System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); + } + } + } + else { + System.out.println("Null Response."); } + return response; } } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/RefundTransaction.java b/src/main/java/net/authorize/sample/PaymentTransactions/RefundTransaction.java index 49017959..a8876574 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/RefundTransaction.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/RefundTransaction.java @@ -45,35 +45,39 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub CreateTransactionResponse response = controller.getApiResponse(); - if (response!=null) { - - // If API Response is ok, go ahead and check the transaction response - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { - - TransactionResponse result = response.getTransactionResponse(); - if (result.getResponseCode().equals("1")) { - System.out.println(result.getResponseCode()); - System.out.println("Successfully Refunded Transaction"); - System.out.println(result.getAuthCode()); - System.out.println(result.getTransId()); - } - else - { - System.out.println("Failed Transaction"+result.getResponseCode()); - } - } - else - { - System.out.println("Failed Transaction: "+response.getMessages().getResultCode()); - if(!response.getMessages().getMessage().isEmpty()) - System.out.println("Error: " + response.getMessages().getMessage().get(0).getCode() + " " + response.getMessages().getMessage().get(0).getText()); - - if (response.getTransactionResponse() != null) - if(!response.getTransactionResponse().getErrors().getError().isEmpty()) - System.out.println("Transaction Error : " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode() + " " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); - } + // If API Response is ok, go ahead and check the transaction response + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + TransactionResponse result = response.getTransactionResponse(); + if(result.getMessages() != null){ + System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); + System.out.println("Auth Code: " + result.getAuthCode()); + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + } + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + else { + System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); + System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); + } + } + } + else { + System.out.println("Null Response."); } + return response; } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/VoidTransaction.java b/src/main/java/net/authorize/sample/PaymentTransactions/VoidTransaction.java index b870f845..a8d6a931 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/VoidTransaction.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/VoidTransaction.java @@ -36,29 +36,39 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri CreateTransactionResponse response = controller.getApiResponse(); - if (response!=null) { - - // If API Response is ok, go ahead and check the transaction response - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { - - TransactionResponse result = response.getTransactionResponse(); - if (result.getResponseCode().equals("1")) { - System.out.println(result.getResponseCode()); - System.out.println("Successfully Voided Transaction"); - System.out.println(result.getAuthCode()); - System.out.println(result.getTransId()); - } - else - { - System.out.println("Failed Transaction"+result.getResponseCode()); - } - } - else - { - System.out.println("Failed Transaction: "+response.getMessages().getResultCode()); - } + // If API Response is ok, go ahead and check the transaction response + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + TransactionResponse result = response.getTransactionResponse(); + if(result.getMessages() != null){ + System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); + System.out.println("Auth Code: " + result.getAuthCode()); + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + } + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + else { + System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); + System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); + } + } } + else { + System.out.println("Null Response."); + } + return response; } diff --git a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCapture.java b/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCapture.java index 12176f7e..85766c6d 100644 --- a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCapture.java +++ b/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCapture.java @@ -54,28 +54,40 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub CreateTransactionResponse response = controller.getApiResponse(); - // If API Response is ok, go ahead and check the transaction response - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { - - if (response.getTransactionResponse() != null) - { - TransactionResponse result = response.getTransactionResponse(); - System.out.println("Successful Paypal Authorize Capture Transaction"); - System.out.println("Response Code : " + result.getResponseCode()); - System.out.println("Transaction ID : " + result.getTransId()); - System.out.println("Secure Acceptance URL : " + result.getSecureAcceptance().getSecureAcceptanceUrl()); - } - } - else - { - System.out.println("Failed Paypal Authorize Capture Transaction"); - if(!response.getMessages().getMessage().isEmpty()) - System.out.println("Error: " + response.getMessages().getMessage().get(0).getCode() + " " + response.getMessages().getMessage().get(0).getText()); - - if (response.getTransactionResponse() != null) - if(!response.getTransactionResponse().getErrors().getError().isEmpty()) - System.out.println("Transaction Error : " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode() + " " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); - } + if (response!=null) { + // If API Response is ok, go ahead and check the transaction response + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + TransactionResponse result = response.getTransactionResponse(); + if(result.getMessages() != null){ + System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); + System.out.println("Secure Acceptance URL : " + result.getSecureAcceptance().getSecureAcceptanceUrl()); + System.out.println("Auth Code: " + result.getAuthCode()); + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + } + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + else { + System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); + System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); + } + } + } + else { + System.out.println("Null Response."); + } + return response; } } diff --git a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCaptureContinue.java b/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCaptureContinue.java index b0d067ad..b884b6e1 100644 --- a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCaptureContinue.java +++ b/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCaptureContinue.java @@ -12,6 +12,7 @@ import net.authorize.api.contract.v1.PayPalType; import net.authorize.api.contract.v1.PaymentType; import net.authorize.api.contract.v1.TransactionRequestType; +import net.authorize.api.contract.v1.TransactionResponse; import net.authorize.api.contract.v1.TransactionTypeEnum; import net.authorize.api.controller.CreateTransactionController; import net.authorize.api.controller.base.ApiOperationBase; @@ -62,22 +63,37 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri CreateTransactionResponse response = controller.getApiResponse(); //validate - if(response != null){ - if(response.getMessages().getResultCode() == MessageTypeEnum.OK){ - if(response.getTransactionResponse() != null){ - if((response.getTransactionResponse().getMessages() != null) && - (!response.getTransactionResponse().getMessages().getMessage().isEmpty())) { - System.out.println("Success, \nMessage : "+response.getTransactionResponse().getMessages().getMessage().get(0).getDescription() ); - // Get Auth Code By : response.getTransactionResponse().getAuthCode() - } - } - } - else { - System.out.println("Error: " + response.getMessages().getMessage().get(0).getCode()+ " " + response.getMessages().getMessage().get(0).getText() ); - if(response.getTransactionResponse() != null){ - System.out.println("Transaction Error : "+ response.getTransactionResponse().getErrors().getError().get(0).getErrorCode() + " " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); - } - } + if (response!=null) { + // If API Response is ok, go ahead and check the transaction response + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + TransactionResponse result = response.getTransactionResponse(); + if(result.getMessages() != null){ + System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); + System.out.println("Auth Code: " + result.getAuthCode()); + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + } + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + else { + System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); + System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); + } + } + } + else { + System.out.println("Null Response."); } return response; diff --git a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationOnly.java b/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationOnly.java index e97841e8..c4882b6d 100644 --- a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationOnly.java +++ b/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationOnly.java @@ -13,6 +13,7 @@ import net.authorize.api.contract.v1.PayPalType; import net.authorize.api.contract.v1.PaymentType; import net.authorize.api.contract.v1.TransactionRequestType; +import net.authorize.api.contract.v1.TransactionResponse; import net.authorize.api.contract.v1.TransactionTypeEnum; import net.authorize.api.controller.CreateTransactionController; import net.authorize.api.controller.base.ApiOperationBase; @@ -57,17 +58,40 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub MessagesType responseMessage = response.getMessages(); //validate - if (responseMessage.getResultCode().equals(MessageTypeEnum.OK)) { - System.out.println("Message Code : " + responseMessage.getMessage().get(0).getCode() + " | Message Text : " + responseMessage.getMessage().get(0).getText()); - if (response.getTransactionResponse() != null) { - System.out.println("Success, Response Code : " + response.getTransactionResponse().getResponseCode() + " | Transaction ID : " + response.getTransactionResponse().getTransId()); - } - } else { - System.out.println("Error: " + response.getMessages().getMessage().get(0).getCode() + " " + response.getMessages().getMessage().get(0).getText()); - if (response.getTransactionResponse() != null) { - System.out.println("Transaction Error : " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode() + " : " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); - } + if (response!=null) { + // If API Response is ok, go ahead and check the transaction response + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + TransactionResponse result = response.getTransactionResponse(); + if(result.getMessages() != null){ + System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); + System.out.println("Secure Acceptance URL : " + result.getSecureAcceptance().getSecureAcceptanceUrl()); + System.out.println("Auth Code: " + result.getAuthCode()); + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + } + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + else { + System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); + System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); + } + } } + else { + System.out.println("Null Response."); + } + return response; } } \ No newline at end of file diff --git a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationOnlyContinued.java b/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationOnlyContinued.java index 9c9ba464..ce8577d4 100644 --- a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationOnlyContinued.java +++ b/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationOnlyContinued.java @@ -57,29 +57,39 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri CreateTransactionResponse response = controller.getApiResponse(); if (response!=null) { - - // If API Response is ok, go ahead and check the transaction response - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { - - TransactionResponse result = response.getTransactionResponse(); - if (result.getResponseCode().equals("1")) { - System.out.println(result.getResponseCode()); - System.out.println("Successful PayPal Transaction"); - //System.out.println("Reference Transaction ID: " + result.getRefTransID()); - System.out.println("Description: "+result.getMessages().getMessage().get(0).getDescription()); - } - else - { - System.out.println(result.getResponseCode()); - System.out.println("Failed Transaction Description: "+result.getErrors().getError().get(0).getErrorText()); - } - } - else - { - System.out.println("Failed Transaction: "+response.getMessages().getResultCode()); - System.out.println("Error Code: "+response.getMessages().getMessage().get(0).getCode()); - } + // If API Response is ok, go ahead and check the transaction response + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + TransactionResponse result = response.getTransactionResponse(); + if(result.getMessages() != null){ + System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); + + System.out.println("Auth Code: " + result.getAuthCode()); + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + } + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + else { + System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); + System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); + } + } + } + else { + System.out.println("Null Response."); } + return response; } diff --git a/src/main/java/net/authorize/sample/PaypalExpressCheckout/Credit.java b/src/main/java/net/authorize/sample/PaypalExpressCheckout/Credit.java index 4b84d8a6..1e0b6a39 100644 --- a/src/main/java/net/authorize/sample/PaypalExpressCheckout/Credit.java +++ b/src/main/java/net/authorize/sample/PaypalExpressCheckout/Credit.java @@ -44,30 +44,39 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri CreateTransactionResponse response = controller.getApiResponse(); - if (response!=null) { - - // If API Response is ok, go ahead and check the transaction response - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { - - TransactionResponse result = response.getTransactionResponse(); - if (result.getResponseCode().equals("1")) { - System.out.println(result.getResponseCode()); - System.out.println("Successful PayPal Transaction"); - //System.out.println("Reference Transaction ID: " + result.getRefTransID()); - System.out.println(result.getMessages().getMessage().get(0).getDescription()); - } - else - { - System.out.println("Transaction Error: "+result.getErrors().getError().get(0).getErrorCode()+" "+result.getErrors().getError().get(0).getErrorText()); - - } - } - else - { - System.out.println("Error: "+response.getMessages().getMessage().get(0).getCode()+ " " + response.getMessages().getMessage().get(0).getText()); - - } - } + if (response!=null) { + // If API Response is ok, go ahead and check the transaction response + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + TransactionResponse result = response.getTransactionResponse(); + if(result.getMessages() != null){ + System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); + System.out.println("Auth Code: " + result.getAuthCode()); + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + } + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + else { + System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); + System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); + } + } + } + else { + System.out.println("Null Response."); + } + return response; } diff --git a/src/main/java/net/authorize/sample/PaypalExpressCheckout/GetDetails.java b/src/main/java/net/authorize/sample/PaypalExpressCheckout/GetDetails.java index 3db99653..e4922e7b 100644 --- a/src/main/java/net/authorize/sample/PaypalExpressCheckout/GetDetails.java +++ b/src/main/java/net/authorize/sample/PaypalExpressCheckout/GetDetails.java @@ -36,29 +36,49 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri CreateTransactionResponse response = controller.getApiResponse(); - if (response!=null && response.getMessages().getResultCode() == MessageTypeEnum.OK) { - - TransactionResponse result = response.getTransactionResponse(); - if (result.getResponseCode().equals("1")) { - System.out.println("Successful PayPal Get Details Transaction"); - System.out.println("Account Type : "+ result.getAccountType()); - if(result.getSecureAcceptance() != null) - System.out.println("PayPal PayerID : "+ result.getSecureAcceptance().getPayerID()); - - if(result.getShipTo() != null) { - System.out.println("Shipping Address : "+ result.getShipTo().getFirstName()); - System.out.println(result.getShipTo().getAddress() +" " + result.getShipTo().getCity()); - System.out.println(result.getShipTo().getState() +" "+ result.getShipTo().getZip()); - System.out.println(result.getShipTo().getCountry()); - } - - System.out.println("Transaction ID : " + result.getTransId()); - } + if (response!=null) { + // If API Response is ok, go ahead and check the transaction response + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + TransactionResponse result = response.getTransactionResponse(); + if(result.getMessages() != null){ + System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); + System.out.println("Auth Code: " + result.getAuthCode()); + + if(result.getSecureAcceptance() != null) + System.out.println("PayPal PayerID : "+ result.getSecureAcceptance().getPayerID()); + + if(result.getShipTo() != null) { + System.out.println("Shipping Address : "+ result.getShipTo().getFirstName()); + System.out.println(result.getShipTo().getAddress() +" " + result.getShipTo().getCity()); + System.out.println(result.getShipTo().getState() +" "+ result.getShipTo().getZip()); + System.out.println(result.getShipTo().getCountry()); + } + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + } + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + else { + System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); + System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); + } + } } - else - { - System.out.println("Failed Transaction: "+response.getMessages().getMessage().get(0).getCode()+ " " + response.getMessages().getMessage().get(0).getText()); + else { + System.out.println("Null Response."); } + return response; } diff --git a/src/main/java/net/authorize/sample/PaypalExpressCheckout/PriorAuthorizationCapture.java b/src/main/java/net/authorize/sample/PaypalExpressCheckout/PriorAuthorizationCapture.java index 9e86cb22..f9326953 100644 --- a/src/main/java/net/authorize/sample/PaypalExpressCheckout/PriorAuthorizationCapture.java +++ b/src/main/java/net/authorize/sample/PaypalExpressCheckout/PriorAuthorizationCapture.java @@ -55,16 +55,39 @@ public static ANetApiResponse run(String apiLoginId, String apiTransactionKey, S CreateTransactionResponse response = controller.getApiResponse(); - // If API Response is ok, go ahead and check the transaction response - if (response.getMessages().getResultCode() == MessageTypeEnum.OK){ - if (response.getTransactionResponse() != null){ - System.out.println("Success, Auth Code: " + response.getTransactionResponse().getAuthCode()); - } + if (response!=null) { + // If API Response is ok, go ahead and check the transaction response + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + TransactionResponse result = response.getTransactionResponse(); + if(result.getMessages() != null){ + System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); + System.out.println("Auth Code: " + result.getAuthCode()); + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + } + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + else { + System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); + System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); + } + } } - else{ - System.out.println("Error: " + response.getMessages().getMessage().get(0).getCode() + - " " + response.getMessages().getMessage().get(0).getText()); + else { + System.out.println("Null Response."); } + return response; } } diff --git a/src/main/java/net/authorize/sample/PaypalExpressCheckout/Void.java b/src/main/java/net/authorize/sample/PaypalExpressCheckout/Void.java index f4fdbfad..6c294b9f 100644 --- a/src/main/java/net/authorize/sample/PaypalExpressCheckout/Void.java +++ b/src/main/java/net/authorize/sample/PaypalExpressCheckout/Void.java @@ -50,26 +50,40 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri CreateTransactionResponse response = controller.getApiResponse(); - // If API Response is ok, go ahead and check the transaction response - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + if (response!=null) { + // If API Response is ok, go ahead and check the transaction response + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + TransactionResponse result = response.getTransactionResponse(); + if(result.getMessages() != null){ + System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); - if (response.getTransactionResponse() != null) - { - TransactionResponse result = response.getTransactionResponse(); - System.out.println("Successful Paypal Void Transaction"); - System.out.println("Response Code : " + result.getResponseCode()); - } - } - else - { - System.out.println("Failed Paypal Void Transaction"); - if(!response.getMessages().getMessage().isEmpty()) - System.out.println("Error: " + response.getMessages().getMessage().get(0).getCode() + " " + response.getMessages().getMessage().get(0).getText()); - - if (response.getTransactionResponse() != null) - if(!response.getTransactionResponse().getErrors().getError().isEmpty()) - System.out.println("Transaction Error : " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode() + " " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); - } + System.out.println("Auth Code: " + result.getAuthCode()); + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + } + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + else { + System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); + System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); + } + } + } + else { + System.out.println("Null Response."); + } + return response; } diff --git a/src/main/java/net/authorize/sample/VisaCheckout/CreateVisaCheckoutTransaction.java b/src/main/java/net/authorize/sample/VisaCheckout/CreateVisaCheckoutTransaction.java index c6b40700..028a2836 100644 --- a/src/main/java/net/authorize/sample/VisaCheckout/CreateVisaCheckoutTransaction.java +++ b/src/main/java/net/authorize/sample/VisaCheckout/CreateVisaCheckoutTransaction.java @@ -57,24 +57,39 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) { CreateTransactionResponse response = controller.getApiResponse(); - if (response!=null) { - - // If API Response is ok, go ahead and check the transaction response - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { - - TransactionResponse result = response.getTransactionResponse(); - if (result.getResponseCode().equals("1")) { - System.out.println(result.getResponseCode()); - System.out.println("Successful Visa Checkout Transaction"); - System.out.println(result.getAuthCode()); - System.out.println(result.getTransId()); - } - else - { - System.out.println("Failed Transaction"+result.getResponseCode()); - } - } - } + if (response!=null) { + // If API Response is ok, go ahead and check the transaction response + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + TransactionResponse result = response.getTransactionResponse(); + if(result.getMessages() != null){ + System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); + System.out.println("Auth Code: " + result.getAuthCode()); + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + } + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + else { + System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); + System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); + } + } + } + else { + System.out.println("Null Response."); + } + return response; } From 9e351fbe0b72fed7d63a861dad0cb7a3e1bd6800 Mon Sep 17 00:00:00 2001 From: srathod Date: Thu, 25 Aug 2016 20:01:04 +0530 Subject: [PATCH 058/176] - Reverting AuthorizeCreditCard change. --- .../PaymentTransactions/AuthorizeCreditCard.java | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/AuthorizeCreditCard.java b/src/main/java/net/authorize/sample/PaymentTransactions/AuthorizeCreditCard.java index 7890d2a0..59b2f943 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/AuthorizeCreditCard.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/AuthorizeCreditCard.java @@ -31,24 +31,12 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub creditCard.setCardNumber("4242424242424242"); creditCard.setExpirationDate("0822"); paymentType.setCreditCard(creditCard); - - - CustomerAddressType customerAddressType = new CustomerAddressType(); - customerAddressType.setFirstName("John"); - customerAddressType.setLastName("Doe"); - customerAddressType.setAddress("123 Main St."); - customerAddressType.setCity("Bellevue"); - customerAddressType.setState("WA"); - customerAddressType.setZip("46282"); - customerAddressType.setCountry("USA"); - customerAddressType.setPhoneNumber("000-000-0000"); // Create the payment transaction request TransactionRequestType txnRequest = new TransactionRequestType(); txnRequest.setTransactionType(TransactionTypeEnum.AUTH_ONLY_TRANSACTION.value()); txnRequest.setPayment(paymentType); txnRequest.setAmount(new BigDecimal(amount).setScale(2, RoundingMode.CEILING)); - txnRequest.setBillTo(customerAddressType); // Make the API Request CreateTransactionRequest apiRequest = new CreateTransactionRequest(); From 4694a25c39b49764d105c79147bc04682c04b1b9 Mon Sep 17 00:00:00 2001 From: srathod Date: Fri, 26 Aug 2016 23:03:58 +0530 Subject: [PATCH 059/176] Adding prints for response codes and message codes. --- .../MobileInappTransactions/CreateAnAcceptTransaction.java | 2 ++ .../CreateAnAndroidPayTransaction.java | 2 ++ .../MobileInappTransactions/CreateAnApplePayTransaction.java | 2 ++ .../sample/PaymentTransactions/AuthorizeCreditCard.java | 2 ++ .../CaptureFundsAuthorizedThroughAnotherChannel.java | 2 ++ .../CapturePreviouslyAuthorizedAmount.java | 2 ++ .../sample/PaymentTransactions/ChargeCreditCard.java | 2 ++ .../sample/PaymentTransactions/ChargeCustomerProfile.java | 2 ++ .../sample/PaymentTransactions/ChargeTokenizedCreditCard.java | 2 ++ .../sample/PaymentTransactions/CreditBankAccount.java | 2 ++ .../sample/PaymentTransactions/DebitBankAccount.java | 2 ++ .../sample/PaymentTransactions/RefundTransaction.java | 2 ++ .../authorize/sample/PaymentTransactions/VoidTransaction.java | 2 ++ .../sample/PaypalExpressCheckout/AuthorizationAndCapture.java | 3 ++- .../AuthorizationAndCaptureContinue.java | 3 ++- .../sample/PaypalExpressCheckout/AuthorizationOnly.java | 3 ++- .../PaypalExpressCheckout/AuthorizationOnlyContinued.java | 4 ++-- .../net/authorize/sample/PaypalExpressCheckout/Credit.java | 3 ++- .../authorize/sample/PaypalExpressCheckout/GetDetails.java | 3 ++- .../PaypalExpressCheckout/PriorAuthorizationCapture.java | 3 ++- .../java/net/authorize/sample/PaypalExpressCheckout/Void.java | 4 ++-- .../sample/VisaCheckout/CreateVisaCheckoutTransaction.java | 2 ++ 22 files changed, 44 insertions(+), 10 deletions(-) diff --git a/src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnAcceptTransaction.java b/src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnAcceptTransaction.java index c70eb81b..37d40487 100644 --- a/src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnAcceptTransaction.java +++ b/src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnAcceptTransaction.java @@ -44,6 +44,8 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) TransactionResponse result = response.getTransactionResponse(); if(result.getMessages() != null){ System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Response Code: " + result.getResponseCode()); + System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); System.out.println("Auth code : " + result.getAuthCode()); } diff --git a/src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnAndroidPayTransaction.java b/src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnAndroidPayTransaction.java index b7c9311f..03e1b0d9 100644 --- a/src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnAndroidPayTransaction.java +++ b/src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnAndroidPayTransaction.java @@ -44,6 +44,8 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) { TransactionResponse result = response.getTransactionResponse(); if (result.getMessages() != null) { System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Response Code: " + result.getResponseCode()); + System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); System.out.println("Auth code : " + result.getAuthCode()); } else { diff --git a/src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnApplePayTransaction.java b/src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnApplePayTransaction.java index 948c532d..a3335ea5 100644 --- a/src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnApplePayTransaction.java +++ b/src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnApplePayTransaction.java @@ -44,6 +44,8 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) TransactionResponse result = response.getTransactionResponse(); if(result.getMessages() != null){ System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Response Code: " + result.getResponseCode()); + System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); System.out.println("Auth code : " + result.getAuthCode()); } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/AuthorizeCreditCard.java b/src/main/java/net/authorize/sample/PaymentTransactions/AuthorizeCreditCard.java index 59b2f943..9797d382 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/AuthorizeCreditCard.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/AuthorizeCreditCard.java @@ -53,6 +53,8 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub TransactionResponse result = response.getTransactionResponse(); if(result.getMessages() != null){ System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Response Code: " + result.getResponseCode()); + System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); System.out.println("Auth code: " + result.getAuthCode()); } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/CaptureFundsAuthorizedThroughAnotherChannel.java b/src/main/java/net/authorize/sample/PaymentTransactions/CaptureFundsAuthorizedThroughAnotherChannel.java index 81079393..1e3edaf1 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/CaptureFundsAuthorizedThroughAnotherChannel.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/CaptureFundsAuthorizedThroughAnotherChannel.java @@ -61,6 +61,8 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub TransactionResponse result = response.getTransactionResponse(); if(result.getMessages() != null){ System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Response Code: " + result.getResponseCode()); + System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); System.out.println("Auth Code: " + result.getAuthCode()); } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/CapturePreviouslyAuthorizedAmount.java b/src/main/java/net/authorize/sample/PaymentTransactions/CapturePreviouslyAuthorizedAmount.java index 7f584a57..5762c281 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/CapturePreviouslyAuthorizedAmount.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/CapturePreviouslyAuthorizedAmount.java @@ -42,6 +42,8 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri TransactionResponse result = response.getTransactionResponse(); if(result.getMessages() != null){ System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Response Code: " + result.getResponseCode()); + System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); System.out.println("Auth Code: " + result.getAuthCode()); } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCreditCard.java b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCreditCard.java index 728820ab..eb165619 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCreditCard.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCreditCard.java @@ -62,6 +62,8 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub TransactionResponse result = response.getTransactionResponse(); if(result.getMessages() != null){ System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Response Code: " + result.getResponseCode()); + System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); System.out.println("Auth Code: " + result.getAuthCode()); } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCustomerProfile.java b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCustomerProfile.java index 5281c97f..6645a2d0 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCustomerProfile.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCustomerProfile.java @@ -64,6 +64,8 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri TransactionResponse result = response.getTransactionResponse(); if(result.getMessages() != null){ System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Response Code: " + result.getResponseCode()); + System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); System.out.println("Auth Code: " + result.getAuthCode()); } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeTokenizedCreditCard.java b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeTokenizedCreditCard.java index 16947723..88140615 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeTokenizedCreditCard.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeTokenizedCreditCard.java @@ -63,6 +63,8 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub TransactionResponse result = response.getTransactionResponse(); if(result.getMessages() != null){ System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Response Code: " + result.getResponseCode()); + System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); System.out.println("Auth Code: " + result.getAuthCode()); } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java b/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java index 5d95e4cc..df8e1ccc 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java @@ -66,6 +66,8 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri TransactionResponse result = response.getTransactionResponse(); if(result.getMessages() != null){ System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Response Code: " + result.getResponseCode()); + System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); System.out.println("Auth Code: " + result.getAuthCode()); } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java b/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java index 4dd76336..f45e53d2 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java @@ -65,6 +65,8 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub TransactionResponse result = response.getTransactionResponse(); if(result.getMessages() != null){ System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Response Code: " + result.getResponseCode()); + System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); System.out.println("Auth Code: " + result.getAuthCode()); } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/RefundTransaction.java b/src/main/java/net/authorize/sample/PaymentTransactions/RefundTransaction.java index a8876574..4c1b1675 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/RefundTransaction.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/RefundTransaction.java @@ -51,6 +51,8 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub TransactionResponse result = response.getTransactionResponse(); if(result.getMessages() != null){ System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Response Code: " + result.getResponseCode()); + System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); System.out.println("Auth Code: " + result.getAuthCode()); } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/VoidTransaction.java b/src/main/java/net/authorize/sample/PaymentTransactions/VoidTransaction.java index a8d6a931..e713249a 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/VoidTransaction.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/VoidTransaction.java @@ -42,6 +42,8 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri TransactionResponse result = response.getTransactionResponse(); if(result.getMessages() != null){ System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Response Code: " + result.getResponseCode()); + System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); System.out.println("Auth Code: " + result.getAuthCode()); } diff --git a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCapture.java b/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCapture.java index 85766c6d..15c273c0 100644 --- a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCapture.java +++ b/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCapture.java @@ -60,9 +60,10 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub TransactionResponse result = response.getTransactionResponse(); if(result.getMessages() != null){ System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Response Code: " + result.getResponseCode()); + System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); System.out.println("Secure Acceptance URL : " + result.getSecureAcceptance().getSecureAcceptanceUrl()); - System.out.println("Auth Code: " + result.getAuthCode()); } else { System.out.println("Failed Transaction."); diff --git a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCaptureContinue.java b/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCaptureContinue.java index b884b6e1..59a00532 100644 --- a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCaptureContinue.java +++ b/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCaptureContinue.java @@ -69,8 +69,9 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri TransactionResponse result = response.getTransactionResponse(); if(result.getMessages() != null){ System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Response Code: " + result.getResponseCode()); + System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); - System.out.println("Auth Code: " + result.getAuthCode()); } else { System.out.println("Failed Transaction."); diff --git a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationOnly.java b/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationOnly.java index c4882b6d..b62461e4 100644 --- a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationOnly.java +++ b/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationOnly.java @@ -64,9 +64,10 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub TransactionResponse result = response.getTransactionResponse(); if(result.getMessages() != null){ System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Response Code: " + result.getResponseCode()); + System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); System.out.println("Secure Acceptance URL : " + result.getSecureAcceptance().getSecureAcceptanceUrl()); - System.out.println("Auth Code: " + result.getAuthCode()); } else { System.out.println("Failed Transaction."); diff --git a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationOnlyContinued.java b/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationOnlyContinued.java index ce8577d4..05954d3b 100644 --- a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationOnlyContinued.java +++ b/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationOnlyContinued.java @@ -62,9 +62,9 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri TransactionResponse result = response.getTransactionResponse(); if(result.getMessages() != null){ System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Response Code: " + result.getResponseCode()); + System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); - - System.out.println("Auth Code: " + result.getAuthCode()); } else { System.out.println("Failed Transaction."); diff --git a/src/main/java/net/authorize/sample/PaypalExpressCheckout/Credit.java b/src/main/java/net/authorize/sample/PaypalExpressCheckout/Credit.java index 1e0b6a39..ea252a74 100644 --- a/src/main/java/net/authorize/sample/PaypalExpressCheckout/Credit.java +++ b/src/main/java/net/authorize/sample/PaypalExpressCheckout/Credit.java @@ -50,8 +50,9 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri TransactionResponse result = response.getTransactionResponse(); if(result.getMessages() != null){ System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Response Code: " + result.getResponseCode()); + System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); - System.out.println("Auth Code: " + result.getAuthCode()); } else { System.out.println("Failed Transaction."); diff --git a/src/main/java/net/authorize/sample/PaypalExpressCheckout/GetDetails.java b/src/main/java/net/authorize/sample/PaypalExpressCheckout/GetDetails.java index e4922e7b..e8b53403 100644 --- a/src/main/java/net/authorize/sample/PaypalExpressCheckout/GetDetails.java +++ b/src/main/java/net/authorize/sample/PaypalExpressCheckout/GetDetails.java @@ -42,8 +42,9 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri TransactionResponse result = response.getTransactionResponse(); if(result.getMessages() != null){ System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Response Code: " + result.getResponseCode()); + System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); - System.out.println("Auth Code: " + result.getAuthCode()); if(result.getSecureAcceptance() != null) System.out.println("PayPal PayerID : "+ result.getSecureAcceptance().getPayerID()); diff --git a/src/main/java/net/authorize/sample/PaypalExpressCheckout/PriorAuthorizationCapture.java b/src/main/java/net/authorize/sample/PaypalExpressCheckout/PriorAuthorizationCapture.java index f9326953..7b143889 100644 --- a/src/main/java/net/authorize/sample/PaypalExpressCheckout/PriorAuthorizationCapture.java +++ b/src/main/java/net/authorize/sample/PaypalExpressCheckout/PriorAuthorizationCapture.java @@ -61,8 +61,9 @@ public static ANetApiResponse run(String apiLoginId, String apiTransactionKey, S TransactionResponse result = response.getTransactionResponse(); if(result.getMessages() != null){ System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Response Code: " + result.getResponseCode()); + System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); - System.out.println("Auth Code: " + result.getAuthCode()); } else { System.out.println("Failed Transaction."); diff --git a/src/main/java/net/authorize/sample/PaypalExpressCheckout/Void.java b/src/main/java/net/authorize/sample/PaypalExpressCheckout/Void.java index 6c294b9f..705d2af7 100644 --- a/src/main/java/net/authorize/sample/PaypalExpressCheckout/Void.java +++ b/src/main/java/net/authorize/sample/PaypalExpressCheckout/Void.java @@ -56,9 +56,9 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri TransactionResponse result = response.getTransactionResponse(); if(result.getMessages() != null){ System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Response Code: " + result.getResponseCode()); + System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); - - System.out.println("Auth Code: " + result.getAuthCode()); } else { System.out.println("Failed Transaction."); diff --git a/src/main/java/net/authorize/sample/VisaCheckout/CreateVisaCheckoutTransaction.java b/src/main/java/net/authorize/sample/VisaCheckout/CreateVisaCheckoutTransaction.java index 028a2836..f4b8d40d 100644 --- a/src/main/java/net/authorize/sample/VisaCheckout/CreateVisaCheckoutTransaction.java +++ b/src/main/java/net/authorize/sample/VisaCheckout/CreateVisaCheckoutTransaction.java @@ -63,6 +63,8 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) { TransactionResponse result = response.getTransactionResponse(); if(result.getMessages() != null){ System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Response Code: " + result.getResponseCode()); + System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); System.out.println("Auth Code: " + result.getAuthCode()); } From 2631236bfa9d789c76b48b947c2e8599379068e4 Mon Sep 17 00:00:00 2001 From: srathod Date: Sun, 28 Aug 2016 11:15:55 +0530 Subject: [PATCH 060/176] - randomizing description to avoid duplicate record error. --- .../sample/CustomerProfiles/CreateCustomerProfile.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfile.java b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfile.java index 52aae7b6..f836c50e 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfile.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfile.java @@ -30,7 +30,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri CustomerProfileType customerProfileType = new CustomerProfileType(); customerProfileType.setMerchantCustomerId("M_" + eMail); - customerProfileType.setDescription("Profile description here"); + customerProfileType.setDescription("Profile description for " + eMail); customerProfileType.setEmail(eMail); customerProfileType.getPaymentProfiles().add(customerPaymentProfileType); From 3948f2576df6d642617c823fb057e2a7aed8674b Mon Sep 17 00:00:00 2001 From: srathod Date: Mon, 3 Oct 2016 18:29:42 +0530 Subject: [PATCH 061/176] - Adding multi threading test. --- .../net/authorize/sample/TestMultiThread.java | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 src/main/java/net/authorize/sample/TestMultiThread.java diff --git a/src/main/java/net/authorize/sample/TestMultiThread.java b/src/main/java/net/authorize/sample/TestMultiThread.java new file mode 100644 index 00000000..d53bd615 --- /dev/null +++ b/src/main/java/net/authorize/sample/TestMultiThread.java @@ -0,0 +1,101 @@ +package net.authorize.sample; + +import java.security.SecureRandom; +import java.text.DecimalFormat; +import java.util.Date; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +import net.authorize.api.contract.v1.CreateCustomerPaymentProfileResponse; +import net.authorize.api.contract.v1.CreateCustomerProfileResponse; +import net.authorize.api.contract.v1.CreateTransactionResponse; +import net.authorize.sample.CustomerProfiles.CreateCustomerPaymentProfile; +import net.authorize.sample.CustomerProfiles.CreateCustomerProfile; +import net.authorize.sample.PaymentTransactions.ChargeCustomerProfile; + +public class TestMultiThread { + + private static final int MYTHREADS = 120; + private static String apiLoginId = "5KP3u95bQpv"; + private static String transactionKey = "346HZ32z3fP4hTG2"; + + static SecureRandom rgenerator = new SecureRandom(); + + private static Double getAmount() + { + double d = (double)(1.05 + (450.0 * rgenerator.nextDouble())); + DecimalFormat df = new DecimalFormat("#.##"); + d = Double.valueOf(df.format(d)); + return d; + } + + private static String getEmail() + { + return rgenerator.nextInt(10000) + "@test.com"; + } + + public static void main(String args[]) throws Exception { + ExecutorService executor = Executors.newFixedThreadPool(MYTHREADS); + + Date dt1 = new Date(); + for (int i = 0; i < MYTHREADS; i++) { + Runnable worker = new MyRunnable(); + executor.execute(worker); + } + executor.shutdown(); + + // Wait until all threads are finish + while (!executor.isTerminated()) { + + } + Date dt2 = new Date(); + long difference = dt2.getTime() - dt1.getTime(); + + System.out.println("\nFinished all threads : " + difference/1000 + " sec"); + } + + public static class MyRunnable implements Runnable { + + @Override + public void run() { + CreateCustomerProfileResponse response = null; + CreateCustomerPaymentProfileResponse paymentProfileResponse = null; + + try{ + response = (CreateCustomerProfileResponse)CreateCustomerProfile.run(apiLoginId, transactionKey, getEmail()); + paymentProfileResponse = (CreateCustomerPaymentProfileResponse)CreateCustomerPaymentProfile.run(apiLoginId, transactionKey, response.getCustomerProfileId()); + } + catch (Exception e) { + System.out.println("Failure in CIM calls."); + System.out.println(e.getMessage()); + return; + } + + try { + Date dt1 = new Date(); + System.out.println("============================================================================"); + System.out.println("chargeResponse Dt1: + " + dt1.toString()); + + if((response.getCustomerProfileId() != null) && (paymentProfileResponse.getCustomerPaymentProfileId() != null)) + { + CreateTransactionResponse chargeResponse = (CreateTransactionResponse) ChargeCustomerProfile.run(apiLoginId, transactionKey, + response.getCustomerProfileId(), paymentProfileResponse.getCustomerPaymentProfileId(), getAmount()); + } + else + { + System.out.println("NULL PROFILE IDS."); + } + + Date dt2 = new Date(); + System.out.println("chargeResponse Dt2: + " + dt2.toString()); + + long difference = dt2.getTime() - dt1.getTime(); + System.out.println("chargeResponse Diff: " + difference/1000); + System.out.println("============================================================================"); + } catch (Exception e) { + System.out.println("Failure in charge customer profile call:"); + System.out.println(e.getMessage()); + } + } + } +} From efc6e24f919a7cf1c1350345522ea69c2bcde86b Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Mon, 3 Oct 2016 22:09:44 +0530 Subject: [PATCH 062/176] Update TestRunner.java --- .../java/net/authorize/sample/SampleCodeTest/TestRunner.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java index 08802010..5e01d360 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java +++ b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java @@ -83,7 +83,7 @@ public class TestRunner { private static String getEmail() { - return rgenerator.nextInt(10000) + "@test.com"; + return rgenerator.nextInt(1000000) + "@test.com"; } private static Double getAmount() From ca9786a6300eca332494945c7c6bd8f7083de71e Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Mon, 3 Oct 2016 22:10:36 +0530 Subject: [PATCH 063/176] Update TestRunner.java --- .../java/net/authorize/sample/SampleCodeTest/TestRunner.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java index 08802010..5e01d360 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java +++ b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java @@ -83,7 +83,7 @@ public class TestRunner { private static String getEmail() { - return rgenerator.nextInt(10000) + "@test.com"; + return rgenerator.nextInt(1000000) + "@test.com"; } private static Double getAmount() From 2fb00fea3a98a234969a01c06c5b64908dcb901e Mon Sep 17 00:00:00 2001 From: brianmc Date: Mon, 3 Oct 2016 15:39:16 -0700 Subject: [PATCH 064/176] added MT Test --- pom.xml | 4 +- .../ChargeCustomerProfilesMT.java | 111 ++++++++++++++++++ .../java/net/authorize/sample/SampleCode.java | 3 + 3 files changed, 116 insertions(+), 2 deletions(-) create mode 100644 src/main/java/net/authorize/sample/PaymentTransactions/ChargeCustomerProfilesMT.java diff --git a/pom.xml b/pom.xml index 204219bb..f45776d8 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,7 @@ - 1.9.0 + 1.9.1-SNAPSHOT 4.0.0 net.authorize.sample @@ -14,7 +14,7 @@ net.authorize anet-java-sdk - ${sdkVersion} + 1.9.0 junit diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCustomerProfilesMT.java b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCustomerProfilesMT.java new file mode 100644 index 00000000..8222bc56 --- /dev/null +++ b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCustomerProfilesMT.java @@ -0,0 +1,111 @@ +package net.authorize.sample.PaymentTransactions; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.security.SecureRandom; +import java.text.DecimalFormat; +import java.util.Date; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +import net.authorize.Environment; +import net.authorize.api.contract.v1.*; +import net.authorize.api.controller.CreateTransactionController; +import net.authorize.api.controller.base.ApiOperationBase; +import net.authorize.sample.CustomerProfiles.CreateCustomerPaymentProfile; +import net.authorize.sample.CustomerProfiles.CreateCustomerProfile; + +public class ChargeCustomerProfilesMT { + + private static final int MYTHREADS = 120; + private static String apiLoginId = "5KP3u95bQpv"; + private static String transactionKey = "346HZ32z3fP4hTG2"; + + static SecureRandom rgenerator = new SecureRandom(); + + private static Double getAmount() + { + double d = (double)(1.05 + (450.0 * rgenerator.nextDouble())); + DecimalFormat df = new DecimalFormat("#.##"); + d = Double.valueOf(df.format(d)); + return d; + } + + private static String getEmail() + { + return rgenerator.nextInt(10000000) + "@test.com"; + } + + // + // Run this sample from command line with: + // java -jar target/ChargeCreditCard-jar-with-dependencies.jar + // + public static Boolean run() { + + + ExecutorService executor = Executors.newFixedThreadPool(MYTHREADS); + + Date dt1 = new Date(); + for (int i = 0; i < MYTHREADS; i++) { + Runnable worker = new MyRunnable(); + executor.execute(worker); + } + executor.shutdown(); + + // Wait until all threads are finish + while (!executor.isTerminated()) { + + } + Date dt2 = new Date(); + long difference = dt2.getTime() - dt1.getTime(); + + System.out.println("\nFinished all threads : " + difference/1000 + " sec"); + + return true; + } + + public static class MyRunnable implements Runnable { + + @Override + public void run() { + CreateCustomerProfileResponse response = null; + CreateCustomerPaymentProfileResponse paymentProfileResponse = null; + + try{ + response = (CreateCustomerProfileResponse) CreateCustomerProfile.run(apiLoginId, transactionKey, getEmail()); + paymentProfileResponse = (CreateCustomerPaymentProfileResponse) CreateCustomerPaymentProfile.run(apiLoginId, transactionKey, response.getCustomerProfileId()); + } + catch (Exception e) { + System.out.println("Failure in CIM calls."); + System.out.println(e.getMessage()); + return; + } + + try { + Date dt1 = new Date(); + System.out.println("============================================================================"); + System.out.println("chargeResponse Dt1: + " + dt1.toString()); + + if((response.getCustomerProfileId() != null) && (paymentProfileResponse.getCustomerPaymentProfileId() != null)) + { + CreateTransactionResponse chargeResponse = (CreateTransactionResponse) ChargeCustomerProfile.run(apiLoginId, transactionKey, + response.getCustomerProfileId(), paymentProfileResponse.getCustomerPaymentProfileId(), getAmount()); + } + else + { + System.out.println("NULL PROFILE IDS."); + } + + Date dt2 = new Date(); + System.out.println("chargeResponse Dt2: + " + dt2.toString()); + + long difference = dt2.getTime() - dt1.getTime(); + System.out.println("chargeResponse Diff: " + difference/1000); + System.out.println("============================================================================"); + } catch (Exception e) { + System.out.println("Failure in charge customer profile call:"); + System.out.println(e.getMessage()); + } + } + } +} diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index c4514ea5..8bcb22b1 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -197,6 +197,9 @@ private static void RunMethod(String methodName) case "ChargeCustomerProfile": ChargeCustomerProfile.run(apiLoginId, transactionKey, customerProfileId, customerPaymentProfileId, amount); break; + case "ChargeCustomerProfilesMT": + ChargeCustomerProfilesMT.run(); + break; case "CreateSubscription": CreateSubscription.run(apiLoginId, transactionKey, (short)12, amount); break; From b4dd6b558b3b6400c62ab6ba98a0796f7de186ba Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Tue, 4 Oct 2016 16:49:23 +0530 Subject: [PATCH 065/176] Update pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f45776d8..14224c10 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,7 @@ - 1.9.1-SNAPSHOT + 1.9.1 4.0.0 net.authorize.sample From e51c081e4a9527409385aa182378e94c9b69bd64 Mon Sep 17 00:00:00 2001 From: sunnyrajrathod Date: Thu, 24 Nov 2016 11:12:11 +0530 Subject: [PATCH 066/176] - Updating samples for q4 api. --- .../GetHostedPaymentPage.java | 60 ++++++++++++ .../UpdateHeldTransaction.java | 98 +++++++++++++++++++ .../java/net/authorize/sample/SampleCode.java | 12 +++ .../GetMerchantDetails.java | 48 +++++++++ .../GetTransactionList.java | 12 +++ .../GetUnsettledTransactionList.java | 16 ++- .../sample/SampleCodeTest/SampleCodeList.txt | 3 + 7 files changed, 246 insertions(+), 3 deletions(-) create mode 100644 src/main/java/net/authorize/sample/CustomerProfiles/GetHostedPaymentPage.java create mode 100644 src/main/java/net/authorize/sample/PaymentTransactions/UpdateHeldTransaction.java create mode 100644 src/main/java/net/authorize/sample/TransactionReporting/GetMerchantDetails.java diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/GetHostedPaymentPage.java b/src/main/java/net/authorize/sample/CustomerProfiles/GetHostedPaymentPage.java new file mode 100644 index 00000000..25c33aae --- /dev/null +++ b/src/main/java/net/authorize/sample/CustomerProfiles/GetHostedPaymentPage.java @@ -0,0 +1,60 @@ +package net.authorize.sample.CustomerProfiles; + +import java.math.BigDecimal; + +import net.authorize.Environment; +import net.authorize.api.contract.v1.*; +import net.authorize.api.controller.base.ApiOperationBase; +import net.authorize.api.controller.GetHostedPaymentPageController; +import net.authorize.api.controller.GetHostedProfilePageController; +import net.authorize.api.controller.base.ApiOperationBase; + +public class GetHostedPaymentPage { + + public static ANetApiResponse run(String apiLoginId, String transactionKey) { + + ApiOperationBase.setEnvironment(Environment.SANDBOX); + + MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; + merchantAuthenticationType.setName(apiLoginId); + merchantAuthenticationType.setTransactionKey(transactionKey); + ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); + + SettingType setting = new SettingType(); + setting.setSettingName("hostedPaymentReturnOptions"); + setting.setSettingValue("https://returnurl.com/return/"); + + ArrayOfSetting alist = new ArrayOfSetting(); + alist.getSetting().add(setting); + + TransactionRequestType reqType = new TransactionRequestType(); + reqType.setAmount(new BigDecimal("12.42")); + reqType.setTransactionType(TransactionTypeEnum.AUTH_ONLY_TRANSACTION.value()); + + GetHostedPaymentPageRequest apiRequest = new GetHostedPaymentPageRequest(); + apiRequest.setTransactionRequest(reqType); + apiRequest.setHostedPaymentSettings(alist); + + GetHostedPaymentPageController controller = new GetHostedPaymentPageController(apiRequest); + controller.execute(); + + GetHostedPaymentPageResponse response = new GetHostedPaymentPageResponse(); + response = controller.getApiResponse(); + + if (response!=null) { + + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + + System.out.println(response.getMessages().getMessage().get(0).getCode()); + System.out.println(response.getMessages().getMessage().get(0).getText()); + + System.out.println(response.getToken()); + } + else + { + System.out.println("Failed to get hosted payment page: " + response.getMessages().getResultCode()); + } + } + return response; + } +} \ No newline at end of file diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/UpdateHeldTransaction.java b/src/main/java/net/authorize/sample/PaymentTransactions/UpdateHeldTransaction.java new file mode 100644 index 00000000..0bae9797 --- /dev/null +++ b/src/main/java/net/authorize/sample/PaymentTransactions/UpdateHeldTransaction.java @@ -0,0 +1,98 @@ +package net.authorize.sample.PaymentTransactions; + +import java.math.BigDecimal; +import java.math.RoundingMode; + +import net.authorize.Environment; +import net.authorize.api.contract.v1.ANetApiResponse; +import net.authorize.api.contract.v1.AfdsTransactionEnum; +import net.authorize.api.contract.v1.CreateTransactionRequest; +import net.authorize.api.contract.v1.CreateTransactionResponse; +import net.authorize.api.contract.v1.CreditCardType; +import net.authorize.api.contract.v1.HeldTransactionRequestType; +import net.authorize.api.contract.v1.MerchantAuthenticationType; +import net.authorize.api.contract.v1.MessageTypeEnum; +import net.authorize.api.contract.v1.PaymentType; +import net.authorize.api.contract.v1.TransactionRequestType; +import net.authorize.api.contract.v1.TransactionResponse; +import net.authorize.api.contract.v1.TransactionTypeEnum; +import net.authorize.api.contract.v1.UpdateHeldTransactionRequest; +import net.authorize.api.contract.v1.UpdateHeldTransactionResponse; +import net.authorize.api.controller.CreateTransactionController; +import net.authorize.api.controller.UpdateHeldTransactionController; +import net.authorize.api.controller.base.ApiOperationBase; + +public class UpdateHeldTransaction { + + public static ANetApiResponse run(String apiLoginId, String transactionKey, String transactionId) { + + //Common code to set for all requests + ApiOperationBase.setEnvironment(Environment.SANDBOX); + + MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; + merchantAuthenticationType.setName(apiLoginId); + merchantAuthenticationType.setTransactionKey(transactionKey); + ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); + + // Populate the payment data + PaymentType paymentType = new PaymentType(); + CreditCardType creditCard = new CreditCardType(); + creditCard.setCardNumber("4242424242424242"); + creditCard.setExpirationDate("0822"); + paymentType.setCreditCard(creditCard); + + // Create the payment transaction request + HeldTransactionRequestType txnRequest = new HeldTransactionRequestType(); + txnRequest.setAction(AfdsTransactionEnum.APPROVE); + txnRequest.setRefTransId(transactionId); + + // Make the API Request + UpdateHeldTransactionRequest apiRequest = new UpdateHeldTransactionRequest(); + apiRequest.setHeldTransactionRequest(txnRequest); + UpdateHeldTransactionController controller = new UpdateHeldTransactionController(apiRequest); + controller.execute(); + + + UpdateHeldTransactionResponse response = controller.getApiResponse(); + + if (response!=null) { + // If API Response is ok, go ahead and check the transaction response + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + TransactionResponse result = response.getTransactionResponse(); + if(result.getMessages() != null){ + System.out.println("Successfully updated transaction with Transaction ID: " + result.getTransId()); + System.out.println("Response Code: " + result.getResponseCode()); + System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); + System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); + System.out.println("Auth Code: " + result.getAuthCode()); + } + else { + System.out.println("Failed while updating transaction."); + if(response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + } + } + else { + System.out.println("Failed while updating transaction."); + if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + else { + System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); + System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); + } + } + } + else { + System.out.println("Null Response."); + } + + return response; + } + + + +} diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index 8bcb22b1..1f5c8b55 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -125,6 +125,9 @@ private static void ShowMethods() System.out.println(" PayPalAuthorizeOnlyContinue"); System.out.println(" PayPalCredit"); System.out.println(" UpdateSplitTenderGroup"); + System.out.println(" GetMerchantDetails"); + System.out.println(" UpdateHeldTransaction"); + System.out.println(" GetHostedPaymentPage"); } private static void RunMethod(String methodName) @@ -307,6 +310,15 @@ private static void RunMethod(String methodName) case "UpdateSplitTenderGroup": UpdateSplitTenderGroup.run(apiLoginId, transactionKey); break; + case "GetMerchantDetails": + GetMerchantDetails.run(apiLoginId, transactionKey); + break; + case "UpdateHeldTransaction": + UpdateHeldTransaction.run(apiLoginId, transactionKey, transactionId); + break; + case "GetHostedPaymentPage": + GetHostedPaymentPage.run(apiLoginId, transactionKey); + break; default: ShowUsage(); break; diff --git a/src/main/java/net/authorize/sample/TransactionReporting/GetMerchantDetails.java b/src/main/java/net/authorize/sample/TransactionReporting/GetMerchantDetails.java new file mode 100644 index 00000000..f4d3b6da --- /dev/null +++ b/src/main/java/net/authorize/sample/TransactionReporting/GetMerchantDetails.java @@ -0,0 +1,48 @@ +package net.authorize.sample.TransactionReporting; + + +import net.authorize.Environment; +import net.authorize.api.contract.v1.*; +import net.authorize.api.controller.GetMerchantDetailsController; +import net.authorize.api.controller.base.ApiOperationBase; + +public class GetMerchantDetails { + + public static ANetApiResponse run(String apiLoginId, String transactionKey) { + + ApiOperationBase.setEnvironment(Environment.SANDBOX); + + MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; + merchantAuthenticationType.setName(apiLoginId); + merchantAuthenticationType.setTransactionKey(transactionKey); + ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); + + GetMerchantDetailsRequest getRequest = new GetMerchantDetailsRequest(); + getRequest.setMerchantAuthentication(merchantAuthenticationType); + + GetMerchantDetailsController controller = new GetMerchantDetailsController(getRequest); + controller.execute(); + GetMerchantDetailsResponse getResponse = controller.getApiResponse(); + + if (getResponse!=null) { + + if (getResponse.getMessages().getResultCode() == MessageTypeEnum.OK) { + + System.out.println("Merchant Name : " + getResponse.getMerchantName()); + System.out.println("Gateway Id : " + getResponse.getGatewayId()); + + System.out.println(getResponse.getMessages().getMessage().get(0).getCode()); + System.out.println(getResponse.getMessages().getMessage().get(0).getText()); + } + else + { + System.out.println("Failed to get merchant details: " + getResponse.getMessages().getResultCode()); + } + } + return getResponse; +} +} + + + + diff --git a/src/main/java/net/authorize/sample/TransactionReporting/GetTransactionList.java b/src/main/java/net/authorize/sample/TransactionReporting/GetTransactionList.java index 7de38531..eb26d6e8 100644 --- a/src/main/java/net/authorize/sample/TransactionReporting/GetTransactionList.java +++ b/src/main/java/net/authorize/sample/TransactionReporting/GetTransactionList.java @@ -21,6 +21,18 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) { GetTransactionListRequest getRequest = new GetTransactionListRequest(); getRequest.setMerchantAuthentication(merchantAuthenticationType); getRequest.setBatchId(batchId); + + Paging paging = new Paging(); + paging.setLimit(100); + paging.setOffset(1); + + getRequest.setPaging(paging); + + TransactionListSorting sorting = new TransactionListSorting(); + sorting.setOrderBy(TransactionListOrderFieldEnum.ID); + sorting.setOrderDescending(true); + + getRequest.setSorting(sorting); GetTransactionListController controller = new GetTransactionListController(getRequest); controller.execute(); diff --git a/src/main/java/net/authorize/sample/TransactionReporting/GetUnsettledTransactionList.java b/src/main/java/net/authorize/sample/TransactionReporting/GetUnsettledTransactionList.java index ea42f806..30db6265 100644 --- a/src/main/java/net/authorize/sample/TransactionReporting/GetUnsettledTransactionList.java +++ b/src/main/java/net/authorize/sample/TransactionReporting/GetUnsettledTransactionList.java @@ -3,7 +3,6 @@ import net.authorize.Environment; import net.authorize.api.contract.v1.*; - import net.authorize.api.controller.GetSettledBatchListController; import net.authorize.api.controller.GetUnsettledTransactionListController; import net.authorize.api.controller.base.ApiOperationBase; @@ -19,10 +18,21 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) { merchantAuthenticationType.setTransactionKey(transactionKey); ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); - GetUnsettledTransactionListRequest getRequest = new GetUnsettledTransactionListRequest(); getRequest.setMerchantAuthentication(merchantAuthenticationType); - + getRequest.setStatus(TransactionGroupStatusEnum.ANY); + + Paging paging = new Paging(); + paging.setLimit(100); + paging.setOffset(1); + + getRequest.setPaging(paging); + + TransactionListSorting sorting = new TransactionListSorting(); + sorting.setOrderBy(TransactionListOrderFieldEnum.ID); + sorting.setOrderDescending(true); + + getRequest.setSorting(sorting); GetUnsettledTransactionListController controller = new GetUnsettledTransactionListController(getRequest); controller.execute(); diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt b/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt index 1a855724..ba871bd6 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt +++ b/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt @@ -14,6 +14,7 @@ CustomerProfiles.GetCustomerShippingAddress 1 1 CustomerProfiles.GetCustomerProfileIds 0 1 CustomerProfiles.GetCustomerProfile 1 1 CustomerProfiles.GetHostedProfilePage 1 1 +CustomerProfiles.GetHostedPaymentPage 0 0 CustomerProfiles.GetCustomerPaymentProfile 1 1 CustomerProfiles.DeleteCustomerShippingAddress 1 1 CustomerProfiles.DeleteCustomerProfile 1 1 @@ -42,11 +43,13 @@ PaymentTransactions.AuthorizeCreditCard 1 1 PaymentTransactions.DebitBankAccount 1 1 PaymentTransactions.ChargeTokenizedCreditCard 1 1 PaymentTransactions.UpdateSplitTenderGroup 0 1 +PaymentTransactions.UpdateHeldTransation 0 0 TransactionReporting.GetTransactionList 0 1 TransactionReporting.GetUnsettledTransactionList 0 1 TransactionReporting.GetBatchStatistics 0 1 TransactionReporting.GetSettledBatchList 0 1 TransactionReporting.GetTransactionDetails 1 1 +TransactionReporting.GetMerchantDetails 1 1 MobileInappTransactions.CreateAnApplePayTransaction 0 0 MobileInappTransactions.CreateAnAndroidPayTransaction 0 0 MobileInappTransactions.CreateAnAcceptTransaction 0 0 From c24fac3c33f776904dce12ff5a6e3cf467bec34a Mon Sep 17 00:00:00 2001 From: sunnyrajrathod Date: Thu, 24 Nov 2016 11:39:30 +0530 Subject: [PATCH 067/176] - Fix in GetHostedPaymentPage --- .../GetHostedPaymentPage.java | 21 +++++++++++++------ .../java/net/authorize/sample/SampleCode.java | 2 +- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/GetHostedPaymentPage.java b/src/main/java/net/authorize/sample/CustomerProfiles/GetHostedPaymentPage.java index 25c33aae..4a478187 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/GetHostedPaymentPage.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/GetHostedPaymentPage.java @@ -1,6 +1,7 @@ package net.authorize.sample.CustomerProfiles; import java.math.BigDecimal; +import java.math.RoundingMode; import net.authorize.Environment; import net.authorize.api.contract.v1.*; @@ -11,7 +12,7 @@ public class GetHostedPaymentPage { - public static ANetApiResponse run(String apiLoginId, String transactionKey) { + public static ANetApiResponse run(String apiLoginId, String transactionKey, Double amount) { ApiOperationBase.setEnvironment(Environment.SANDBOX); @@ -19,6 +20,18 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) { merchantAuthenticationType.setName(apiLoginId); merchantAuthenticationType.setTransactionKey(transactionKey); ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); + + PaymentType paymentType = new PaymentType(); + CreditCardType creditCard = new CreditCardType(); + creditCard.setCardNumber("4242424242424242"); + creditCard.setExpirationDate("0822"); + paymentType.setCreditCard(creditCard); + + // Create the payment transaction request + TransactionRequestType txnRequest = new TransactionRequestType(); + txnRequest.setTransactionType(TransactionTypeEnum.AUTH_CAPTURE_TRANSACTION.value()); + txnRequest.setPayment(paymentType); + txnRequest.setAmount(new BigDecimal(amount).setScale(2, RoundingMode.CEILING)); SettingType setting = new SettingType(); setting.setSettingName("hostedPaymentReturnOptions"); @@ -26,13 +39,9 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) { ArrayOfSetting alist = new ArrayOfSetting(); alist.getSetting().add(setting); - - TransactionRequestType reqType = new TransactionRequestType(); - reqType.setAmount(new BigDecimal("12.42")); - reqType.setTransactionType(TransactionTypeEnum.AUTH_ONLY_TRANSACTION.value()); GetHostedPaymentPageRequest apiRequest = new GetHostedPaymentPageRequest(); - apiRequest.setTransactionRequest(reqType); + apiRequest.setTransactionRequest(txnRequest); apiRequest.setHostedPaymentSettings(alist); GetHostedPaymentPageController controller = new GetHostedPaymentPageController(apiRequest); diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index 1f5c8b55..e0c499f6 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -317,7 +317,7 @@ private static void RunMethod(String methodName) UpdateHeldTransaction.run(apiLoginId, transactionKey, transactionId); break; case "GetHostedPaymentPage": - GetHostedPaymentPage.run(apiLoginId, transactionKey); + GetHostedPaymentPage.run(apiLoginId, transactionKey, amount); break; default: ShowUsage(); From 5495836f2c88602f4c27d0385af5bbad5ce892ff Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Thu, 24 Nov 2016 19:01:40 +0530 Subject: [PATCH 068/176] Update pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 14224c10..c030d706 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,7 @@ - 1.9.1 + 1.9.2 4.0.0 net.authorize.sample From c7b88bb7b52e3198535a1909a70af3f990860ed6 Mon Sep 17 00:00:00 2001 From: sunnyrajrathod Date: Fri, 25 Nov 2016 15:06:45 +0530 Subject: [PATCH 069/176] - Adding samples for new APIs. --- .../GetHostedPaymentPage.java | 23 ++++++++----------- .../sample/SampleCodeTest/SampleCodeList.txt | 4 ++-- .../sample/SampleCodeTest/TestRunner.java | 9 +++++++- 3 files changed, 20 insertions(+), 16 deletions(-) rename src/main/java/net/authorize/sample/{CustomerProfiles => PaymentTransactions}/GetHostedPaymentPage.java (77%) diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/GetHostedPaymentPage.java b/src/main/java/net/authorize/sample/PaymentTransactions/GetHostedPaymentPage.java similarity index 77% rename from src/main/java/net/authorize/sample/CustomerProfiles/GetHostedPaymentPage.java rename to src/main/java/net/authorize/sample/PaymentTransactions/GetHostedPaymentPage.java index 4a478187..fa85893d 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/GetHostedPaymentPage.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/GetHostedPaymentPage.java @@ -1,4 +1,4 @@ -package net.authorize.sample.CustomerProfiles; +package net.authorize.sample.PaymentTransactions; import java.math.BigDecimal; import java.math.RoundingMode; @@ -7,7 +7,6 @@ import net.authorize.api.contract.v1.*; import net.authorize.api.controller.base.ApiOperationBase; import net.authorize.api.controller.GetHostedPaymentPageController; -import net.authorize.api.controller.GetHostedProfilePageController; import net.authorize.api.controller.base.ApiOperationBase; public class GetHostedPaymentPage { @@ -21,24 +20,22 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub merchantAuthenticationType.setTransactionKey(transactionKey); ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); - PaymentType paymentType = new PaymentType(); - CreditCardType creditCard = new CreditCardType(); - creditCard.setCardNumber("4242424242424242"); - creditCard.setExpirationDate("0822"); - paymentType.setCreditCard(creditCard); - // Create the payment transaction request TransactionRequestType txnRequest = new TransactionRequestType(); txnRequest.setTransactionType(TransactionTypeEnum.AUTH_CAPTURE_TRANSACTION.value()); - txnRequest.setPayment(paymentType); txnRequest.setAmount(new BigDecimal(amount).setScale(2, RoundingMode.CEILING)); - SettingType setting = new SettingType(); - setting.setSettingName("hostedPaymentReturnOptions"); - setting.setSettingValue("https://returnurl.com/return/"); + SettingType setting1 = new SettingType(); + setting1.setSettingName("hostedPaymentButtonOptions"); + setting1.setSettingValue("{\"text\": \"Pay\"}"); + + SettingType setting2 = new SettingType(); + setting2.setSettingName("hostedPaymentOrderOptions"); + setting2.setSettingValue("{\"show\": false}"); ArrayOfSetting alist = new ArrayOfSetting(); - alist.getSetting().add(setting); + alist.getSetting().add(setting1); + alist.getSetting().add(setting2); GetHostedPaymentPageRequest apiRequest = new GetHostedPaymentPageRequest(); apiRequest.setTransactionRequest(txnRequest); diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt b/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt index ba871bd6..bedd5da6 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt +++ b/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt @@ -14,7 +14,6 @@ CustomerProfiles.GetCustomerShippingAddress 1 1 CustomerProfiles.GetCustomerProfileIds 0 1 CustomerProfiles.GetCustomerProfile 1 1 CustomerProfiles.GetHostedProfilePage 1 1 -CustomerProfiles.GetHostedPaymentPage 0 0 CustomerProfiles.GetCustomerPaymentProfile 1 1 CustomerProfiles.DeleteCustomerShippingAddress 1 1 CustomerProfiles.DeleteCustomerProfile 1 1 @@ -44,12 +43,13 @@ PaymentTransactions.DebitBankAccount 1 1 PaymentTransactions.ChargeTokenizedCreditCard 1 1 PaymentTransactions.UpdateSplitTenderGroup 0 1 PaymentTransactions.UpdateHeldTransation 0 0 +PaymentTransactions.GetHostedPaymentPage 1 1 TransactionReporting.GetTransactionList 0 1 TransactionReporting.GetUnsettledTransactionList 0 1 TransactionReporting.GetBatchStatistics 0 1 TransactionReporting.GetSettledBatchList 0 1 TransactionReporting.GetTransactionDetails 1 1 -TransactionReporting.GetMerchantDetails 1 1 +TransactionReporting.GetMerchantDetails 0 1 MobileInappTransactions.CreateAnApplePayTransaction 0 0 MobileInappTransactions.CreateAnAndroidPayTransaction 0 0 MobileInappTransactions.CreateAnAcceptTransaction 0 0 diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java index 5e01d360..4966fde5 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java +++ b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java @@ -71,6 +71,7 @@ import net.authorize.sample.RecurringBilling.GetSubscriptionStatus; import net.authorize.sample.RecurringBilling.UpdateSubscription; import net.authorize.sample.TransactionReporting.GetTransactionDetails; +import net.authorize.sample.PaymentTransactions.GetHostedPaymentPage; public class TestRunner { @@ -441,7 +442,8 @@ public ANetApiResponse TestPayPalCredit() public ANetApiResponse TestPayPalGetDetails() { CreateTransactionResponse response = (CreateTransactionResponse)AuthorizationAndCapture.run(apiLoginId, transactionKey, getAmount()); - return GetDetails.run(apiLoginId, transactionKey, response.getTransactionResponse().getTransId()); + return GetDetails.run(apiLoginId, transactionKey, response.getTransactionResponse() + .getTransId()); } public ANetApiResponse TestPayPalPriorAuthorizationCapture() @@ -532,4 +534,9 @@ public ANetApiResponse TestCreateCustomerPaymentProfile() CreateCustomerProfileResponse response = (CreateCustomerProfileResponse)CreateCustomerProfile.run(apiLoginId, transactionKey, getEmail()); return CreateCustomerPaymentProfile.run(apiLoginId, transactionKey, response.getCustomerProfileId()); } + + public ANetApiResponse TestGetHostedPaymentPage() + { + return GetHostedPaymentPage.run(apiLoginId, transactionKey, getAmount()); + } } From 6852135827ca933e7f65aec124337636e10ae979 Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Fri, 25 Nov 2016 15:15:39 +0530 Subject: [PATCH 070/176] Delete TestMultiThread.java --- .../net/authorize/sample/TestMultiThread.java | 101 ------------------ 1 file changed, 101 deletions(-) delete mode 100644 src/main/java/net/authorize/sample/TestMultiThread.java diff --git a/src/main/java/net/authorize/sample/TestMultiThread.java b/src/main/java/net/authorize/sample/TestMultiThread.java deleted file mode 100644 index d53bd615..00000000 --- a/src/main/java/net/authorize/sample/TestMultiThread.java +++ /dev/null @@ -1,101 +0,0 @@ -package net.authorize.sample; - -import java.security.SecureRandom; -import java.text.DecimalFormat; -import java.util.Date; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -import net.authorize.api.contract.v1.CreateCustomerPaymentProfileResponse; -import net.authorize.api.contract.v1.CreateCustomerProfileResponse; -import net.authorize.api.contract.v1.CreateTransactionResponse; -import net.authorize.sample.CustomerProfiles.CreateCustomerPaymentProfile; -import net.authorize.sample.CustomerProfiles.CreateCustomerProfile; -import net.authorize.sample.PaymentTransactions.ChargeCustomerProfile; - -public class TestMultiThread { - - private static final int MYTHREADS = 120; - private static String apiLoginId = "5KP3u95bQpv"; - private static String transactionKey = "346HZ32z3fP4hTG2"; - - static SecureRandom rgenerator = new SecureRandom(); - - private static Double getAmount() - { - double d = (double)(1.05 + (450.0 * rgenerator.nextDouble())); - DecimalFormat df = new DecimalFormat("#.##"); - d = Double.valueOf(df.format(d)); - return d; - } - - private static String getEmail() - { - return rgenerator.nextInt(10000) + "@test.com"; - } - - public static void main(String args[]) throws Exception { - ExecutorService executor = Executors.newFixedThreadPool(MYTHREADS); - - Date dt1 = new Date(); - for (int i = 0; i < MYTHREADS; i++) { - Runnable worker = new MyRunnable(); - executor.execute(worker); - } - executor.shutdown(); - - // Wait until all threads are finish - while (!executor.isTerminated()) { - - } - Date dt2 = new Date(); - long difference = dt2.getTime() - dt1.getTime(); - - System.out.println("\nFinished all threads : " + difference/1000 + " sec"); - } - - public static class MyRunnable implements Runnable { - - @Override - public void run() { - CreateCustomerProfileResponse response = null; - CreateCustomerPaymentProfileResponse paymentProfileResponse = null; - - try{ - response = (CreateCustomerProfileResponse)CreateCustomerProfile.run(apiLoginId, transactionKey, getEmail()); - paymentProfileResponse = (CreateCustomerPaymentProfileResponse)CreateCustomerPaymentProfile.run(apiLoginId, transactionKey, response.getCustomerProfileId()); - } - catch (Exception e) { - System.out.println("Failure in CIM calls."); - System.out.println(e.getMessage()); - return; - } - - try { - Date dt1 = new Date(); - System.out.println("============================================================================"); - System.out.println("chargeResponse Dt1: + " + dt1.toString()); - - if((response.getCustomerProfileId() != null) && (paymentProfileResponse.getCustomerPaymentProfileId() != null)) - { - CreateTransactionResponse chargeResponse = (CreateTransactionResponse) ChargeCustomerProfile.run(apiLoginId, transactionKey, - response.getCustomerProfileId(), paymentProfileResponse.getCustomerPaymentProfileId(), getAmount()); - } - else - { - System.out.println("NULL PROFILE IDS."); - } - - Date dt2 = new Date(); - System.out.println("chargeResponse Dt2: + " + dt2.toString()); - - long difference = dt2.getTime() - dt1.getTime(); - System.out.println("chargeResponse Diff: " + difference/1000); - System.out.println("============================================================================"); - } catch (Exception e) { - System.out.println("Failure in charge customer profile call:"); - System.out.println(e.getMessage()); - } - } - } -} From c323a21457dd26b78725186f785cb75e183c8a60 Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Fri, 25 Nov 2016 15:18:29 +0530 Subject: [PATCH 071/176] Update pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c030d706..b83c729a 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ net.authorize anet-java-sdk - 1.9.0 + 1.9.2 junit From e3543e9a57f05a14bf4d95a5aa4a58cb7e265aaf Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Fri, 25 Nov 2016 19:56:43 -0800 Subject: [PATCH 072/176] Update and rename GetHostedProfilePage.java to GetAcceptCustomerProfilePage.java --- ...stedProfilePage.java => GetAcceptCustomerProfilePage.java} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename src/main/java/net/authorize/sample/CustomerProfiles/{GetHostedProfilePage.java => GetAcceptCustomerProfilePage.java} (97%) diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/GetHostedProfilePage.java b/src/main/java/net/authorize/sample/CustomerProfiles/GetAcceptCustomerProfilePage.java similarity index 97% rename from src/main/java/net/authorize/sample/CustomerProfiles/GetHostedProfilePage.java rename to src/main/java/net/authorize/sample/CustomerProfiles/GetAcceptCustomerProfilePage.java index 5e1b7fd6..050ae365 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/GetHostedProfilePage.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/GetAcceptCustomerProfilePage.java @@ -8,7 +8,7 @@ import net.authorize.api.controller.GetHostedProfilePageController; import net.authorize.api.controller.base.ApiOperationBase; -public class GetHostedProfilePage { +public class GetAcceptCustomerProfilePage { public static ANetApiResponse run(String apiLoginId, String transactionKey, String customerProfileId) { @@ -52,4 +52,4 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri } return response; } -} \ No newline at end of file +} From daff021a426d94777bff0d8d8a649bb68d5c21b8 Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Fri, 25 Nov 2016 19:58:26 -0800 Subject: [PATCH 073/176] Update TestRunner.java --- .../java/net/authorize/sample/SampleCodeTest/TestRunner.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java index 4966fde5..7cacecda 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java +++ b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java @@ -42,7 +42,7 @@ import net.authorize.sample.CustomerProfiles.GetCustomerPaymentProfile; import net.authorize.sample.CustomerProfiles.GetCustomerProfile; import net.authorize.sample.CustomerProfiles.GetCustomerShippingAddress; -import net.authorize.sample.CustomerProfiles.GetHostedProfilePage; +import net.authorize.sample.CustomerProfiles.GetAcceptCustomerProfilePage; import net.authorize.sample.CustomerProfiles.UpdateCustomerPaymentProfile; import net.authorize.sample.CustomerProfiles.UpdateCustomerProfile; import net.authorize.sample.CustomerProfiles.UpdateCustomerShippingAddress; From 4fc45885a84b5e03204868c1c30f772d7eca7426 Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Fri, 25 Nov 2016 19:59:45 -0800 Subject: [PATCH 074/176] Update SampleCode.java --- src/main/java/net/authorize/sample/SampleCode.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index e0c499f6..b0d68435 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -112,7 +112,7 @@ private static void ShowMethods() System.out.println(" GetCustomerProfile"); System.out.println(" GetCustomerProfileIds"); System.out.println(" GetCustomerShippingAddress"); - System.out.println(" GetHostedProfilePage"); + System.out.println(" GetAcceptCustomerProfilePage"); System.out.println(" UpdateCustomerPaymentProfile"); System.out.println(" UpdateCustomerShippingAddress"); System.out.println(" ValidateCustomerPaymentProfile"); @@ -272,8 +272,8 @@ private static void RunMethod(String methodName) case "GetCustomerShippingAddress": GetCustomerShippingAddress.run(apiLoginId, transactionKey, customerProfileId, customerAddressId); break; - case "GetHostedProfilePage": - GetHostedProfilePage.run(apiLoginId, transactionKey, customerProfileId); + case "GetAcceptCustomerProfilePage": + GetAcceptCustomerProfilePage.run(apiLoginId, transactionKey, customerProfileId); break; case "UpdateCustomerPaymentProfile": UpdateCustomerPaymentProfile.run(apiLoginId, transactionKey, customerProfileId, customerPaymentProfileId); From 3fa891ea4652d204e30b337f2b866e304c2e0e63 Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Fri, 25 Nov 2016 20:00:16 -0800 Subject: [PATCH 075/176] Update SampleCodeList.txt --- .../java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt b/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt index bedd5da6..41911af9 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt +++ b/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt @@ -13,7 +13,7 @@ CustomerProfiles.UpdateCustomerPaymentProfile 1 1 CustomerProfiles.GetCustomerShippingAddress 1 1 CustomerProfiles.GetCustomerProfileIds 0 1 CustomerProfiles.GetCustomerProfile 1 1 -CustomerProfiles.GetHostedProfilePage 1 1 +CustomerProfiles.GetAcceptCustomerProfilePage 1 1 CustomerProfiles.GetCustomerPaymentProfile 1 1 CustomerProfiles.DeleteCustomerShippingAddress 1 1 CustomerProfiles.DeleteCustomerProfile 1 1 From 49b7a7cdf5d4ccd82c014f5926d77ad644e23e30 Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Fri, 25 Nov 2016 20:02:25 -0800 Subject: [PATCH 076/176] Update TestRunner.java --- .../java/net/authorize/sample/SampleCodeTest/TestRunner.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java index 7cacecda..affa7cf9 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java +++ b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java @@ -280,10 +280,10 @@ public ANetApiResponse TestGetCustomerProfile() return profileResponse; } - public ANetApiResponse TestGetHostedProfilePage() + public ANetApiResponse TestGetAcceptCustomerProfilePage() { CreateCustomerProfileResponse response = (CreateCustomerProfileResponse)CreateCustomerProfile.run(apiLoginId, transactionKey, getEmail()); - GetHostedProfilePageResponse profileResponse = (GetHostedProfilePageResponse) GetHostedProfilePage.run(apiLoginId, transactionKey, response.getCustomerProfileId()); + GetHostedProfilePageResponse profileResponse = (GetHostedProfilePageResponse) GetAcceptCustomerProfilePage.run(apiLoginId, transactionKey, response.getCustomerProfileId()); DeleteCustomerProfile.run(apiLoginId, transactionKey, response.getCustomerProfileId()); return profileResponse; From 886c6c14cd5ced28155c66321ed2bda7326737de Mon Sep 17 00:00:00 2001 From: brianmc Date: Thu, 8 Dec 2016 09:20:59 -0800 Subject: [PATCH 077/176] Updated Fraud Samples --- .../ApproveOrDeclineHeldTransaction.java} | 10 +-- .../GetHeldTransactionList.java | 65 +++++++++++++++++++ .../java/net/authorize/sample/SampleCode.java | 10 ++- 3 files changed, 74 insertions(+), 11 deletions(-) rename src/main/java/net/authorize/sample/{PaymentTransactions/UpdateHeldTransaction.java => FraudManagement/ApproveOrDeclineHeldTransaction.java} (91%) create mode 100644 src/main/java/net/authorize/sample/FraudManagement/GetHeldTransactionList.java diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/UpdateHeldTransaction.java b/src/main/java/net/authorize/sample/FraudManagement/ApproveOrDeclineHeldTransaction.java similarity index 91% rename from src/main/java/net/authorize/sample/PaymentTransactions/UpdateHeldTransaction.java rename to src/main/java/net/authorize/sample/FraudManagement/ApproveOrDeclineHeldTransaction.java index 0bae9797..31ed226e 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/UpdateHeldTransaction.java +++ b/src/main/java/net/authorize/sample/FraudManagement/ApproveOrDeclineHeldTransaction.java @@ -22,7 +22,7 @@ import net.authorize.api.controller.UpdateHeldTransactionController; import net.authorize.api.controller.base.ApiOperationBase; -public class UpdateHeldTransaction { +public class ApproveOrDeclineHeldTransaction { public static ANetApiResponse run(String apiLoginId, String transactionKey, String transactionId) { @@ -34,17 +34,11 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri merchantAuthenticationType.setTransactionKey(transactionKey); ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); - // Populate the payment data - PaymentType paymentType = new PaymentType(); - CreditCardType creditCard = new CreditCardType(); - creditCard.setCardNumber("4242424242424242"); - creditCard.setExpirationDate("0822"); - paymentType.setCreditCard(creditCard); // Create the payment transaction request HeldTransactionRequestType txnRequest = new HeldTransactionRequestType(); txnRequest.setAction(AfdsTransactionEnum.APPROVE); - txnRequest.setRefTransId(transactionId); + txnRequest.setRefTransId("60012148613"); // Make the API Request UpdateHeldTransactionRequest apiRequest = new UpdateHeldTransactionRequest(); diff --git a/src/main/java/net/authorize/sample/FraudManagement/GetHeldTransactionList.java b/src/main/java/net/authorize/sample/FraudManagement/GetHeldTransactionList.java new file mode 100644 index 00000000..ec763e6f --- /dev/null +++ b/src/main/java/net/authorize/sample/FraudManagement/GetHeldTransactionList.java @@ -0,0 +1,65 @@ +package net.authorize.sample.TransactionReporting; + + +import net.authorize.Environment; +import net.authorize.api.contract.v1.*; +import net.authorize.api.controller.GetSettledBatchListController; +import net.authorize.api.controller.GetUnsettledTransactionListController; +import net.authorize.api.controller.base.ApiOperationBase; + +//author @krgupta +public class GetHeldTransactionList{ + + public static ANetApiResponse run(String apiLoginId, String transactionKey) { + ApiOperationBase.setEnvironment(Environment.SANDBOX); + + MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; + merchantAuthenticationType.setName(apiLoginId); + merchantAuthenticationType.setTransactionKey(transactionKey); + ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); + + GetUnsettledTransactionListRequest getRequest = new GetUnsettledTransactionListRequest(); + getRequest.setMerchantAuthentication(merchantAuthenticationType); + getRequest.setStatus(TransactionGroupStatusEnum.PENDING_APPROVAL); + + Paging paging = new Paging(); + paging.setLimit(100); + paging.setOffset(1); + + getRequest.setPaging(paging); + + TransactionListSorting sorting = new TransactionListSorting(); + sorting.setOrderBy(TransactionListOrderFieldEnum.ID); + sorting.setOrderDescending(true); + + getRequest.setSorting(sorting); + + GetUnsettledTransactionListController controller = new GetUnsettledTransactionListController(getRequest); + controller.execute(); + GetUnsettledTransactionListResponse getResponse = controller.getApiResponse(); + + if (getResponse!=null) { + + if (getResponse.getMessages().getResultCode() == MessageTypeEnum.OK) { + + System.out.println(getResponse.getMessages().getMessage().get(0).getCode()); + System.out.println(getResponse.getMessages().getMessage().get(0).getText()); + getResponse.getTransactions(); + + ArrayOfTransactionSummaryType txnList = getResponse.getTransactions(); + if (txnList != null) { + System.out.println("List of Suspicious Transactions :"); + for (TransactionSummaryType txn : txnList.getTransaction()) { + System.out.println(txn.getTransId()); + } + } + } + else + { + System.out.println("Failed to get unsettled transaction list: " + getResponse.getMessages().getResultCode()); + } + } + return getResponse; + + } +} diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index b0d68435..fc4a253d 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -126,7 +126,8 @@ private static void ShowMethods() System.out.println(" PayPalCredit"); System.out.println(" UpdateSplitTenderGroup"); System.out.println(" GetMerchantDetails"); - System.out.println(" UpdateHeldTransaction"); + System.out.println(" GetHeldTransactionList"); + System.out.println(" ApproveOrDeclineHeldTransaction"); System.out.println(" GetHostedPaymentPage"); } @@ -313,8 +314,11 @@ private static void RunMethod(String methodName) case "GetMerchantDetails": GetMerchantDetails.run(apiLoginId, transactionKey); break; - case "UpdateHeldTransaction": - UpdateHeldTransaction.run(apiLoginId, transactionKey, transactionId); + case "GetHeldTransactionList": + GetHeldTransactionList.run(apiLoginId, transactionKey); + break; + case "ApproveOrDeclineHeldTransaction": + ApproveOrDeclineHeldTransaction.run(apiLoginId, transactionKey, transactionId); break; case "GetHostedPaymentPage": GetHostedPaymentPage.run(apiLoginId, transactionKey, amount); From 7e6ed900759be64936dec185cc023b1f587ca781 Mon Sep 17 00:00:00 2001 From: brianmc Date: Thu, 8 Dec 2016 09:22:58 -0800 Subject: [PATCH 078/176] Updated Fraud Samples --- .../FraudManagement/GetHeldTransactions.java | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 src/main/java/net/authorize/sample/FraudManagement/GetHeldTransactions.java diff --git a/src/main/java/net/authorize/sample/FraudManagement/GetHeldTransactions.java b/src/main/java/net/authorize/sample/FraudManagement/GetHeldTransactions.java new file mode 100644 index 00000000..ec763e6f --- /dev/null +++ b/src/main/java/net/authorize/sample/FraudManagement/GetHeldTransactions.java @@ -0,0 +1,65 @@ +package net.authorize.sample.TransactionReporting; + + +import net.authorize.Environment; +import net.authorize.api.contract.v1.*; +import net.authorize.api.controller.GetSettledBatchListController; +import net.authorize.api.controller.GetUnsettledTransactionListController; +import net.authorize.api.controller.base.ApiOperationBase; + +//author @krgupta +public class GetHeldTransactionList{ + + public static ANetApiResponse run(String apiLoginId, String transactionKey) { + ApiOperationBase.setEnvironment(Environment.SANDBOX); + + MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; + merchantAuthenticationType.setName(apiLoginId); + merchantAuthenticationType.setTransactionKey(transactionKey); + ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); + + GetUnsettledTransactionListRequest getRequest = new GetUnsettledTransactionListRequest(); + getRequest.setMerchantAuthentication(merchantAuthenticationType); + getRequest.setStatus(TransactionGroupStatusEnum.PENDING_APPROVAL); + + Paging paging = new Paging(); + paging.setLimit(100); + paging.setOffset(1); + + getRequest.setPaging(paging); + + TransactionListSorting sorting = new TransactionListSorting(); + sorting.setOrderBy(TransactionListOrderFieldEnum.ID); + sorting.setOrderDescending(true); + + getRequest.setSorting(sorting); + + GetUnsettledTransactionListController controller = new GetUnsettledTransactionListController(getRequest); + controller.execute(); + GetUnsettledTransactionListResponse getResponse = controller.getApiResponse(); + + if (getResponse!=null) { + + if (getResponse.getMessages().getResultCode() == MessageTypeEnum.OK) { + + System.out.println(getResponse.getMessages().getMessage().get(0).getCode()); + System.out.println(getResponse.getMessages().getMessage().get(0).getText()); + getResponse.getTransactions(); + + ArrayOfTransactionSummaryType txnList = getResponse.getTransactions(); + if (txnList != null) { + System.out.println("List of Suspicious Transactions :"); + for (TransactionSummaryType txn : txnList.getTransaction()) { + System.out.println(txn.getTransId()); + } + } + } + else + { + System.out.println("Failed to get unsettled transaction list: " + getResponse.getMessages().getResultCode()); + } + } + return getResponse; + + } +} From d00f0b88c6b594e8066323c8c817a619dbb236f7 Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Mon, 19 Dec 2016 20:43:38 -0800 Subject: [PATCH 079/176] Delete GetHeldTransactions.java --- .../FraudManagement/GetHeldTransactions.java | 65 ------------------- 1 file changed, 65 deletions(-) delete mode 100644 src/main/java/net/authorize/sample/FraudManagement/GetHeldTransactions.java diff --git a/src/main/java/net/authorize/sample/FraudManagement/GetHeldTransactions.java b/src/main/java/net/authorize/sample/FraudManagement/GetHeldTransactions.java deleted file mode 100644 index ec763e6f..00000000 --- a/src/main/java/net/authorize/sample/FraudManagement/GetHeldTransactions.java +++ /dev/null @@ -1,65 +0,0 @@ -package net.authorize.sample.TransactionReporting; - - -import net.authorize.Environment; -import net.authorize.api.contract.v1.*; -import net.authorize.api.controller.GetSettledBatchListController; -import net.authorize.api.controller.GetUnsettledTransactionListController; -import net.authorize.api.controller.base.ApiOperationBase; - -//author @krgupta -public class GetHeldTransactionList{ - - public static ANetApiResponse run(String apiLoginId, String transactionKey) { - ApiOperationBase.setEnvironment(Environment.SANDBOX); - - MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; - merchantAuthenticationType.setName(apiLoginId); - merchantAuthenticationType.setTransactionKey(transactionKey); - ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); - - GetUnsettledTransactionListRequest getRequest = new GetUnsettledTransactionListRequest(); - getRequest.setMerchantAuthentication(merchantAuthenticationType); - getRequest.setStatus(TransactionGroupStatusEnum.PENDING_APPROVAL); - - Paging paging = new Paging(); - paging.setLimit(100); - paging.setOffset(1); - - getRequest.setPaging(paging); - - TransactionListSorting sorting = new TransactionListSorting(); - sorting.setOrderBy(TransactionListOrderFieldEnum.ID); - sorting.setOrderDescending(true); - - getRequest.setSorting(sorting); - - GetUnsettledTransactionListController controller = new GetUnsettledTransactionListController(getRequest); - controller.execute(); - GetUnsettledTransactionListResponse getResponse = controller.getApiResponse(); - - if (getResponse!=null) { - - if (getResponse.getMessages().getResultCode() == MessageTypeEnum.OK) { - - System.out.println(getResponse.getMessages().getMessage().get(0).getCode()); - System.out.println(getResponse.getMessages().getMessage().get(0).getText()); - getResponse.getTransactions(); - - ArrayOfTransactionSummaryType txnList = getResponse.getTransactions(); - if (txnList != null) { - System.out.println("List of Suspicious Transactions :"); - for (TransactionSummaryType txn : txnList.getTransaction()) { - System.out.println(txn.getTransId()); - } - } - } - else - { - System.out.println("Failed to get unsettled transaction list: " + getResponse.getMessages().getResultCode()); - } - } - return getResponse; - - } -} From e2d12810b10612b0238016be08ffa3187028c3fd Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Thu, 29 Dec 2016 07:32:01 -0800 Subject: [PATCH 080/176] Update ApproveOrDeclineHeldTransaction.java --- .../sample/FraudManagement/ApproveOrDeclineHeldTransaction.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/authorize/sample/FraudManagement/ApproveOrDeclineHeldTransaction.java b/src/main/java/net/authorize/sample/FraudManagement/ApproveOrDeclineHeldTransaction.java index 31ed226e..6df07501 100644 --- a/src/main/java/net/authorize/sample/FraudManagement/ApproveOrDeclineHeldTransaction.java +++ b/src/main/java/net/authorize/sample/FraudManagement/ApproveOrDeclineHeldTransaction.java @@ -1,4 +1,4 @@ -package net.authorize.sample.PaymentTransactions; +package net.authorize.sample.FraudManagement; import java.math.BigDecimal; import java.math.RoundingMode; From 96f6a9e17051c83e5ac15d3ebb8d97be38c025bf Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Thu, 29 Dec 2016 07:32:37 -0800 Subject: [PATCH 081/176] Update GetHeldTransactionList.java --- .../sample/FraudManagement/GetHeldTransactionList.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/authorize/sample/FraudManagement/GetHeldTransactionList.java b/src/main/java/net/authorize/sample/FraudManagement/GetHeldTransactionList.java index ec763e6f..6089d973 100644 --- a/src/main/java/net/authorize/sample/FraudManagement/GetHeldTransactionList.java +++ b/src/main/java/net/authorize/sample/FraudManagement/GetHeldTransactionList.java @@ -1,4 +1,4 @@ -package net.authorize.sample.TransactionReporting; +package net.authorize.sample.FraudManagement; import net.authorize.Environment; From 226987750aebef7d43504bf5c1936f5c439e3229 Mon Sep 17 00:00:00 2001 From: Tammineni Date: Tue, 17 Jan 2017 21:26:32 -0800 Subject: [PATCH 082/176] fix the namespace for the main file --- src/main/java/net/authorize/sample/SampleCode.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index fc4a253d..3cd6f6b7 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -12,6 +12,7 @@ import net.authorize.sample.TransactionReporting.*; import net.authorize.sample.CustomerProfiles.*; import net.authorize.sample.MobileInappTransactions.*; +import net.authorize.sample.FraudManagement.*; /** * Created by anetdeveloper on 8/5/15. */ From 525ae55b5e8bf62d12f7961f97e84ec322703b4a Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Wed, 25 Jan 2017 07:23:40 -0800 Subject: [PATCH 083/176] Update and rename GetHostedPaymentPage.java to GetAnAcceptPaymentPage.java --- ...{GetHostedPaymentPage.java => GetAnAcceptPaymentPage.java} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename src/main/java/net/authorize/sample/PaymentTransactions/{GetHostedPaymentPage.java => GetAnAcceptPaymentPage.java} (98%) diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/GetHostedPaymentPage.java b/src/main/java/net/authorize/sample/PaymentTransactions/GetAnAcceptPaymentPage.java similarity index 98% rename from src/main/java/net/authorize/sample/PaymentTransactions/GetHostedPaymentPage.java rename to src/main/java/net/authorize/sample/PaymentTransactions/GetAnAcceptPaymentPage.java index fa85893d..29624b33 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/GetHostedPaymentPage.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/GetAnAcceptPaymentPage.java @@ -9,7 +9,7 @@ import net.authorize.api.controller.GetHostedPaymentPageController; import net.authorize.api.controller.base.ApiOperationBase; -public class GetHostedPaymentPage { +public class GetAnAcceptPaymentPage { public static ANetApiResponse run(String apiLoginId, String transactionKey, Double amount) { @@ -63,4 +63,4 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub } return response; } -} \ No newline at end of file +} From 403f2e81d0ae403b552bb53049d8445ea059f5e2 Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Wed, 25 Jan 2017 07:24:37 -0800 Subject: [PATCH 084/176] Update SampleCode.java --- src/main/java/net/authorize/sample/SampleCode.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index 3cd6f6b7..6510860d 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -129,7 +129,7 @@ private static void ShowMethods() System.out.println(" GetMerchantDetails"); System.out.println(" GetHeldTransactionList"); System.out.println(" ApproveOrDeclineHeldTransaction"); - System.out.println(" GetHostedPaymentPage"); + System.out.println(" GetAnAcceptPaymentPage"); } private static void RunMethod(String methodName) @@ -321,8 +321,8 @@ private static void RunMethod(String methodName) case "ApproveOrDeclineHeldTransaction": ApproveOrDeclineHeldTransaction.run(apiLoginId, transactionKey, transactionId); break; - case "GetHostedPaymentPage": - GetHostedPaymentPage.run(apiLoginId, transactionKey, amount); + case "GetAnAcceptPaymentPage": + GetAnAcceptPaymentPage.run(apiLoginId, transactionKey, amount); break; default: ShowUsage(); From 1318f9b9a965098bbe07f8c06e6875006257940b Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Wed, 25 Jan 2017 07:26:07 -0800 Subject: [PATCH 085/176] Update SampleCodeList.txt --- .../java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt b/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt index 41911af9..153c6666 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt +++ b/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt @@ -43,7 +43,7 @@ PaymentTransactions.DebitBankAccount 1 1 PaymentTransactions.ChargeTokenizedCreditCard 1 1 PaymentTransactions.UpdateSplitTenderGroup 0 1 PaymentTransactions.UpdateHeldTransation 0 0 -PaymentTransactions.GetHostedPaymentPage 1 1 +PaymentTransactions.GetAnAcceptPaymentPage 1 1 TransactionReporting.GetTransactionList 0 1 TransactionReporting.GetUnsettledTransactionList 0 1 TransactionReporting.GetBatchStatistics 0 1 From 9321bc0a7c68a1fff785f25f9f1b8e3c0b1b047b Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Wed, 25 Jan 2017 07:26:42 -0800 Subject: [PATCH 086/176] Update TestRunner.java --- .../java/net/authorize/sample/SampleCodeTest/TestRunner.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java index affa7cf9..42115521 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java +++ b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java @@ -535,8 +535,8 @@ public ANetApiResponse TestCreateCustomerPaymentProfile() return CreateCustomerPaymentProfile.run(apiLoginId, transactionKey, response.getCustomerProfileId()); } - public ANetApiResponse TestGetHostedPaymentPage() + public ANetApiResponse TestGetAnAcceptPaymentPage() { - return GetHostedPaymentPage.run(apiLoginId, transactionKey, getAmount()); + return GetAnAcceptPaymentPage.run(apiLoginId, transactionKey, getAmount()); } } From 706e18290816ee87ef3b76edc7ebe4acfbcf80f4 Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Tue, 21 Feb 2017 22:12:56 -0800 Subject: [PATCH 087/176] Update AuthorizeCreditCard.java --- .../sample/PaymentTransactions/AuthorizeCreditCard.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/AuthorizeCreditCard.java b/src/main/java/net/authorize/sample/PaymentTransactions/AuthorizeCreditCard.java index 9797d382..a0b96a87 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/AuthorizeCreditCard.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/AuthorizeCreditCard.java @@ -23,7 +23,6 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; merchantAuthenticationType.setName(apiLoginId); merchantAuthenticationType.setTransactionKey(transactionKey); - ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); // Populate the payment data PaymentType paymentType = new PaymentType(); @@ -38,8 +37,10 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub txnRequest.setPayment(paymentType); txnRequest.setAmount(new BigDecimal(amount).setScale(2, RoundingMode.CEILING)); - // Make the API Request + // Make the API Request & set the merchant details for this specific request CreateTransactionRequest apiRequest = new CreateTransactionRequest(); + apiRequest.setMerchantAuthentication(merchantAuthenticationType); + apiRequest.setTransactionRequest(txnRequest); CreateTransactionController controller = new CreateTransactionController(apiRequest); controller.execute(); From 191cd878759947786bf4a311b59b718335e90b94 Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Tue, 21 Feb 2017 23:11:44 -0800 Subject: [PATCH 088/176] Update TestRunner.java --- .../java/net/authorize/sample/SampleCodeTest/TestRunner.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java index 42115521..07232c5f 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java +++ b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java @@ -71,7 +71,7 @@ import net.authorize.sample.RecurringBilling.GetSubscriptionStatus; import net.authorize.sample.RecurringBilling.UpdateSubscription; import net.authorize.sample.TransactionReporting.GetTransactionDetails; -import net.authorize.sample.PaymentTransactions.GetHostedPaymentPage; +import net.authorize.sample.PaymentTransactions.GetAnAcceptPaymentPage; public class TestRunner { From f489f39900b5a4e1d526dbdb08cfcdfd6205700b Mon Sep 17 00:00:00 2001 From: Aaron Wright Date: Mon, 20 Mar 2017 17:06:29 -0600 Subject: [PATCH 089/176] add isPaymentToken --- .../sample/PaymentTransactions/ChargeTokenizedCreditCard.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeTokenizedCreditCard.java b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeTokenizedCreditCard.java index 88140615..584bee19 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeTokenizedCreditCard.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeTokenizedCreditCard.java @@ -39,6 +39,8 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub CreditCardType creditCard = new CreditCardType(); creditCard.setCardNumber("4242424242424242"); creditCard.setExpirationDate("0822"); + // Set the token specific info + creditCard.setIsPaymentToken(true); creditCard.setCryptogram("EjRWeJASNFZ4kBI0VniQEjRWeJA="); paymentType.setCreditCard(creditCard); From 02b833f9ffc2dbd4fda336e1756a86936f1620c3 Mon Sep 17 00:00:00 2001 From: Aaron Wright Date: Mon, 20 Mar 2017 17:12:42 -0600 Subject: [PATCH 090/176] formatting README.md --- README.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index fd5000cd..c022b872 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # Sample Java Code for Authorize.Net -[![Build Status](https://travis-ci.org/AuthorizeNet/sample-code-java.png?branch=master)] -(https://travis-ci.org/AuthorizeNet/sample-code-java) +[![Build Status](https://travis-ci.org/AuthorizeNet/sample-code-java.png?branch=master)](https://travis-ci.org/AuthorizeNet/sample-code-java) This repository contains working code samples which demonstrate Java integration with the Authorize.Net Java SDK The samples are organized just like our API, which you can also try out directly here: http://developer.authorize.net/api/reference @@ -14,13 +13,13 @@ The samples are all completely independent and self-contained so you can look at 1. Clone this repository. 2. Run "mvn package" in the root directory to create the SampleCode console app. 3. Then run a sample directly by name: -```` +``` > java -jar target/SampleCode.jar [CodeSampleName] -```` +``` e.g. -```` +``` > java -jar target/SampleCode.jar ChargeCreditCard -```` +``` Running SampleCode without a parameter will give you the list of sample names. Handy or what! **NOTE : You can update to your Sandbox credentials in SampleCode.java** @@ -28,10 +27,10 @@ Running SampleCode without a parameter will give you the list of sample names. **For using behind proxy** Please set the JAVA environment proxy using a similar code : -```` +``` System.setProperty("https.proxyUse", "true"); System.setProperty("https.proxyHost", "127.0.0.1"); System.setProperty("https.proxyPort", "3128"); -```` +``` *PLEASE NOTE THIS PROJECT IS CURRENTLY UNDER DEVELOPMENT* From ecc67680a5ff2607a437faafeeddf8a1a4cb5d78 Mon Sep 17 00:00:00 2001 From: Aaron Wright Date: Mon, 20 Mar 2017 17:13:11 -0600 Subject: [PATCH 091/176] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c022b872..5954d39d 100644 --- a/README.md +++ b/README.md @@ -5,11 +5,11 @@ This repository contains working code samples which demonstrate Java integration The samples are organized just like our API, which you can also try out directly here: http://developer.authorize.net/api/reference -##Using the Sample Code +## Using the Sample Code The samples are all completely independent and self-contained so you can look at them to get a gist of how the method works, you can use the snippets to try in your own sample project, or you can run each sample from the command line. -##Running the Samples +## Running the Samples 1. Clone this repository. 2. Run "mvn package" in the root directory to create the SampleCode console app. 3. Then run a sample directly by name: From fb4c0e7ae13ff05ee667e7ebc1df7095f678bf18 Mon Sep 17 00:00:00 2001 From: akashah Date: Thu, 13 Apr 2017 14:30:27 +0530 Subject: [PATCH 092/176] Adding GetCustomerProfileTransactionList sample code --- .../java/net/authorize/sample/SampleCode.java | 5 ++ .../GetCustomerProfileTransactionList.java | 66 +++++++++++++++++++ .../sample/SampleCodeTest/SampleCodeList.txt | 1 + 3 files changed, 72 insertions(+) create mode 100644 src/main/java/net/authorize/sample/TransactionReporting/GetCustomerProfileTransactionList.java diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index 6510860d..4803d1f9 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -112,6 +112,7 @@ private static void ShowMethods() System.out.println(" GetCustomerPaymentProfileList"); System.out.println(" GetCustomerProfile"); System.out.println(" GetCustomerProfileIds"); + System.out.println(" GetCustomerProfileTransactionList"); System.out.println(" GetCustomerShippingAddress"); System.out.println(" GetAcceptCustomerProfilePage"); System.out.println(" UpdateCustomerPaymentProfile"); @@ -271,6 +272,10 @@ private static void RunMethod(String methodName) case "GetCustomerProfileIds": GetCustomerProfileIds.run(apiLoginId, transactionKey); break; + case "GetCustomerProfileTransactionList": + customerProfileId = "1811474252"; + GetCustomerProfileTransactionList.run(apiLoginId, transactionKey, customerProfileId); + break; case "GetCustomerShippingAddress": GetCustomerShippingAddress.run(apiLoginId, transactionKey, customerProfileId, customerAddressId); break; diff --git a/src/main/java/net/authorize/sample/TransactionReporting/GetCustomerProfileTransactionList.java b/src/main/java/net/authorize/sample/TransactionReporting/GetCustomerProfileTransactionList.java new file mode 100644 index 00000000..8f893091 --- /dev/null +++ b/src/main/java/net/authorize/sample/TransactionReporting/GetCustomerProfileTransactionList.java @@ -0,0 +1,66 @@ +package net.authorize.sample.TransactionReporting; + +import java.util.List; + +import net.authorize.Environment; +import net.authorize.api.contract.v1.*; +import net.authorize.api.controller.GetTransactionListForCustomerController; +import net.authorize.api.controller.base.ApiOperationBase; + +//author @akashah +public class GetCustomerProfileTransactionList{ + + public static ANetApiResponse run(String apiLoginId, String transactionKey, String customerProfileId) { + ApiOperationBase.setEnvironment(Environment.SANDBOX); + + MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; + merchantAuthenticationType.setName(apiLoginId); + merchantAuthenticationType.setTransactionKey(transactionKey); + ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); + + + GetTransactionListForCustomerRequest getRequest = new GetTransactionListForCustomerRequest(); + getRequest.setMerchantAuthentication(merchantAuthenticationType); + getRequest.setCustomerProfileId(customerProfileId); + + Paging paging = new Paging(); + paging.setLimit(100); + paging.setOffset(1); + + getRequest.setPaging(paging); + + TransactionListSorting sorting = new TransactionListSorting(); + sorting.setOrderBy(TransactionListOrderFieldEnum.ID); + sorting.setOrderDescending(true); + + getRequest.setSorting(sorting); + + GetTransactionListForCustomerController controller = new GetTransactionListForCustomerController(getRequest); + controller.execute(); + + GetTransactionListResponse getResponse = controller.getApiResponse(); + if (getResponse!=null) { + ArrayOfTransactionSummaryType transactions = getResponse.getTransactions(); + List list = transactions.getTransaction(); + + for(TransactionSummaryType summary : list) + { + System.out.println(summary.getFirstName()); + System.out.println(summary.getTransId()); + System.out.println(summary.getSettleAmount()); + System.out.println(summary.getSubmitTimeLocal()); + } + + if (getResponse.getMessages().getResultCode() == MessageTypeEnum.OK) { + System.out.println(getResponse.getMessages().getMessage().get(0).getCode()); + System.out.println(getResponse.getMessages().getMessage().get(0).getText()); + } + else + { + System.out.println("Failed to get transaction list: " + getResponse.getMessages().getResultCode()); + } + } + return getResponse; + + } +} diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt b/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt index 153c6666..73dc212c 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt +++ b/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt @@ -45,6 +45,7 @@ PaymentTransactions.UpdateSplitTenderGroup 0 1 PaymentTransactions.UpdateHeldTransation 0 0 PaymentTransactions.GetAnAcceptPaymentPage 1 1 TransactionReporting.GetTransactionList 0 1 +TransactionReporting.GetTransactionListForCustomer 1 1 TransactionReporting.GetUnsettledTransactionList 0 1 TransactionReporting.GetBatchStatistics 0 1 TransactionReporting.GetSettledBatchList 0 1 From 474e003d2a23f4295557ce4da0e25bfd21353119 Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Tue, 25 Apr 2017 14:48:00 +0530 Subject: [PATCH 093/176] Update pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b83c729a..afb4ccc8 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,7 @@ - 1.9.2 + 1.9.3 4.0.0 net.authorize.sample From 68b7a70a81ac202ea962629dce37f76dc1d249fe Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Tue, 25 Apr 2017 15:24:46 +0530 Subject: [PATCH 094/176] Update SampleCodeList.txt --- .../java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt b/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt index 73dc212c..d0fafca9 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt +++ b/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt @@ -45,7 +45,7 @@ PaymentTransactions.UpdateSplitTenderGroup 0 1 PaymentTransactions.UpdateHeldTransation 0 0 PaymentTransactions.GetAnAcceptPaymentPage 1 1 TransactionReporting.GetTransactionList 0 1 -TransactionReporting.GetTransactionListForCustomer 1 1 +TransactionReporting.GetTransactionListForCustomer 0 0 TransactionReporting.GetUnsettledTransactionList 0 1 TransactionReporting.GetBatchStatistics 0 1 TransactionReporting.GetSettledBatchList 0 1 From 593fdc5bcf772a56579a7477d8cbee6a01723aeb Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Wed, 26 Apr 2017 11:50:31 +0530 Subject: [PATCH 095/176] Update pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index afb4ccc8..60cedf47 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ net.authorize anet-java-sdk - 1.9.2 + 1.9.3 junit From e626eec7847259a78db2ad449da72a8c0c60685d Mon Sep 17 00:00:00 2001 From: adavidw Date: Mon, 19 Jun 2017 12:56:16 -0600 Subject: [PATCH 096/176] Rename directory to match online API Reference --- .../CreateAnAcceptTransaction.java | 0 .../CreateAnAndroidPayTransaction.java | 0 .../CreateAnApplePayTransaction.java | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename src/main/java/net/authorize/sample/{MobileInappTransactions => MobileInAppTransactions}/CreateAnAcceptTransaction.java (100%) rename src/main/java/net/authorize/sample/{MobileInappTransactions => MobileInAppTransactions}/CreateAnAndroidPayTransaction.java (100%) rename src/main/java/net/authorize/sample/{MobileInappTransactions => MobileInAppTransactions}/CreateAnApplePayTransaction.java (100%) diff --git a/src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnAcceptTransaction.java b/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAcceptTransaction.java similarity index 100% rename from src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnAcceptTransaction.java rename to src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAcceptTransaction.java diff --git a/src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnAndroidPayTransaction.java b/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAndroidPayTransaction.java similarity index 100% rename from src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnAndroidPayTransaction.java rename to src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAndroidPayTransaction.java diff --git a/src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnApplePayTransaction.java b/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnApplePayTransaction.java similarity index 100% rename from src/main/java/net/authorize/sample/MobileInappTransactions/CreateAnApplePayTransaction.java rename to src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnApplePayTransaction.java From 800dc49de18d9b3d921bcf6bf04277ebaea53d79 Mon Sep 17 00:00:00 2001 From: adavidw Date: Mon, 19 Jun 2017 13:50:25 -0600 Subject: [PATCH 097/176] create sample code for Create an Accept Payment Transaction --- .../CreateAnAcceptPaymentTransaction.java | 100 ++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 src/main/java/net/authorize/sample/PaymentTransactions/CreateAnAcceptPaymentTransaction.java diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/CreateAnAcceptPaymentTransaction.java b/src/main/java/net/authorize/sample/PaymentTransactions/CreateAnAcceptPaymentTransaction.java new file mode 100644 index 00000000..15505df5 --- /dev/null +++ b/src/main/java/net/authorize/sample/PaymentTransactions/CreateAnAcceptPaymentTransaction.java @@ -0,0 +1,100 @@ +package net.authorize.sample.PaymentTransactions; + +import java.math.BigDecimal; +import java.math.RoundingMode; + +import net.authorize.Environment; +import net.authorize.api.contract.v1.ANetApiResponse; +import net.authorize.api.contract.v1.CreateTransactionRequest; +import net.authorize.api.contract.v1.CreateTransactionResponse; +import net.authorize.api.contract.v1.OpaqueDataType; +import net.authorize.api.contract.v1.MerchantAuthenticationType; +import net.authorize.api.contract.v1.MessageTypeEnum; +import net.authorize.api.contract.v1.PaymentType; +import net.authorize.api.contract.v1.TransactionRequestType; +import net.authorize.api.contract.v1.TransactionResponse; +import net.authorize.api.contract.v1.TransactionTypeEnum; +import net.authorize.api.controller.CreateTransactionController; +import net.authorize.api.controller.base.ApiOperationBase; + +public class CreateAnAcceptPaymentTransaction { + + // + // Run this sample from command line with: + // java -jar target/CreateAnAcceptPaymentTransaction-jar-with-dependencies.jar + // + public static ANetApiResponse run(String apiLoginId, String transactionKey, Double amount) { + + + //Common code to set for all requests + ApiOperationBase.setEnvironment(Environment.SANDBOX); + + MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; + merchantAuthenticationType.setName(apiLoginId); + merchantAuthenticationType.setTransactionKey(transactionKey); + ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); + + // Populate the payment data + PaymentType paymentType = new PaymentType(); + OpaqueDataType OpaqueData = new OpaqueDataType(); + OpaqueData.setDataDescriptor("COMMON.ACCEPT.INAPP.PAYMENT"); + OpaqueData.setDataValue("119eyJjb2RlIjoiNTBfMl8wNjAwMDUyN0JEODE4RjQxOUEyRjhGQkIxMkY0MzdGQjAxQUIwRTY2NjhFNEFCN0VENzE4NTUwMjlGRUU0M0JFMENERUIwQzM2M0ExOUEwMDAzNzlGRDNFMjBCODJEMDFCQjkyNEJDIiwidG9rZW4iOiI5NDkwMjMyMTAyOTQwOTk5NDA0NjAzIiwidiI6IjEuMSJ9"); + paymentType.setOpaqueData(OpaqueData); + + // Create the payment transaction request + TransactionRequestType txnRequest = new TransactionRequestType(); + txnRequest.setTransactionType(TransactionTypeEnum.AUTH_CAPTURE_TRANSACTION.value()); + txnRequest.setPayment(paymentType); + txnRequest.setAmount(new BigDecimal(amount).setScale(2, RoundingMode.CEILING)); + + // Make the API Request + CreateTransactionRequest apiRequest = new CreateTransactionRequest(); + apiRequest.setTransactionRequest(txnRequest); + CreateTransactionController controller = new CreateTransactionController(apiRequest); + controller.execute(); + + + CreateTransactionResponse response = controller.getApiResponse(); + + if (response!=null) { + // If API Response is ok, go ahead and check the transaction response + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + TransactionResponse result = response.getTransactionResponse(); + if(result.getMessages() != null){ + System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Response Code: " + result.getResponseCode()); + System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); + System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); + System.out.println("Auth Code: " + result.getAuthCode()); + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + } + } + else { + System.out.println("Failed Transaction."); + if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + else { + System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); + System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); + } + } + } + else { + System.out.println("Null Response."); + } + + return response; + + } + + + +} From 73191d91349f8956d5d79d5d049d9ad33332e261 Mon Sep 17 00:00:00 2001 From: Aaron Wright Date: Fri, 23 Jun 2017 09:49:29 -0600 Subject: [PATCH 098/176] Update SampleCodeList.txt update to match new directory names --- .../net/authorize/sample/SampleCodeTest/SampleCodeList.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt b/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt index d0fafca9..0b9ba897 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt +++ b/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt @@ -51,8 +51,8 @@ TransactionReporting.GetBatchStatistics 0 1 TransactionReporting.GetSettledBatchList 0 1 TransactionReporting.GetTransactionDetails 1 1 TransactionReporting.GetMerchantDetails 0 1 -MobileInappTransactions.CreateAnApplePayTransaction 0 0 -MobileInappTransactions.CreateAnAndroidPayTransaction 0 0 -MobileInappTransactions.CreateAnAcceptTransaction 0 0 +MobileInAppTransactions.CreateAnApplePayTransaction 0 0 +MobileInAppTransactions.CreateAnAndroidPayTransaction 0 0 +MobileInAppTransactions.CreateAnAcceptTransaction 0 0 VisaCheckout.DecryptVisaCheckoutData 0 1 VisaCheckout.CreateVisaCheckoutTransaction 0 0 From af9084fbee380e83dcb7f6ce7b98ffebe7983f62 Mon Sep 17 00:00:00 2001 From: adavidw Date: Tue, 26 Sep 2017 12:15:54 -0600 Subject: [PATCH 099/176] Rename directory to match the names used in the online API Reference guide --- .gitignore | 4 ++++ .../AuthorizationAndCapture.java | 2 +- .../AuthorizationAndCaptureContinue.java | 2 +- .../AuthorizationOnly.java | 2 +- .../AuthorizationOnlyContinued.java | 2 +- .../Credit.java | 2 +- .../GetDetails.java | 2 +- .../PriorAuthorizationCapture.java | 4 ++-- .../Void.java | 2 +- .../java/net/authorize/sample/SampleCode.java | 6 +++--- .../sample/SampleCodeTest/SampleCodeList.txt | 16 ++++++++-------- .../sample/SampleCodeTest/TestRunner.java | 16 ++++++++-------- 12 files changed, 32 insertions(+), 28 deletions(-) rename src/main/java/net/authorize/sample/{PaypalExpressCheckout => PayPalExpressCheckout}/AuthorizationAndCapture.java (98%) rename src/main/java/net/authorize/sample/{PaypalExpressCheckout => PayPalExpressCheckout}/AuthorizationAndCaptureContinue.java (98%) rename src/main/java/net/authorize/sample/{PaypalExpressCheckout => PayPalExpressCheckout}/AuthorizationOnly.java (98%) rename src/main/java/net/authorize/sample/{PaypalExpressCheckout => PayPalExpressCheckout}/AuthorizationOnlyContinued.java (98%) rename src/main/java/net/authorize/sample/{PaypalExpressCheckout => PayPalExpressCheckout}/Credit.java (98%) rename src/main/java/net/authorize/sample/{PaypalExpressCheckout => PayPalExpressCheckout}/GetDetails.java (98%) rename src/main/java/net/authorize/sample/{PaypalExpressCheckout => PayPalExpressCheckout}/PriorAuthorizationCapture.java (97%) rename src/main/java/net/authorize/sample/{PaypalExpressCheckout => PayPalExpressCheckout}/Void.java (98%) diff --git a/.gitignore b/.gitignore index 68546a7a..f067f9e7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +# Compiled class file *.class # Mobile Tools for Java (J2ME) @@ -11,6 +12,9 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* +# Ignore Mac DS_Store files +.DS_Store + /logs/ /target/ diff --git a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCapture.java b/src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationAndCapture.java similarity index 98% rename from src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCapture.java rename to src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationAndCapture.java index 15c273c0..a0feac0a 100644 --- a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCapture.java +++ b/src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationAndCapture.java @@ -1,4 +1,4 @@ -package net.authorize.sample.PaypalExpressCheckout; +package net.authorize.sample.PayPalExpressCheckout; import java.math.BigDecimal; import java.math.RoundingMode; diff --git a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCaptureContinue.java b/src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationAndCaptureContinue.java similarity index 98% rename from src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCaptureContinue.java rename to src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationAndCaptureContinue.java index 59a00532..3dc811bd 100644 --- a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationAndCaptureContinue.java +++ b/src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationAndCaptureContinue.java @@ -1,4 +1,4 @@ -package net.authorize.sample.PaypalExpressCheckout; +package net.authorize.sample.PayPalExpressCheckout; import java.math.BigDecimal; import java.math.RoundingMode; diff --git a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationOnly.java b/src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationOnly.java similarity index 98% rename from src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationOnly.java rename to src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationOnly.java index b62461e4..47ae725e 100644 --- a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationOnly.java +++ b/src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationOnly.java @@ -1,4 +1,4 @@ -package net.authorize.sample.PaypalExpressCheckout; +package net.authorize.sample.PayPalExpressCheckout; import java.math.BigDecimal; import java.math.RoundingMode; diff --git a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationOnlyContinued.java b/src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationOnlyContinued.java similarity index 98% rename from src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationOnlyContinued.java rename to src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationOnlyContinued.java index 05954d3b..15d73185 100644 --- a/src/main/java/net/authorize/sample/PaypalExpressCheckout/AuthorizationOnlyContinued.java +++ b/src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationOnlyContinued.java @@ -1,4 +1,4 @@ -package net.authorize.sample.PaypalExpressCheckout; +package net.authorize.sample.PayPalExpressCheckout; import java.math.BigDecimal; import java.math.RoundingMode; diff --git a/src/main/java/net/authorize/sample/PaypalExpressCheckout/Credit.java b/src/main/java/net/authorize/sample/PayPalExpressCheckout/Credit.java similarity index 98% rename from src/main/java/net/authorize/sample/PaypalExpressCheckout/Credit.java rename to src/main/java/net/authorize/sample/PayPalExpressCheckout/Credit.java index ea252a74..62d45fe8 100644 --- a/src/main/java/net/authorize/sample/PaypalExpressCheckout/Credit.java +++ b/src/main/java/net/authorize/sample/PayPalExpressCheckout/Credit.java @@ -1,4 +1,4 @@ -package net.authorize.sample.PaypalExpressCheckout; +package net.authorize.sample.PayPalExpressCheckout; import java.math.BigDecimal; diff --git a/src/main/java/net/authorize/sample/PaypalExpressCheckout/GetDetails.java b/src/main/java/net/authorize/sample/PayPalExpressCheckout/GetDetails.java similarity index 98% rename from src/main/java/net/authorize/sample/PaypalExpressCheckout/GetDetails.java rename to src/main/java/net/authorize/sample/PayPalExpressCheckout/GetDetails.java index e8b53403..05471def 100644 --- a/src/main/java/net/authorize/sample/PaypalExpressCheckout/GetDetails.java +++ b/src/main/java/net/authorize/sample/PayPalExpressCheckout/GetDetails.java @@ -1,4 +1,4 @@ -package net.authorize.sample.PaypalExpressCheckout; +package net.authorize.sample.PayPalExpressCheckout; import net.authorize.Environment; import net.authorize.api.contract.v1.*; diff --git a/src/main/java/net/authorize/sample/PaypalExpressCheckout/PriorAuthorizationCapture.java b/src/main/java/net/authorize/sample/PayPalExpressCheckout/PriorAuthorizationCapture.java similarity index 97% rename from src/main/java/net/authorize/sample/PaypalExpressCheckout/PriorAuthorizationCapture.java rename to src/main/java/net/authorize/sample/PayPalExpressCheckout/PriorAuthorizationCapture.java index 7b143889..14da7f5b 100644 --- a/src/main/java/net/authorize/sample/PaypalExpressCheckout/PriorAuthorizationCapture.java +++ b/src/main/java/net/authorize/sample/PayPalExpressCheckout/PriorAuthorizationCapture.java @@ -4,7 +4,7 @@ * and open the template in the editor. */ -package net.authorize.sample.PaypalExpressCheckout; +package net.authorize.sample.PayPalExpressCheckout; import java.math.BigDecimal; import net.authorize.api.controller.base.ApiOperationBase; @@ -18,7 +18,7 @@ */ public class PriorAuthorizationCapture { public static ANetApiResponse run(String apiLoginId, String apiTransactionKey, String transactionId){ - System.out.println("Paypal Prior Authorization Transaction"); + System.out.println("PayPal Prior Authorization Transaction"); //Common code to set for all requests ApiOperationBase.setEnvironment(Environment.SANDBOX); diff --git a/src/main/java/net/authorize/sample/PaypalExpressCheckout/Void.java b/src/main/java/net/authorize/sample/PayPalExpressCheckout/Void.java similarity index 98% rename from src/main/java/net/authorize/sample/PaypalExpressCheckout/Void.java rename to src/main/java/net/authorize/sample/PayPalExpressCheckout/Void.java index 705d2af7..1faa11cd 100644 --- a/src/main/java/net/authorize/sample/PaypalExpressCheckout/Void.java +++ b/src/main/java/net/authorize/sample/PayPalExpressCheckout/Void.java @@ -1,4 +1,4 @@ -package net.authorize.sample.PaypalExpressCheckout; +package net.authorize.sample.PayPalExpressCheckout; import net.authorize.Environment; import net.authorize.api.contract.v1.ANetApiResponse; diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index 4803d1f9..b350100d 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -6,8 +6,8 @@ import net.authorize.sample.VisaCheckout.*; import net.authorize.sample.PaymentTransactions.*; -import net.authorize.sample.PaypalExpressCheckout.*; -import net.authorize.sample.PaypalExpressCheckout.Void; +import net.authorize.sample.PayPalExpressCheckout.*; +import net.authorize.sample.PayPalExpressCheckout.Void; import net.authorize.sample.RecurringBilling.*; import net.authorize.sample.TransactionReporting.*; import net.authorize.sample.CustomerProfiles.*; @@ -311,7 +311,7 @@ private static void RunMethod(String methodName) break; case "PayPalGetDetails": GetDetails.run(apiLoginId, transactionKey, transactionId); - case "PaypalPriorAuthorizationCapture": + case "PayPalPriorAuthorizationCapture": PriorAuthorizationCapture.run(apiLoginId, transactionKey, transactionId); break; case "UpdateSplitTenderGroup": diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt b/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt index d0fafca9..0329a664 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt +++ b/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt @@ -23,14 +23,14 @@ CustomerProfiles.CreateCustomerProfileFromTransaction 1 1 CustomerProfiles.GetCustomerPaymentProfileList 0 1 CustomerProfiles.CreateCustomerProfile 1 1 CustomerProfiles.CreateCustomerPaymentProfile 1 1 -PaypalExpressCheckout.PayPalAuthorizationOnly 1 1 -PaypalExpressCheckout.PayPalVoid 1 0 -PaypalExpressCheckout.PayPalAuthorizationAndCapture 1 1 -PaypalExpressCheckout.PayPalAuthorizationAndCaptureContinue 1 1 -PaypalExpressCheckout.PayPalAuthorizationOnlyContinued 1 0 -PaypalExpressCheckout.PayPalCredit 1 0 -PaypalExpressCheckout.PayPalGetDetails 1 1 -PaypalExpressCheckout.PayPalPriorAuthorizationCapture 1 0 +PayPalExpressCheckout.PayPalAuthorizationOnly 1 1 +PayPalExpressCheckout.PayPalVoid 1 0 +PayPalExpressCheckout.PayPalAuthorizationAndCapture 1 1 +PayPalExpressCheckout.PayPalAuthorizationAndCaptureContinue 1 1 +PayPalExpressCheckout.PayPalAuthorizationOnlyContinued 1 0 +PayPalExpressCheckout.PayPalCredit 1 0 +PayPalExpressCheckout.PayPalGetDetails 1 1 +PayPalExpressCheckout.PayPalPriorAuthorizationCapture 1 0 PaymentTransactions.ChargeCreditCard 1 1 PaymentTransactions.CapturePreviouslyAuthorizedAmount 1 1 PaymentTransactions.RefundTransaction 1 0 diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java index 07232c5f..aa3205b0 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java +++ b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java @@ -57,13 +57,13 @@ import net.authorize.sample.PaymentTransactions.DebitBankAccount; import net.authorize.sample.PaymentTransactions.RefundTransaction; import net.authorize.sample.PaymentTransactions.VoidTransaction; -import net.authorize.sample.PaypalExpressCheckout.AuthorizationAndCapture; -import net.authorize.sample.PaypalExpressCheckout.AuthorizationAndCaptureContinue; -import net.authorize.sample.PaypalExpressCheckout.AuthorizationOnly; -import net.authorize.sample.PaypalExpressCheckout.AuthorizationOnlyContinued; -import net.authorize.sample.PaypalExpressCheckout.Credit; -import net.authorize.sample.PaypalExpressCheckout.GetDetails; -import net.authorize.sample.PaypalExpressCheckout.PriorAuthorizationCapture; +import net.authorize.sample.PayPalExpressCheckout.AuthorizationAndCapture; +import net.authorize.sample.PayPalExpressCheckout.AuthorizationAndCaptureContinue; +import net.authorize.sample.PayPalExpressCheckout.AuthorizationOnly; +import net.authorize.sample.PayPalExpressCheckout.AuthorizationOnlyContinued; +import net.authorize.sample.PayPalExpressCheckout.Credit; +import net.authorize.sample.PayPalExpressCheckout.GetDetails; +import net.authorize.sample.PayPalExpressCheckout.PriorAuthorizationCapture; import net.authorize.sample.RecurringBilling.CancelSubscription; import net.authorize.sample.RecurringBilling.CreateSubscription; import net.authorize.sample.RecurringBilling.CreateSubscriptionFromCustomerProfile; @@ -409,7 +409,7 @@ public ANetApiResponse TestChargeCustomerProfile() public ANetApiResponse TestPayPalVoid() { CreateTransactionResponse response = (CreateTransactionResponse)AuthorizationAndCapture.run(apiLoginId, transactionKey, getAmount()); - return net.authorize.sample.PaypalExpressCheckout.Void.run(apiLoginId, transactionKey, response.getTransactionResponse().getTransId()); + return net.authorize.sample.PayPalExpressCheckout.Void.run(apiLoginId, transactionKey, response.getTransactionResponse().getTransId()); } public ANetApiResponse TestPayPalAuthorizationAndCapture() From 9fb08fd876d1521468fbdfcf9d02e366eb81bcf7 Mon Sep 17 00:00:00 2001 From: sapbasu Date: Tue, 3 Oct 2017 19:17:24 +0530 Subject: [PATCH 100/176] -- updated debit bank account account and routing number --- .../sample/PaymentTransactions/DebitBankAccount.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java b/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java index f45e53d2..c723e2f4 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java @@ -39,8 +39,8 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub PaymentType paymentType = new PaymentType(); BankAccountType bankAccountType = new BankAccountType(); bankAccountType.setAccountType(BankAccountTypeEnum.CHECKING); - bankAccountType.setRoutingNumber("125000024"); - bankAccountType.setAccountNumber("12345678"); + bankAccountType.setRoutingNumber("121042882"); + bankAccountType.setAccountNumber("123456789"); bankAccountType.setNameOnAccount("John Doe"); paymentType.setBankAccount(bankAccountType); From d1cc31977a79e3987ea2a6765d42ae4c415e2346 Mon Sep 17 00:00:00 2001 From: adavidw Date: Tue, 10 Oct 2017 12:54:25 -0600 Subject: [PATCH 101/176] update Travis testing environments --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1d29ab7f..81a3f3e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,6 @@ sudo: jdk: - oraclejdk8 - - oraclejdk7 + - oraclejdk9 - openjdk7 From 41623b07809b9c756f483771798bb39b6483ba38 Mon Sep 17 00:00:00 2001 From: adavidw Date: Tue, 10 Oct 2017 14:58:09 -0600 Subject: [PATCH 102/176] allow travis failures on jdk9 until backward compatibility is worked out --- .travis.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 81a3f3e8..383c89dc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,11 @@ sudo: false jdk: - - oraclejdk8 - - oraclejdk9 - - openjdk7 + - oraclejdk8 + - oraclejdk9 + - openjdk7 + +matrix: + allow_failures: + - jdk: oraclejdk9 From b327955ca07de8f18cd414cf73eb5358f610f53b Mon Sep 17 00:00:00 2001 From: adavidw Date: Tue, 17 Oct 2017 12:27:12 -0600 Subject: [PATCH 103/176] unify format and wording of README files --- README.md | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 5954d39d..891ea5ad 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,24 @@ -# Sample Java Code for Authorize.Net -[![Build Status](https://travis-ci.org/AuthorizeNet/sample-code-java.png?branch=master)](https://travis-ci.org/AuthorizeNet/sample-code-java) +# Java Sample Code for the Authorize.Net SDK +[![Travis CI Status](https://travis-ci.org/AuthorizeNet/sample-code-java.svg?branch=master)](https://travis-ci.org/AuthorizeNet/sample-code-java) -This repository contains working code samples which demonstrate Java integration with the Authorize.Net Java 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 Java integration with the [Authorize.Net Java SDK](https://www.github.com/AuthorizeNet/sdk-java). + +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. +The samples are all completely independent and self-contained. You can analyze them to get an understanding of how a particular method works, or you can use the snippets as a starting point for your own project. + +You can also run each sample directly from the command line. -## Running the Samples - 1. Clone this repository. - 2. Run "mvn package" in the root directory to create the SampleCode console app. - 3. Then run a sample directly by name: +## Running the Samples From the Command Line +* Clone this repository: +``` + $ git clone https://github.com/AuthorizeNet/sample-code-java.git +``` +* Run "mvn package" in the root directory to create the SampleCode console app. +* Run the individual samples by name. For example: ``` > java -jar target/SampleCode.jar [CodeSampleName] ``` @@ -20,7 +26,7 @@ e.g. ``` > java -jar target/SampleCode.jar ChargeCreditCard ``` -Running SampleCode without a parameter will give you the list of sample names. Handy or what! +Running SampleCode without a parameter will give you the list of sample names. **NOTE : You can update to your Sandbox credentials in SampleCode.java** @@ -32,5 +38,3 @@ Please set the JAVA environment proxy using a similar code : System.setProperty("https.proxyHost", "127.0.0.1"); System.setProperty("https.proxyPort", "3128"); ``` - -*PLEASE NOTE THIS PROJECT IS CURRENTLY UNDER DEVELOPMENT* From f9ec093d260c4fecce909547e5c6558e4f60c192 Mon Sep 17 00:00:00 2001 From: adavidw Date: Wed, 8 Nov 2017 11:31:14 -0700 Subject: [PATCH 104/176] Match the names as used in the API Reference --- ...ureContinue.java => AuthorizationAndCaptureContinued.java} | 2 +- src/main/java/net/authorize/sample/SampleCode.java | 2 +- .../net/authorize/sample/SampleCodeTest/SampleCodeList.txt | 2 +- .../java/net/authorize/sample/SampleCodeTest/TestRunner.java | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) rename src/main/java/net/authorize/sample/PayPalExpressCheckout/{AuthorizationAndCaptureContinue.java => AuthorizationAndCaptureContinued.java} (99%) diff --git a/src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationAndCaptureContinue.java b/src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationAndCaptureContinued.java similarity index 99% rename from src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationAndCaptureContinue.java rename to src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationAndCaptureContinued.java index 3dc811bd..6a176b88 100644 --- a/src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationAndCaptureContinue.java +++ b/src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationAndCaptureContinued.java @@ -18,7 +18,7 @@ import net.authorize.api.controller.base.ApiOperationBase; -public class AuthorizationAndCaptureContinue +public class AuthorizationAndCaptureContinued { public static ANetApiResponse run(String apiLoginId, String transactionKey, String TransactionID, String payerID , Double amount){ diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index b350100d..a8f0a6be 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -301,7 +301,7 @@ private static void RunMethod(String methodName) AuthorizationOnly.run(apiLoginId, transactionKey, amount); break; case "PayPalAuthorizeCaptureContinue": - AuthorizationAndCaptureContinue.run(apiLoginId, transactionKey, transactionId, payerId, amount); + AuthorizationAndCaptureContinued.run(apiLoginId, transactionKey, transactionId, payerId, amount); break; case "PayPalAuthorizeOnlyContinue": AuthorizationOnlyContinued.run(apiLoginId, transactionKey, transactionId, payerId, amount); diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt b/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt index 929e99ce..c794b052 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt +++ b/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt @@ -26,7 +26,7 @@ CustomerProfiles.CreateCustomerPaymentProfile 1 1 PayPalExpressCheckout.PayPalAuthorizationOnly 1 1 PayPalExpressCheckout.PayPalVoid 1 0 PayPalExpressCheckout.PayPalAuthorizationAndCapture 1 1 -PayPalExpressCheckout.PayPalAuthorizationAndCaptureContinue 1 1 +PayPalExpressCheckout.PayPalAuthorizationAndCaptureContinued 1 1 PayPalExpressCheckout.PayPalAuthorizationOnlyContinued 1 0 PayPalExpressCheckout.PayPalCredit 1 0 PayPalExpressCheckout.PayPalGetDetails 1 1 diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java index aa3205b0..7fe679fe 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java +++ b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java @@ -58,7 +58,7 @@ import net.authorize.sample.PaymentTransactions.RefundTransaction; import net.authorize.sample.PaymentTransactions.VoidTransaction; import net.authorize.sample.PayPalExpressCheckout.AuthorizationAndCapture; -import net.authorize.sample.PayPalExpressCheckout.AuthorizationAndCaptureContinue; +import net.authorize.sample.PayPalExpressCheckout.AuthorizationAndCaptureContinued; import net.authorize.sample.PayPalExpressCheckout.AuthorizationOnly; import net.authorize.sample.PayPalExpressCheckout.AuthorizationOnlyContinued; import net.authorize.sample.PayPalExpressCheckout.Credit; @@ -420,7 +420,7 @@ public ANetApiResponse TestPayPalAuthorizationAndCapture() public ANetApiResponse TestPayPalAuthorizationAndCaptureContinue() { CreateTransactionResponse response = (CreateTransactionResponse)AuthorizationAndCapture.run(apiLoginId, transactionKey, getAmount()); - return AuthorizationAndCaptureContinue.run(apiLoginId, transactionKey, response.getTransactionResponse().getTransId(), payerID, getAmount()); + return AuthorizationAndCaptureContinued.run(apiLoginId, transactionKey, response.getTransactionResponse().getTransId(), payerID, getAmount()); } public ANetApiResponse TestPayPalAuthorizationOnly() From f42bfaf14a35eb94dae834ff4b3047a9ce6f125a Mon Sep 17 00:00:00 2001 From: adavidw Date: Wed, 8 Nov 2017 11:39:12 -0700 Subject: [PATCH 105/176] Match the names as used in the API Reference --- .../AuthorizationAndCaptureContinued.java | 2 +- .../PayPalExpressCheckout/AuthorizationOnlyContinued.java | 2 +- src/main/java/net/authorize/sample/SampleCode.java | 8 ++++---- .../net/authorize/sample/SampleCodeTest/TestRunner.java | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationAndCaptureContinued.java b/src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationAndCaptureContinued.java index 6a176b88..28215af9 100644 --- a/src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationAndCaptureContinued.java +++ b/src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationAndCaptureContinued.java @@ -22,7 +22,7 @@ public class AuthorizationAndCaptureContinued { public static ANetApiResponse run(String apiLoginId, String transactionKey, String TransactionID, String payerID , Double amount){ - System.out.println("PayPal Authorize Capture-Continue Transaction"); + System.out.println("PayPal Authorization and Capture, Continued Transaction"); //Common code to set for all requests ApiOperationBase.setEnvironment(Environment.SANDBOX); diff --git a/src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationOnlyContinued.java b/src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationOnlyContinued.java index 15d73185..354b79c3 100644 --- a/src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationOnlyContinued.java +++ b/src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationOnlyContinued.java @@ -22,7 +22,7 @@ public class AuthorizationOnlyContinued { public static ANetApiResponse run(String apiLoginId, String transactionKey, String transactionId, String payerId, Double amount) { - System.out.println("PayPal Authorize Only-Continue Transaction"); + System.out.println("PayPal Authorization Only, Continued Transaction"); //Common code to set for all requests ApiOperationBase.setEnvironment(Environment.SANDBOX); MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index a8f0a6be..9656c61c 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -121,10 +121,10 @@ private static void ShowMethods() System.out.println(" PayPalAuthorizeCapture"); System.out.println(" PayPalVoid"); System.out.println(" PayPalAuthorizationOnly"); - System.out.println(" PayPalAuthorizeCaptureContinue"); + System.out.println(" PayPalAuthorizeCaptureContinued"); System.out.println(" PayPalGetDetails"); System.out.println(" PayPalPriorAuthorizationCapture"); - System.out.println(" PayPalAuthorizeOnlyContinue"); + System.out.println(" PayPalAuthorizeOnlyContinued"); System.out.println(" PayPalCredit"); System.out.println(" UpdateSplitTenderGroup"); System.out.println(" GetMerchantDetails"); @@ -300,10 +300,10 @@ private static void RunMethod(String methodName) case "PayPalAuthorizationOnly": AuthorizationOnly.run(apiLoginId, transactionKey, amount); break; - case "PayPalAuthorizeCaptureContinue": + case "PayPalAuthorizeCaptureContinued": AuthorizationAndCaptureContinued.run(apiLoginId, transactionKey, transactionId, payerId, amount); break; - case "PayPalAuthorizeOnlyContinue": + case "PayPalAuthorizeOnlyContinued": AuthorizationOnlyContinued.run(apiLoginId, transactionKey, transactionId, payerId, amount); break; case "PayPalCredit": diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java index 7fe679fe..1dc8493e 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java +++ b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java @@ -417,7 +417,7 @@ public ANetApiResponse TestPayPalAuthorizationAndCapture() return AuthorizationAndCapture.run(apiLoginId, transactionKey, getAmount()); } - public ANetApiResponse TestPayPalAuthorizationAndCaptureContinue() + public ANetApiResponse TestPayPalAuthorizationAndCaptureContinued() { CreateTransactionResponse response = (CreateTransactionResponse)AuthorizationAndCapture.run(apiLoginId, transactionKey, getAmount()); return AuthorizationAndCaptureContinued.run(apiLoginId, transactionKey, response.getTransactionResponse().getTransId(), payerID, getAmount()); From 4509302026fc4aa59938688687b2d9df53942d5b Mon Sep 17 00:00:00 2001 From: adavidw Date: Thu, 16 Nov 2017 00:12:04 -0800 Subject: [PATCH 106/176] update bank account --- .../sample/PaymentTransactions/CreditBankAccount.java | 4 ++-- .../sample/PaymentTransactions/DebitBankAccount.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java b/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java index df8e1ccc..b156625c 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java @@ -39,8 +39,8 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri PaymentType paymentType = new PaymentType(); BankAccountType bankAccountType = new BankAccountType(); bankAccountType.setAccountType(BankAccountTypeEnum.CHECKING); - bankAccountType.setRoutingNumber("125000024"); - bankAccountType.setAccountNumber("12345678"); + bankAccountType.setRoutingNumber("121042882"); + bankAccountType.setAccountNumber("1234567890"); bankAccountType.setNameOnAccount("John Doe"); paymentType.setBankAccount(bankAccountType); diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java b/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java index c723e2f4..5d8256d7 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java @@ -40,7 +40,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub BankAccountType bankAccountType = new BankAccountType(); bankAccountType.setAccountType(BankAccountTypeEnum.CHECKING); bankAccountType.setRoutingNumber("121042882"); - bankAccountType.setAccountNumber("123456789"); + bankAccountType.setAccountNumber("1234567890"); bankAccountType.setNameOnAccount("John Doe"); paymentType.setBankAccount(bankAccountType); From 6c20e20922545c114fd9b9c3f69710f143a69f74 Mon Sep 17 00:00:00 2001 From: adavidw Date: Thu, 16 Nov 2017 11:28:13 -0800 Subject: [PATCH 107/176] formatting changes to try to make formatting more consistent --- .../CreateCustomerPaymentProfile.java | 2 +- .../CreateCustomerProfile.java | 68 +++++++---- .../CreateCustomerProfileFromTransaction.java | 2 +- .../GetCustomerPaymentProfile.java | 10 +- .../GetCustomerPaymentProfileList.java | 58 +++++----- .../CustomerProfiles/GetCustomerProfile.java | 18 ++- .../GetCustomerProfileIds.java | 2 +- .../GetCustomerShippingAddress.java | 10 +- .../ApproveOrDeclineHeldTransaction.java | 62 +++++----- .../CreateAnAcceptTransaction.java | 18 ++- .../CreateAnApplePayTransaction.java | 18 ++- .../AuthorizationAndCapture.java | 6 +- .../AuthorizationAndCaptureContinued.java | 8 +- .../AuthorizationOnly.java | 6 +- .../AuthorizationOnlyContinued.java | 6 +- .../sample/PayPalExpressCheckout/Credit.java | 6 +- .../PayPalExpressCheckout/GetDetails.java | 10 +- .../PriorAuthorizationCapture.java | 8 +- .../sample/PayPalExpressCheckout/Void.java | 6 +- .../AuthorizeCreditCard.java | 109 ++++++++++-------- ...eFundsAuthorizedThroughAnotherChannel.java | 6 +- .../CapturePreviouslyAuthorizedAmount.java | 6 +- .../PaymentTransactions/ChargeCreditCard.java | 91 +++++++-------- .../ChargeCustomerProfile.java | 6 +- .../ChargeCustomerProfilesMT.java | 2 +- .../ChargeTokenizedCreditCard.java | 6 +- .../CreateAnAcceptPaymentTransaction.java | 6 +- .../CreditBankAccount.java | 6 +- .../PaymentTransactions/DebitBankAccount.java | 6 +- .../RefundTransaction.java | 18 ++- .../UpdateSplitTenderGroup.java | 2 +- .../PaymentTransactions/VoidTransaction.java | 6 +- .../RecurringBilling/GetSubscription.java | 56 ++++----- .../java/net/authorize/sample/SampleCode.java | 4 +- .../GetCustomerProfileTransactionList.java | 15 +-- .../CreateVisaCheckoutTransaction.java | 6 +- .../VisaCheckout/DecryptVisaCheckoutData.java | 2 +- .../sample/SampleCodeTest/TestRunner.java | 4 +- 38 files changed, 344 insertions(+), 337 deletions(-) diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerPaymentProfile.java b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerPaymentProfile.java index d3169b35..f377e88d 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerPaymentProfile.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerPaymentProfile.java @@ -69,7 +69,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri System.out.println(response.getCustomerPaymentProfileId()); System.out.println(response.getMessages().getMessage().get(0).getCode()); System.out.println(response.getMessages().getMessage().get(0).getText()); - if(response.getValidationDirectResponse() != null) + if (response.getValidationDirectResponse() != null) System.out.println(response.getValidationDirectResponse()); } else diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfile.java b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfile.java index f836c50e..96a3a7d0 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfile.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfile.java @@ -7,57 +7,77 @@ import net.authorize.api.controller.base.ApiOperationBase; public class CreateCustomerProfile { + public static ANetApiResponse run(String apiLoginId, String transactionKey, String eMail) { - public static ANetApiResponse run(String apiLoginId, String transactionKey, String eMail) { - - ApiOperationBase.setEnvironment(Environment.SANDBOX); - + // Set the request to operate in either the sandbox or production environment + ApiOperationBase.setEnvironment(Environment.SANDBOX); + + // Create object with merchant authentication details MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; merchantAuthenticationType.setName(apiLoginId); merchantAuthenticationType.setTransactionKey(transactionKey); - ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); + // Populate the payment data CreditCardType creditCard = new CreditCardType(); - creditCard.setCardNumber("4111111111111111"); - creditCard.setExpirationDate("1220"); - - PaymentType paymentType = new PaymentType(); - paymentType.setCreditCard(creditCard); + creditCard.setCardNumber("4111111111111111"); + creditCard.setExpirationDate("1220"); + PaymentType paymentType = new PaymentType(); + paymentType.setCreditCard(creditCard); - CustomerPaymentProfileType customerPaymentProfileType = new CustomerPaymentProfileType(); - customerPaymentProfileType.setCustomerType(CustomerTypeEnum.INDIVIDUAL); - customerPaymentProfileType.setPayment(paymentType); + // Set payment profile data + CustomerPaymentProfileType customerPaymentProfileType = new CustomerPaymentProfileType(); + customerPaymentProfileType.setCustomerType(CustomerTypeEnum.INDIVIDUAL); + customerPaymentProfileType.setPayment(paymentType); + // Set customer profile data CustomerProfileType customerProfileType = new CustomerProfileType(); customerProfileType.setMerchantCustomerId("M_" + eMail); customerProfileType.setDescription("Profile description for " + eMail); customerProfileType.setEmail(eMail); customerProfileType.getPaymentProfiles().add(customerPaymentProfileType); + // Create the API request and set the parameters for this specific request CreateCustomerProfileRequest apiRequest = new CreateCustomerProfileRequest(); + apiRequest.setMerchantAuthentication(merchantAuthenticationType); apiRequest.setProfile(customerProfileType); apiRequest.setValidationMode(ValidationModeEnum.TEST_MODE); + + // Call the controller CreateCustomerProfileController controller = new CreateCustomerProfileController(apiRequest); controller.execute(); - CreateCustomerProfileResponse response = controller.getApiResponse(); - if (response!=null) { - - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + // Get the response + CreateCustomerProfileResponse response = new CreateCustomerProfileResponse(); + response = controller.getApiResponse(); + + // Parse the response to determine results + if (response!=null) { + // If API Response is OK, go ahead and check the transaction response + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { System.out.println(response.getCustomerProfileId()); - if(!response.getCustomerPaymentProfileIdList().getNumericString().isEmpty()) - System.out.println(response.getCustomerPaymentProfileIdList().getNumericString().get(0)); - if(!response.getCustomerShippingAddressIdList().getNumericString().isEmpty()) - System.out.println(response.getCustomerShippingAddressIdList().getNumericString().get(0)); - if(!response.getValidationDirectResponseList().getString().isEmpty()) - System.out.println(response.getValidationDirectResponseList().getString().get(0)); + if (!response.getCustomerPaymentProfileIdList().getNumericString().isEmpty()) { + System.out.println(response.getCustomerPaymentProfileIdList().getNumericString().get(0)); + } + if (!response.getCustomerShippingAddressIdList().getNumericString().isEmpty()) { + System.out.println(response.getCustomerShippingAddressIdList().getNumericString().get(0)); + } + if (!response.getValidationDirectResponseList().getString().isEmpty()) { + System.out.println(response.getValidationDirectResponseList().getString().get(0)); + } } else { System.out.println("Failed to create customer profile: " + response.getMessages().getResultCode()); } + } else { + // Display the error code and message when response is null + ANetApiResponse errorResponse = controller.getErrorResponse(); + System.out.println("Failed to get response"); + if (!errorResponse.getMessages().getMessage().isEmpty()) { + System.out.println("Error: "+errorResponse.getMessages().getMessage().get(0).getCode()+" \n"+ errorResponse.getMessages().getMessage().get(0).getText()); + } } - return response; + return response; } } \ No newline at end of file diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfileFromTransaction.java b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfileFromTransaction.java index 44d674fe..7cc3865f 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfileFromTransaction.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfileFromTransaction.java @@ -71,7 +71,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub createProfileController.execute(); CreateCustomerProfileResponse customer_response = createProfileController.getApiResponse(); - if(customer_response != null) { + if (customer_response != null) { System.out.println(transaction_request.getTransId()); } return customer_response; diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerPaymentProfile.java b/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerPaymentProfile.java index b8627b2e..022f5d38 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerPaymentProfile.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerPaymentProfile.java @@ -53,15 +53,13 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri System.out.println(response.getPaymentProfile().getPayment().getCreditCard().getCardNumber()); System.out.println(response.getPaymentProfile().getPayment().getCreditCard().getExpirationDate()); - if((response.getPaymentProfile().getSubscriptionIds() != null) && (response.getPaymentProfile().getSubscriptionIds().getSubscriptionId() != null) && - (!response.getPaymentProfile().getSubscriptionIds().getSubscriptionId().isEmpty())){ + if ((response.getPaymentProfile().getSubscriptionIds() != null) && (response.getPaymentProfile().getSubscriptionIds().getSubscriptionId() != null) && + (!response.getPaymentProfile().getSubscriptionIds().getSubscriptionId().isEmpty())) { System.out.println("List of subscriptions:"); - for(String subscriptionid : response.getPaymentProfile().getSubscriptionIds().getSubscriptionId()) + for (String subscriptionid : response.getPaymentProfile().getSubscriptionIds().getSubscriptionId()) System.out.println(subscriptionid); } - } - else - { + } else { System.out.println("Failed to get customer payment profile: " + response.getMessages().getResultCode()); } } diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerPaymentProfileList.java b/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerPaymentProfileList.java index 1633abc8..f55c204e 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerPaymentProfileList.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerPaymentProfileList.java @@ -7,19 +7,18 @@ import net.authorize.api.controller.base.ApiOperationBase; import net.authorize.api.controller.*; -public class GetCustomerPaymentProfileList -{ - public static ANetApiResponse run(String apiLoginId,String transactionKey) - { +public class GetCustomerPaymentProfileList { + public static ANetApiResponse run(String apiLoginId,String transactionKey) { + + // Set the request to operate in either the sandbox or production environment ApiOperationBase.setEnvironment(Environment.SANDBOX); - // Giving the merchant authentication information + // Create object with merchant authentication details MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; merchantAuthenticationType.setName(apiLoginId); merchantAuthenticationType.setTransactionKey(transactionKey); - ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); - //Setting the paging + // Setting the paging Paging paging = new Paging(); paging.setLimit(100); paging.setOffset(1); @@ -33,56 +32,57 @@ public static ANetApiResponse run(String apiLoginId,String transactionKey) // Setting the searchType CustomerPaymentProfileSearchTypeEnum searchType = CustomerPaymentProfileSearchTypeEnum.CARDS_EXPIRING_IN_MONTH; - // Making the API request + // Create the API request and set the parameters for this specific request GetCustomerPaymentProfileListRequest apiRequest = new GetCustomerPaymentProfileListRequest(); + apiRequest.setMerchantAuthentication(merchantAuthenticationType); apiRequest.setPaging(paging); apiRequest.setSearchType(searchType); apiRequest.setSorting(sorting); apiRequest.setMonth("2020-12"); - // Calling the controller + // Call the controller GetCustomerPaymentProfileListController controller = new GetCustomerPaymentProfileListController(apiRequest); controller.execute(); - // Getting the response + + // Get the response GetCustomerPaymentProfileListResponse response = new GetCustomerPaymentProfileListResponse(); response = controller.getApiResponse(); - // Checking id the response is not null then printing the details - if(response != null) - { - if(response.getMessages().getResultCode() == MessageTypeEnum.OK) - { + + // Parse the response to determine results + if (response != null) { + // If API Response is OK, go ahead and check the transaction response + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { System.out.println("Successfully got customer payment profile list"); System.out.println("Message Code:" + response.getMessages().getMessage().get(0).getCode()); System.out.println("Message Text:" + response.getMessages().getMessage().get(0).getText()); System.out.println("Total Number of Results in the Results Set:" + response.getTotalNumInResultSet()); List arr = response.getPaymentProfiles().getPaymentProfile(); - for(CustomerPaymentProfileListItemType element : arr) - { + for (CustomerPaymentProfileListItemType element : arr) { System.out.println(); - if(element.getBillTo()!=null) + if (element.getBillTo()!=null) { System.out.println("Customer name : "+element.getBillTo().getFirstName()+" "+element.getBillTo().getLastName()); + } System.out.println("Credit card number: "+element.getPayment().getCreditCard().getCardNumber()); System.out.println("Customer Profile ID : "+element.getCustomerProfileId()); System.out.println("Customer Payment Profile ID : "+element.getCustomerPaymentProfileId()); } - } - else - { - // When the error occurs + } else { + // Displaying the error code and message when error occurs System.out.println("Failed to get customer payment profile list"); - if(!response.getMessages().getMessage().isEmpty()) + if (!response.getMessages().getMessage().isEmpty()) { System.out.println("Error: "+response.getMessages().getMessage().get(0).getCode()+" "+ response.getMessages().getMessage().get(0).getText()); + } } - } - else - { - // Displaying the error code and message when response is null + } else { + // Display the error code and message when response is null ANetApiResponse errorResponse = controller.getErrorResponse(); System.out.println("Failed to get response"); - if(!errorResponse.getMessages().getMessage().isEmpty()) + if (!errorResponse.getMessages().getMessage().isEmpty()) { System.out.println("Error: "+errorResponse.getMessages().getMessage().get(0).getCode()+" \n"+ errorResponse.getMessages().getMessage().get(0).getText()); + } } - return response; + + return response; } } diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerProfile.java b/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerProfile.java index 033e3865..c797ce69 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerProfile.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerProfile.java @@ -30,7 +30,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri if (response!=null) { - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { System.out.println(response.getMessages().getMessage().get(0).getCode()); System.out.println(response.getMessages().getMessage().get(0).getText()); @@ -40,8 +40,8 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri System.out.println(response.getProfile().getEmail()); System.out.println(response.getProfile().getCustomerProfileId()); - if((!response.getProfile().getPaymentProfiles().isEmpty()) && - (response.getProfile().getPaymentProfiles().get(0).getBillTo() != null)){ + if ((!response.getProfile().getPaymentProfiles().isEmpty()) && + (response.getProfile().getPaymentProfiles().get(0).getBillTo() != null)) { System.out.println(response.getProfile().getPaymentProfiles().get(0).getBillTo().getFirstName()); System.out.println(response.getProfile().getPaymentProfiles().get(0).getBillTo().getLastName()); System.out.println(response.getProfile().getPaymentProfiles().get(0).getBillTo().getCompany()); @@ -59,7 +59,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri System.out.println(response.getProfile().getPaymentProfiles().get(0).getPayment().getCreditCard().getExpirationDate()); } - if(!response.getProfile().getShipToList().isEmpty()){ + if (!response.getProfile().getShipToList().isEmpty()) { System.out.println(response.getProfile().getShipToList().get(0).getFirstName()); System.out.println(response.getProfile().getShipToList().get(0).getLastName()); System.out.println(response.getProfile().getShipToList().get(0).getCompany()); @@ -72,16 +72,14 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri System.out.println(response.getProfile().getShipToList().get(0).getFaxNumber()); } - if((response.getSubscriptionIds() != null) && (response.getSubscriptionIds().getSubscriptionId() != null) && - (!response.getSubscriptionIds().getSubscriptionId().isEmpty())){ + if ((response.getSubscriptionIds() != null) && (response.getSubscriptionIds().getSubscriptionId() != null) && + (!response.getSubscriptionIds().getSubscriptionId().isEmpty())) { System.out.println("List of subscriptions:"); - for(String subscriptionid : response.getSubscriptionIds().getSubscriptionId()) + for (String subscriptionid : response.getSubscriptionIds().getSubscriptionId()) System.out.println(subscriptionid); } - } - else - { + } else { System.out.println("Failed to get customer profile: " + response.getMessages().getResultCode()); } } diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerProfileIds.java b/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerProfileIds.java index e2666fee..6e25d51c 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerProfileIds.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerProfileIds.java @@ -34,7 +34,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) { System.out.println(response.getMessages().getMessage().get(0).getCode()); System.out.println(response.getMessages().getMessage().get(0).getText()); - for(int i =0; i < response.getIds().getNumericString().size(); i++) { + for (int i =0; i < response.getIds().getNumericString().size(); i++) { System.out.println(response.getIds().getNumericString().get(i)); } diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerShippingAddress.java b/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerShippingAddress.java index 8b245436..e5f63005 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerShippingAddress.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerShippingAddress.java @@ -50,15 +50,13 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri System.out.println(response.getAddress().getCustomerAddressId()); - if((response.getSubscriptionIds() != null) && (response.getSubscriptionIds().getSubscriptionId() != null) && - (!response.getSubscriptionIds().getSubscriptionId().isEmpty())){ + if ((response.getSubscriptionIds() != null) && (response.getSubscriptionIds().getSubscriptionId() != null) && + (!response.getSubscriptionIds().getSubscriptionId().isEmpty())) { System.out.println("List of subscriptions:"); - for(String subscriptionid : response.getSubscriptionIds().getSubscriptionId()) + for (String subscriptionid : response.getSubscriptionIds().getSubscriptionId()) System.out.println(subscriptionid); } - } - else - { + } else { System.out.println("Failed to get customer shipping address: " + response.getMessages().getResultCode()); } } diff --git a/src/main/java/net/authorize/sample/FraudManagement/ApproveOrDeclineHeldTransaction.java b/src/main/java/net/authorize/sample/FraudManagement/ApproveOrDeclineHeldTransaction.java index 6df07501..7afab2ac 100644 --- a/src/main/java/net/authorize/sample/FraudManagement/ApproveOrDeclineHeldTransaction.java +++ b/src/main/java/net/authorize/sample/FraudManagement/ApproveOrDeclineHeldTransaction.java @@ -50,41 +50,37 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri UpdateHeldTransactionResponse response = controller.getApiResponse(); if (response!=null) { - // If API Response is ok, go ahead and check the transaction response - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { - TransactionResponse result = response.getTransactionResponse(); - if(result.getMessages() != null){ - System.out.println("Successfully updated transaction with Transaction ID: " + result.getTransId()); - System.out.println("Response Code: " + result.getResponseCode()); - System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); - System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); - System.out.println("Auth Code: " + result.getAuthCode()); - } - else { - System.out.println("Failed while updating transaction."); - if(response.getTransactionResponse().getErrors() != null){ - System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); - System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); - } - } - } - else { - System.out.println("Failed while updating transaction."); - if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ - System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); - System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); - } - else { - System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); - System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); - } - } - } - else { - System.out.println("Null Response."); + // If API Response is ok, go ahead and check the transaction response + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + TransactionResponse result = response.getTransactionResponse(); + if (result.getMessages() != null) { + System.out.println("Successfully updated transaction with Transaction ID: " + result.getTransId()); + System.out.println("Response Code: " + result.getResponseCode()); + System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); + System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); + System.out.println("Auth Code: " + result.getAuthCode()); + } else { + System.out.println("Failed while updating transaction."); + if (response.getTransactionResponse().getErrors() != null) { + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + } + } else { + System.out.println("Failed while updating transaction."); + if (response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null) { + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } else { + System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); + System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); + } + } + } else { + System.out.println("Null Response."); } - return response; + return response; } diff --git a/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAcceptTransaction.java b/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAcceptTransaction.java index 37d40487..6ff9d90a 100644 --- a/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAcceptTransaction.java +++ b/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAcceptTransaction.java @@ -42,34 +42,30 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) // If API Response is ok, go ahead and check the transaction response if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { TransactionResponse result = response.getTransactionResponse(); - if(result.getMessages() != null){ + if (result.getMessages() != null) { System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); System.out.println("Response Code: " + result.getResponseCode()); System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); System.out.println("Auth code : " + result.getAuthCode()); - } - else { + } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } } - } - else { + } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); - } - else { + } else { System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); } } - } - else { + } else { System.out.println("Null Response."); } diff --git a/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnApplePayTransaction.java b/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnApplePayTransaction.java index a3335ea5..d03b4812 100644 --- a/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnApplePayTransaction.java +++ b/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnApplePayTransaction.java @@ -42,34 +42,30 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) // If API Response is ok, go ahead and check the transaction response if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { TransactionResponse result = response.getTransactionResponse(); - if(result.getMessages() != null){ + if (result.getMessages() != null) { System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); System.out.println("Response Code: " + result.getResponseCode()); System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); System.out.println("Auth code : " + result.getAuthCode()); - } - else { + } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } } - } - else { + } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); - } - else { + } else { System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); } } - } - else { + } else { System.out.println("Null Response."); } diff --git a/src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationAndCapture.java b/src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationAndCapture.java index a0feac0a..3705af7f 100644 --- a/src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationAndCapture.java +++ b/src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationAndCapture.java @@ -58,7 +58,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub // If API Response is ok, go ahead and check the transaction response if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { TransactionResponse result = response.getTransactionResponse(); - if(result.getMessages() != null){ + if (result.getMessages() != null) { System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); System.out.println("Response Code: " + result.getResponseCode()); System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); @@ -67,7 +67,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } @@ -75,7 +75,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } diff --git a/src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationAndCaptureContinued.java b/src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationAndCaptureContinued.java index 28215af9..6b0844f8 100644 --- a/src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationAndCaptureContinued.java +++ b/src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationAndCaptureContinued.java @@ -20,7 +20,7 @@ public class AuthorizationAndCaptureContinued { - public static ANetApiResponse run(String apiLoginId, String transactionKey, String TransactionID, String payerID , Double amount){ + public static ANetApiResponse run(String apiLoginId, String transactionKey, String TransactionID, String payerID , Double amount) { System.out.println("PayPal Authorization and Capture, Continued Transaction"); @@ -67,7 +67,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri // If API Response is ok, go ahead and check the transaction response if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { TransactionResponse result = response.getTransactionResponse(); - if(result.getMessages() != null){ + if (result.getMessages() != null) { System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); System.out.println("Response Code: " + result.getResponseCode()); System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); @@ -75,7 +75,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } @@ -83,7 +83,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } diff --git a/src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationOnly.java b/src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationOnly.java index 47ae725e..28fb438b 100644 --- a/src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationOnly.java +++ b/src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationOnly.java @@ -62,7 +62,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub // If API Response is ok, go ahead and check the transaction response if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { TransactionResponse result = response.getTransactionResponse(); - if(result.getMessages() != null){ + if (result.getMessages() != null) { System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); System.out.println("Response Code: " + result.getResponseCode()); System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); @@ -71,7 +71,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } @@ -79,7 +79,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } diff --git a/src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationOnlyContinued.java b/src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationOnlyContinued.java index 354b79c3..1d665f42 100644 --- a/src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationOnlyContinued.java +++ b/src/main/java/net/authorize/sample/PayPalExpressCheckout/AuthorizationOnlyContinued.java @@ -60,7 +60,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri // If API Response is ok, go ahead and check the transaction response if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { TransactionResponse result = response.getTransactionResponse(); - if(result.getMessages() != null){ + if (result.getMessages() != null) { System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); System.out.println("Response Code: " + result.getResponseCode()); System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); @@ -68,7 +68,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } @@ -76,7 +76,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } diff --git a/src/main/java/net/authorize/sample/PayPalExpressCheckout/Credit.java b/src/main/java/net/authorize/sample/PayPalExpressCheckout/Credit.java index 62d45fe8..43ef3add 100644 --- a/src/main/java/net/authorize/sample/PayPalExpressCheckout/Credit.java +++ b/src/main/java/net/authorize/sample/PayPalExpressCheckout/Credit.java @@ -48,7 +48,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri // If API Response is ok, go ahead and check the transaction response if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { TransactionResponse result = response.getTransactionResponse(); - if(result.getMessages() != null){ + if (result.getMessages() != null) { System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); System.out.println("Response Code: " + result.getResponseCode()); System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); @@ -56,7 +56,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } @@ -64,7 +64,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } diff --git a/src/main/java/net/authorize/sample/PayPalExpressCheckout/GetDetails.java b/src/main/java/net/authorize/sample/PayPalExpressCheckout/GetDetails.java index 05471def..2d6796d6 100644 --- a/src/main/java/net/authorize/sample/PayPalExpressCheckout/GetDetails.java +++ b/src/main/java/net/authorize/sample/PayPalExpressCheckout/GetDetails.java @@ -40,16 +40,16 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri // If API Response is ok, go ahead and check the transaction response if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { TransactionResponse result = response.getTransactionResponse(); - if(result.getMessages() != null){ + if (result.getMessages() != null) { System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); System.out.println("Response Code: " + result.getResponseCode()); System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); - if(result.getSecureAcceptance() != null) + if (result.getSecureAcceptance() != null) System.out.println("PayPal PayerID : "+ result.getSecureAcceptance().getPayerID()); - if(result.getShipTo() != null) { + if (result.getShipTo() != null) { System.out.println("Shipping Address : "+ result.getShipTo().getFirstName()); System.out.println(result.getShipTo().getAddress() +" " + result.getShipTo().getCity()); System.out.println(result.getShipTo().getState() +" "+ result.getShipTo().getZip()); @@ -58,7 +58,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } @@ -66,7 +66,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } diff --git a/src/main/java/net/authorize/sample/PayPalExpressCheckout/PriorAuthorizationCapture.java b/src/main/java/net/authorize/sample/PayPalExpressCheckout/PriorAuthorizationCapture.java index 14da7f5b..b088f493 100644 --- a/src/main/java/net/authorize/sample/PayPalExpressCheckout/PriorAuthorizationCapture.java +++ b/src/main/java/net/authorize/sample/PayPalExpressCheckout/PriorAuthorizationCapture.java @@ -17,7 +17,7 @@ * @author gnongsie */ public class PriorAuthorizationCapture { - public static ANetApiResponse run(String apiLoginId, String apiTransactionKey, String transactionId){ + public static ANetApiResponse run(String apiLoginId, String apiTransactionKey, String transactionId) { System.out.println("PayPal Prior Authorization Transaction"); //Common code to set for all requests @@ -59,7 +59,7 @@ public static ANetApiResponse run(String apiLoginId, String apiTransactionKey, S // If API Response is ok, go ahead and check the transaction response if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { TransactionResponse result = response.getTransactionResponse(); - if(result.getMessages() != null){ + if (result.getMessages() != null) { System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); System.out.println("Response Code: " + result.getResponseCode()); System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); @@ -67,7 +67,7 @@ public static ANetApiResponse run(String apiLoginId, String apiTransactionKey, S } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } @@ -75,7 +75,7 @@ public static ANetApiResponse run(String apiLoginId, String apiTransactionKey, S } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } diff --git a/src/main/java/net/authorize/sample/PayPalExpressCheckout/Void.java b/src/main/java/net/authorize/sample/PayPalExpressCheckout/Void.java index 1faa11cd..7a872e60 100644 --- a/src/main/java/net/authorize/sample/PayPalExpressCheckout/Void.java +++ b/src/main/java/net/authorize/sample/PayPalExpressCheckout/Void.java @@ -54,7 +54,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri // If API Response is ok, go ahead and check the transaction response if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { TransactionResponse result = response.getTransactionResponse(); - if(result.getMessages() != null){ + if (result.getMessages() != null) { System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); System.out.println("Response Code: " + result.getResponseCode()); System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); @@ -62,7 +62,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } @@ -70,7 +70,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/AuthorizeCreditCard.java b/src/main/java/net/authorize/sample/PaymentTransactions/AuthorizeCreditCard.java index a0b96a87..60acd464 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/AuthorizeCreditCard.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/AuthorizeCreditCard.java @@ -4,22 +4,31 @@ import java.math.RoundingMode; import net.authorize.Environment; -import net.authorize.api.contract.v1.*; -import net.authorize.api.controller.base.ApiOperationBase; +import net.authorize.api.contract.v1.ANetApiResponse; +import net.authorize.api.contract.v1.CreateTransactionRequest; +import net.authorize.api.contract.v1.CreateTransactionResponse; +import net.authorize.api.contract.v1.CreditCardType; +import net.authorize.api.contract.v1.MerchantAuthenticationType; +import net.authorize.api.contract.v1.MessageTypeEnum; +import net.authorize.api.contract.v1.PaymentType; +import net.authorize.api.contract.v1.TransactionRequestType; +import net.authorize.api.contract.v1.TransactionResponse; +import net.authorize.api.contract.v1.TransactionTypeEnum; import net.authorize.api.controller.CreateTransactionController; +import net.authorize.api.controller.base.ApiOperationBase; public class AuthorizeCreditCard { // // Run this sample from command line with: - // java -jar target/ChargeCreditCard-jar-with-dependencies.jar + // java -jar target/AuthorizeCreditCard-jar-with-dependencies.jar // public static ANetApiResponse run(String apiLoginId, String transactionKey, Double amount) { - - //Common code to set for all requests + // Set the request to operate in either the sandbox or production environment ApiOperationBase.setEnvironment(Environment.SANDBOX); - + + // Create object with merchant authentication details MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; merchantAuthenticationType.setName(apiLoginId); merchantAuthenticationType.setTransactionKey(transactionKey); @@ -31,62 +40,62 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub creditCard.setExpirationDate("0822"); paymentType.setCreditCard(creditCard); - // Create the payment transaction request + // Create the payment transaction object TransactionRequestType txnRequest = new TransactionRequestType(); txnRequest.setTransactionType(TransactionTypeEnum.AUTH_ONLY_TRANSACTION.value()); txnRequest.setPayment(paymentType); txnRequest.setAmount(new BigDecimal(amount).setScale(2, RoundingMode.CEILING)); - // Make the API Request & set the merchant details for this specific request + // Create the API request and set the parameters for this specific request CreateTransactionRequest apiRequest = new CreateTransactionRequest(); - apiRequest.setMerchantAuthentication(merchantAuthenticationType); - + apiRequest.setMerchantAuthentication(merchantAuthenticationType); apiRequest.setTransactionRequest(txnRequest); + + // Call the controller CreateTransactionController controller = new CreateTransactionController(apiRequest); controller.execute(); - - CreateTransactionResponse response = controller.getApiResponse(); - + // Get the response + CreateTransactionResponse response = new CreateTransactionResponse(); + response = controller.getApiResponse(); + + // Parse the response to determine results if (response!=null) { - // If API Response is ok, go ahead and check the transaction response - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { - TransactionResponse result = response.getTransactionResponse(); - if(result.getMessages() != null){ - System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); - System.out.println("Response Code: " + result.getResponseCode()); - System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); - System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); - System.out.println("Auth code: " + result.getAuthCode()); - } - else { - System.out.println("Failed Transaction."); - if(response.getTransactionResponse().getErrors() != null){ - System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); - System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); - } - } - } - else { - System.out.println("Failed Transaction."); - if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ - System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); - System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); - } - else { - System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); - System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); - } - } - } - else { - System.out.println("Null Response."); + // If API Response is OK, go ahead and check the transaction response + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + TransactionResponse result = response.getTransactionResponse(); + if (result.getMessages() != null) { + System.out.println("Successfully created auth-only transaction with Transaction ID: " + result.getTransId()); + System.out.println("Response Code: " + result.getResponseCode()); + System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); + System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); + System.out.println("Auth Code: " + result.getAuthCode()); + } else { + System.out.println("Failed Transaction."); + if (response.getTransactionResponse().getErrors() != null) { + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + } + } else { + System.out.println("Failed Transaction."); + if (response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null) { + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } else { + System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); + System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); + } + } + } else { + // Display the error code and message when response is null + ANetApiResponse errorResponse = controller.getErrorResponse(); + System.out.println("Failed to get response"); + if (!errorResponse.getMessages().getMessage().isEmpty()) { + System.out.println("Error: "+errorResponse.getMessages().getMessage().get(0).getCode()+" \n"+ errorResponse.getMessages().getMessage().get(0).getText()); + } } - return response; - + return response; } - - - } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/CaptureFundsAuthorizedThroughAnotherChannel.java b/src/main/java/net/authorize/sample/PaymentTransactions/CaptureFundsAuthorizedThroughAnotherChannel.java index 1e3edaf1..6127e0f1 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/CaptureFundsAuthorizedThroughAnotherChannel.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/CaptureFundsAuthorizedThroughAnotherChannel.java @@ -59,7 +59,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub // If API Response is ok, go ahead and check the transaction response if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { TransactionResponse result = response.getTransactionResponse(); - if(result.getMessages() != null){ + if (result.getMessages() != null) { System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); System.out.println("Response Code: " + result.getResponseCode()); System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); @@ -68,7 +68,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } @@ -76,7 +76,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/CapturePreviouslyAuthorizedAmount.java b/src/main/java/net/authorize/sample/PaymentTransactions/CapturePreviouslyAuthorizedAmount.java index 5762c281..9cecf8ea 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/CapturePreviouslyAuthorizedAmount.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/CapturePreviouslyAuthorizedAmount.java @@ -40,7 +40,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri // If API Response is ok, go ahead and check the transaction response if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { TransactionResponse result = response.getTransactionResponse(); - if(result.getMessages() != null){ + if (result.getMessages() != null) { System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); System.out.println("Response Code: " + result.getResponseCode()); System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); @@ -49,7 +49,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } @@ -57,7 +57,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCreditCard.java b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCreditCard.java index eb165619..ad57ac16 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCreditCard.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCreditCard.java @@ -25,14 +25,13 @@ public class ChargeCreditCard { // public static ANetApiResponse run(String apiLoginId, String transactionKey, Double amount) { - - //Common code to set for all requests + // Set the request to operate in either the sandbox or production environment ApiOperationBase.setEnvironment(Environment.SANDBOX); + // Create object with merchant authentication details MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; merchantAuthenticationType.setName(apiLoginId); merchantAuthenticationType.setTransactionKey(transactionKey); - ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); // Populate the payment data PaymentType paymentType = new PaymentType(); @@ -41,60 +40,62 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub creditCard.setExpirationDate("0822"); paymentType.setCreditCard(creditCard); - // Create the payment transaction request + // Create the payment transaction object TransactionRequestType txnRequest = new TransactionRequestType(); txnRequest.setTransactionType(TransactionTypeEnum.AUTH_CAPTURE_TRANSACTION.value()); txnRequest.setPayment(paymentType); txnRequest.setAmount(new BigDecimal(amount).setScale(2, RoundingMode.CEILING)); - // Make the API Request + // Create the API request and set the parameters for this specific request CreateTransactionRequest apiRequest = new CreateTransactionRequest(); + apiRequest.setMerchantAuthentication(merchantAuthenticationType); apiRequest.setTransactionRequest(txnRequest); + + // Call the controller CreateTransactionController controller = new CreateTransactionController(apiRequest); controller.execute(); - - CreateTransactionResponse response = controller.getApiResponse(); - + // Get the response + CreateTransactionResponse response = new CreateTransactionResponse(); + response = controller.getApiResponse(); + + // Parse the response to determine results if (response!=null) { - // If API Response is ok, go ahead and check the transaction response - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { - TransactionResponse result = response.getTransactionResponse(); - if(result.getMessages() != null){ - System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); - System.out.println("Response Code: " + result.getResponseCode()); - System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); - System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); - System.out.println("Auth Code: " + result.getAuthCode()); - } - else { - System.out.println("Failed Transaction."); - if(response.getTransactionResponse().getErrors() != null){ - System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); - System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); - } - } - } - else { - System.out.println("Failed Transaction."); - if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ - System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); - System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); - } - else { - System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); - System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); - } - } - } - else { - System.out.println("Null Response."); + // If API Response is OK, go ahead and check the transaction response + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + TransactionResponse result = response.getTransactionResponse(); + if (result.getMessages() != null) { + System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Response Code: " + result.getResponseCode()); + System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); + System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); + System.out.println("Auth Code: " + result.getAuthCode()); + } else { + System.out.println("Failed Transaction."); + if (response.getTransactionResponse().getErrors() != null) { + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + } + } else { + System.out.println("Failed Transaction."); + if (response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null) { + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } else { + System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); + System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); + } + } + } else { + // Display the error code and message when response is null + ANetApiResponse errorResponse = controller.getErrorResponse(); + System.out.println("Failed to get response"); + if (!errorResponse.getMessages().getMessage().isEmpty()) { + System.out.println("Error: "+errorResponse.getMessages().getMessage().get(0).getCode()+" \n"+ errorResponse.getMessages().getMessage().get(0).getText()); + } } - return response; - + return response; } - - - } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCustomerProfile.java b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCustomerProfile.java index 6645a2d0..0d86c650 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCustomerProfile.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCustomerProfile.java @@ -62,7 +62,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri // If API Response is ok, go ahead and check the transaction response if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { TransactionResponse result = response.getTransactionResponse(); - if(result.getMessages() != null){ + if (result.getMessages() != null) { System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); System.out.println("Response Code: " + result.getResponseCode()); System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); @@ -71,7 +71,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } @@ -79,7 +79,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCustomerProfilesMT.java b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCustomerProfilesMT.java index 8222bc56..7b250046 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCustomerProfilesMT.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCustomerProfilesMT.java @@ -86,7 +86,7 @@ public void run() { System.out.println("============================================================================"); System.out.println("chargeResponse Dt1: + " + dt1.toString()); - if((response.getCustomerProfileId() != null) && (paymentProfileResponse.getCustomerPaymentProfileId() != null)) + if ((response.getCustomerProfileId() != null) && (paymentProfileResponse.getCustomerPaymentProfileId() != null)) { CreateTransactionResponse chargeResponse = (CreateTransactionResponse) ChargeCustomerProfile.run(apiLoginId, transactionKey, response.getCustomerProfileId(), paymentProfileResponse.getCustomerPaymentProfileId(), getAmount()); diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeTokenizedCreditCard.java b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeTokenizedCreditCard.java index 584bee19..25b507c5 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeTokenizedCreditCard.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeTokenizedCreditCard.java @@ -63,7 +63,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub // If API Response is ok, go ahead and check the transaction response if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { TransactionResponse result = response.getTransactionResponse(); - if(result.getMessages() != null){ + if (result.getMessages() != null) { System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); System.out.println("Response Code: " + result.getResponseCode()); System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); @@ -72,7 +72,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } @@ -80,7 +80,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/CreateAnAcceptPaymentTransaction.java b/src/main/java/net/authorize/sample/PaymentTransactions/CreateAnAcceptPaymentTransaction.java index 15505df5..cc8bb29e 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/CreateAnAcceptPaymentTransaction.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/CreateAnAcceptPaymentTransaction.java @@ -60,7 +60,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub // If API Response is ok, go ahead and check the transaction response if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { TransactionResponse result = response.getTransactionResponse(); - if(result.getMessages() != null){ + if (result.getMessages() != null) { System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); System.out.println("Response Code: " + result.getResponseCode()); System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); @@ -69,7 +69,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } @@ -77,7 +77,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java b/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java index b156625c..69e912ea 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java @@ -64,7 +64,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri // If API Response is ok, go ahead and check the transaction response if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { TransactionResponse result = response.getTransactionResponse(); - if(result.getMessages() != null){ + if (result.getMessages() != null) { System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); System.out.println("Response Code: " + result.getResponseCode()); System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); @@ -73,7 +73,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } @@ -81,7 +81,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java b/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java index 5d8256d7..99121d3d 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java @@ -63,7 +63,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub // If API Response is ok, go ahead and check the transaction response if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { TransactionResponse result = response.getTransactionResponse(); - if(result.getMessages() != null){ + if (result.getMessages() != null) { System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); System.out.println("Response Code: " + result.getResponseCode()); System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); @@ -72,7 +72,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } @@ -80,7 +80,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/RefundTransaction.java b/src/main/java/net/authorize/sample/PaymentTransactions/RefundTransaction.java index 4c1b1675..41913cc0 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/RefundTransaction.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/RefundTransaction.java @@ -49,34 +49,30 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub // If API Response is ok, go ahead and check the transaction response if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { TransactionResponse result = response.getTransactionResponse(); - if(result.getMessages() != null){ + if (result.getMessages() != null) { System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); System.out.println("Response Code: " + result.getResponseCode()); System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); System.out.println("Auth Code: " + result.getAuthCode()); - } - else { + } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } } - } - else { + } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); - } - else { + } else { System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); } } - } - else { + } else { System.out.println("Null Response."); } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/UpdateSplitTenderGroup.java b/src/main/java/net/authorize/sample/PaymentTransactions/UpdateSplitTenderGroup.java index a6bccc94..456d3fdc 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/UpdateSplitTenderGroup.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/UpdateSplitTenderGroup.java @@ -39,7 +39,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) { UpdateSplitTenderGroupResponse response = controller.getApiResponse(); - if (response.getMessages().getResultCode() == MessageTypeEnum.OK){ + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { System.out.println(response.getMessages().getMessage().get(0).getCode()); System.out.println(response.getMessages().getMessage().get(0).getText()); } diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/VoidTransaction.java b/src/main/java/net/authorize/sample/PaymentTransactions/VoidTransaction.java index e713249a..781f4152 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/VoidTransaction.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/VoidTransaction.java @@ -40,7 +40,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri // If API Response is ok, go ahead and check the transaction response if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { TransactionResponse result = response.getTransactionResponse(); - if(result.getMessages() != null){ + if (result.getMessages() != null) { System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); System.out.println("Response Code: " + result.getResponseCode()); System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); @@ -49,7 +49,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } @@ -57,7 +57,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } diff --git a/src/main/java/net/authorize/sample/RecurringBilling/GetSubscription.java b/src/main/java/net/authorize/sample/RecurringBilling/GetSubscription.java index 6b1ebc41..5377db4b 100644 --- a/src/main/java/net/authorize/sample/RecurringBilling/GetSubscription.java +++ b/src/main/java/net/authorize/sample/RecurringBilling/GetSubscription.java @@ -10,32 +10,36 @@ import net.authorize.api.controller.ARBGetSubscriptionController; import net.authorize.api.controller.base.ApiOperationBase; -public class GetSubscription -{ - public static ANetApiResponse run(String apiLoginId,String transactionKey, String subscriptionId) - { +public class GetSubscription { + public static ANetApiResponse run(String apiLoginId,String transactionKey, String subscriptionId) { + + // Set the request to operate in either the sandbox or production environment ApiOperationBase.setEnvironment(Environment.SANDBOX); - // Giving the merchant authentication information + + // Create object with merchant authentication details MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; merchantAuthenticationType.setName(apiLoginId); merchantAuthenticationType.setTransactionKey(transactionKey); - ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); - // Making the API request + + // Create the API request and set the parameters for this specific request ARBGetSubscriptionRequest apiRequest = new ARBGetSubscriptionRequest(); + apiRequest.setMerchantAuthentication(merchantAuthenticationType); apiRequest.setRefId("Sample"); apiRequest.setSubscriptionId(subscriptionId); - // Calling the controller + + // Call the controller ARBGetSubscriptionController controller = new ARBGetSubscriptionController(apiRequest); controller.execute(); - // Getting the response - ARBGetSubscriptionResponse response = controller.getApiResponse(); + + // Get the response + ARBGetSubscriptionResponse response = new ARBGetSubscriptionResponse(); + response = controller.getApiResponse(); - if(response!=null) - { - if(response.getMessages().getResultCode() == MessageTypeEnum.OK) - { - if(response.getSubscription() != null) - { + // Parse the response to determine results + if (response!=null) { + // If API Response is OK, go ahead and check the transaction response + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + if (response.getSubscription() != null) { // Displaying the subscription details System.out.println("Successfully got ARB Subscription"); System.out.println("Subscription Details:"); @@ -46,24 +50,22 @@ public static ANetApiResponse run(String apiLoginId,String transactionKey, Strin System.out.println("Subscription Description: "+response.getSubscription().getProfile().getDescription()); System.out.println("Customer Profile ID: "+ response.getSubscription().getProfile().getCustomerProfileId()); } - } - else - { + } else { // Displaying the error code and message when error occurs System.out.println("Failed to get ARB Subscription"); - if(!response.getMessages().getMessage().isEmpty()) + if (!response.getMessages().getMessage().isEmpty()) { System.out.println("Error: "+response.getMessages().getMessage().get(0).getCode()+" "+ response.getMessages().getMessage().get(0).getText()); + } } - } - else - { - // Displaying the error code and message when response is null + } else { + // Display the error code and message when response is null ANetApiResponse errorResponse = controller.getErrorResponse(); - System.out.println("Failed to get response"); - if(!errorResponse.getMessages().getMessage().isEmpty()) + if (!errorResponse.getMessages().getMessage().isEmpty()) { System.out.println("Error: "+errorResponse.getMessages().getMessage().get(0).getCode()+" \n"+ errorResponse.getMessages().getMessage().get(0).getText()); + } } - return response; + + return response; } } diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index 9656c61c..8e66debd 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -40,7 +40,7 @@ else if (args.length == 1) BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); try{ int i = Integer.parseInt(br.readLine()); - }catch(Exception ex){ + }catch(Exception ex) { } } @@ -67,7 +67,7 @@ private static void SelectMethod() BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); try{ RunMethod(br.readLine()); - }catch(Exception ex){ + }catch(Exception ex) { System.out.println(ex.toString()); } } diff --git a/src/main/java/net/authorize/sample/TransactionReporting/GetCustomerProfileTransactionList.java b/src/main/java/net/authorize/sample/TransactionReporting/GetCustomerProfileTransactionList.java index 8f893091..680385e1 100644 --- a/src/main/java/net/authorize/sample/TransactionReporting/GetCustomerProfileTransactionList.java +++ b/src/main/java/net/authorize/sample/TransactionReporting/GetCustomerProfileTransactionList.java @@ -43,22 +43,19 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri ArrayOfTransactionSummaryType transactions = getResponse.getTransactions(); List list = transactions.getTransaction(); - for(TransactionSummaryType summary : list) - { + for (TransactionSummaryType summary : list) { System.out.println(summary.getFirstName()); System.out.println(summary.getTransId()); System.out.println(summary.getSettleAmount()); System.out.println(summary.getSubmitTimeLocal()); } - if (getResponse.getMessages().getResultCode() == MessageTypeEnum.OK) { + if (getResponse.getMessages().getResultCode() == MessageTypeEnum.OK) { System.out.println(getResponse.getMessages().getMessage().get(0).getCode()); - System.out.println(getResponse.getMessages().getMessage().get(0).getText()); - } - else - { - System.out.println("Failed to get transaction list: " + getResponse.getMessages().getResultCode()); - } + System.out.println(getResponse.getMessages().getMessage().get(0).getText()); + } else { + System.out.println("Failed to get transaction list: " + getResponse.getMessages().getResultCode()); + } } return getResponse; diff --git a/src/main/java/net/authorize/sample/VisaCheckout/CreateVisaCheckoutTransaction.java b/src/main/java/net/authorize/sample/VisaCheckout/CreateVisaCheckoutTransaction.java index f4b8d40d..f936546d 100644 --- a/src/main/java/net/authorize/sample/VisaCheckout/CreateVisaCheckoutTransaction.java +++ b/src/main/java/net/authorize/sample/VisaCheckout/CreateVisaCheckoutTransaction.java @@ -61,7 +61,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) { // If API Response is ok, go ahead and check the transaction response if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { TransactionResponse result = response.getTransactionResponse(); - if(result.getMessages() != null){ + if (result.getMessages() != null) { System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); System.out.println("Response Code: " + result.getResponseCode()); System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); @@ -70,7 +70,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) { } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } @@ -78,7 +78,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) { } else { System.out.println("Failed Transaction."); - if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){ + if (response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null) { System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); } diff --git a/src/main/java/net/authorize/sample/VisaCheckout/DecryptVisaCheckoutData.java b/src/main/java/net/authorize/sample/VisaCheckout/DecryptVisaCheckoutData.java index c9a09763..90f95ce7 100644 --- a/src/main/java/net/authorize/sample/VisaCheckout/DecryptVisaCheckoutData.java +++ b/src/main/java/net/authorize/sample/VisaCheckout/DecryptVisaCheckoutData.java @@ -39,7 +39,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) { DecryptPaymentDataResponse response = controller.getApiResponse(); - if (response != null){ + if (response != null) { System.out.println("Response Code : "+ response.getMessages().getResultCode()); if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java index 1dc8493e..c8a30c8a 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java +++ b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java @@ -142,7 +142,7 @@ public void TestAllSampleCodes() cnt++; - for(int i = 0;i Date: Wed, 24 Jan 2018 14:43:16 +0530 Subject: [PATCH 108/176] Update DebitBankAccount.java --- .../authorize/sample/PaymentTransactions/DebitBankAccount.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java b/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java index 99121d3d..3541e250 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java @@ -39,7 +39,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub PaymentType paymentType = new PaymentType(); BankAccountType bankAccountType = new BankAccountType(); bankAccountType.setAccountType(BankAccountTypeEnum.CHECKING); - bankAccountType.setRoutingNumber("121042882"); + bankAccountType.setRoutingNumber("125000105"); bankAccountType.setAccountNumber("1234567890"); bankAccountType.setNameOnAccount("John Doe"); paymentType.setBankAccount(bankAccountType); From 00249c46af0e8a7f836abd85e637099afd698e2a Mon Sep 17 00:00:00 2001 From: Sunny Raj Rathod Date: Wed, 24 Jan 2018 15:07:10 +0530 Subject: [PATCH 109/176] Update CreditBankAccount.java --- .../authorize/sample/PaymentTransactions/CreditBankAccount.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java b/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java index 69e912ea..f2c45ff4 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java @@ -39,7 +39,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri PaymentType paymentType = new PaymentType(); BankAccountType bankAccountType = new BankAccountType(); bankAccountType.setAccountType(BankAccountTypeEnum.CHECKING); - bankAccountType.setRoutingNumber("121042882"); + bankAccountType.setRoutingNumber("125000105"); bankAccountType.setAccountNumber("1234567890"); bankAccountType.setNameOnAccount("John Doe"); paymentType.setBankAccount(bankAccountType); From ab415d68891f03b9f61715b7c3448f4d9efd6ab4 Mon Sep 17 00:00:00 2001 From: gnongsie Date: Fri, 2 Mar 2018 07:12:18 -0800 Subject: [PATCH 110/176] + Fix build issue for Eclipse IDE --- .../CreateAnAcceptTransaction.java | 2 +- .../CreateAnAndroidPayTransaction.java | 2 +- .../CreateAnApplePayTransaction.java | 2 +- src/main/java/net/authorize/sample/SampleCode.java | 11 ++++++++++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAcceptTransaction.java b/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAcceptTransaction.java index 6ff9d90a..58df0c52 100644 --- a/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAcceptTransaction.java +++ b/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAcceptTransaction.java @@ -1,4 +1,4 @@ -package net.authorize.sample.MobileInappTransactions; +package net.authorize.sample.MobileInAppTransactions; import java.math.BigDecimal; import net.authorize.Environment; diff --git a/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAndroidPayTransaction.java b/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAndroidPayTransaction.java index 03e1b0d9..cc7eb6dc 100644 --- a/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAndroidPayTransaction.java +++ b/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAndroidPayTransaction.java @@ -1,4 +1,4 @@ -package net.authorize.sample.MobileInappTransactions; +package net.authorize.sample.MobileInAppTransactions; import java.math.BigDecimal; import net.authorize.Environment; diff --git a/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnApplePayTransaction.java b/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnApplePayTransaction.java index d03b4812..bcce6929 100644 --- a/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnApplePayTransaction.java +++ b/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnApplePayTransaction.java @@ -1,4 +1,4 @@ -package net.authorize.sample.MobileInappTransactions; +package net.authorize.sample.MobileInAppTransactions; import java.math.BigDecimal; import net.authorize.Environment; diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index 8e66debd..63f7a7a7 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -11,7 +11,7 @@ import net.authorize.sample.RecurringBilling.*; import net.authorize.sample.TransactionReporting.*; import net.authorize.sample.CustomerProfiles.*; -import net.authorize.sample.MobileInappTransactions.*; +import net.authorize.sample.MobileInAppTransactions.*; import net.authorize.sample.FraudManagement.*; /** * Created by anetdeveloper on 8/5/15. @@ -153,6 +153,15 @@ private static void RunMethod(String methodName) String subscriptionId = "2930242"; Double amount = 123.45; + +// Proxy server settings. +// Enable these lines for using Sample Codes behind a proxy server + +// System.setProperty("https.proxyUse", "true"); +// System.setProperty("https.proxyHost", "example.proxy.server"); +// System.setProperty("https.proxyPort", "portNumber"); +// System.setProperty("https.proxyUser", "exampleUsername"); +// System.setProperty("https.proxyPassword", "examplePassword"); switch (methodName) { case "DecryptVisaCheckoutData": From be0415201e79c714b9bd51faa4afadfab451a745 Mon Sep 17 00:00:00 2001 From: Kaushik Kumar Mahato Date: Tue, 6 Mar 2018 09:51:06 +0530 Subject: [PATCH 111/176] Update SampleCode.java Update https.proxyUser to https.proxyUserName --- src/main/java/net/authorize/sample/SampleCode.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index 63f7a7a7..56cada19 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -160,7 +160,7 @@ private static void RunMethod(String methodName) // System.setProperty("https.proxyUse", "true"); // System.setProperty("https.proxyHost", "example.proxy.server"); // System.setProperty("https.proxyPort", "portNumber"); -// System.setProperty("https.proxyUser", "exampleUsername"); +// System.setProperty("https.proxyUserName", "exampleUsername"); // System.setProperty("https.proxyPassword", "examplePassword"); switch (methodName) { From 461ac560c8044b23e5ac900311a0fe531c5919fc Mon Sep 17 00:00:00 2001 From: brianmc Date: Thu, 22 Mar 2018 07:39:46 -0700 Subject: [PATCH 112/176] Added sample for email setting --- .../PaymentTransactions/ChargeCreditCard.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCreditCard.java b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCreditCard.java index ad57ac16..ed601009 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCreditCard.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCreditCard.java @@ -4,16 +4,7 @@ import java.math.RoundingMode; import net.authorize.Environment; -import net.authorize.api.contract.v1.ANetApiResponse; -import net.authorize.api.contract.v1.CreateTransactionRequest; -import net.authorize.api.contract.v1.CreateTransactionResponse; -import net.authorize.api.contract.v1.CreditCardType; -import net.authorize.api.contract.v1.MerchantAuthenticationType; -import net.authorize.api.contract.v1.MessageTypeEnum; -import net.authorize.api.contract.v1.PaymentType; -import net.authorize.api.contract.v1.TransactionRequestType; -import net.authorize.api.contract.v1.TransactionResponse; -import net.authorize.api.contract.v1.TransactionTypeEnum; +import net.authorize.api.contract.v1.*; import net.authorize.api.controller.CreateTransactionController; import net.authorize.api.controller.base.ApiOperationBase; @@ -40,10 +31,15 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub creditCard.setExpirationDate("0822"); paymentType.setCreditCard(creditCard); + // Set email address (optional) + CustomerDataType customer = new CustomerDataType(); + customer.setEmail("test@test.test"); + // Create the payment transaction object TransactionRequestType txnRequest = new TransactionRequestType(); txnRequest.setTransactionType(TransactionTypeEnum.AUTH_CAPTURE_TRANSACTION.value()); txnRequest.setPayment(paymentType); + txnRequest.setCustomer(customer); txnRequest.setAmount(new BigDecimal(amount).setScale(2, RoundingMode.CEILING)); // Create the API request and set the parameters for this specific request From a3b942369a7af913418c469a53db7f83ae541127 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Thu, 29 Mar 2018 08:22:49 +0530 Subject: [PATCH 113/176] Adding documentation about proxy auth --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 891ea5ad..f11cc20f 100644 --- a/README.md +++ b/README.md @@ -38,3 +38,10 @@ Please set the JAVA environment proxy using a similar code : System.setProperty("https.proxyHost", "127.0.0.1"); System.setProperty("https.proxyPort", "3128"); ``` +**For using proxy authentication** + +Please set the JAVA environment proxy credentials using a similar code : +``` + System.setProperty("https.proxyUserName", "exampleUsername"); + System.setProperty("https.proxyPassword", "examplePassword"); +``` From 9bae6a6e8134e0e74c04654405ef6bbbee9f336e Mon Sep 17 00:00:00 2001 From: Kaushik Date: Sun, 6 May 2018 18:02:58 +0530 Subject: [PATCH 114/176] Updating Bank Routing Number --- .../authorize/sample/PaymentTransactions/CreditBankAccount.java | 2 +- .../authorize/sample/PaymentTransactions/DebitBankAccount.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java b/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java index f2c45ff4..4e4f33c8 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java @@ -39,7 +39,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri PaymentType paymentType = new PaymentType(); BankAccountType bankAccountType = new BankAccountType(); bankAccountType.setAccountType(BankAccountTypeEnum.CHECKING); - bankAccountType.setRoutingNumber("125000105"); + bankAccountType.setRoutingNumber("122235821"); bankAccountType.setAccountNumber("1234567890"); bankAccountType.setNameOnAccount("John Doe"); paymentType.setBankAccount(bankAccountType); diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java b/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java index 3541e250..1d30a4ee 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java @@ -39,7 +39,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub PaymentType paymentType = new PaymentType(); BankAccountType bankAccountType = new BankAccountType(); bankAccountType.setAccountType(BankAccountTypeEnum.CHECKING); - bankAccountType.setRoutingNumber("125000105"); + bankAccountType.setRoutingNumber("122235821"); bankAccountType.setAccountNumber("1234567890"); bankAccountType.setNameOnAccount("John Doe"); paymentType.setBankAccount(bankAccountType); From 51e31a40d5603a9c3d454e7109d005477a9d2eea Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Wed, 13 Jun 2018 15:25:52 +0530 Subject: [PATCH 115/176] Adding missing case for UpdateCustomerProfile --- pom.xml | 20 ++++++++++++++++++- .../UpdateCustomerProfile.java | 3 ++- .../java/net/authorize/sample/SampleCode.java | 4 ++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 60cedf47..99fd471d 100644 --- a/pom.xml +++ b/pom.xml @@ -14,13 +14,31 @@ net.authorize anet-java-sdk - 1.9.3 + 1.9.6 junit junit 4.8.1 + + commons-logging + commons-logging + 1.1.1 + compile + + + org.apache.httpcomponents + httpclient + 4.5.3 + compile + + + org.apache.httpcomponents + httpcore + 4.4.6 + compile + diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/UpdateCustomerProfile.java b/src/main/java/net/authorize/sample/CustomerProfiles/UpdateCustomerProfile.java index e03bbf79..ef888414 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/UpdateCustomerProfile.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/UpdateCustomerProfile.java @@ -16,11 +16,12 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri merchantAuthenticationType.setTransactionKey(transactionKey); ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); - CustomerProfileExType customer = new CustomerProfileExType(); + CustomerProfileInfoExType customer = new CustomerProfileInfoExType(); customer.setMerchantCustomerId("custId123"); customer.setDescription("some description"); customer.setEmail("newaddress@example.com"); customer.setCustomerProfileId(customerProfileId); + customer.setProfileType(CustomerProfileTypeEnum.REGULAR); UpdateCustomerProfileRequest apiRequest = new UpdateCustomerProfileRequest(); apiRequest.setProfile(customer); diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index 56cada19..af576055 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -115,6 +115,7 @@ private static void ShowMethods() System.out.println(" GetCustomerProfileTransactionList"); System.out.println(" GetCustomerShippingAddress"); System.out.println(" GetAcceptCustomerProfilePage"); + System.out.println(" UpdateCustomerProfile"); System.out.println(" UpdateCustomerPaymentProfile"); System.out.println(" UpdateCustomerShippingAddress"); System.out.println(" ValidateCustomerPaymentProfile"); @@ -291,6 +292,9 @@ private static void RunMethod(String methodName) case "GetAcceptCustomerProfilePage": GetAcceptCustomerProfilePage.run(apiLoginId, transactionKey, customerProfileId); break; + case "UpdateCustomerProfile": + UpdateCustomerProfile.run(apiLoginId, transactionKey, customerProfileId); + break; case "UpdateCustomerPaymentProfile": UpdateCustomerPaymentProfile.run(apiLoginId, transactionKey, customerProfileId, customerPaymentProfileId); break; From 26a1837adf7838c005340aa67a3badea5b30be55 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Wed, 13 Jun 2018 15:52:09 +0530 Subject: [PATCH 116/176] Update CreditBankAccount.java --- .../authorize/sample/PaymentTransactions/CreditBankAccount.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java b/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java index 4e4f33c8..9999aecc 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java @@ -39,7 +39,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri PaymentType paymentType = new PaymentType(); BankAccountType bankAccountType = new BankAccountType(); bankAccountType.setAccountType(BankAccountTypeEnum.CHECKING); - bankAccountType.setRoutingNumber("122235821"); + bankAccountType.setRoutingNumber("125008547"); bankAccountType.setAccountNumber("1234567890"); bankAccountType.setNameOnAccount("John Doe"); paymentType.setBankAccount(bankAccountType); From ccb2f6d25e6ab6fefe5b322eda06f8f0d52962b1 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Wed, 13 Jun 2018 15:52:33 +0530 Subject: [PATCH 117/176] Update DebitBankAccount.java --- .../authorize/sample/PaymentTransactions/DebitBankAccount.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java b/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java index 1d30a4ee..d7b6e3a9 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java @@ -39,7 +39,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub PaymentType paymentType = new PaymentType(); BankAccountType bankAccountType = new BankAccountType(); bankAccountType.setAccountType(BankAccountTypeEnum.CHECKING); - bankAccountType.setRoutingNumber("122235821"); + bankAccountType.setRoutingNumber("125008547"); bankAccountType.setAccountNumber("1234567890"); bankAccountType.setNameOnAccount("John Doe"); paymentType.setBankAccount(bankAccountType); From ff573e033eae3c662d1d8a73e991e7275b3c050f Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Thu, 14 Jun 2018 16:46:35 +0530 Subject: [PATCH 118/176] Update SampleCode.java Updating customerProfileId, customerPaymentProfileId, customerAddressId and subscriptionId, --- src/main/java/net/authorize/sample/SampleCode.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index 56cada19..01afc5cf 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -144,13 +144,13 @@ private static void RunMethod(String methodName) //Update the transactionId with which you want to run the sample code String transactionId = "123456"; - String customerProfileId = "36731856"; - String customerPaymentProfileId = "33211899"; - String customerAddressId = "123"; + String customerProfileId = "37905546"; + String customerPaymentProfileId = "34461178"; + String customerAddressId = "1871959249"; String emailId = "test@test.com"; - String subscriptionId = "2930242"; + String subscriptionId = "2925606"; Double amount = 123.45; From 78bcda928069f45fec31a231c4fd8a94693161d9 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Mon, 18 Jun 2018 11:10:29 +0530 Subject: [PATCH 119/176] + Latest version of SDK consumed --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 99fd471d..a9a4c46f 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,7 @@ - 1.9.3 + 1.9.7 4.0.0 net.authorize.sample @@ -14,7 +14,7 @@ net.authorize anet-java-sdk - 1.9.6 + 1.9.7 junit From 60a443c5dc79b4db7d0698ecb478aa37f6ca0d33 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Mon, 18 Jun 2018 11:24:20 +0530 Subject: [PATCH 120/176] - Removing extra dependencies --- pom.xml | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/pom.xml b/pom.xml index a9a4c46f..28a8d486 100644 --- a/pom.xml +++ b/pom.xml @@ -21,24 +21,6 @@ junit 4.8.1 - - commons-logging - commons-logging - 1.1.1 - compile - - - org.apache.httpcomponents - httpclient - 4.5.3 - compile - - - org.apache.httpcomponents - httpcore - 4.4.6 - compile - From b6b0ec5f34cb647a7818965bdcd65bc221e848c2 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Mon, 25 Jun 2018 21:17:22 +0530 Subject: [PATCH 121/176] + Added functionality to handle ErrorResponse --- pom.xml | 4 +- .../CreateCustomerPaymentProfile.java | 42 ++++++------ .../CreateCustomerProfile.java | 55 ++++++++-------- .../CreateCustomerProfileFromTransaction.java | 66 +++++++++++++++---- .../CreateCustomerShippingAddress.java | 34 ++++++---- .../DeleteCustomerPaymentProfile.java | 37 ++++++----- .../DeleteCustomerProfile.java | 39 ++++++----- .../DeleteCustomerShippingAddress.java | 37 ++++++----- .../GetAcceptCustomerProfilePage.java | 40 +++++------ 9 files changed, 205 insertions(+), 149 deletions(-) diff --git a/pom.xml b/pom.xml index 28a8d486..f0c55c3a 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,7 @@ - 1.9.7 + 1.9.8-SNAPSHOT 4.0.0 net.authorize.sample @@ -14,7 +14,7 @@ net.authorize anet-java-sdk - 1.9.7 + 1.9.8-SNAPSHOT junit diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerPaymentProfile.java b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerPaymentProfile.java index f377e88d..469df5e7 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerPaymentProfile.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerPaymentProfile.java @@ -6,14 +6,7 @@ import net.authorize.api.contract.v1.MerchantAuthenticationType; import net.authorize.api.controller.base.ApiOperationBase; -import net.authorize.Transaction; -import net.authorize.api.controller.CreateCustomerProfileController; -import net.authorize.api.controller.CreateCustomerProfileFromTransactionController; import net.authorize.api.controller.CreateCustomerPaymentProfileController; -import net.authorize.api.controller.base.ApiOperationBase; -import net.authorize.cim.Result; -import net.authorize.cim.TransactionType; -import net.authorize.cim.ValidationModeType; //author @krgupta public class CreateCustomerPaymentProfile { @@ -61,23 +54,30 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri CreateCustomerPaymentProfileController controller = new CreateCustomerPaymentProfileController(apiRequest); controller.execute(); - CreateCustomerPaymentProfileResponse response = new CreateCustomerPaymentProfileResponse(); - response = controller.getApiResponse(); - if (response!=null) { - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { - - System.out.println(response.getCustomerPaymentProfileId()); - System.out.println(response.getMessages().getMessage().get(0).getCode()); - System.out.println(response.getMessages().getMessage().get(0).getText()); - if (response.getValidationDirectResponse() != null) - System.out.println(response.getValidationDirectResponse()); + ANetApiResponse apiResponse = controller.getApiResponse(); + if (apiResponse != null) { + if (apiResponse instanceof CreateCustomerPaymentProfileResponse) { + CreateCustomerPaymentProfileResponse response = (CreateCustomerPaymentProfileResponse) apiResponse; + + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + System.out.println(response.getCustomerPaymentProfileId()); + System.out.println(response.getMessages().getMessage().get(0).getCode()); + System.out.println(response.getMessages().getMessage().get(0).getText()); + if (response.getValidationDirectResponse() != null) + System.out.println(response.getValidationDirectResponse()); + } + else if (response.getMessages().getResultCode() == MessageTypeEnum.ERROR) { + System.out.println(response.getMessages().getMessage().get(0).getCode()); + System.out.println(response.getMessages().getMessage().get(0).getText()); + } } - else - { - System.out.println("Failed to create customer payment profile: " + response.getMessages().getResultCode()); + else if (apiResponse instanceof ErrorResponse) { + System.out.println(apiResponse.getMessages().getMessage().get(0).getCode()); + System.out.println(apiResponse.getMessages().getMessage().get(0).getText()); + System.out.println("Failed to create customer payment profile: " + apiResponse.getMessages().getResultCode()); } } - return response; + return apiResponse; } } diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfile.java b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfile.java index 96a3a7d0..70d6bcd7 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfile.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfile.java @@ -2,7 +2,6 @@ import net.authorize.Environment; import net.authorize.api.contract.v1.*; -import java.math.BigDecimal; import net.authorize.api.controller.CreateCustomerProfileController; import net.authorize.api.controller.base.ApiOperationBase; @@ -47,37 +46,37 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri controller.execute(); // Get the response - CreateCustomerProfileResponse response = new CreateCustomerProfileResponse(); - response = controller.getApiResponse(); + ANetApiResponse apiResponse = controller.getApiResponse(); // Parse the response to determine results - if (response!=null) { + if (apiResponse != null) { + if (apiResponse instanceof CreateCustomerProfileResponse) { // If API Response is OK, go ahead and check the transaction response - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { - System.out.println(response.getCustomerProfileId()); - if (!response.getCustomerPaymentProfileIdList().getNumericString().isEmpty()) { - System.out.println(response.getCustomerPaymentProfileIdList().getNumericString().get(0)); - } - if (!response.getCustomerShippingAddressIdList().getNumericString().isEmpty()) { - System.out.println(response.getCustomerShippingAddressIdList().getNumericString().get(0)); - } - if (!response.getValidationDirectResponseList().getString().isEmpty()) { - System.out.println(response.getValidationDirectResponseList().getString().get(0)); - } + CreateCustomerProfileResponse response = (CreateCustomerProfileResponse) apiResponse; + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + System.out.println(response.getCustomerProfileId()); + if (!response.getCustomerPaymentProfileIdList().getNumericString().isEmpty()) { + System.out.println(response.getCustomerPaymentProfileIdList().getNumericString().get(0)); + } + if (!response.getCustomerShippingAddressIdList().getNumericString().isEmpty()) { + System.out.println(response.getCustomerShippingAddressIdList().getNumericString().get(0)); + } + if (!response.getValidationDirectResponseList().getString().isEmpty()) { + System.out.println(response.getValidationDirectResponseList().getString().get(0)); + } + } + else if (response.getMessages().getResultCode() == MessageTypeEnum.ERROR) { + System.out.println(response.getMessages().getMessage().get(0).getCode()); + System.out.println(response.getMessages().getMessage().get(0).getText()); + } + } + else if (apiResponse instanceof ErrorResponse) { + System.out.println(apiResponse.getMessages().getMessage().get(0).getCode()); + System.out.println(apiResponse.getMessages().getMessage().get(0).getText()); + System.out.println("Failed to create customer profile: " + apiResponse.getMessages().getResultCode()); } - else - { - System.out.println("Failed to create customer profile: " + response.getMessages().getResultCode()); - } - } else { - // Display the error code and message when response is null - ANetApiResponse errorResponse = controller.getErrorResponse(); - System.out.println("Failed to get response"); - if (!errorResponse.getMessages().getMessage().isEmpty()) { - System.out.println("Error: "+errorResponse.getMessages().getMessage().get(0).getCode()+" \n"+ errorResponse.getMessages().getMessage().get(0).getText()); - } - } - return response; + } + return apiResponse; } } \ No newline at end of file diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfileFromTransaction.java b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfileFromTransaction.java index 7cc3865f..5b4728c7 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfileFromTransaction.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfileFromTransaction.java @@ -12,7 +12,9 @@ import net.authorize.api.contract.v1.CreditCardType; import net.authorize.api.contract.v1.CustomerDataType; import net.authorize.api.contract.v1.CustomerProfileBaseType; +import net.authorize.api.contract.v1.ErrorResponse; import net.authorize.api.contract.v1.MerchantAuthenticationType; +import net.authorize.api.contract.v1.MessageTypeEnum; import net.authorize.api.contract.v1.PaymentType; import net.authorize.api.contract.v1.TransactionRequestType; import net.authorize.api.controller.CreateCustomerProfileFromTransactionController; @@ -46,34 +48,72 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub customer.setEmail(email); requestInternal.setCustomer(customer); - CreateTransactionRequest request = new CreateTransactionRequest(); - request.setTransactionRequest(requestInternal); + CreateTransactionRequest transactionRequest = new CreateTransactionRequest(); + transactionRequest.setTransactionRequest(requestInternal); - CreateTransactionController controller = new CreateTransactionController(request); + CreateTransactionController controller = new CreateTransactionController(transactionRequest); controller.execute(); - CreateTransactionResponse response = controller.getApiResponse(); + ANetApiResponse apiResponseForTransaction = controller.getApiResponse(); + + if (apiResponseForTransaction != null) { + if (!(apiResponseForTransaction instanceof CreateTransactionResponse) && !(apiResponseForTransaction instanceof ErrorResponse)) { + System.out.println(apiResponseForTransaction.getMessages().getMessage().get(0).getCode()); + System.out.println(apiResponseForTransaction.getMessages().getMessage().get(0).getText()); + System.out.println("Failed to create transaction: " + apiResponseForTransaction.getMessages().getResultCode()); + + return apiResponseForTransaction; + } + } + + CreateTransactionResponse transactionResponse = (CreateTransactionResponse) apiResponseForTransaction; CustomerProfileBaseType customerProfile = new CustomerProfileBaseType(); customerProfile.setMerchantCustomerId("123213"); customerProfile.setEmail("johnsnow@castleblack.com"); customerProfile.setDescription("This is a sample customer profile"); - CreateCustomerProfileFromTransactionRequest transaction_request = new CreateCustomerProfileFromTransactionRequest(); - transaction_request.setTransId(response.getTransactionResponse().getTransId()); + CreateCustomerProfileFromTransactionRequest request = new CreateCustomerProfileFromTransactionRequest(); + request.setTransId(transactionResponse.getTransactionResponse().getTransId()); // You can either specify the customer information in form of customerProfileBaseType object - transaction_request.setCustomer(customerProfile); + request.setCustomer(customerProfile); // OR // You can just provide the customer Profile ID // transaction_request.setCustomerProfileId("1232132"); - CreateCustomerProfileFromTransactionController createProfileController = new CreateCustomerProfileFromTransactionController(transaction_request); + CreateCustomerProfileFromTransactionController createProfileController = new CreateCustomerProfileFromTransactionController(request); createProfileController.execute(); - CreateCustomerProfileResponse customer_response = createProfileController.getApiResponse(); + ANetApiResponse apiResponse = createProfileController.getApiResponse(); - if (customer_response != null) { - System.out.println(transaction_request.getTransId()); - } - return customer_response; + if (apiResponse != null) { + if (apiResponse instanceof CreateCustomerProfileResponse) { + CreateCustomerProfileResponse response = (CreateCustomerProfileResponse) apiResponse; + + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + System.out.println("Transaction ID : " + transactionResponse.getTransactionResponse().getTransId()); + System.out.println("Customer Profile Created : " + response.getCustomerProfileId()); + if (!response.getCustomerPaymentProfileIdList().getNumericString().isEmpty()) { + System.out.println(response.getCustomerPaymentProfileIdList().getNumericString().get(0)); + } + if (!response.getCustomerShippingAddressIdList().getNumericString().isEmpty()) { + System.out.println(response.getCustomerShippingAddressIdList().getNumericString().get(0)); + } + if (!response.getValidationDirectResponseList().getString().isEmpty()) { + System.out.println(response.getValidationDirectResponseList().getString().get(0)); + } + } + else if (response.getMessages().getResultCode() == MessageTypeEnum.ERROR) { + System.out.println(response.getMessages().getMessage().get(0).getCode()); + System.out.println(response.getMessages().getMessage().get(0).getText()); + } + } + else if (apiResponse instanceof ErrorResponse) { + System.out.println(apiResponse.getMessages().getMessage().get(0).getCode()); + System.out.println(apiResponse.getMessages().getMessage().get(0).getText()); + System.out.println("Failed to create customer payment profile: " + apiResponse.getMessages().getResultCode()); + } + } + + return apiResponse; } } diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerShippingAddress.java b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerShippingAddress.java index b3187096..d36fd54a 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerShippingAddress.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerShippingAddress.java @@ -2,7 +2,6 @@ import net.authorize.Environment; import net.authorize.api.contract.v1.*; -import java.math.BigDecimal; import net.authorize.api.controller.CreateCustomerShippingAddressController; import net.authorize.api.controller.base.ApiOperationBase; @@ -34,21 +33,28 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri CreateCustomerShippingAddressController controller = new CreateCustomerShippingAddressController(apiRequest); controller.execute(); - CreateCustomerShippingAddressResponse response = controller.getApiResponse(); - if (response!=null) { - - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { - - System.out.println(response.getCustomerAddressId()); - System.out.println(response.getMessages().getMessage().get(0).getCode()); - System.out.println(response.getMessages().getMessage().get(0).getText()); - } - else - { - System.out.println("Failed to create customer shipping address: " + response.getMessages().getResultCode()); + ANetApiResponse apiResponse = controller.getApiResponse(); + if (apiResponse != null) { + if (apiResponse instanceof CreateCustomerShippingAddressResponse) { + CreateCustomerShippingAddressResponse response = (CreateCustomerShippingAddressResponse) apiResponse; + + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + System.out.println(response.getCustomerAddressId()); + System.out.println(response.getMessages().getMessage().get(0).getCode()); + System.out.println(response.getMessages().getMessage().get(0).getText()); + } + else if (response.getMessages().getResultCode() == MessageTypeEnum.ERROR) { + System.out.println(response.getMessages().getMessage().get(0).getCode()); + System.out.println(response.getMessages().getMessage().get(0).getText()); + } + } + else if (apiResponse instanceof ErrorResponse) { + System.out.println(apiResponse.getMessages().getMessage().get(0).getCode()); + System.out.println(apiResponse.getMessages().getMessage().get(0).getText()); + System.out.println("Failed to create customer shipping address: " + apiResponse.getMessages().getResultCode()); } } - return response; + return apiResponse; } } \ No newline at end of file diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/DeleteCustomerPaymentProfile.java b/src/main/java/net/authorize/sample/CustomerProfiles/DeleteCustomerPaymentProfile.java index 684206a6..ed58dd32 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/DeleteCustomerPaymentProfile.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/DeleteCustomerPaymentProfile.java @@ -2,11 +2,8 @@ import net.authorize.Environment; import net.authorize.api.contract.v1.*; - -import net.authorize.api.contract.v1.MerchantAuthenticationType; import net.authorize.api.controller.base.ApiOperationBase; import net.authorize.api.controller.DeleteCustomerPaymentProfileController; -import net.authorize.api.controller.base.ApiOperationBase; public class DeleteCustomerPaymentProfile { @@ -27,21 +24,27 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri DeleteCustomerPaymentProfileController controller = new DeleteCustomerPaymentProfileController(apiRequest); controller.execute(); - DeleteCustomerPaymentProfileResponse response = new DeleteCustomerPaymentProfileResponse(); - response = controller.getApiResponse(); - - if (response!=null) { - - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { - - System.out.println(response.getMessages().getMessage().get(0).getCode()); - System.out.println(response.getMessages().getMessage().get(0).getText()); - } - else - { - System.out.println("Failed to delete customer payment profile: " + response.getMessages().getResultCode()); + ANetApiResponse apiResponse = controller.getApiResponse(); + + if (apiResponse != null) { + if (apiResponse instanceof DeleteCustomerPaymentProfileResponse) { + DeleteCustomerPaymentProfileResponse response = (DeleteCustomerPaymentProfileResponse) apiResponse; + + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + System.out.println(response.getMessages().getMessage().get(0).getCode()); + System.out.println(response.getMessages().getMessage().get(0).getText()); + } + else if (response.getMessages().getResultCode() == MessageTypeEnum.ERROR) { + System.out.println(response.getMessages().getMessage().get(0).getCode()); + System.out.println(response.getMessages().getMessage().get(0).getText()); + } + } + else if (apiResponse instanceof ErrorResponse) { + System.out.println(apiResponse.getMessages().getMessage().get(0).getCode()); + System.out.println(apiResponse.getMessages().getMessage().get(0).getText()); + System.out.println("Failed to delete customer payment profile: " + apiResponse.getMessages().getResultCode()); } } - return response; + return apiResponse; } } \ No newline at end of file diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/DeleteCustomerProfile.java b/src/main/java/net/authorize/sample/CustomerProfiles/DeleteCustomerProfile.java index 6eb49847..4a132c70 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/DeleteCustomerProfile.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/DeleteCustomerProfile.java @@ -2,11 +2,8 @@ import net.authorize.Environment; import net.authorize.api.contract.v1.*; - -import net.authorize.api.contract.v1.MerchantAuthenticationType; import net.authorize.api.controller.base.ApiOperationBase; import net.authorize.api.controller.DeleteCustomerProfileController; -import net.authorize.api.controller.base.ApiOperationBase; public class DeleteCustomerProfile { @@ -25,21 +22,27 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri DeleteCustomerProfileController controller = new DeleteCustomerProfileController(apiRequest); controller.execute(); - DeleteCustomerProfileResponse response = new DeleteCustomerProfileResponse(); - response = controller.getApiResponse(); - - if (response!=null) { - - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { - - System.out.println(response.getMessages().getMessage().get(0).getCode()); - System.out.println(response.getMessages().getMessage().get(0).getText()); - } - else - { - System.out.println("Failed to delete customer profile: " + response.getMessages().getResultCode()); - } + ANetApiResponse apiResponse = controller.getApiResponse(); + + if (apiResponse != null) { + if (apiResponse instanceof DeleteCustomerProfileResponse) { + DeleteCustomerProfileResponse response = (DeleteCustomerProfileResponse) apiResponse; + + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + System.out.println(response.getMessages().getMessage().get(0).getCode()); + System.out.println(response.getMessages().getMessage().get(0).getText()); + } + else if (response.getMessages().getResultCode() == MessageTypeEnum.ERROR) { + System.out.println(response.getMessages().getMessage().get(0).getCode()); + System.out.println(response.getMessages().getMessage().get(0).getText()); + } + } + else if (apiResponse instanceof ErrorResponse) { + System.out.println(apiResponse.getMessages().getMessage().get(0).getCode()); + System.out.println(apiResponse.getMessages().getMessage().get(0).getText()); + System.out.println("Failed to delete customer profile: " + apiResponse.getMessages().getResultCode()); + } } - return response; + return apiResponse; } } \ No newline at end of file diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/DeleteCustomerShippingAddress.java b/src/main/java/net/authorize/sample/CustomerProfiles/DeleteCustomerShippingAddress.java index 2f5c4ead..0506ef80 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/DeleteCustomerShippingAddress.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/DeleteCustomerShippingAddress.java @@ -2,11 +2,8 @@ import net.authorize.Environment; import net.authorize.api.contract.v1.*; - -import net.authorize.api.contract.v1.MerchantAuthenticationType; import net.authorize.api.controller.base.ApiOperationBase; import net.authorize.api.controller.DeleteCustomerShippingAddressController; -import net.authorize.api.controller.base.ApiOperationBase; public class DeleteCustomerShippingAddress { @@ -27,21 +24,27 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri DeleteCustomerShippingAddressController controller = new DeleteCustomerShippingAddressController(apiRequest); controller.execute(); - DeleteCustomerShippingAddressResponse response = new DeleteCustomerShippingAddressResponse(); - response = controller.getApiResponse(); - - if (response!=null) { - - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { - - System.out.println(response.getMessages().getMessage().get(0).getCode()); - System.out.println(response.getMessages().getMessage().get(0).getText()); - } - else - { - System.out.println("Failed to delete customer shipping address: " + response.getMessages().getResultCode()); + ANetApiResponse apiResponse = controller.getApiResponse(); + + if (apiResponse != null) { + if (apiResponse instanceof DeleteCustomerShippingAddressResponse) { + DeleteCustomerShippingAddressResponse response = (DeleteCustomerShippingAddressResponse) apiResponse; + + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + System.out.println(response.getMessages().getMessage().get(0).getCode()); + System.out.println(response.getMessages().getMessage().get(0).getText()); + } + else if (response.getMessages().getResultCode() == MessageTypeEnum.ERROR) { + System.out.println(response.getMessages().getMessage().get(0).getCode()); + System.out.println(response.getMessages().getMessage().get(0).getText()); + } + } + else if (apiResponse instanceof ErrorResponse) { + System.out.println(apiResponse.getMessages().getMessage().get(0).getCode()); + System.out.println(apiResponse.getMessages().getMessage().get(0).getText()); + System.out.println("Failed to delete customer shipping address: " + apiResponse.getMessages().getResultCode()); } } - return response; + return apiResponse; } } \ No newline at end of file diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/GetAcceptCustomerProfilePage.java b/src/main/java/net/authorize/sample/CustomerProfiles/GetAcceptCustomerProfilePage.java index 050ae365..4c6f4b64 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/GetAcceptCustomerProfilePage.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/GetAcceptCustomerProfilePage.java @@ -2,11 +2,8 @@ import net.authorize.Environment; import net.authorize.api.contract.v1.*; - -import net.authorize.api.contract.v1.MerchantAuthenticationType; import net.authorize.api.controller.base.ApiOperationBase; import net.authorize.api.controller.GetHostedProfilePageController; -import net.authorize.api.controller.base.ApiOperationBase; public class GetAcceptCustomerProfilePage { @@ -32,24 +29,29 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri GetHostedProfilePageController controller = new GetHostedProfilePageController(apiRequest); controller.execute(); - - GetHostedProfilePageResponse response = new GetHostedProfilePageResponse(); - response = controller.getApiResponse(); - - if (response!=null) { - - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { - - System.out.println(response.getMessages().getMessage().get(0).getCode()); - System.out.println(response.getMessages().getMessage().get(0).getText()); - - System.out.println(response.getToken()); + + ANetApiResponse apiResponse = controller.getApiResponse(); + if (apiResponse != null) { + if (apiResponse instanceof GetHostedProfilePageResponse) { + GetHostedProfilePageResponse response = (GetHostedProfilePageResponse) apiResponse; + + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + System.out.println(response.getToken()); + System.out.println(response.getMessages().getMessage().get(0).getCode()); + System.out.println(response.getMessages().getMessage().get(0).getText()); + } + else if (response.getMessages().getResultCode() == MessageTypeEnum.ERROR) { + System.out.println(response.getMessages().getMessage().get(0).getCode()); + System.out.println(response.getMessages().getMessage().get(0).getText()); + } } - else - { - System.out.println("Failed to get hosted profile page: " + response.getMessages().getResultCode()); + else if (apiResponse instanceof ErrorResponse) { + System.out.println(apiResponse.getMessages().getMessage().get(0).getCode()); + System.out.println(apiResponse.getMessages().getMessage().get(0).getText()); + System.out.println("Failed to get hosted profile page: " + apiResponse.getMessages().getResultCode()); } } - return response; + + return apiResponse; } } From 27e78fbe0f5412d830e72aa8bab95d88fd5979ab Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Mon, 25 Jun 2018 21:21:34 +0530 Subject: [PATCH 122/176] Update pom.xml - Reverting version of SDK --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index f0c55c3a..28a8d486 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,7 @@ - 1.9.8-SNAPSHOT + 1.9.7 4.0.0 net.authorize.sample @@ -14,7 +14,7 @@ net.authorize anet-java-sdk - 1.9.8-SNAPSHOT + 1.9.7 junit From 6ef3eb9258ac7f573758694b77bbe5260f9cc151 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Mon, 16 Jul 2018 15:15:59 +0530 Subject: [PATCH 123/176] Update DebitBankAccount.java Changing account type --- .../authorize/sample/PaymentTransactions/DebitBankAccount.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java b/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java index d7b6e3a9..c5d8d304 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java @@ -38,7 +38,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub // Populate the payment data PaymentType paymentType = new PaymentType(); BankAccountType bankAccountType = new BankAccountType(); - bankAccountType.setAccountType(BankAccountTypeEnum.CHECKING); + bankAccountType.setAccountType(BankAccountTypeEnum.SAVINGS); bankAccountType.setRoutingNumber("125008547"); bankAccountType.setAccountNumber("1234567890"); bankAccountType.setNameOnAccount("John Doe"); From ef5df32d772f1534075413a5efe035239698f1f3 Mon Sep 17 00:00:00 2001 From: Kaushik Kumar Mahato Date: Mon, 16 Jul 2018 15:31:48 +0530 Subject: [PATCH 124/176] Update CreditBankAccount.java --- .../authorize/sample/PaymentTransactions/CreditBankAccount.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java b/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java index 9999aecc..921921d1 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java @@ -39,7 +39,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri PaymentType paymentType = new PaymentType(); BankAccountType bankAccountType = new BankAccountType(); bankAccountType.setAccountType(BankAccountTypeEnum.CHECKING); - bankAccountType.setRoutingNumber("125008547"); + bankAccountType.setRoutingNumber("121141754"); bankAccountType.setAccountNumber("1234567890"); bankAccountType.setNameOnAccount("John Doe"); paymentType.setBankAccount(bankAccountType); From e9916701ea3048d0c540c461b07664f6c37c257b Mon Sep 17 00:00:00 2001 From: Kaushik Kumar Mahato Date: Mon, 16 Jul 2018 15:32:14 +0530 Subject: [PATCH 125/176] Update DebitBankAccount.java --- .../sample/PaymentTransactions/DebitBankAccount.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java b/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java index c5d8d304..33c91be2 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java @@ -38,8 +38,8 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub // Populate the payment data PaymentType paymentType = new PaymentType(); BankAccountType bankAccountType = new BankAccountType(); - bankAccountType.setAccountType(BankAccountTypeEnum.SAVINGS); - bankAccountType.setRoutingNumber("125008547"); + bankAccountType.setAccountType(BankAccountTypeEnum.CHECKING); + bankAccountType.setRoutingNumber("121141754"); bankAccountType.setAccountNumber("1234567890"); bankAccountType.setNameOnAccount("John Doe"); paymentType.setBankAccount(bankAccountType); From 8dd55fbcdbe0803fe3fa574ef96bea4cbe5289f2 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Fri, 10 Aug 2018 16:03:40 +0530 Subject: [PATCH 126/176] + Adding Accept Suite --- .../CreateAnAcceptPaymentTransaction.java | 0 .../CreateAnAcceptTransaction.java | 0 .../GetAcceptCustomerProfilePage.java | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename src/main/java/net/authorize/sample/{PaymentTransactions => AcceptSuite}/CreateAnAcceptPaymentTransaction.java (100%) rename src/main/java/net/authorize/sample/{MobileInAppTransactions => AcceptSuite}/CreateAnAcceptTransaction.java (100%) rename src/main/java/net/authorize/sample/{CustomerProfiles => AcceptSuite}/GetAcceptCustomerProfilePage.java (100%) diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/CreateAnAcceptPaymentTransaction.java b/src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptPaymentTransaction.java similarity index 100% rename from src/main/java/net/authorize/sample/PaymentTransactions/CreateAnAcceptPaymentTransaction.java rename to src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptPaymentTransaction.java diff --git a/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAcceptTransaction.java b/src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptTransaction.java similarity index 100% rename from src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAcceptTransaction.java rename to src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptTransaction.java diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/GetAcceptCustomerProfilePage.java b/src/main/java/net/authorize/sample/AcceptSuite/GetAcceptCustomerProfilePage.java similarity index 100% rename from src/main/java/net/authorize/sample/CustomerProfiles/GetAcceptCustomerProfilePage.java rename to src/main/java/net/authorize/sample/AcceptSuite/GetAcceptCustomerProfilePage.java From bbda1af9eae193c103a1581407a0d48e9b9cb9fa Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Fri, 10 Aug 2018 16:31:14 +0530 Subject: [PATCH 127/176] Revert "+ Adding Accept Suite" This reverts commit 8dd55fbcdbe0803fe3fa574ef96bea4cbe5289f2. Reverting changes --- .../GetAcceptCustomerProfilePage.java | 0 .../CreateAnAcceptTransaction.java | 0 .../CreateAnAcceptPaymentTransaction.java | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename src/main/java/net/authorize/sample/{AcceptSuite => CustomerProfiles}/GetAcceptCustomerProfilePage.java (100%) rename src/main/java/net/authorize/sample/{AcceptSuite => MobileInAppTransactions}/CreateAnAcceptTransaction.java (100%) rename src/main/java/net/authorize/sample/{AcceptSuite => PaymentTransactions}/CreateAnAcceptPaymentTransaction.java (100%) diff --git a/src/main/java/net/authorize/sample/AcceptSuite/GetAcceptCustomerProfilePage.java b/src/main/java/net/authorize/sample/CustomerProfiles/GetAcceptCustomerProfilePage.java similarity index 100% rename from src/main/java/net/authorize/sample/AcceptSuite/GetAcceptCustomerProfilePage.java rename to src/main/java/net/authorize/sample/CustomerProfiles/GetAcceptCustomerProfilePage.java diff --git a/src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptTransaction.java b/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAcceptTransaction.java similarity index 100% rename from src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptTransaction.java rename to src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAcceptTransaction.java diff --git a/src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptPaymentTransaction.java b/src/main/java/net/authorize/sample/PaymentTransactions/CreateAnAcceptPaymentTransaction.java similarity index 100% rename from src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptPaymentTransaction.java rename to src/main/java/net/authorize/sample/PaymentTransactions/CreateAnAcceptPaymentTransaction.java From a5e123395e99bd5f4ea3b7a53de82198723a0442 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Fri, 10 Aug 2018 16:31:37 +0530 Subject: [PATCH 128/176] Revert "Update pom.xml" This reverts commit 27e78fbe0f5412d830e72aa8bab95d88fd5979ab. Reverting changes --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 28a8d486..f0c55c3a 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,7 @@ - 1.9.7 + 1.9.8-SNAPSHOT 4.0.0 net.authorize.sample @@ -14,7 +14,7 @@ net.authorize anet-java-sdk - 1.9.7 + 1.9.8-SNAPSHOT junit From aec1072695f55d9c84500b9c6528887a593c71d5 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Fri, 10 Aug 2018 16:31:51 +0530 Subject: [PATCH 129/176] Revert "+ Added functionality to handle ErrorResponse" This reverts commit b6b0ec5f34cb647a7818965bdcd65bc221e848c2. Reverting changes --- pom.xml | 4 +- .../CreateCustomerPaymentProfile.java | 42 ++++++------ .../CreateCustomerProfile.java | 55 ++++++++-------- .../CreateCustomerProfileFromTransaction.java | 66 ++++--------------- .../CreateCustomerShippingAddress.java | 34 ++++------ .../DeleteCustomerPaymentProfile.java | 37 +++++------ .../DeleteCustomerProfile.java | 39 +++++------ .../DeleteCustomerShippingAddress.java | 37 +++++------ .../GetAcceptCustomerProfilePage.java | 40 ++++++----- 9 files changed, 149 insertions(+), 205 deletions(-) diff --git a/pom.xml b/pom.xml index f0c55c3a..28a8d486 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,7 @@ - 1.9.8-SNAPSHOT + 1.9.7 4.0.0 net.authorize.sample @@ -14,7 +14,7 @@ net.authorize anet-java-sdk - 1.9.8-SNAPSHOT + 1.9.7 junit diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerPaymentProfile.java b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerPaymentProfile.java index 469df5e7..f377e88d 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerPaymentProfile.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerPaymentProfile.java @@ -6,7 +6,14 @@ import net.authorize.api.contract.v1.MerchantAuthenticationType; import net.authorize.api.controller.base.ApiOperationBase; +import net.authorize.Transaction; +import net.authorize.api.controller.CreateCustomerProfileController; +import net.authorize.api.controller.CreateCustomerProfileFromTransactionController; import net.authorize.api.controller.CreateCustomerPaymentProfileController; +import net.authorize.api.controller.base.ApiOperationBase; +import net.authorize.cim.Result; +import net.authorize.cim.TransactionType; +import net.authorize.cim.ValidationModeType; //author @krgupta public class CreateCustomerPaymentProfile { @@ -54,30 +61,23 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri CreateCustomerPaymentProfileController controller = new CreateCustomerPaymentProfileController(apiRequest); controller.execute(); - ANetApiResponse apiResponse = controller.getApiResponse(); - if (apiResponse != null) { - if (apiResponse instanceof CreateCustomerPaymentProfileResponse) { - CreateCustomerPaymentProfileResponse response = (CreateCustomerPaymentProfileResponse) apiResponse; - - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { - System.out.println(response.getCustomerPaymentProfileId()); - System.out.println(response.getMessages().getMessage().get(0).getCode()); - System.out.println(response.getMessages().getMessage().get(0).getText()); - if (response.getValidationDirectResponse() != null) - System.out.println(response.getValidationDirectResponse()); - } - else if (response.getMessages().getResultCode() == MessageTypeEnum.ERROR) { - System.out.println(response.getMessages().getMessage().get(0).getCode()); - System.out.println(response.getMessages().getMessage().get(0).getText()); - } + CreateCustomerPaymentProfileResponse response = new CreateCustomerPaymentProfileResponse(); + response = controller.getApiResponse(); + if (response!=null) { + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + + System.out.println(response.getCustomerPaymentProfileId()); + System.out.println(response.getMessages().getMessage().get(0).getCode()); + System.out.println(response.getMessages().getMessage().get(0).getText()); + if (response.getValidationDirectResponse() != null) + System.out.println(response.getValidationDirectResponse()); } - else if (apiResponse instanceof ErrorResponse) { - System.out.println(apiResponse.getMessages().getMessage().get(0).getCode()); - System.out.println(apiResponse.getMessages().getMessage().get(0).getText()); - System.out.println("Failed to create customer payment profile: " + apiResponse.getMessages().getResultCode()); + else + { + System.out.println("Failed to create customer payment profile: " + response.getMessages().getResultCode()); } } - return apiResponse; + return response; } } diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfile.java b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfile.java index 70d6bcd7..96a3a7d0 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfile.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfile.java @@ -2,6 +2,7 @@ import net.authorize.Environment; import net.authorize.api.contract.v1.*; +import java.math.BigDecimal; import net.authorize.api.controller.CreateCustomerProfileController; import net.authorize.api.controller.base.ApiOperationBase; @@ -46,37 +47,37 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri controller.execute(); // Get the response - ANetApiResponse apiResponse = controller.getApiResponse(); + CreateCustomerProfileResponse response = new CreateCustomerProfileResponse(); + response = controller.getApiResponse(); // Parse the response to determine results - if (apiResponse != null) { - if (apiResponse instanceof CreateCustomerProfileResponse) { + if (response!=null) { // If API Response is OK, go ahead and check the transaction response - CreateCustomerProfileResponse response = (CreateCustomerProfileResponse) apiResponse; - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { - System.out.println(response.getCustomerProfileId()); - if (!response.getCustomerPaymentProfileIdList().getNumericString().isEmpty()) { - System.out.println(response.getCustomerPaymentProfileIdList().getNumericString().get(0)); - } - if (!response.getCustomerShippingAddressIdList().getNumericString().isEmpty()) { - System.out.println(response.getCustomerShippingAddressIdList().getNumericString().get(0)); - } - if (!response.getValidationDirectResponseList().getString().isEmpty()) { - System.out.println(response.getValidationDirectResponseList().getString().get(0)); - } - } - else if (response.getMessages().getResultCode() == MessageTypeEnum.ERROR) { - System.out.println(response.getMessages().getMessage().get(0).getCode()); - System.out.println(response.getMessages().getMessage().get(0).getText()); - } - } - else if (apiResponse instanceof ErrorResponse) { - System.out.println(apiResponse.getMessages().getMessage().get(0).getCode()); - System.out.println(apiResponse.getMessages().getMessage().get(0).getText()); - System.out.println("Failed to create customer profile: " + apiResponse.getMessages().getResultCode()); + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + System.out.println(response.getCustomerProfileId()); + if (!response.getCustomerPaymentProfileIdList().getNumericString().isEmpty()) { + System.out.println(response.getCustomerPaymentProfileIdList().getNumericString().get(0)); + } + if (!response.getCustomerShippingAddressIdList().getNumericString().isEmpty()) { + System.out.println(response.getCustomerShippingAddressIdList().getNumericString().get(0)); + } + if (!response.getValidationDirectResponseList().getString().isEmpty()) { + System.out.println(response.getValidationDirectResponseList().getString().get(0)); + } } - } - return apiResponse; + else + { + System.out.println("Failed to create customer profile: " + response.getMessages().getResultCode()); + } + } else { + // Display the error code and message when response is null + ANetApiResponse errorResponse = controller.getErrorResponse(); + System.out.println("Failed to get response"); + if (!errorResponse.getMessages().getMessage().isEmpty()) { + System.out.println("Error: "+errorResponse.getMessages().getMessage().get(0).getCode()+" \n"+ errorResponse.getMessages().getMessage().get(0).getText()); + } + } + return response; } } \ No newline at end of file diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfileFromTransaction.java b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfileFromTransaction.java index 5b4728c7..7cc3865f 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfileFromTransaction.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfileFromTransaction.java @@ -12,9 +12,7 @@ import net.authorize.api.contract.v1.CreditCardType; import net.authorize.api.contract.v1.CustomerDataType; import net.authorize.api.contract.v1.CustomerProfileBaseType; -import net.authorize.api.contract.v1.ErrorResponse; import net.authorize.api.contract.v1.MerchantAuthenticationType; -import net.authorize.api.contract.v1.MessageTypeEnum; import net.authorize.api.contract.v1.PaymentType; import net.authorize.api.contract.v1.TransactionRequestType; import net.authorize.api.controller.CreateCustomerProfileFromTransactionController; @@ -48,72 +46,34 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub customer.setEmail(email); requestInternal.setCustomer(customer); - CreateTransactionRequest transactionRequest = new CreateTransactionRequest(); - transactionRequest.setTransactionRequest(requestInternal); + CreateTransactionRequest request = new CreateTransactionRequest(); + request.setTransactionRequest(requestInternal); - CreateTransactionController controller = new CreateTransactionController(transactionRequest); + CreateTransactionController controller = new CreateTransactionController(request); controller.execute(); - ANetApiResponse apiResponseForTransaction = controller.getApiResponse(); - - if (apiResponseForTransaction != null) { - if (!(apiResponseForTransaction instanceof CreateTransactionResponse) && !(apiResponseForTransaction instanceof ErrorResponse)) { - System.out.println(apiResponseForTransaction.getMessages().getMessage().get(0).getCode()); - System.out.println(apiResponseForTransaction.getMessages().getMessage().get(0).getText()); - System.out.println("Failed to create transaction: " + apiResponseForTransaction.getMessages().getResultCode()); - - return apiResponseForTransaction; - } - } - - CreateTransactionResponse transactionResponse = (CreateTransactionResponse) apiResponseForTransaction; + CreateTransactionResponse response = controller.getApiResponse(); CustomerProfileBaseType customerProfile = new CustomerProfileBaseType(); customerProfile.setMerchantCustomerId("123213"); customerProfile.setEmail("johnsnow@castleblack.com"); customerProfile.setDescription("This is a sample customer profile"); - CreateCustomerProfileFromTransactionRequest request = new CreateCustomerProfileFromTransactionRequest(); - request.setTransId(transactionResponse.getTransactionResponse().getTransId()); + CreateCustomerProfileFromTransactionRequest transaction_request = new CreateCustomerProfileFromTransactionRequest(); + transaction_request.setTransId(response.getTransactionResponse().getTransId()); // You can either specify the customer information in form of customerProfileBaseType object - request.setCustomer(customerProfile); + transaction_request.setCustomer(customerProfile); // OR // You can just provide the customer Profile ID // transaction_request.setCustomerProfileId("1232132"); - CreateCustomerProfileFromTransactionController createProfileController = new CreateCustomerProfileFromTransactionController(request); + CreateCustomerProfileFromTransactionController createProfileController = new CreateCustomerProfileFromTransactionController(transaction_request); createProfileController.execute(); - ANetApiResponse apiResponse = createProfileController.getApiResponse(); + CreateCustomerProfileResponse customer_response = createProfileController.getApiResponse(); - if (apiResponse != null) { - if (apiResponse instanceof CreateCustomerProfileResponse) { - CreateCustomerProfileResponse response = (CreateCustomerProfileResponse) apiResponse; - - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { - System.out.println("Transaction ID : " + transactionResponse.getTransactionResponse().getTransId()); - System.out.println("Customer Profile Created : " + response.getCustomerProfileId()); - if (!response.getCustomerPaymentProfileIdList().getNumericString().isEmpty()) { - System.out.println(response.getCustomerPaymentProfileIdList().getNumericString().get(0)); - } - if (!response.getCustomerShippingAddressIdList().getNumericString().isEmpty()) { - System.out.println(response.getCustomerShippingAddressIdList().getNumericString().get(0)); - } - if (!response.getValidationDirectResponseList().getString().isEmpty()) { - System.out.println(response.getValidationDirectResponseList().getString().get(0)); - } - } - else if (response.getMessages().getResultCode() == MessageTypeEnum.ERROR) { - System.out.println(response.getMessages().getMessage().get(0).getCode()); - System.out.println(response.getMessages().getMessage().get(0).getText()); - } - } - else if (apiResponse instanceof ErrorResponse) { - System.out.println(apiResponse.getMessages().getMessage().get(0).getCode()); - System.out.println(apiResponse.getMessages().getMessage().get(0).getText()); - System.out.println("Failed to create customer payment profile: " + apiResponse.getMessages().getResultCode()); - } - } - - return apiResponse; + if (customer_response != null) { + System.out.println(transaction_request.getTransId()); + } + return customer_response; } } diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerShippingAddress.java b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerShippingAddress.java index d36fd54a..b3187096 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerShippingAddress.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerShippingAddress.java @@ -2,6 +2,7 @@ import net.authorize.Environment; import net.authorize.api.contract.v1.*; +import java.math.BigDecimal; import net.authorize.api.controller.CreateCustomerShippingAddressController; import net.authorize.api.controller.base.ApiOperationBase; @@ -33,28 +34,21 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri CreateCustomerShippingAddressController controller = new CreateCustomerShippingAddressController(apiRequest); controller.execute(); - ANetApiResponse apiResponse = controller.getApiResponse(); - if (apiResponse != null) { - if (apiResponse instanceof CreateCustomerShippingAddressResponse) { - CreateCustomerShippingAddressResponse response = (CreateCustomerShippingAddressResponse) apiResponse; - - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { - System.out.println(response.getCustomerAddressId()); - System.out.println(response.getMessages().getMessage().get(0).getCode()); - System.out.println(response.getMessages().getMessage().get(0).getText()); - } - else if (response.getMessages().getResultCode() == MessageTypeEnum.ERROR) { - System.out.println(response.getMessages().getMessage().get(0).getCode()); - System.out.println(response.getMessages().getMessage().get(0).getText()); - } - } - else if (apiResponse instanceof ErrorResponse) { - System.out.println(apiResponse.getMessages().getMessage().get(0).getCode()); - System.out.println(apiResponse.getMessages().getMessage().get(0).getText()); - System.out.println("Failed to create customer shipping address: " + apiResponse.getMessages().getResultCode()); + CreateCustomerShippingAddressResponse response = controller.getApiResponse(); + if (response!=null) { + + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + + System.out.println(response.getCustomerAddressId()); + System.out.println(response.getMessages().getMessage().get(0).getCode()); + System.out.println(response.getMessages().getMessage().get(0).getText()); + } + else + { + System.out.println("Failed to create customer shipping address: " + response.getMessages().getResultCode()); } } - return apiResponse; + return response; } } \ No newline at end of file diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/DeleteCustomerPaymentProfile.java b/src/main/java/net/authorize/sample/CustomerProfiles/DeleteCustomerPaymentProfile.java index ed58dd32..684206a6 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/DeleteCustomerPaymentProfile.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/DeleteCustomerPaymentProfile.java @@ -2,8 +2,11 @@ import net.authorize.Environment; import net.authorize.api.contract.v1.*; + +import net.authorize.api.contract.v1.MerchantAuthenticationType; import net.authorize.api.controller.base.ApiOperationBase; import net.authorize.api.controller.DeleteCustomerPaymentProfileController; +import net.authorize.api.controller.base.ApiOperationBase; public class DeleteCustomerPaymentProfile { @@ -24,27 +27,21 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri DeleteCustomerPaymentProfileController controller = new DeleteCustomerPaymentProfileController(apiRequest); controller.execute(); - ANetApiResponse apiResponse = controller.getApiResponse(); - - if (apiResponse != null) { - if (apiResponse instanceof DeleteCustomerPaymentProfileResponse) { - DeleteCustomerPaymentProfileResponse response = (DeleteCustomerPaymentProfileResponse) apiResponse; - - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { - System.out.println(response.getMessages().getMessage().get(0).getCode()); - System.out.println(response.getMessages().getMessage().get(0).getText()); - } - else if (response.getMessages().getResultCode() == MessageTypeEnum.ERROR) { - System.out.println(response.getMessages().getMessage().get(0).getCode()); - System.out.println(response.getMessages().getMessage().get(0).getText()); - } - } - else if (apiResponse instanceof ErrorResponse) { - System.out.println(apiResponse.getMessages().getMessage().get(0).getCode()); - System.out.println(apiResponse.getMessages().getMessage().get(0).getText()); - System.out.println("Failed to delete customer payment profile: " + apiResponse.getMessages().getResultCode()); + DeleteCustomerPaymentProfileResponse response = new DeleteCustomerPaymentProfileResponse(); + response = controller.getApiResponse(); + + if (response!=null) { + + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + + System.out.println(response.getMessages().getMessage().get(0).getCode()); + System.out.println(response.getMessages().getMessage().get(0).getText()); + } + else + { + System.out.println("Failed to delete customer payment profile: " + response.getMessages().getResultCode()); } } - return apiResponse; + return response; } } \ No newline at end of file diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/DeleteCustomerProfile.java b/src/main/java/net/authorize/sample/CustomerProfiles/DeleteCustomerProfile.java index 4a132c70..6eb49847 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/DeleteCustomerProfile.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/DeleteCustomerProfile.java @@ -2,8 +2,11 @@ import net.authorize.Environment; import net.authorize.api.contract.v1.*; + +import net.authorize.api.contract.v1.MerchantAuthenticationType; import net.authorize.api.controller.base.ApiOperationBase; import net.authorize.api.controller.DeleteCustomerProfileController; +import net.authorize.api.controller.base.ApiOperationBase; public class DeleteCustomerProfile { @@ -22,27 +25,21 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri DeleteCustomerProfileController controller = new DeleteCustomerProfileController(apiRequest); controller.execute(); - ANetApiResponse apiResponse = controller.getApiResponse(); - - if (apiResponse != null) { - if (apiResponse instanceof DeleteCustomerProfileResponse) { - DeleteCustomerProfileResponse response = (DeleteCustomerProfileResponse) apiResponse; - - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { - System.out.println(response.getMessages().getMessage().get(0).getCode()); - System.out.println(response.getMessages().getMessage().get(0).getText()); - } - else if (response.getMessages().getResultCode() == MessageTypeEnum.ERROR) { - System.out.println(response.getMessages().getMessage().get(0).getCode()); - System.out.println(response.getMessages().getMessage().get(0).getText()); - } - } - else if (apiResponse instanceof ErrorResponse) { - System.out.println(apiResponse.getMessages().getMessage().get(0).getCode()); - System.out.println(apiResponse.getMessages().getMessage().get(0).getText()); - System.out.println("Failed to delete customer profile: " + apiResponse.getMessages().getResultCode()); - } + DeleteCustomerProfileResponse response = new DeleteCustomerProfileResponse(); + response = controller.getApiResponse(); + + if (response!=null) { + + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + + System.out.println(response.getMessages().getMessage().get(0).getCode()); + System.out.println(response.getMessages().getMessage().get(0).getText()); + } + else + { + System.out.println("Failed to delete customer profile: " + response.getMessages().getResultCode()); + } } - return apiResponse; + return response; } } \ No newline at end of file diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/DeleteCustomerShippingAddress.java b/src/main/java/net/authorize/sample/CustomerProfiles/DeleteCustomerShippingAddress.java index 0506ef80..2f5c4ead 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/DeleteCustomerShippingAddress.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/DeleteCustomerShippingAddress.java @@ -2,8 +2,11 @@ import net.authorize.Environment; import net.authorize.api.contract.v1.*; + +import net.authorize.api.contract.v1.MerchantAuthenticationType; import net.authorize.api.controller.base.ApiOperationBase; import net.authorize.api.controller.DeleteCustomerShippingAddressController; +import net.authorize.api.controller.base.ApiOperationBase; public class DeleteCustomerShippingAddress { @@ -24,27 +27,21 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri DeleteCustomerShippingAddressController controller = new DeleteCustomerShippingAddressController(apiRequest); controller.execute(); - ANetApiResponse apiResponse = controller.getApiResponse(); - - if (apiResponse != null) { - if (apiResponse instanceof DeleteCustomerShippingAddressResponse) { - DeleteCustomerShippingAddressResponse response = (DeleteCustomerShippingAddressResponse) apiResponse; - - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { - System.out.println(response.getMessages().getMessage().get(0).getCode()); - System.out.println(response.getMessages().getMessage().get(0).getText()); - } - else if (response.getMessages().getResultCode() == MessageTypeEnum.ERROR) { - System.out.println(response.getMessages().getMessage().get(0).getCode()); - System.out.println(response.getMessages().getMessage().get(0).getText()); - } - } - else if (apiResponse instanceof ErrorResponse) { - System.out.println(apiResponse.getMessages().getMessage().get(0).getCode()); - System.out.println(apiResponse.getMessages().getMessage().get(0).getText()); - System.out.println("Failed to delete customer shipping address: " + apiResponse.getMessages().getResultCode()); + DeleteCustomerShippingAddressResponse response = new DeleteCustomerShippingAddressResponse(); + response = controller.getApiResponse(); + + if (response!=null) { + + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + + System.out.println(response.getMessages().getMessage().get(0).getCode()); + System.out.println(response.getMessages().getMessage().get(0).getText()); + } + else + { + System.out.println("Failed to delete customer shipping address: " + response.getMessages().getResultCode()); } } - return apiResponse; + return response; } } \ No newline at end of file diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/GetAcceptCustomerProfilePage.java b/src/main/java/net/authorize/sample/CustomerProfiles/GetAcceptCustomerProfilePage.java index 4c6f4b64..050ae365 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/GetAcceptCustomerProfilePage.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/GetAcceptCustomerProfilePage.java @@ -2,8 +2,11 @@ import net.authorize.Environment; import net.authorize.api.contract.v1.*; + +import net.authorize.api.contract.v1.MerchantAuthenticationType; import net.authorize.api.controller.base.ApiOperationBase; import net.authorize.api.controller.GetHostedProfilePageController; +import net.authorize.api.controller.base.ApiOperationBase; public class GetAcceptCustomerProfilePage { @@ -29,29 +32,24 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri GetHostedProfilePageController controller = new GetHostedProfilePageController(apiRequest); controller.execute(); - - ANetApiResponse apiResponse = controller.getApiResponse(); - if (apiResponse != null) { - if (apiResponse instanceof GetHostedProfilePageResponse) { - GetHostedProfilePageResponse response = (GetHostedProfilePageResponse) apiResponse; - - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { - System.out.println(response.getToken()); - System.out.println(response.getMessages().getMessage().get(0).getCode()); - System.out.println(response.getMessages().getMessage().get(0).getText()); - } - else if (response.getMessages().getResultCode() == MessageTypeEnum.ERROR) { - System.out.println(response.getMessages().getMessage().get(0).getCode()); - System.out.println(response.getMessages().getMessage().get(0).getText()); - } + + GetHostedProfilePageResponse response = new GetHostedProfilePageResponse(); + response = controller.getApiResponse(); + + if (response!=null) { + + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + + System.out.println(response.getMessages().getMessage().get(0).getCode()); + System.out.println(response.getMessages().getMessage().get(0).getText()); + + System.out.println(response.getToken()); } - else if (apiResponse instanceof ErrorResponse) { - System.out.println(apiResponse.getMessages().getMessage().get(0).getCode()); - System.out.println(apiResponse.getMessages().getMessage().get(0).getText()); - System.out.println("Failed to get hosted profile page: " + apiResponse.getMessages().getResultCode()); + else + { + System.out.println("Failed to get hosted profile page: " + response.getMessages().getResultCode()); } } - - return apiResponse; + return response; } } From b4da3d2c0a3c6cd4a69a91889266eef232c51430 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Fri, 10 Aug 2018 16:34:16 +0530 Subject: [PATCH 130/176] + Adding files to Accept Suite --- .../CreateAnAcceptPaymentTransaction.java | 0 .../CreateAnAcceptTransaction.java | 0 .../GetAcceptCustomerProfilePage.java | 0 .../GetAnAcceptPaymentPage.java | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename src/main/java/net/authorize/sample/{PaymentTransactions => AcceptSuite}/CreateAnAcceptPaymentTransaction.java (100%) rename src/main/java/net/authorize/sample/{MobileInAppTransactions => AcceptSuite}/CreateAnAcceptTransaction.java (100%) rename src/main/java/net/authorize/sample/{CustomerProfiles => AcceptSuite}/GetAcceptCustomerProfilePage.java (100%) rename src/main/java/net/authorize/sample/{PaymentTransactions => AcceptSuite}/GetAnAcceptPaymentPage.java (100%) diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/CreateAnAcceptPaymentTransaction.java b/src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptPaymentTransaction.java similarity index 100% rename from src/main/java/net/authorize/sample/PaymentTransactions/CreateAnAcceptPaymentTransaction.java rename to src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptPaymentTransaction.java diff --git a/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAcceptTransaction.java b/src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptTransaction.java similarity index 100% rename from src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAcceptTransaction.java rename to src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptTransaction.java diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/GetAcceptCustomerProfilePage.java b/src/main/java/net/authorize/sample/AcceptSuite/GetAcceptCustomerProfilePage.java similarity index 100% rename from src/main/java/net/authorize/sample/CustomerProfiles/GetAcceptCustomerProfilePage.java rename to src/main/java/net/authorize/sample/AcceptSuite/GetAcceptCustomerProfilePage.java diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/GetAnAcceptPaymentPage.java b/src/main/java/net/authorize/sample/AcceptSuite/GetAnAcceptPaymentPage.java similarity index 100% rename from src/main/java/net/authorize/sample/PaymentTransactions/GetAnAcceptPaymentPage.java rename to src/main/java/net/authorize/sample/AcceptSuite/GetAnAcceptPaymentPage.java From ab36aec29491e6a9a68ebe743d41b0ac941283ec Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Fri, 10 Aug 2018 17:00:05 +0530 Subject: [PATCH 131/176] + Fixing package names --- .../sample/AcceptSuite/CreateAnAcceptPaymentTransaction.java | 2 +- .../sample/AcceptSuite/CreateAnAcceptTransaction.java | 2 +- .../sample/AcceptSuite/GetAcceptCustomerProfilePage.java | 2 +- .../authorize/sample/AcceptSuite/GetAnAcceptPaymentPage.java | 2 +- src/main/java/net/authorize/sample/SampleCode.java | 1 + .../java/net/authorize/sample/SampleCodeTest/TestRunner.java | 4 ++-- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptPaymentTransaction.java b/src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptPaymentTransaction.java index cc8bb29e..a4b551ff 100644 --- a/src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptPaymentTransaction.java +++ b/src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptPaymentTransaction.java @@ -1,4 +1,4 @@ -package net.authorize.sample.PaymentTransactions; +package net.authorize.sample.AcceptSuite; import java.math.BigDecimal; import java.math.RoundingMode; diff --git a/src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptTransaction.java b/src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptTransaction.java index 58df0c52..39b9da96 100644 --- a/src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptTransaction.java +++ b/src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptTransaction.java @@ -1,4 +1,4 @@ -package net.authorize.sample.MobileInAppTransactions; +package net.authorize.sample.AcceptSuite; import java.math.BigDecimal; import net.authorize.Environment; diff --git a/src/main/java/net/authorize/sample/AcceptSuite/GetAcceptCustomerProfilePage.java b/src/main/java/net/authorize/sample/AcceptSuite/GetAcceptCustomerProfilePage.java index 050ae365..b9ff5fa7 100644 --- a/src/main/java/net/authorize/sample/AcceptSuite/GetAcceptCustomerProfilePage.java +++ b/src/main/java/net/authorize/sample/AcceptSuite/GetAcceptCustomerProfilePage.java @@ -1,4 +1,4 @@ -package net.authorize.sample.CustomerProfiles; +package net.authorize.sample.AcceptSuite; import net.authorize.Environment; import net.authorize.api.contract.v1.*; diff --git a/src/main/java/net/authorize/sample/AcceptSuite/GetAnAcceptPaymentPage.java b/src/main/java/net/authorize/sample/AcceptSuite/GetAnAcceptPaymentPage.java index 29624b33..5b3f9394 100644 --- a/src/main/java/net/authorize/sample/AcceptSuite/GetAnAcceptPaymentPage.java +++ b/src/main/java/net/authorize/sample/AcceptSuite/GetAnAcceptPaymentPage.java @@ -1,4 +1,4 @@ -package net.authorize.sample.PaymentTransactions; +package net.authorize.sample.AcceptSuite; import java.math.BigDecimal; import java.math.RoundingMode; diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index 3e66e7e9..b616e425 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -10,6 +10,7 @@ import net.authorize.sample.PayPalExpressCheckout.Void; import net.authorize.sample.RecurringBilling.*; import net.authorize.sample.TransactionReporting.*; +import net.authorize.sample.AcceptSuite.*; import net.authorize.sample.CustomerProfiles.*; import net.authorize.sample.MobileInAppTransactions.*; import net.authorize.sample.FraudManagement.*; diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java index c8a30c8a..6aa8511e 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java +++ b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java @@ -32,6 +32,8 @@ import net.authorize.api.contract.v1.UpdateCustomerProfileResponse; import net.authorize.api.contract.v1.UpdateCustomerShippingAddressResponse; import net.authorize.api.contract.v1.ValidateCustomerPaymentProfileResponse; +import net.authorize.sample.AcceptSuite.GetAcceptCustomerProfilePage; +import net.authorize.sample.AcceptSuite.GetAnAcceptPaymentPage; import net.authorize.sample.CustomerProfiles.CreateCustomerPaymentProfile; import net.authorize.sample.CustomerProfiles.CreateCustomerProfile; import net.authorize.sample.CustomerProfiles.CreateCustomerProfileFromTransaction; @@ -42,7 +44,6 @@ import net.authorize.sample.CustomerProfiles.GetCustomerPaymentProfile; import net.authorize.sample.CustomerProfiles.GetCustomerProfile; import net.authorize.sample.CustomerProfiles.GetCustomerShippingAddress; -import net.authorize.sample.CustomerProfiles.GetAcceptCustomerProfilePage; import net.authorize.sample.CustomerProfiles.UpdateCustomerPaymentProfile; import net.authorize.sample.CustomerProfiles.UpdateCustomerProfile; import net.authorize.sample.CustomerProfiles.UpdateCustomerShippingAddress; @@ -71,7 +72,6 @@ import net.authorize.sample.RecurringBilling.GetSubscriptionStatus; import net.authorize.sample.RecurringBilling.UpdateSubscription; import net.authorize.sample.TransactionReporting.GetTransactionDetails; -import net.authorize.sample.PaymentTransactions.GetAnAcceptPaymentPage; public class TestRunner { From 156bcf2b56f9fbee0438d899afad2f848cfd8144 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Fri, 10 Aug 2018 23:47:54 +0530 Subject: [PATCH 132/176] Revert "+ Fixing package names" This reverts commit ab36aec29491e6a9a68ebe743d41b0ac941283ec. Reverting changes --- .../sample/AcceptSuite/CreateAnAcceptPaymentTransaction.java | 2 +- .../sample/AcceptSuite/CreateAnAcceptTransaction.java | 2 +- .../sample/AcceptSuite/GetAcceptCustomerProfilePage.java | 2 +- .../authorize/sample/AcceptSuite/GetAnAcceptPaymentPage.java | 2 +- src/main/java/net/authorize/sample/SampleCode.java | 1 - .../java/net/authorize/sample/SampleCodeTest/TestRunner.java | 4 ++-- 6 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptPaymentTransaction.java b/src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptPaymentTransaction.java index a4b551ff..cc8bb29e 100644 --- a/src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptPaymentTransaction.java +++ b/src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptPaymentTransaction.java @@ -1,4 +1,4 @@ -package net.authorize.sample.AcceptSuite; +package net.authorize.sample.PaymentTransactions; import java.math.BigDecimal; import java.math.RoundingMode; diff --git a/src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptTransaction.java b/src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptTransaction.java index 39b9da96..58df0c52 100644 --- a/src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptTransaction.java +++ b/src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptTransaction.java @@ -1,4 +1,4 @@ -package net.authorize.sample.AcceptSuite; +package net.authorize.sample.MobileInAppTransactions; import java.math.BigDecimal; import net.authorize.Environment; diff --git a/src/main/java/net/authorize/sample/AcceptSuite/GetAcceptCustomerProfilePage.java b/src/main/java/net/authorize/sample/AcceptSuite/GetAcceptCustomerProfilePage.java index b9ff5fa7..050ae365 100644 --- a/src/main/java/net/authorize/sample/AcceptSuite/GetAcceptCustomerProfilePage.java +++ b/src/main/java/net/authorize/sample/AcceptSuite/GetAcceptCustomerProfilePage.java @@ -1,4 +1,4 @@ -package net.authorize.sample.AcceptSuite; +package net.authorize.sample.CustomerProfiles; import net.authorize.Environment; import net.authorize.api.contract.v1.*; diff --git a/src/main/java/net/authorize/sample/AcceptSuite/GetAnAcceptPaymentPage.java b/src/main/java/net/authorize/sample/AcceptSuite/GetAnAcceptPaymentPage.java index 5b3f9394..29624b33 100644 --- a/src/main/java/net/authorize/sample/AcceptSuite/GetAnAcceptPaymentPage.java +++ b/src/main/java/net/authorize/sample/AcceptSuite/GetAnAcceptPaymentPage.java @@ -1,4 +1,4 @@ -package net.authorize.sample.AcceptSuite; +package net.authorize.sample.PaymentTransactions; import java.math.BigDecimal; import java.math.RoundingMode; diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index b616e425..3e66e7e9 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -10,7 +10,6 @@ import net.authorize.sample.PayPalExpressCheckout.Void; import net.authorize.sample.RecurringBilling.*; import net.authorize.sample.TransactionReporting.*; -import net.authorize.sample.AcceptSuite.*; import net.authorize.sample.CustomerProfiles.*; import net.authorize.sample.MobileInAppTransactions.*; import net.authorize.sample.FraudManagement.*; diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java index 6aa8511e..c8a30c8a 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java +++ b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java @@ -32,8 +32,6 @@ import net.authorize.api.contract.v1.UpdateCustomerProfileResponse; import net.authorize.api.contract.v1.UpdateCustomerShippingAddressResponse; import net.authorize.api.contract.v1.ValidateCustomerPaymentProfileResponse; -import net.authorize.sample.AcceptSuite.GetAcceptCustomerProfilePage; -import net.authorize.sample.AcceptSuite.GetAnAcceptPaymentPage; import net.authorize.sample.CustomerProfiles.CreateCustomerPaymentProfile; import net.authorize.sample.CustomerProfiles.CreateCustomerProfile; import net.authorize.sample.CustomerProfiles.CreateCustomerProfileFromTransaction; @@ -44,6 +42,7 @@ import net.authorize.sample.CustomerProfiles.GetCustomerPaymentProfile; import net.authorize.sample.CustomerProfiles.GetCustomerProfile; import net.authorize.sample.CustomerProfiles.GetCustomerShippingAddress; +import net.authorize.sample.CustomerProfiles.GetAcceptCustomerProfilePage; import net.authorize.sample.CustomerProfiles.UpdateCustomerPaymentProfile; import net.authorize.sample.CustomerProfiles.UpdateCustomerProfile; import net.authorize.sample.CustomerProfiles.UpdateCustomerShippingAddress; @@ -72,6 +71,7 @@ import net.authorize.sample.RecurringBilling.GetSubscriptionStatus; import net.authorize.sample.RecurringBilling.UpdateSubscription; import net.authorize.sample.TransactionReporting.GetTransactionDetails; +import net.authorize.sample.PaymentTransactions.GetAnAcceptPaymentPage; public class TestRunner { From ddbe56feb684b9da2d7ee957ed7e200d945d19a2 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Fri, 10 Aug 2018 23:48:12 +0530 Subject: [PATCH 133/176] Revert "+ Adding files to Accept Suite" This reverts commit b4da3d2c0a3c6cd4a69a91889266eef232c51430. Reverting changes --- .../GetAcceptCustomerProfilePage.java | 0 .../CreateAnAcceptTransaction.java | 0 .../CreateAnAcceptPaymentTransaction.java | 0 .../GetAnAcceptPaymentPage.java | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename src/main/java/net/authorize/sample/{AcceptSuite => CustomerProfiles}/GetAcceptCustomerProfilePage.java (100%) rename src/main/java/net/authorize/sample/{AcceptSuite => MobileInAppTransactions}/CreateAnAcceptTransaction.java (100%) rename src/main/java/net/authorize/sample/{AcceptSuite => PaymentTransactions}/CreateAnAcceptPaymentTransaction.java (100%) rename src/main/java/net/authorize/sample/{AcceptSuite => PaymentTransactions}/GetAnAcceptPaymentPage.java (100%) diff --git a/src/main/java/net/authorize/sample/AcceptSuite/GetAcceptCustomerProfilePage.java b/src/main/java/net/authorize/sample/CustomerProfiles/GetAcceptCustomerProfilePage.java similarity index 100% rename from src/main/java/net/authorize/sample/AcceptSuite/GetAcceptCustomerProfilePage.java rename to src/main/java/net/authorize/sample/CustomerProfiles/GetAcceptCustomerProfilePage.java diff --git a/src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptTransaction.java b/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAcceptTransaction.java similarity index 100% rename from src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptTransaction.java rename to src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAcceptTransaction.java diff --git a/src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptPaymentTransaction.java b/src/main/java/net/authorize/sample/PaymentTransactions/CreateAnAcceptPaymentTransaction.java similarity index 100% rename from src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptPaymentTransaction.java rename to src/main/java/net/authorize/sample/PaymentTransactions/CreateAnAcceptPaymentTransaction.java diff --git a/src/main/java/net/authorize/sample/AcceptSuite/GetAnAcceptPaymentPage.java b/src/main/java/net/authorize/sample/PaymentTransactions/GetAnAcceptPaymentPage.java similarity index 100% rename from src/main/java/net/authorize/sample/AcceptSuite/GetAnAcceptPaymentPage.java rename to src/main/java/net/authorize/sample/PaymentTransactions/GetAnAcceptPaymentPage.java From b0170d6653d8c184aa1017caf200affeedb3c990 Mon Sep 17 00:00:00 2001 From: Ashutosh Singh Date: Mon, 13 Aug 2018 22:30:08 +0530 Subject: [PATCH 134/176] Corrected formatting Corrected formatting --- .../GetUnsettledTransactionList.java | 73 +++++++++---------- 1 file changed, 35 insertions(+), 38 deletions(-) diff --git a/src/main/java/net/authorize/sample/TransactionReporting/GetUnsettledTransactionList.java b/src/main/java/net/authorize/sample/TransactionReporting/GetUnsettledTransactionList.java index 30db6265..72b8b237 100644 --- a/src/main/java/net/authorize/sample/TransactionReporting/GetUnsettledTransactionList.java +++ b/src/main/java/net/authorize/sample/TransactionReporting/GetUnsettledTransactionList.java @@ -9,48 +9,45 @@ //author @krgupta public class GetUnsettledTransactionList{ - - public static ANetApiResponse run(String apiLoginId, String transactionKey) { - ApiOperationBase.setEnvironment(Environment.SANDBOX); + public static ANetApiResponse run(String apiLoginId, String transactionKey) { + ApiOperationBase.setEnvironment(Environment.SANDBOX); - MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; - merchantAuthenticationType.setName(apiLoginId); - merchantAuthenticationType.setTransactionKey(transactionKey); - ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); + MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; + merchantAuthenticationType.setName(apiLoginId); + merchantAuthenticationType.setTransactionKey(transactionKey); + ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); - GetUnsettledTransactionListRequest getRequest = new GetUnsettledTransactionListRequest(); - getRequest.setMerchantAuthentication(merchantAuthenticationType); - getRequest.setStatus(TransactionGroupStatusEnum.ANY); + GetUnsettledTransactionListRequest getRequest = new GetUnsettledTransactionListRequest(); + getRequest.setMerchantAuthentication(merchantAuthenticationType); + getRequest.setStatus(TransactionGroupStatusEnum.ANY); - Paging paging = new Paging(); - paging.setLimit(100); - paging.setOffset(1); + Paging paging = new Paging(); + paging.setLimit(100); + paging.setOffset(1); - getRequest.setPaging(paging); + getRequest.setPaging(paging); - TransactionListSorting sorting = new TransactionListSorting(); - sorting.setOrderBy(TransactionListOrderFieldEnum.ID); - sorting.setOrderDescending(true); + TransactionListSorting sorting = new TransactionListSorting(); + sorting.setOrderBy(TransactionListOrderFieldEnum.ID); + sorting.setOrderDescending(true); - getRequest.setSorting(sorting); - - GetUnsettledTransactionListController controller = new GetUnsettledTransactionListController(getRequest); - controller.execute(); - GetUnsettledTransactionListResponse getResponse = controller.getApiResponse(); - - if (getResponse!=null) { - - if (getResponse.getMessages().getResultCode() == MessageTypeEnum.OK) { - - System.out.println(getResponse.getMessages().getMessage().get(0).getCode()); - System.out.println(getResponse.getMessages().getMessage().get(0).getText()); - } - else - { - System.out.println("Failed to get unsettled transaction list: " + getResponse.getMessages().getResultCode()); - } - } - return getResponse; - - } + getRequest.setSorting(sorting); + + GetUnsettledTransactionListController controller = new GetUnsettledTransactionListController(getRequest); + controller.execute(); + GetUnsettledTransactionListResponse getResponse = controller.getApiResponse(); + + if (getResponse!=null) { + if (getResponse.getMessages().getResultCode() == MessageTypeEnum.OK) { + System.out.println(getResponse.getMessages().getMessage().get(0).getCode()); + System.out.println(getResponse.getMessages().getMessage().get(0).getText()); + } + else + { + System.out.println("Failed to get unsettled transaction list: " + getResponse.getMessages().getResultCode()); + } + } + return getResponse; + + } } From 0a722481d1df306878897b07b968e7844cb020a1 Mon Sep 17 00:00:00 2001 From: ashtru Date: Thu, 20 Sep 2018 23:03:24 +0530 Subject: [PATCH 135/176] Test files for Cybs REST API Reference --- .../sample/REST/Capture/CapturePayment.java | 101 ++++++++++++++++++ .../REST/KeyGeneration/GenerateKey.java | 101 ++++++++++++++++++ 2 files changed, 202 insertions(+) create mode 100644 src/main/java/net/authorize/sample/REST/Capture/CapturePayment.java create mode 100644 src/main/java/net/authorize/sample/REST/KeyGeneration/GenerateKey.java diff --git a/src/main/java/net/authorize/sample/REST/Capture/CapturePayment.java b/src/main/java/net/authorize/sample/REST/Capture/CapturePayment.java new file mode 100644 index 00000000..60acd464 --- /dev/null +++ b/src/main/java/net/authorize/sample/REST/Capture/CapturePayment.java @@ -0,0 +1,101 @@ +package net.authorize.sample.PaymentTransactions; + +import java.math.BigDecimal; +import java.math.RoundingMode; + +import net.authorize.Environment; +import net.authorize.api.contract.v1.ANetApiResponse; +import net.authorize.api.contract.v1.CreateTransactionRequest; +import net.authorize.api.contract.v1.CreateTransactionResponse; +import net.authorize.api.contract.v1.CreditCardType; +import net.authorize.api.contract.v1.MerchantAuthenticationType; +import net.authorize.api.contract.v1.MessageTypeEnum; +import net.authorize.api.contract.v1.PaymentType; +import net.authorize.api.contract.v1.TransactionRequestType; +import net.authorize.api.contract.v1.TransactionResponse; +import net.authorize.api.contract.v1.TransactionTypeEnum; +import net.authorize.api.controller.CreateTransactionController; +import net.authorize.api.controller.base.ApiOperationBase; + +public class AuthorizeCreditCard { + + // + // Run this sample from command line with: + // java -jar target/AuthorizeCreditCard-jar-with-dependencies.jar + // + public static ANetApiResponse run(String apiLoginId, String transactionKey, Double amount) { + + // Set the request to operate in either the sandbox or production environment + ApiOperationBase.setEnvironment(Environment.SANDBOX); + + // Create object with merchant authentication details + MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; + merchantAuthenticationType.setName(apiLoginId); + merchantAuthenticationType.setTransactionKey(transactionKey); + + // Populate the payment data + PaymentType paymentType = new PaymentType(); + CreditCardType creditCard = new CreditCardType(); + creditCard.setCardNumber("4242424242424242"); + creditCard.setExpirationDate("0822"); + paymentType.setCreditCard(creditCard); + + // Create the payment transaction object + TransactionRequestType txnRequest = new TransactionRequestType(); + txnRequest.setTransactionType(TransactionTypeEnum.AUTH_ONLY_TRANSACTION.value()); + txnRequest.setPayment(paymentType); + txnRequest.setAmount(new BigDecimal(amount).setScale(2, RoundingMode.CEILING)); + + // Create the API request and set the parameters for this specific request + CreateTransactionRequest apiRequest = new CreateTransactionRequest(); + apiRequest.setMerchantAuthentication(merchantAuthenticationType); + apiRequest.setTransactionRequest(txnRequest); + + // Call the controller + CreateTransactionController controller = new CreateTransactionController(apiRequest); + controller.execute(); + + // Get the response + CreateTransactionResponse response = new CreateTransactionResponse(); + response = controller.getApiResponse(); + + // Parse the response to determine results + if (response!=null) { + // If API Response is OK, go ahead and check the transaction response + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + TransactionResponse result = response.getTransactionResponse(); + if (result.getMessages() != null) { + System.out.println("Successfully created auth-only transaction with Transaction ID: " + result.getTransId()); + System.out.println("Response Code: " + result.getResponseCode()); + System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); + System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); + System.out.println("Auth Code: " + result.getAuthCode()); + } else { + System.out.println("Failed Transaction."); + if (response.getTransactionResponse().getErrors() != null) { + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + } + } else { + System.out.println("Failed Transaction."); + if (response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null) { + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } else { + System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); + System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); + } + } + } else { + // Display the error code and message when response is null + ANetApiResponse errorResponse = controller.getErrorResponse(); + System.out.println("Failed to get response"); + if (!errorResponse.getMessages().getMessage().isEmpty()) { + System.out.println("Error: "+errorResponse.getMessages().getMessage().get(0).getCode()+" \n"+ errorResponse.getMessages().getMessage().get(0).getText()); + } + } + + return response; + } +} diff --git a/src/main/java/net/authorize/sample/REST/KeyGeneration/GenerateKey.java b/src/main/java/net/authorize/sample/REST/KeyGeneration/GenerateKey.java new file mode 100644 index 00000000..60acd464 --- /dev/null +++ b/src/main/java/net/authorize/sample/REST/KeyGeneration/GenerateKey.java @@ -0,0 +1,101 @@ +package net.authorize.sample.PaymentTransactions; + +import java.math.BigDecimal; +import java.math.RoundingMode; + +import net.authorize.Environment; +import net.authorize.api.contract.v1.ANetApiResponse; +import net.authorize.api.contract.v1.CreateTransactionRequest; +import net.authorize.api.contract.v1.CreateTransactionResponse; +import net.authorize.api.contract.v1.CreditCardType; +import net.authorize.api.contract.v1.MerchantAuthenticationType; +import net.authorize.api.contract.v1.MessageTypeEnum; +import net.authorize.api.contract.v1.PaymentType; +import net.authorize.api.contract.v1.TransactionRequestType; +import net.authorize.api.contract.v1.TransactionResponse; +import net.authorize.api.contract.v1.TransactionTypeEnum; +import net.authorize.api.controller.CreateTransactionController; +import net.authorize.api.controller.base.ApiOperationBase; + +public class AuthorizeCreditCard { + + // + // Run this sample from command line with: + // java -jar target/AuthorizeCreditCard-jar-with-dependencies.jar + // + public static ANetApiResponse run(String apiLoginId, String transactionKey, Double amount) { + + // Set the request to operate in either the sandbox or production environment + ApiOperationBase.setEnvironment(Environment.SANDBOX); + + // Create object with merchant authentication details + MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; + merchantAuthenticationType.setName(apiLoginId); + merchantAuthenticationType.setTransactionKey(transactionKey); + + // Populate the payment data + PaymentType paymentType = new PaymentType(); + CreditCardType creditCard = new CreditCardType(); + creditCard.setCardNumber("4242424242424242"); + creditCard.setExpirationDate("0822"); + paymentType.setCreditCard(creditCard); + + // Create the payment transaction object + TransactionRequestType txnRequest = new TransactionRequestType(); + txnRequest.setTransactionType(TransactionTypeEnum.AUTH_ONLY_TRANSACTION.value()); + txnRequest.setPayment(paymentType); + txnRequest.setAmount(new BigDecimal(amount).setScale(2, RoundingMode.CEILING)); + + // Create the API request and set the parameters for this specific request + CreateTransactionRequest apiRequest = new CreateTransactionRequest(); + apiRequest.setMerchantAuthentication(merchantAuthenticationType); + apiRequest.setTransactionRequest(txnRequest); + + // Call the controller + CreateTransactionController controller = new CreateTransactionController(apiRequest); + controller.execute(); + + // Get the response + CreateTransactionResponse response = new CreateTransactionResponse(); + response = controller.getApiResponse(); + + // Parse the response to determine results + if (response!=null) { + // If API Response is OK, go ahead and check the transaction response + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + TransactionResponse result = response.getTransactionResponse(); + if (result.getMessages() != null) { + System.out.println("Successfully created auth-only transaction with Transaction ID: " + result.getTransId()); + System.out.println("Response Code: " + result.getResponseCode()); + System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); + System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); + System.out.println("Auth Code: " + result.getAuthCode()); + } else { + System.out.println("Failed Transaction."); + if (response.getTransactionResponse().getErrors() != null) { + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + } + } else { + System.out.println("Failed Transaction."); + if (response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null) { + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } else { + System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); + System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); + } + } + } else { + // Display the error code and message when response is null + ANetApiResponse errorResponse = controller.getErrorResponse(); + System.out.println("Failed to get response"); + if (!errorResponse.getMessages().getMessage().isEmpty()) { + System.out.println("Error: "+errorResponse.getMessages().getMessage().get(0).getCode()+" \n"+ errorResponse.getMessages().getMessage().get(0).getText()); + } + } + + return response; + } +} From 55f13dbe1445435ec0403b57190d648279067aae Mon Sep 17 00:00:00 2001 From: ashtru Date: Thu, 20 Sep 2018 23:13:30 +0530 Subject: [PATCH 136/176] Files for testing rest api reference --- .../REST/Sample/Capture/CapturePayment.java | 101 ++++++++++++++ .../REST/Sample/Capture/capture-payment.php | 132 ++++++++++++++++++ .../Sample/KeyGeneration/GenerateKey.java | 101 ++++++++++++++ 3 files changed, 334 insertions(+) create mode 100644 REST/anet-rest-samplecode/src/AuthorizeNet/REST/Sample/Capture/CapturePayment.java create mode 100644 REST/anet-rest-samplecode/src/AuthorizeNet/REST/Sample/Capture/capture-payment.php create mode 100644 REST/anet-rest-samplecode/src/AuthorizeNet/REST/Sample/KeyGeneration/GenerateKey.java diff --git a/REST/anet-rest-samplecode/src/AuthorizeNet/REST/Sample/Capture/CapturePayment.java b/REST/anet-rest-samplecode/src/AuthorizeNet/REST/Sample/Capture/CapturePayment.java new file mode 100644 index 00000000..60acd464 --- /dev/null +++ b/REST/anet-rest-samplecode/src/AuthorizeNet/REST/Sample/Capture/CapturePayment.java @@ -0,0 +1,101 @@ +package net.authorize.sample.PaymentTransactions; + +import java.math.BigDecimal; +import java.math.RoundingMode; + +import net.authorize.Environment; +import net.authorize.api.contract.v1.ANetApiResponse; +import net.authorize.api.contract.v1.CreateTransactionRequest; +import net.authorize.api.contract.v1.CreateTransactionResponse; +import net.authorize.api.contract.v1.CreditCardType; +import net.authorize.api.contract.v1.MerchantAuthenticationType; +import net.authorize.api.contract.v1.MessageTypeEnum; +import net.authorize.api.contract.v1.PaymentType; +import net.authorize.api.contract.v1.TransactionRequestType; +import net.authorize.api.contract.v1.TransactionResponse; +import net.authorize.api.contract.v1.TransactionTypeEnum; +import net.authorize.api.controller.CreateTransactionController; +import net.authorize.api.controller.base.ApiOperationBase; + +public class AuthorizeCreditCard { + + // + // Run this sample from command line with: + // java -jar target/AuthorizeCreditCard-jar-with-dependencies.jar + // + public static ANetApiResponse run(String apiLoginId, String transactionKey, Double amount) { + + // Set the request to operate in either the sandbox or production environment + ApiOperationBase.setEnvironment(Environment.SANDBOX); + + // Create object with merchant authentication details + MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; + merchantAuthenticationType.setName(apiLoginId); + merchantAuthenticationType.setTransactionKey(transactionKey); + + // Populate the payment data + PaymentType paymentType = new PaymentType(); + CreditCardType creditCard = new CreditCardType(); + creditCard.setCardNumber("4242424242424242"); + creditCard.setExpirationDate("0822"); + paymentType.setCreditCard(creditCard); + + // Create the payment transaction object + TransactionRequestType txnRequest = new TransactionRequestType(); + txnRequest.setTransactionType(TransactionTypeEnum.AUTH_ONLY_TRANSACTION.value()); + txnRequest.setPayment(paymentType); + txnRequest.setAmount(new BigDecimal(amount).setScale(2, RoundingMode.CEILING)); + + // Create the API request and set the parameters for this specific request + CreateTransactionRequest apiRequest = new CreateTransactionRequest(); + apiRequest.setMerchantAuthentication(merchantAuthenticationType); + apiRequest.setTransactionRequest(txnRequest); + + // Call the controller + CreateTransactionController controller = new CreateTransactionController(apiRequest); + controller.execute(); + + // Get the response + CreateTransactionResponse response = new CreateTransactionResponse(); + response = controller.getApiResponse(); + + // Parse the response to determine results + if (response!=null) { + // If API Response is OK, go ahead and check the transaction response + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + TransactionResponse result = response.getTransactionResponse(); + if (result.getMessages() != null) { + System.out.println("Successfully created auth-only transaction with Transaction ID: " + result.getTransId()); + System.out.println("Response Code: " + result.getResponseCode()); + System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); + System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); + System.out.println("Auth Code: " + result.getAuthCode()); + } else { + System.out.println("Failed Transaction."); + if (response.getTransactionResponse().getErrors() != null) { + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + } + } else { + System.out.println("Failed Transaction."); + if (response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null) { + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } else { + System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); + System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); + } + } + } else { + // Display the error code and message when response is null + ANetApiResponse errorResponse = controller.getErrorResponse(); + System.out.println("Failed to get response"); + if (!errorResponse.getMessages().getMessage().isEmpty()) { + System.out.println("Error: "+errorResponse.getMessages().getMessage().get(0).getCode()+" \n"+ errorResponse.getMessages().getMessage().get(0).getText()); + } + } + + return response; + } +} diff --git a/REST/anet-rest-samplecode/src/AuthorizeNet/REST/Sample/Capture/capture-payment.php b/REST/anet-rest-samplecode/src/AuthorizeNet/REST/Sample/Capture/capture-payment.php new file mode 100644 index 00000000..c401d814 --- /dev/null +++ b/REST/anet-rest-samplecode/src/AuthorizeNet/REST/Sample/Capture/capture-payment.php @@ -0,0 +1,132 @@ +setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); + + // Set the transaction's refId + $refId = 'ref' . time(); + + // Create the payment data for a credit card + $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() == \SampleCode\Constants::RESPONSE_OK) { + // Since the API request was successful, look for a transaction response + // and parse it to display the results of authorizing the card + $tresponse = $response->getTransactionResponse(); + + if ($tresponse != null && $tresponse->getMessages() != null) { + echo " Successfully created transaction with Transaction ID: " . $tresponse->getTransId() . "\n"; + echo " Transaction Response Code: " . $tresponse->getResponseCode() . "\n"; + echo " Message Code: " . $tresponse->getMessages()[0]->getCode() . "\n"; + echo " Auth Code: " . $tresponse->getAuthCode() . "\n"; + echo " Description: " . $tresponse->getMessages()[0]->getDescription() . "\n"; + } else { + echo "Transaction Failed \n"; + if ($tresponse->getErrors() != null) { + echo " Error Code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; + echo " Error Message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; + } + } + // Or, print errors if the API request wasn't successful + } else { + echo "Transaction Failed \n"; + $tresponse = $response->getTransactionResponse(); + + if ($tresponse != null && $tresponse->getErrors() != null) { + echo " Error Code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; + echo " Error Message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; + } else { + echo " Error Code : " . $response->getMessages()->getMessage()[0]->getCode() . "\n"; + echo " Error Message : " . $response->getMessages()->getMessage()[0]->getText() . "\n"; + } + } + } else { + echo "No response returned \n"; + } + + return $response; +} + +if (!defined('DONT_RUN_SAMPLES')) { + chargeCreditCard(\SampleCode\Constants::SAMPLE_AMOUNT); +} diff --git a/REST/anet-rest-samplecode/src/AuthorizeNet/REST/Sample/KeyGeneration/GenerateKey.java b/REST/anet-rest-samplecode/src/AuthorizeNet/REST/Sample/KeyGeneration/GenerateKey.java new file mode 100644 index 00000000..60acd464 --- /dev/null +++ b/REST/anet-rest-samplecode/src/AuthorizeNet/REST/Sample/KeyGeneration/GenerateKey.java @@ -0,0 +1,101 @@ +package net.authorize.sample.PaymentTransactions; + +import java.math.BigDecimal; +import java.math.RoundingMode; + +import net.authorize.Environment; +import net.authorize.api.contract.v1.ANetApiResponse; +import net.authorize.api.contract.v1.CreateTransactionRequest; +import net.authorize.api.contract.v1.CreateTransactionResponse; +import net.authorize.api.contract.v1.CreditCardType; +import net.authorize.api.contract.v1.MerchantAuthenticationType; +import net.authorize.api.contract.v1.MessageTypeEnum; +import net.authorize.api.contract.v1.PaymentType; +import net.authorize.api.contract.v1.TransactionRequestType; +import net.authorize.api.contract.v1.TransactionResponse; +import net.authorize.api.contract.v1.TransactionTypeEnum; +import net.authorize.api.controller.CreateTransactionController; +import net.authorize.api.controller.base.ApiOperationBase; + +public class AuthorizeCreditCard { + + // + // Run this sample from command line with: + // java -jar target/AuthorizeCreditCard-jar-with-dependencies.jar + // + public static ANetApiResponse run(String apiLoginId, String transactionKey, Double amount) { + + // Set the request to operate in either the sandbox or production environment + ApiOperationBase.setEnvironment(Environment.SANDBOX); + + // Create object with merchant authentication details + MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; + merchantAuthenticationType.setName(apiLoginId); + merchantAuthenticationType.setTransactionKey(transactionKey); + + // Populate the payment data + PaymentType paymentType = new PaymentType(); + CreditCardType creditCard = new CreditCardType(); + creditCard.setCardNumber("4242424242424242"); + creditCard.setExpirationDate("0822"); + paymentType.setCreditCard(creditCard); + + // Create the payment transaction object + TransactionRequestType txnRequest = new TransactionRequestType(); + txnRequest.setTransactionType(TransactionTypeEnum.AUTH_ONLY_TRANSACTION.value()); + txnRequest.setPayment(paymentType); + txnRequest.setAmount(new BigDecimal(amount).setScale(2, RoundingMode.CEILING)); + + // Create the API request and set the parameters for this specific request + CreateTransactionRequest apiRequest = new CreateTransactionRequest(); + apiRequest.setMerchantAuthentication(merchantAuthenticationType); + apiRequest.setTransactionRequest(txnRequest); + + // Call the controller + CreateTransactionController controller = new CreateTransactionController(apiRequest); + controller.execute(); + + // Get the response + CreateTransactionResponse response = new CreateTransactionResponse(); + response = controller.getApiResponse(); + + // Parse the response to determine results + if (response!=null) { + // If API Response is OK, go ahead and check the transaction response + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + TransactionResponse result = response.getTransactionResponse(); + if (result.getMessages() != null) { + System.out.println("Successfully created auth-only transaction with Transaction ID: " + result.getTransId()); + System.out.println("Response Code: " + result.getResponseCode()); + System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); + System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); + System.out.println("Auth Code: " + result.getAuthCode()); + } else { + System.out.println("Failed Transaction."); + if (response.getTransactionResponse().getErrors() != null) { + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + } + } else { + System.out.println("Failed Transaction."); + if (response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null) { + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } else { + System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); + System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); + } + } + } else { + // Display the error code and message when response is null + ANetApiResponse errorResponse = controller.getErrorResponse(); + System.out.println("Failed to get response"); + if (!errorResponse.getMessages().getMessage().isEmpty()) { + System.out.println("Error: "+errorResponse.getMessages().getMessage().get(0).getCode()+" \n"+ errorResponse.getMessages().getMessage().get(0).getText()); + } + } + + return response; + } +} From fc6d0acc9d285800b5a56daa2f70a5f8b77e5ed3 Mon Sep 17 00:00:00 2001 From: Ashutosh Singh Date: Thu, 20 Sep 2018 23:17:39 +0530 Subject: [PATCH 137/176] Delete CapturePayment.java --- .../REST/Sample/Capture/CapturePayment.java | 101 ------------------ 1 file changed, 101 deletions(-) delete mode 100644 REST/anet-rest-samplecode/src/AuthorizeNet/REST/Sample/Capture/CapturePayment.java diff --git a/REST/anet-rest-samplecode/src/AuthorizeNet/REST/Sample/Capture/CapturePayment.java b/REST/anet-rest-samplecode/src/AuthorizeNet/REST/Sample/Capture/CapturePayment.java deleted file mode 100644 index 60acd464..00000000 --- a/REST/anet-rest-samplecode/src/AuthorizeNet/REST/Sample/Capture/CapturePayment.java +++ /dev/null @@ -1,101 +0,0 @@ -package net.authorize.sample.PaymentTransactions; - -import java.math.BigDecimal; -import java.math.RoundingMode; - -import net.authorize.Environment; -import net.authorize.api.contract.v1.ANetApiResponse; -import net.authorize.api.contract.v1.CreateTransactionRequest; -import net.authorize.api.contract.v1.CreateTransactionResponse; -import net.authorize.api.contract.v1.CreditCardType; -import net.authorize.api.contract.v1.MerchantAuthenticationType; -import net.authorize.api.contract.v1.MessageTypeEnum; -import net.authorize.api.contract.v1.PaymentType; -import net.authorize.api.contract.v1.TransactionRequestType; -import net.authorize.api.contract.v1.TransactionResponse; -import net.authorize.api.contract.v1.TransactionTypeEnum; -import net.authorize.api.controller.CreateTransactionController; -import net.authorize.api.controller.base.ApiOperationBase; - -public class AuthorizeCreditCard { - - // - // Run this sample from command line with: - // java -jar target/AuthorizeCreditCard-jar-with-dependencies.jar - // - public static ANetApiResponse run(String apiLoginId, String transactionKey, Double amount) { - - // Set the request to operate in either the sandbox or production environment - ApiOperationBase.setEnvironment(Environment.SANDBOX); - - // Create object with merchant authentication details - MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; - merchantAuthenticationType.setName(apiLoginId); - merchantAuthenticationType.setTransactionKey(transactionKey); - - // Populate the payment data - PaymentType paymentType = new PaymentType(); - CreditCardType creditCard = new CreditCardType(); - creditCard.setCardNumber("4242424242424242"); - creditCard.setExpirationDate("0822"); - paymentType.setCreditCard(creditCard); - - // Create the payment transaction object - TransactionRequestType txnRequest = new TransactionRequestType(); - txnRequest.setTransactionType(TransactionTypeEnum.AUTH_ONLY_TRANSACTION.value()); - txnRequest.setPayment(paymentType); - txnRequest.setAmount(new BigDecimal(amount).setScale(2, RoundingMode.CEILING)); - - // Create the API request and set the parameters for this specific request - CreateTransactionRequest apiRequest = new CreateTransactionRequest(); - apiRequest.setMerchantAuthentication(merchantAuthenticationType); - apiRequest.setTransactionRequest(txnRequest); - - // Call the controller - CreateTransactionController controller = new CreateTransactionController(apiRequest); - controller.execute(); - - // Get the response - CreateTransactionResponse response = new CreateTransactionResponse(); - response = controller.getApiResponse(); - - // Parse the response to determine results - if (response!=null) { - // If API Response is OK, go ahead and check the transaction response - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { - TransactionResponse result = response.getTransactionResponse(); - if (result.getMessages() != null) { - System.out.println("Successfully created auth-only transaction with Transaction ID: " + result.getTransId()); - System.out.println("Response Code: " + result.getResponseCode()); - System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); - System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); - System.out.println("Auth Code: " + result.getAuthCode()); - } else { - System.out.println("Failed Transaction."); - if (response.getTransactionResponse().getErrors() != null) { - System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); - System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); - } - } - } else { - System.out.println("Failed Transaction."); - if (response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null) { - System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); - System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); - } else { - System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); - System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); - } - } - } else { - // Display the error code and message when response is null - ANetApiResponse errorResponse = controller.getErrorResponse(); - System.out.println("Failed to get response"); - if (!errorResponse.getMessages().getMessage().isEmpty()) { - System.out.println("Error: "+errorResponse.getMessages().getMessage().get(0).getCode()+" \n"+ errorResponse.getMessages().getMessage().get(0).getText()); - } - } - - return response; - } -} From c323d3a0830e03c3500d417721b5901d224c53d2 Mon Sep 17 00:00:00 2001 From: Ashutosh Singh Date: Thu, 20 Sep 2018 23:17:59 +0530 Subject: [PATCH 138/176] Delete capture-payment.php --- .../REST/Sample/Capture/capture-payment.php | 132 ------------------ 1 file changed, 132 deletions(-) delete mode 100644 REST/anet-rest-samplecode/src/AuthorizeNet/REST/Sample/Capture/capture-payment.php diff --git a/REST/anet-rest-samplecode/src/AuthorizeNet/REST/Sample/Capture/capture-payment.php b/REST/anet-rest-samplecode/src/AuthorizeNet/REST/Sample/Capture/capture-payment.php deleted file mode 100644 index c401d814..00000000 --- a/REST/anet-rest-samplecode/src/AuthorizeNet/REST/Sample/Capture/capture-payment.php +++ /dev/null @@ -1,132 +0,0 @@ -setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); - $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY); - - // Set the transaction's refId - $refId = 'ref' . time(); - - // Create the payment data for a credit card - $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() == \SampleCode\Constants::RESPONSE_OK) { - // Since the API request was successful, look for a transaction response - // and parse it to display the results of authorizing the card - $tresponse = $response->getTransactionResponse(); - - if ($tresponse != null && $tresponse->getMessages() != null) { - echo " Successfully created transaction with Transaction ID: " . $tresponse->getTransId() . "\n"; - echo " Transaction Response Code: " . $tresponse->getResponseCode() . "\n"; - echo " Message Code: " . $tresponse->getMessages()[0]->getCode() . "\n"; - echo " Auth Code: " . $tresponse->getAuthCode() . "\n"; - echo " Description: " . $tresponse->getMessages()[0]->getDescription() . "\n"; - } else { - echo "Transaction Failed \n"; - if ($tresponse->getErrors() != null) { - echo " Error Code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; - echo " Error Message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; - } - } - // Or, print errors if the API request wasn't successful - } else { - echo "Transaction Failed \n"; - $tresponse = $response->getTransactionResponse(); - - if ($tresponse != null && $tresponse->getErrors() != null) { - echo " Error Code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; - echo " Error Message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; - } else { - echo " Error Code : " . $response->getMessages()->getMessage()[0]->getCode() . "\n"; - echo " Error Message : " . $response->getMessages()->getMessage()[0]->getText() . "\n"; - } - } - } else { - echo "No response returned \n"; - } - - return $response; -} - -if (!defined('DONT_RUN_SAMPLES')) { - chargeCreditCard(\SampleCode\Constants::SAMPLE_AMOUNT); -} From 8983fc208ed6ddb6f8d2dc00ec4e1c1a0d28aba5 Mon Sep 17 00:00:00 2001 From: Ashutosh Singh Date: Thu, 20 Sep 2018 23:18:13 +0530 Subject: [PATCH 139/176] Delete GenerateKey.java --- .../Sample/KeyGeneration/GenerateKey.java | 101 ------------------ 1 file changed, 101 deletions(-) delete mode 100644 REST/anet-rest-samplecode/src/AuthorizeNet/REST/Sample/KeyGeneration/GenerateKey.java diff --git a/REST/anet-rest-samplecode/src/AuthorizeNet/REST/Sample/KeyGeneration/GenerateKey.java b/REST/anet-rest-samplecode/src/AuthorizeNet/REST/Sample/KeyGeneration/GenerateKey.java deleted file mode 100644 index 60acd464..00000000 --- a/REST/anet-rest-samplecode/src/AuthorizeNet/REST/Sample/KeyGeneration/GenerateKey.java +++ /dev/null @@ -1,101 +0,0 @@ -package net.authorize.sample.PaymentTransactions; - -import java.math.BigDecimal; -import java.math.RoundingMode; - -import net.authorize.Environment; -import net.authorize.api.contract.v1.ANetApiResponse; -import net.authorize.api.contract.v1.CreateTransactionRequest; -import net.authorize.api.contract.v1.CreateTransactionResponse; -import net.authorize.api.contract.v1.CreditCardType; -import net.authorize.api.contract.v1.MerchantAuthenticationType; -import net.authorize.api.contract.v1.MessageTypeEnum; -import net.authorize.api.contract.v1.PaymentType; -import net.authorize.api.contract.v1.TransactionRequestType; -import net.authorize.api.contract.v1.TransactionResponse; -import net.authorize.api.contract.v1.TransactionTypeEnum; -import net.authorize.api.controller.CreateTransactionController; -import net.authorize.api.controller.base.ApiOperationBase; - -public class AuthorizeCreditCard { - - // - // Run this sample from command line with: - // java -jar target/AuthorizeCreditCard-jar-with-dependencies.jar - // - public static ANetApiResponse run(String apiLoginId, String transactionKey, Double amount) { - - // Set the request to operate in either the sandbox or production environment - ApiOperationBase.setEnvironment(Environment.SANDBOX); - - // Create object with merchant authentication details - MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; - merchantAuthenticationType.setName(apiLoginId); - merchantAuthenticationType.setTransactionKey(transactionKey); - - // Populate the payment data - PaymentType paymentType = new PaymentType(); - CreditCardType creditCard = new CreditCardType(); - creditCard.setCardNumber("4242424242424242"); - creditCard.setExpirationDate("0822"); - paymentType.setCreditCard(creditCard); - - // Create the payment transaction object - TransactionRequestType txnRequest = new TransactionRequestType(); - txnRequest.setTransactionType(TransactionTypeEnum.AUTH_ONLY_TRANSACTION.value()); - txnRequest.setPayment(paymentType); - txnRequest.setAmount(new BigDecimal(amount).setScale(2, RoundingMode.CEILING)); - - // Create the API request and set the parameters for this specific request - CreateTransactionRequest apiRequest = new CreateTransactionRequest(); - apiRequest.setMerchantAuthentication(merchantAuthenticationType); - apiRequest.setTransactionRequest(txnRequest); - - // Call the controller - CreateTransactionController controller = new CreateTransactionController(apiRequest); - controller.execute(); - - // Get the response - CreateTransactionResponse response = new CreateTransactionResponse(); - response = controller.getApiResponse(); - - // Parse the response to determine results - if (response!=null) { - // If API Response is OK, go ahead and check the transaction response - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { - TransactionResponse result = response.getTransactionResponse(); - if (result.getMessages() != null) { - System.out.println("Successfully created auth-only transaction with Transaction ID: " + result.getTransId()); - System.out.println("Response Code: " + result.getResponseCode()); - System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); - System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); - System.out.println("Auth Code: " + result.getAuthCode()); - } else { - System.out.println("Failed Transaction."); - if (response.getTransactionResponse().getErrors() != null) { - System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); - System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); - } - } - } else { - System.out.println("Failed Transaction."); - if (response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null) { - System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); - System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); - } else { - System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); - System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); - } - } - } else { - // Display the error code and message when response is null - ANetApiResponse errorResponse = controller.getErrorResponse(); - System.out.println("Failed to get response"); - if (!errorResponse.getMessages().getMessage().isEmpty()) { - System.out.println("Error: "+errorResponse.getMessages().getMessage().get(0).getCode()+" \n"+ errorResponse.getMessages().getMessage().get(0).getText()); - } - } - - return response; - } -} From de483419706f2e9bae01eb18c543071e5ad9385a Mon Sep 17 00:00:00 2001 From: ashtru Date: Thu, 20 Sep 2018 23:44:26 +0530 Subject: [PATCH 140/176] Deleting unused files --- .../sample/REST/Capture/CapturePayment.java | 101 ------------------ .../REST/KeyGeneration/GenerateKey.java | 101 ------------------ 2 files changed, 202 deletions(-) delete mode 100644 src/main/java/net/authorize/sample/REST/Capture/CapturePayment.java delete mode 100644 src/main/java/net/authorize/sample/REST/KeyGeneration/GenerateKey.java diff --git a/src/main/java/net/authorize/sample/REST/Capture/CapturePayment.java b/src/main/java/net/authorize/sample/REST/Capture/CapturePayment.java deleted file mode 100644 index 60acd464..00000000 --- a/src/main/java/net/authorize/sample/REST/Capture/CapturePayment.java +++ /dev/null @@ -1,101 +0,0 @@ -package net.authorize.sample.PaymentTransactions; - -import java.math.BigDecimal; -import java.math.RoundingMode; - -import net.authorize.Environment; -import net.authorize.api.contract.v1.ANetApiResponse; -import net.authorize.api.contract.v1.CreateTransactionRequest; -import net.authorize.api.contract.v1.CreateTransactionResponse; -import net.authorize.api.contract.v1.CreditCardType; -import net.authorize.api.contract.v1.MerchantAuthenticationType; -import net.authorize.api.contract.v1.MessageTypeEnum; -import net.authorize.api.contract.v1.PaymentType; -import net.authorize.api.contract.v1.TransactionRequestType; -import net.authorize.api.contract.v1.TransactionResponse; -import net.authorize.api.contract.v1.TransactionTypeEnum; -import net.authorize.api.controller.CreateTransactionController; -import net.authorize.api.controller.base.ApiOperationBase; - -public class AuthorizeCreditCard { - - // - // Run this sample from command line with: - // java -jar target/AuthorizeCreditCard-jar-with-dependencies.jar - // - public static ANetApiResponse run(String apiLoginId, String transactionKey, Double amount) { - - // Set the request to operate in either the sandbox or production environment - ApiOperationBase.setEnvironment(Environment.SANDBOX); - - // Create object with merchant authentication details - MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; - merchantAuthenticationType.setName(apiLoginId); - merchantAuthenticationType.setTransactionKey(transactionKey); - - // Populate the payment data - PaymentType paymentType = new PaymentType(); - CreditCardType creditCard = new CreditCardType(); - creditCard.setCardNumber("4242424242424242"); - creditCard.setExpirationDate("0822"); - paymentType.setCreditCard(creditCard); - - // Create the payment transaction object - TransactionRequestType txnRequest = new TransactionRequestType(); - txnRequest.setTransactionType(TransactionTypeEnum.AUTH_ONLY_TRANSACTION.value()); - txnRequest.setPayment(paymentType); - txnRequest.setAmount(new BigDecimal(amount).setScale(2, RoundingMode.CEILING)); - - // Create the API request and set the parameters for this specific request - CreateTransactionRequest apiRequest = new CreateTransactionRequest(); - apiRequest.setMerchantAuthentication(merchantAuthenticationType); - apiRequest.setTransactionRequest(txnRequest); - - // Call the controller - CreateTransactionController controller = new CreateTransactionController(apiRequest); - controller.execute(); - - // Get the response - CreateTransactionResponse response = new CreateTransactionResponse(); - response = controller.getApiResponse(); - - // Parse the response to determine results - if (response!=null) { - // If API Response is OK, go ahead and check the transaction response - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { - TransactionResponse result = response.getTransactionResponse(); - if (result.getMessages() != null) { - System.out.println("Successfully created auth-only transaction with Transaction ID: " + result.getTransId()); - System.out.println("Response Code: " + result.getResponseCode()); - System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); - System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); - System.out.println("Auth Code: " + result.getAuthCode()); - } else { - System.out.println("Failed Transaction."); - if (response.getTransactionResponse().getErrors() != null) { - System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); - System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); - } - } - } else { - System.out.println("Failed Transaction."); - if (response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null) { - System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); - System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); - } else { - System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); - System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); - } - } - } else { - // Display the error code and message when response is null - ANetApiResponse errorResponse = controller.getErrorResponse(); - System.out.println("Failed to get response"); - if (!errorResponse.getMessages().getMessage().isEmpty()) { - System.out.println("Error: "+errorResponse.getMessages().getMessage().get(0).getCode()+" \n"+ errorResponse.getMessages().getMessage().get(0).getText()); - } - } - - return response; - } -} diff --git a/src/main/java/net/authorize/sample/REST/KeyGeneration/GenerateKey.java b/src/main/java/net/authorize/sample/REST/KeyGeneration/GenerateKey.java deleted file mode 100644 index 60acd464..00000000 --- a/src/main/java/net/authorize/sample/REST/KeyGeneration/GenerateKey.java +++ /dev/null @@ -1,101 +0,0 @@ -package net.authorize.sample.PaymentTransactions; - -import java.math.BigDecimal; -import java.math.RoundingMode; - -import net.authorize.Environment; -import net.authorize.api.contract.v1.ANetApiResponse; -import net.authorize.api.contract.v1.CreateTransactionRequest; -import net.authorize.api.contract.v1.CreateTransactionResponse; -import net.authorize.api.contract.v1.CreditCardType; -import net.authorize.api.contract.v1.MerchantAuthenticationType; -import net.authorize.api.contract.v1.MessageTypeEnum; -import net.authorize.api.contract.v1.PaymentType; -import net.authorize.api.contract.v1.TransactionRequestType; -import net.authorize.api.contract.v1.TransactionResponse; -import net.authorize.api.contract.v1.TransactionTypeEnum; -import net.authorize.api.controller.CreateTransactionController; -import net.authorize.api.controller.base.ApiOperationBase; - -public class AuthorizeCreditCard { - - // - // Run this sample from command line with: - // java -jar target/AuthorizeCreditCard-jar-with-dependencies.jar - // - public static ANetApiResponse run(String apiLoginId, String transactionKey, Double amount) { - - // Set the request to operate in either the sandbox or production environment - ApiOperationBase.setEnvironment(Environment.SANDBOX); - - // Create object with merchant authentication details - MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; - merchantAuthenticationType.setName(apiLoginId); - merchantAuthenticationType.setTransactionKey(transactionKey); - - // Populate the payment data - PaymentType paymentType = new PaymentType(); - CreditCardType creditCard = new CreditCardType(); - creditCard.setCardNumber("4242424242424242"); - creditCard.setExpirationDate("0822"); - paymentType.setCreditCard(creditCard); - - // Create the payment transaction object - TransactionRequestType txnRequest = new TransactionRequestType(); - txnRequest.setTransactionType(TransactionTypeEnum.AUTH_ONLY_TRANSACTION.value()); - txnRequest.setPayment(paymentType); - txnRequest.setAmount(new BigDecimal(amount).setScale(2, RoundingMode.CEILING)); - - // Create the API request and set the parameters for this specific request - CreateTransactionRequest apiRequest = new CreateTransactionRequest(); - apiRequest.setMerchantAuthentication(merchantAuthenticationType); - apiRequest.setTransactionRequest(txnRequest); - - // Call the controller - CreateTransactionController controller = new CreateTransactionController(apiRequest); - controller.execute(); - - // Get the response - CreateTransactionResponse response = new CreateTransactionResponse(); - response = controller.getApiResponse(); - - // Parse the response to determine results - if (response!=null) { - // If API Response is OK, go ahead and check the transaction response - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { - TransactionResponse result = response.getTransactionResponse(); - if (result.getMessages() != null) { - System.out.println("Successfully created auth-only transaction with Transaction ID: " + result.getTransId()); - System.out.println("Response Code: " + result.getResponseCode()); - System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); - System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); - System.out.println("Auth Code: " + result.getAuthCode()); - } else { - System.out.println("Failed Transaction."); - if (response.getTransactionResponse().getErrors() != null) { - System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); - System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); - } - } - } else { - System.out.println("Failed Transaction."); - if (response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null) { - System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); - System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); - } else { - System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); - System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); - } - } - } else { - // Display the error code and message when response is null - ANetApiResponse errorResponse = controller.getErrorResponse(); - System.out.println("Failed to get response"); - if (!errorResponse.getMessages().getMessage().isEmpty()) { - System.out.println("Error: "+errorResponse.getMessages().getMessage().get(0).getCode()+" \n"+ errorResponse.getMessages().getMessage().get(0).getText()); - } - } - - return response; - } -} From 50546fdf69eed6c04835ca4c015e2501889cbc46 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Mon, 15 Oct 2018 13:48:29 +0530 Subject: [PATCH 141/176] Update bank account number --- .../authorize/sample/PaymentTransactions/DebitBankAccount.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java b/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java index 33c91be2..23a57b8f 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/DebitBankAccount.java @@ -40,7 +40,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub BankAccountType bankAccountType = new BankAccountType(); bankAccountType.setAccountType(BankAccountTypeEnum.CHECKING); bankAccountType.setRoutingNumber("121141754"); - bankAccountType.setAccountNumber("1234567890"); + bankAccountType.setAccountNumber("7687245428"); bankAccountType.setNameOnAccount("John Doe"); paymentType.setBankAccount(bankAccountType); From a3315fc33d15e10840d81dad17ab2f08a452ef30 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Mon, 15 Oct 2018 13:51:06 +0530 Subject: [PATCH 142/176] Update bank account number --- .../authorize/sample/PaymentTransactions/CreditBankAccount.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java b/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java index 921921d1..06dd7733 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/CreditBankAccount.java @@ -40,7 +40,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri BankAccountType bankAccountType = new BankAccountType(); bankAccountType.setAccountType(BankAccountTypeEnum.CHECKING); bankAccountType.setRoutingNumber("121141754"); - bankAccountType.setAccountNumber("1234567890"); + bankAccountType.setAccountNumber("7687245428"); bankAccountType.setNameOnAccount("John Doe"); paymentType.setBankAccount(bankAccountType); From bc3ff06e4aa11e4ed3377b46ae3e1650d7dfceab Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Tue, 16 Oct 2018 10:32:49 +0530 Subject: [PATCH 143/176] October 18 Release of API Reference --- .../CreateAnAcceptPaymentTransaction.java | 0 .../GetAcceptCustomerProfilePage.java | 0 .../GetAnAcceptPaymentPage.java | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename src/main/java/net/authorize/sample/{PaymentTransactions => AcceptSuite}/CreateAnAcceptPaymentTransaction.java (100%) rename src/main/java/net/authorize/sample/{CustomerProfiles => AcceptSuite}/GetAcceptCustomerProfilePage.java (100%) rename src/main/java/net/authorize/sample/{PaymentTransactions => AcceptSuite}/GetAnAcceptPaymentPage.java (100%) diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/CreateAnAcceptPaymentTransaction.java b/src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptPaymentTransaction.java similarity index 100% rename from src/main/java/net/authorize/sample/PaymentTransactions/CreateAnAcceptPaymentTransaction.java rename to src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptPaymentTransaction.java diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/GetAcceptCustomerProfilePage.java b/src/main/java/net/authorize/sample/AcceptSuite/GetAcceptCustomerProfilePage.java similarity index 100% rename from src/main/java/net/authorize/sample/CustomerProfiles/GetAcceptCustomerProfilePage.java rename to src/main/java/net/authorize/sample/AcceptSuite/GetAcceptCustomerProfilePage.java diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/GetAnAcceptPaymentPage.java b/src/main/java/net/authorize/sample/AcceptSuite/GetAnAcceptPaymentPage.java similarity index 100% rename from src/main/java/net/authorize/sample/PaymentTransactions/GetAnAcceptPaymentPage.java rename to src/main/java/net/authorize/sample/AcceptSuite/GetAnAcceptPaymentPage.java From 9dfc1e6595e63bcb5f9d18d31eb2ece62c263a33 Mon Sep 17 00:00:00 2001 From: pavankumar Date: Tue, 20 Nov 2018 11:39:46 +0530 Subject: [PATCH 144/176] Sample code XSD changes --- .../sample/AcceptSuite/CreateAnAcceptPaymentTransaction.java | 2 +- .../sample/AcceptSuite/GetAcceptCustomerProfilePage.java | 2 +- .../authorize/sample/AcceptSuite/GetAnAcceptPaymentPage.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptPaymentTransaction.java b/src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptPaymentTransaction.java index cc8bb29e..a4b551ff 100644 --- a/src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptPaymentTransaction.java +++ b/src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptPaymentTransaction.java @@ -1,4 +1,4 @@ -package net.authorize.sample.PaymentTransactions; +package net.authorize.sample.AcceptSuite; import java.math.BigDecimal; import java.math.RoundingMode; diff --git a/src/main/java/net/authorize/sample/AcceptSuite/GetAcceptCustomerProfilePage.java b/src/main/java/net/authorize/sample/AcceptSuite/GetAcceptCustomerProfilePage.java index 050ae365..b9ff5fa7 100644 --- a/src/main/java/net/authorize/sample/AcceptSuite/GetAcceptCustomerProfilePage.java +++ b/src/main/java/net/authorize/sample/AcceptSuite/GetAcceptCustomerProfilePage.java @@ -1,4 +1,4 @@ -package net.authorize.sample.CustomerProfiles; +package net.authorize.sample.AcceptSuite; import net.authorize.Environment; import net.authorize.api.contract.v1.*; diff --git a/src/main/java/net/authorize/sample/AcceptSuite/GetAnAcceptPaymentPage.java b/src/main/java/net/authorize/sample/AcceptSuite/GetAnAcceptPaymentPage.java index 29624b33..5b3f9394 100644 --- a/src/main/java/net/authorize/sample/AcceptSuite/GetAnAcceptPaymentPage.java +++ b/src/main/java/net/authorize/sample/AcceptSuite/GetAnAcceptPaymentPage.java @@ -1,4 +1,4 @@ -package net.authorize.sample.PaymentTransactions; +package net.authorize.sample.AcceptSuite; import java.math.BigDecimal; import java.math.RoundingMode; From 52a8dc1fb552c6fde57d83b798012cbea0302752 Mon Sep 17 00:00:00 2001 From: pavankumar Date: Tue, 20 Nov 2018 12:24:36 +0530 Subject: [PATCH 145/176] XSD Sample code --- src/main/java/net/authorize/sample/SampleCode.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index 3e66e7e9..14a13fb0 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -13,6 +13,8 @@ import net.authorize.sample.CustomerProfiles.*; import net.authorize.sample.MobileInAppTransactions.*; import net.authorize.sample.FraudManagement.*; +import net.authorize.sample.AcceptSuite.GetAcceptCustomerProfilePage; +import net.authorize.sample.AcceptSuite.GetAnAcceptPaymentPage; /** * Created by anetdeveloper on 8/5/15. */ From 067463fd3acc83fa82f61aae3da6270a2edd33c8 Mon Sep 17 00:00:00 2001 From: pavankumar Date: Tue, 20 Nov 2018 12:33:07 +0530 Subject: [PATCH 146/176] XSD sample code changes --- .../java/net/authorize/sample/SampleCodeTest/TestRunner.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java index c8a30c8a..6aa8511e 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java +++ b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java @@ -32,6 +32,8 @@ import net.authorize.api.contract.v1.UpdateCustomerProfileResponse; import net.authorize.api.contract.v1.UpdateCustomerShippingAddressResponse; import net.authorize.api.contract.v1.ValidateCustomerPaymentProfileResponse; +import net.authorize.sample.AcceptSuite.GetAcceptCustomerProfilePage; +import net.authorize.sample.AcceptSuite.GetAnAcceptPaymentPage; import net.authorize.sample.CustomerProfiles.CreateCustomerPaymentProfile; import net.authorize.sample.CustomerProfiles.CreateCustomerProfile; import net.authorize.sample.CustomerProfiles.CreateCustomerProfileFromTransaction; @@ -42,7 +44,6 @@ import net.authorize.sample.CustomerProfiles.GetCustomerPaymentProfile; import net.authorize.sample.CustomerProfiles.GetCustomerProfile; import net.authorize.sample.CustomerProfiles.GetCustomerShippingAddress; -import net.authorize.sample.CustomerProfiles.GetAcceptCustomerProfilePage; import net.authorize.sample.CustomerProfiles.UpdateCustomerPaymentProfile; import net.authorize.sample.CustomerProfiles.UpdateCustomerProfile; import net.authorize.sample.CustomerProfiles.UpdateCustomerShippingAddress; @@ -71,7 +72,6 @@ import net.authorize.sample.RecurringBilling.GetSubscriptionStatus; import net.authorize.sample.RecurringBilling.UpdateSubscription; import net.authorize.sample.TransactionReporting.GetTransactionDetails; -import net.authorize.sample.PaymentTransactions.GetAnAcceptPaymentPage; public class TestRunner { From 2fa735e07fd10a9b050aa7a7ff4c2589026833d7 Mon Sep 17 00:00:00 2001 From: pavankumar Date: Tue, 20 Nov 2018 17:58:32 +0530 Subject: [PATCH 147/176] XSD Sample code --- src/main/java/net/authorize/sample/SampleCode.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index 14a13fb0..458f18ec 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -147,9 +147,9 @@ private static void RunMethod(String methodName) //Update the transactionId with which you want to run the sample code String transactionId = "123456"; - String customerProfileId = "37905546"; - String customerPaymentProfileId = "34461178"; - String customerAddressId = "1871959249"; + String customerProfileId = "36596285"; + String customerPaymentProfileId = "33086593"; + String customerAddressId = "1873761911"; String emailId = "test@test.com"; @@ -222,7 +222,7 @@ private static void RunMethod(String methodName) CreateSubscription.run(apiLoginId, transactionKey, (short)12, amount); break; case "CreateSubscriptionFromCustomerProfile": - CreateSubscriptionFromCustomerProfile.run(apiLoginId, transactionKey, (short)12, amount, "123212", "123213", "123213"); + CreateSubscriptionFromCustomerProfile.run(apiLoginId, transactionKey, (short)12, amount, customerProfileId, customerPaymentProfileId, amount); break; case "GetSubscription": GetSubscription.run(apiLoginId, transactionKey, subscriptionId); From ad4f71d2c8f5e72834d4758f8faaad72e2f4077a Mon Sep 17 00:00:00 2001 From: pavankumar Date: Wed, 21 Nov 2018 11:12:04 +0530 Subject: [PATCH 148/176] XSD Sample code changes --- src/main/java/net/authorize/sample/SampleCode.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index 458f18ec..faa57188 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -222,7 +222,7 @@ private static void RunMethod(String methodName) CreateSubscription.run(apiLoginId, transactionKey, (short)12, amount); break; case "CreateSubscriptionFromCustomerProfile": - CreateSubscriptionFromCustomerProfile.run(apiLoginId, transactionKey, (short)12, amount, customerProfileId, customerPaymentProfileId, amount); + CreateSubscriptionFromCustomerProfile.run(apiLoginId, transactionKey, (short)12, amount, customerProfileId, customerPaymentProfileId, customerAddressId); break; case "GetSubscription": GetSubscription.run(apiLoginId, transactionKey, subscriptionId); From 534c6c3ca3ed6b8e9ee9cd0882403b4c14894a45 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Fri, 7 Dec 2018 11:20:46 +0530 Subject: [PATCH 149/176] Update to latest version of SDK --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 28a8d486..bd7423fd 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ net.authorize anet-java-sdk - 1.9.7 + 1.9.9 junit From 80ba5533b21f5974ccaaaef7f0b401987676b4a6 Mon Sep 17 00:00:00 2001 From: pavankumar Date: Wed, 12 Dec 2018 10:47:05 +0530 Subject: [PATCH 150/176] Chase Pay Transaction changes in sample code --- .../CreateChasePayTransaction.java | 108 ++++++++++++++++++ .../java/net/authorize/sample/SampleCode.java | 4 + 2 files changed, 112 insertions(+) create mode 100644 src/main/java/net/authorize/sample/PaymentTransactions/CreateChasePayTransaction.java diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/CreateChasePayTransaction.java b/src/main/java/net/authorize/sample/PaymentTransactions/CreateChasePayTransaction.java new file mode 100644 index 00000000..d1e676b8 --- /dev/null +++ b/src/main/java/net/authorize/sample/PaymentTransactions/CreateChasePayTransaction.java @@ -0,0 +1,108 @@ +package net.authorize.sample.PaymentTransactions; + +import java.math.BigDecimal; +import java.math.RoundingMode; + +import net.authorize.Environment; +import net.authorize.api.contract.v1.ANetApiResponse; +import net.authorize.api.contract.v1.CreateTransactionRequest; +import net.authorize.api.contract.v1.CreateTransactionResponse; +import net.authorize.api.contract.v1.CreditCardType; +import net.authorize.api.contract.v1.MerchantAuthenticationType; +import net.authorize.api.contract.v1.MessageTypeEnum; +import net.authorize.api.contract.v1.PaymentType; +import net.authorize.api.contract.v1.TransactionRequestType; +import net.authorize.api.contract.v1.TransactionResponse; +import net.authorize.api.contract.v1.TransactionTypeEnum; +import net.authorize.api.controller.CreateTransactionController; +import net.authorize.api.controller.base.ApiOperationBase; + +public class CreateChasePayTransaction { + + // + // Run this sample from command line with: + // java -jar target/ChargeCreditCard-jar-with-dependencies.jar + // + public static ANetApiResponse run(String apiLoginId, String transactionKey, Double amount) { + + + //Common code to set for all requests + ApiOperationBase.setEnvironment(Environment.SANDBOX); + + MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; + merchantAuthenticationType.setName(apiLoginId); + merchantAuthenticationType.setTransactionKey(transactionKey); + ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); + + // Populate the payment data + PaymentType paymentType = new PaymentType(); + CreditCardType creditCard = new CreditCardType(); + creditCard.setCardNumber("4111111111111111"); + creditCard.setExpirationDate("2020-12"); + // Set the token specific info + creditCard.setIsPaymentToken(true); + creditCard.setCryptogram("EjRWeJASNFZ4kBI0VniQEjRWeJA="); + creditCard.setTokenRequestorName("CHASE_PAY"); + creditCard.setTokenRequestorId("12345678901"); + creditCard.setTokenRequestorEci("07"); + creditCard.setCardCode("999"); + paymentType.setCreditCard(creditCard); + + // Create the payment transaction request + TransactionRequestType txnRequest = new TransactionRequestType(); + txnRequest.setTransactionType(TransactionTypeEnum.AUTH_CAPTURE_TRANSACTION.value()); + txnRequest.setPayment(paymentType); + txnRequest.setAmount(new BigDecimal(amount).setScale(2, RoundingMode.CEILING)); + //txnRequest.s + // Make the API Request + CreateTransactionRequest apiRequest = new CreateTransactionRequest(); + apiRequest.setTransactionRequest(txnRequest); + //apiRequest.setRefId("123456"); + CreateTransactionController controller = new CreateTransactionController(apiRequest); + controller.execute(); + + + CreateTransactionResponse response = controller.getApiResponse(); + + if (response!=null) { + // If API Response is ok, go ahead and check the transaction response + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + TransactionResponse result = response.getTransactionResponse(); + if (result.getMessages() != null) { + System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Response Code: " + result.getResponseCode()); + System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); + System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); + System.out.println("Auth Code: " + result.getAuthCode()); + } + else { + System.out.println("Failed get Transaction."); + if (response.getTransactionResponse().getErrors() != null) { + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + } + } + else { + System.out.println("Failed get Transaction."); + if (response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null) { + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + else { + System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); + System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); + } + } + } + else { + System.out.println("Null Response."); + } + + return response; + + } + + + +} diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index faa57188..ea08a6c1 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -134,6 +134,7 @@ private static void ShowMethods() System.out.println(" GetHeldTransactionList"); System.out.println(" ApproveOrDeclineHeldTransaction"); System.out.println(" GetAnAcceptPaymentPage"); + System.out.println(" CreateChasePayTransaction"); } private static void RunMethod(String methodName) @@ -343,6 +344,9 @@ private static void RunMethod(String methodName) break; case "GetAnAcceptPaymentPage": GetAnAcceptPaymentPage.run(apiLoginId, transactionKey, amount); + break; + case "CreateChasePayTransaction": + CreateChasePayTransaction.run(apiLoginId, transactionKey, amount); break; default: ShowUsage(); From b27310b2aa2318e27ca28ac62679f1ddec9d1fd8 Mon Sep 17 00:00:00 2001 From: pavankumar Date: Wed, 12 Dec 2018 15:02:46 +0530 Subject: [PATCH 151/176] Chase pay changes in sample code --- .../CreateChasePayTransaction.java | 158 +++-- .../java/net/authorize/sample/SampleCode.java | 638 +++++++++--------- 2 files changed, 391 insertions(+), 405 deletions(-) diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/CreateChasePayTransaction.java b/src/main/java/net/authorize/sample/PaymentTransactions/CreateChasePayTransaction.java index d1e676b8..c0a4ca97 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/CreateChasePayTransaction.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/CreateChasePayTransaction.java @@ -19,90 +19,84 @@ public class CreateChasePayTransaction { - // - // Run this sample from command line with: - // java -jar target/ChargeCreditCard-jar-with-dependencies.jar - // - public static ANetApiResponse run(String apiLoginId, String transactionKey, Double amount) { + // + // Run this sample from command line with: + // + public static ANetApiResponse run(String apiLoginId, String transactionKey, Double amount) { + + // Common code to set for all requests + ApiOperationBase.setEnvironment(Environment.SANDBOX); + + MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType(); + merchantAuthenticationType.setName(apiLoginId); + merchantAuthenticationType.setTransactionKey(transactionKey); + ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); + + // Populate the payment data + PaymentType paymentType = new PaymentType(); + CreditCardType creditCard = new CreditCardType(); + creditCard.setCardNumber("4111111111111111"); + creditCard.setExpirationDate("2020-12"); + // Set the token specific info + creditCard.setIsPaymentToken(true); + creditCard.setCryptogram("EjRWeJASNFZ4kBI0VniQEjRWeJA="); + creditCard.setTokenRequestorName("CHASE_PAY"); + creditCard.setTokenRequestorId("12345678901"); + creditCard.setTokenRequestorEci("07"); + creditCard.setCardCode("999"); + paymentType.setCreditCard(creditCard); + + // Create the payment transaction request + TransactionRequestType txnRequest = new TransactionRequestType(); + txnRequest.setTransactionType(TransactionTypeEnum.AUTH_CAPTURE_TRANSACTION.value()); + txnRequest.setPayment(paymentType); + txnRequest.setAmount(new BigDecimal(amount).setScale(2, RoundingMode.CEILING)); + // Make the API Request + CreateTransactionRequest apiRequest = new CreateTransactionRequest(); + apiRequest.setTransactionRequest(txnRequest); + CreateTransactionController controller = new CreateTransactionController(apiRequest); + controller.execute(); + + CreateTransactionResponse response = controller.getApiResponse(); + + if (response != null) { + // If API Response is ok, go ahead and check the transaction response + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + TransactionResponse result = response.getTransactionResponse(); + if (result.getMessages() != null) { + System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Response Code: " + result.getResponseCode()); + System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); + System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); + System.out.println("Auth Code: " + result.getAuthCode()); + } else { + System.out.println("Failed get Transaction."); + if (response.getTransactionResponse().getErrors() != null) { + System.out.println("Error Code: " + + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + } + } else { + System.out.println("Failed get Transaction."); + if (response.getTransactionResponse() != null + && response.getTransactionResponse().getErrors() != null) { + System.out.println("Error Code: " + + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } else { + System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); + System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); + } + } + } else { + System.out.println("Null Response."); + } - - //Common code to set for all requests - ApiOperationBase.setEnvironment(Environment.SANDBOX); - - MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; - merchantAuthenticationType.setName(apiLoginId); - merchantAuthenticationType.setTransactionKey(transactionKey); - ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); - - // Populate the payment data - PaymentType paymentType = new PaymentType(); - CreditCardType creditCard = new CreditCardType(); - creditCard.setCardNumber("4111111111111111"); - creditCard.setExpirationDate("2020-12"); - // Set the token specific info - creditCard.setIsPaymentToken(true); - creditCard.setCryptogram("EjRWeJASNFZ4kBI0VniQEjRWeJA="); - creditCard.setTokenRequestorName("CHASE_PAY"); - creditCard.setTokenRequestorId("12345678901"); - creditCard.setTokenRequestorEci("07"); - creditCard.setCardCode("999"); - paymentType.setCreditCard(creditCard); - - // Create the payment transaction request - TransactionRequestType txnRequest = new TransactionRequestType(); - txnRequest.setTransactionType(TransactionTypeEnum.AUTH_CAPTURE_TRANSACTION.value()); - txnRequest.setPayment(paymentType); - txnRequest.setAmount(new BigDecimal(amount).setScale(2, RoundingMode.CEILING)); - //txnRequest.s - // Make the API Request - CreateTransactionRequest apiRequest = new CreateTransactionRequest(); - apiRequest.setTransactionRequest(txnRequest); - //apiRequest.setRefId("123456"); - CreateTransactionController controller = new CreateTransactionController(apiRequest); - controller.execute(); - - - CreateTransactionResponse response = controller.getApiResponse(); - - if (response!=null) { - // If API Response is ok, go ahead and check the transaction response - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { - TransactionResponse result = response.getTransactionResponse(); - if (result.getMessages() != null) { - System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); - System.out.println("Response Code: " + result.getResponseCode()); - System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); - System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); - System.out.println("Auth Code: " + result.getAuthCode()); - } - else { - System.out.println("Failed get Transaction."); - if (response.getTransactionResponse().getErrors() != null) { - System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); - System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); - } - } - } - else { - System.out.println("Failed get Transaction."); - if (response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null) { - System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); - System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); - } - else { - System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); - System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); - } - } - } - else { - System.out.println("Null Response."); - } - return response; - } - - + } } diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index ea08a6c1..c07a2824 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -15,342 +15,334 @@ import net.authorize.sample.FraudManagement.*; import net.authorize.sample.AcceptSuite.GetAcceptCustomerProfilePage; import net.authorize.sample.AcceptSuite.GetAnAcceptPaymentPage; + /** * Created by anetdeveloper on 8/5/15. */ public class SampleCode { - public static void main( String[] args ) - { + public static void main(String[] args) { + + if (args.length == 0) { + SelectMethod(); + } else if (args.length == 1) { + RunMethod(args[0]); + return; + } else { + ShowUsage(); + } + + System.out.println(""); + System.out.print("Press to finish ..."); + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + try { + int i = Integer.parseInt(br.readLine()); + } catch (Exception ex) { + } + + } + + private static void ShowUsage() { + System.out.println("Usage : java -jar SampleCode.jar [CodeSampleName]"); + System.out.println(""); + System.out.println("Run with no parameter to select a method. Otherwise pass a method name."); + System.out.println(""); + System.out.println("Code Sample Names: "); + ShowMethods(); + + } - if (args.length == 0) - { - SelectMethod(); - } - else if (args.length == 1) - { - RunMethod(args[0]); - return; - } - else - { - ShowUsage(); - } + private static void SelectMethod() { + System.out.println("Code Sample Names: "); + System.out.println(""); + ShowMethods(); + System.out.println(""); + System.out.print("Type a sample name & then press : "); + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + try { + RunMethod(br.readLine()); + } catch (Exception ex) { + System.out.println(ex.toString()); + } + } - System.out.println(""); - System.out.print("Press to finish ..."); - BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); - try{ - int i = Integer.parseInt(br.readLine()); - }catch(Exception ex) { - } + private static void ShowMethods() { + System.out.println(" DecryptVisaCheckoutData"); + System.out.println(" CreateVisaCheckoutTransaction"); + System.out.println(" ChargeCreditCard"); + System.out.println(" AuthorizeCreditCard"); + System.out.println(" RefundTransaction"); + System.out.println(" VoidTransaction"); + System.out.println(" CreateCustomerProfileFromTransaction"); + System.out.println(" CaptureFundsAuthorizedThroughAnotherChannel"); + System.out.println(" CapturePreviouslyAuthorizedAmount"); + System.out.println(" DebitBankAccount"); + System.out.println(" CreditBankAccount"); + System.out.println(" ChargeTokenizedCreditCard"); + System.out.println(" CreateAnApplePayTransaction"); + System.out.println(" CreateAnAndroidPayTransaction"); + System.out.println(" CreateAnAcceptTransaction"); + System.out.println(" ChargeCustomerProfile"); + System.out.println(" CreateSubscription"); + System.out.println(" CreateSubscriptionFromCustomerProfile"); + System.out.println(" GetSubscription"); + System.out.println(" GetSubscriptionStatus"); + System.out.println(" CancelSubscription"); + System.out.println(" UpdateSubscription"); + System.out.println(" GetListOfSubscriptions"); + System.out.println(" GetBatchStatistics"); + System.out.println(" GetSettledBatchList"); + System.out.println(" GetTransactionList"); + System.out.println(" GetUnsettledTransactionList"); + System.out.println(" GetTransactionDetails"); + System.out.println(" CreateCustomerProfile"); + System.out.println(" CreateCustomerPaymentProfile"); + System.out.println(" CreateCustomerShippingAddress"); + System.out.println(" DeleteCustomerPaymentProfile"); + System.out.println(" DeleteCustomerProfile"); + System.out.println(" DeleteCustomerShippingAddress"); + System.out.println(" GetCustomerPaymentProfile"); + System.out.println(" GetCustomerPaymentProfileList"); + System.out.println(" GetCustomerProfile"); + System.out.println(" GetCustomerProfileIds"); + System.out.println(" GetCustomerProfileTransactionList"); + System.out.println(" GetCustomerShippingAddress"); + System.out.println(" GetAcceptCustomerProfilePage"); + System.out.println(" UpdateCustomerProfile"); + System.out.println(" UpdateCustomerPaymentProfile"); + System.out.println(" UpdateCustomerShippingAddress"); + System.out.println(" ValidateCustomerPaymentProfile"); + System.out.println(" PayPalAuthorizeCapture"); + System.out.println(" PayPalVoid"); + System.out.println(" PayPalAuthorizationOnly"); + System.out.println(" PayPalAuthorizeCaptureContinued"); + System.out.println(" PayPalGetDetails"); + System.out.println(" PayPalPriorAuthorizationCapture"); + System.out.println(" PayPalAuthorizeOnlyContinued"); + System.out.println(" PayPalCredit"); + System.out.println(" UpdateSplitTenderGroup"); + System.out.println(" GetMerchantDetails"); + System.out.println(" GetHeldTransactionList"); + System.out.println(" ApproveOrDeclineHeldTransaction"); + System.out.println(" GetAnAcceptPaymentPage"); + System.out.println(" CreateChasePayTransaction"); + } - } + private static void RunMethod(String methodName) { + // These are default transaction keys. + // You can create your own keys in seconds by signing up for a sandbox account + // here: https://developer.authorize.net/sandbox/ + String apiLoginId = "5KP3u95bQpv"; + String transactionKey = "346HZ32z3fP4hTG2"; + // Update the payedId with which you want to run the sample code + String payerId = "6ZSCSYG33VP8Q"; + // Update the transactionId with which you want to run the sample code + String transactionId = "123456"; - private static void ShowUsage() - { - System.out.println("Usage : java -jar SampleCode.jar [CodeSampleName]"); - System.out.println(""); - System.out.println("Run with no parameter to select a method. Otherwise pass a method name."); - System.out.println(""); - System.out.println("Code Sample Names: "); - ShowMethods(); + String customerProfileId = "36596285"; + String customerPaymentProfileId = "33086593"; + String customerAddressId = "1873761911"; + String emailId = "test@test.com"; - } + String subscriptionId = "2925606"; - private static void SelectMethod() - { - System.out.println("Code Sample Names: "); - System.out.println(""); - ShowMethods(); - System.out.println(""); - System.out.print("Type a sample name & then press : "); - BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); - try{ - RunMethod(br.readLine()); - }catch(Exception ex) { - System.out.println(ex.toString()); - } - } + Double amount = 123.45; - private static void ShowMethods() - { - System.out.println(" DecryptVisaCheckoutData"); - System.out.println(" CreateVisaCheckoutTransaction"); - System.out.println(" ChargeCreditCard"); - System.out.println(" AuthorizeCreditCard"); - System.out.println(" RefundTransaction"); - System.out.println(" VoidTransaction"); - System.out.println(" CreateCustomerProfileFromTransaction"); - System.out.println(" CaptureFundsAuthorizedThroughAnotherChannel"); - System.out.println(" CapturePreviouslyAuthorizedAmount"); - System.out.println(" DebitBankAccount"); - System.out.println(" CreditBankAccount"); - System.out.println(" ChargeTokenizedCreditCard"); - System.out.println(" CreateAnApplePayTransaction"); - System.out.println(" CreateAnAndroidPayTransaction"); - System.out.println(" CreateAnAcceptTransaction"); - System.out.println(" ChargeCustomerProfile"); - System.out.println(" CreateSubscription"); - System.out.println(" CreateSubscriptionFromCustomerProfile"); - System.out.println(" GetSubscription"); - System.out.println(" GetSubscriptionStatus"); - System.out.println(" CancelSubscription"); - System.out.println(" UpdateSubscription"); - System.out.println(" GetListOfSubscriptions"); - System.out.println(" GetBatchStatistics"); - System.out.println(" GetSettledBatchList"); - System.out.println(" GetTransactionList"); - System.out.println(" GetUnsettledTransactionList"); - System.out.println(" GetTransactionDetails"); - System.out.println(" CreateCustomerProfile"); - System.out.println(" CreateCustomerPaymentProfile"); - System.out.println(" CreateCustomerShippingAddress"); - System.out.println(" DeleteCustomerPaymentProfile"); - System.out.println(" DeleteCustomerProfile"); - System.out.println(" DeleteCustomerShippingAddress"); - System.out.println(" GetCustomerPaymentProfile"); - System.out.println(" GetCustomerPaymentProfileList"); - System.out.println(" GetCustomerProfile"); - System.out.println(" GetCustomerProfileIds"); - System.out.println(" GetCustomerProfileTransactionList"); - System.out.println(" GetCustomerShippingAddress"); - System.out.println(" GetAcceptCustomerProfilePage"); - System.out.println(" UpdateCustomerProfile"); - System.out.println(" UpdateCustomerPaymentProfile"); - System.out.println(" UpdateCustomerShippingAddress"); - System.out.println(" ValidateCustomerPaymentProfile"); - System.out.println(" PayPalAuthorizeCapture"); - System.out.println(" PayPalVoid"); - System.out.println(" PayPalAuthorizationOnly"); - System.out.println(" PayPalAuthorizeCaptureContinued"); - System.out.println(" PayPalGetDetails"); - System.out.println(" PayPalPriorAuthorizationCapture"); - System.out.println(" PayPalAuthorizeOnlyContinued"); - System.out.println(" PayPalCredit"); - System.out.println(" UpdateSplitTenderGroup"); - System.out.println(" GetMerchantDetails"); - System.out.println(" GetHeldTransactionList"); - System.out.println(" ApproveOrDeclineHeldTransaction"); - System.out.println(" GetAnAcceptPaymentPage"); - System.out.println(" CreateChasePayTransaction"); - } + // Proxy server settings. + // Enable these lines for using Sample Codes behind a proxy server - private static void RunMethod(String methodName) - { - // These are default transaction keys. - // You can create your own keys in seconds by signing up for a sandbox account here: https://developer.authorize.net/sandbox/ - String apiLoginId = "5KP3u95bQpv"; - String transactionKey = "346HZ32z3fP4hTG2"; - //Update the payedId with which you want to run the sample code - String payerId = "6ZSCSYG33VP8Q"; - //Update the transactionId with which you want to run the sample code - String transactionId = "123456"; - - String customerProfileId = "36596285"; - String customerPaymentProfileId = "33086593"; - String customerAddressId = "1873761911"; - - String emailId = "test@test.com"; - - String subscriptionId = "2925606"; - - Double amount = 123.45; - -// Proxy server settings. -// Enable these lines for using Sample Codes behind a proxy server - -// System.setProperty("https.proxyUse", "true"); -// System.setProperty("https.proxyHost", "example.proxy.server"); -// System.setProperty("https.proxyPort", "portNumber"); -// System.setProperty("https.proxyUserName", "exampleUsername"); -// System.setProperty("https.proxyPassword", "examplePassword"); + // System.setProperty("https.proxyUse", "true"); + // System.setProperty("https.proxyHost", "example.proxy.server"); + // System.setProperty("https.proxyPort", "portNumber"); + // System.setProperty("https.proxyUserName", "exampleUsername"); + // System.setProperty("https.proxyPassword", "examplePassword"); - switch (methodName) { - case "DecryptVisaCheckoutData": - DecryptVisaCheckoutData.run(apiLoginId, transactionKey); - break; - case "CreateVisaCheckoutTransaction": - CreateVisaCheckoutTransaction.run(apiLoginId, transactionKey); - break; - case "ChargeCreditCard": - ChargeCreditCard.run(apiLoginId, transactionKey, amount); - break; - case "VoidTransaction": - VoidTransaction.run(apiLoginId, transactionKey, transactionId); - break; - case "AuthorizeCreditCard": - AuthorizeCreditCard.run(apiLoginId, transactionKey, amount); - break; - case "RefundTransaction": - RefundTransaction.run(apiLoginId, transactionKey , amount, transactionId); - break; - case "CreateCustomerProfileFromTransaction": - CreateCustomerProfileFromTransaction.run(apiLoginId, transactionKey, amount, emailId); - break; - case "CaptureFundsAuthorizedThroughAnotherChannel": - CaptureFundsAuthorizedThroughAnotherChannel.run(apiLoginId, transactionKey, amount); - break; - case "CapturePreviouslyAuthorizedAmount": - CapturePreviouslyAuthorizedAmount.run(apiLoginId, transactionKey, transactionId); - break; - case "DebitBankAccount": - DebitBankAccount.run(apiLoginId, transactionKey, amount); - break; - case "CreditBankAccount": - CreditBankAccount.run(apiLoginId, transactionKey, transactionId, amount); - break; - case "ChargeTokenizedCreditCard": - ChargeTokenizedCreditCard.run(apiLoginId, transactionKey, amount); - break; - case "CreateAnApplePayTransaction": - CreateAnApplePayTransaction.run(apiLoginId, transactionKey); - break; - case "CreateAnAndroidPayTransaction": - CreateAnAndroidPayTransaction.run(apiLoginId, transactionKey); - break; - case "CreateAnAcceptTransaction": - CreateAnAcceptTransaction.run(apiLoginId, transactionKey); - break; - case "ChargeCustomerProfile": - ChargeCustomerProfile.run(apiLoginId, transactionKey, customerProfileId, customerPaymentProfileId, amount); - break; - case "ChargeCustomerProfilesMT": - ChargeCustomerProfilesMT.run(); - break; - case "CreateSubscription": - CreateSubscription.run(apiLoginId, transactionKey, (short)12, amount); - break; - case "CreateSubscriptionFromCustomerProfile": - CreateSubscriptionFromCustomerProfile.run(apiLoginId, transactionKey, (short)12, amount, customerProfileId, customerPaymentProfileId, customerAddressId); - break; - case "GetSubscription": - GetSubscription.run(apiLoginId, transactionKey, subscriptionId); - break; - case "GetSubscriptionStatus": - GetSubscriptionStatus.run(apiLoginId, transactionKey, subscriptionId); - break; - case "CancelSubscription": - CancelSubscription.run(apiLoginId, transactionKey, subscriptionId); - break; - case "UpdateSubscription": - UpdateSubscription.run(apiLoginId, transactionKey, subscriptionId); - break; - case "GetListOfSubscriptions": - GetListOfSubscriptions.run(apiLoginId, transactionKey); - break; - case "GetBatchStatistics": - GetBatchStatistics.run(apiLoginId, transactionKey); - break; - case "GetSettledBatchList": - GetSettledBatchList.run(apiLoginId, transactionKey); - break; - case "GetTransactionList": - GetTransactionList.run(apiLoginId, transactionKey); - break; - case "GetUnsettledTransactionList": - GetUnsettledTransactionList.run(apiLoginId, transactionKey); - break; - case "GetTransactionDetails": - GetTransactionDetails.run(apiLoginId, transactionKey, transactionId); - break; - case "CreateCustomerProfile": - CreateCustomerProfile.run(apiLoginId, transactionKey, emailId); - break; - case "CreateCustomerPaymentProfile": - CreateCustomerPaymentProfile.run(apiLoginId, transactionKey, customerProfileId); - break; - case "CreateCustomerShippingAddress": - CreateCustomerShippingAddress.run(apiLoginId, transactionKey, customerProfileId); - break; - case "DeleteCustomerPaymentProfile": - DeleteCustomerPaymentProfile.run(apiLoginId, transactionKey, customerProfileId, customerPaymentProfileId); - break; - case "DeleteCustomerProfile": - DeleteCustomerProfile.run(apiLoginId, transactionKey, customerProfileId); - break; - case "DeleteCustomerShippingAddress": - DeleteCustomerShippingAddress.run(apiLoginId, transactionKey, customerProfileId, customerAddressId); - break; - case "GetCustomerPaymentProfile": - GetCustomerPaymentProfile.run(apiLoginId, transactionKey, customerProfileId, customerPaymentProfileId); - break; - case "GetCustomerPaymentProfileList": - GetCustomerPaymentProfileList.run(apiLoginId, transactionKey); - break; - case "GetCustomerProfile": - GetCustomerProfile.run(apiLoginId, transactionKey, customerProfileId); - break; - case "GetCustomerProfileIds": - GetCustomerProfileIds.run(apiLoginId, transactionKey); - break; - case "GetCustomerProfileTransactionList": - customerProfileId = "1811474252"; - GetCustomerProfileTransactionList.run(apiLoginId, transactionKey, customerProfileId); - break; - case "GetCustomerShippingAddress": - GetCustomerShippingAddress.run(apiLoginId, transactionKey, customerProfileId, customerAddressId); - break; - case "GetAcceptCustomerProfilePage": - GetAcceptCustomerProfilePage.run(apiLoginId, transactionKey, customerProfileId); - break; - case "UpdateCustomerProfile": - UpdateCustomerProfile.run(apiLoginId, transactionKey, customerProfileId); - break; - case "UpdateCustomerPaymentProfile": - UpdateCustomerPaymentProfile.run(apiLoginId, transactionKey, customerProfileId, customerPaymentProfileId); - break; - case "UpdateCustomerShippingAddress": - UpdateCustomerShippingAddress.run(apiLoginId, transactionKey, customerProfileId, customerAddressId); - break; - case "ValidateCustomerPaymentProfile": - ValidateCustomerPaymentProfile.run(apiLoginId, transactionKey, customerProfileId, customerPaymentProfileId); - break; - case "PayPalAuthorizeCapture": - AuthorizationAndCapture.run(apiLoginId, transactionKey, amount); - break; - case "PayPalVoid": - Void.run(apiLoginId, transactionKey, transactionId); - break; - case "PayPalAuthorizationOnly": - AuthorizationOnly.run(apiLoginId, transactionKey, amount); - break; - case "PayPalAuthorizeCaptureContinued": - AuthorizationAndCaptureContinued.run(apiLoginId, transactionKey, transactionId, payerId, amount); - break; - case "PayPalAuthorizeOnlyContinued": - AuthorizationOnlyContinued.run(apiLoginId, transactionKey, transactionId, payerId, amount); - break; - case "PayPalCredit": - Credit.run(apiLoginId, transactionKey, transactionId); - break; - case "PayPalGetDetails": - GetDetails.run(apiLoginId, transactionKey, transactionId); - case "PayPalPriorAuthorizationCapture": - PriorAuthorizationCapture.run(apiLoginId, transactionKey, transactionId); - break; - case "UpdateSplitTenderGroup": - UpdateSplitTenderGroup.run(apiLoginId, transactionKey); - break; - case "GetMerchantDetails": - GetMerchantDetails.run(apiLoginId, transactionKey); - break; - case "GetHeldTransactionList": - GetHeldTransactionList.run(apiLoginId, transactionKey); - break; - case "ApproveOrDeclineHeldTransaction": - ApproveOrDeclineHeldTransaction.run(apiLoginId, transactionKey, transactionId); - break; - case "GetAnAcceptPaymentPage": - GetAnAcceptPaymentPage.run(apiLoginId, transactionKey, amount); - break; - case "CreateChasePayTransaction": - CreateChasePayTransaction.run(apiLoginId, transactionKey, amount); - break; - default: - ShowUsage(); - break; - } - } + switch (methodName) { + case "DecryptVisaCheckoutData": + DecryptVisaCheckoutData.run(apiLoginId, transactionKey); + break; + case "CreateVisaCheckoutTransaction": + CreateVisaCheckoutTransaction.run(apiLoginId, transactionKey); + break; + case "ChargeCreditCard": + ChargeCreditCard.run(apiLoginId, transactionKey, amount); + break; + case "VoidTransaction": + VoidTransaction.run(apiLoginId, transactionKey, transactionId); + break; + case "AuthorizeCreditCard": + AuthorizeCreditCard.run(apiLoginId, transactionKey, amount); + break; + case "RefundTransaction": + RefundTransaction.run(apiLoginId, transactionKey, amount, transactionId); + break; + case "CreateCustomerProfileFromTransaction": + CreateCustomerProfileFromTransaction.run(apiLoginId, transactionKey, amount, emailId); + break; + case "CaptureFundsAuthorizedThroughAnotherChannel": + CaptureFundsAuthorizedThroughAnotherChannel.run(apiLoginId, transactionKey, amount); + break; + case "CapturePreviouslyAuthorizedAmount": + CapturePreviouslyAuthorizedAmount.run(apiLoginId, transactionKey, transactionId); + break; + case "DebitBankAccount": + DebitBankAccount.run(apiLoginId, transactionKey, amount); + break; + case "CreditBankAccount": + CreditBankAccount.run(apiLoginId, transactionKey, transactionId, amount); + break; + case "ChargeTokenizedCreditCard": + ChargeTokenizedCreditCard.run(apiLoginId, transactionKey, amount); + break; + case "CreateAnApplePayTransaction": + CreateAnApplePayTransaction.run(apiLoginId, transactionKey); + break; + case "CreateAnAndroidPayTransaction": + CreateAnAndroidPayTransaction.run(apiLoginId, transactionKey); + break; + case "CreateAnAcceptTransaction": + CreateAnAcceptTransaction.run(apiLoginId, transactionKey); + break; + case "ChargeCustomerProfile": + ChargeCustomerProfile.run(apiLoginId, transactionKey, customerProfileId, customerPaymentProfileId, amount); + break; + case "ChargeCustomerProfilesMT": + ChargeCustomerProfilesMT.run(); + break; + case "CreateSubscription": + CreateSubscription.run(apiLoginId, transactionKey, (short) 12, amount); + break; + case "CreateSubscriptionFromCustomerProfile": + CreateSubscriptionFromCustomerProfile.run(apiLoginId, transactionKey, (short) 12, amount, customerProfileId, + customerPaymentProfileId, customerAddressId); + break; + case "GetSubscription": + GetSubscription.run(apiLoginId, transactionKey, subscriptionId); + break; + case "GetSubscriptionStatus": + GetSubscriptionStatus.run(apiLoginId, transactionKey, subscriptionId); + break; + case "CancelSubscription": + CancelSubscription.run(apiLoginId, transactionKey, subscriptionId); + break; + case "UpdateSubscription": + UpdateSubscription.run(apiLoginId, transactionKey, subscriptionId); + break; + case "GetListOfSubscriptions": + GetListOfSubscriptions.run(apiLoginId, transactionKey); + break; + case "GetBatchStatistics": + GetBatchStatistics.run(apiLoginId, transactionKey); + break; + case "GetSettledBatchList": + GetSettledBatchList.run(apiLoginId, transactionKey); + break; + case "GetTransactionList": + GetTransactionList.run(apiLoginId, transactionKey); + break; + case "GetUnsettledTransactionList": + GetUnsettledTransactionList.run(apiLoginId, transactionKey); + break; + case "GetTransactionDetails": + GetTransactionDetails.run(apiLoginId, transactionKey, transactionId); + break; + case "CreateCustomerProfile": + CreateCustomerProfile.run(apiLoginId, transactionKey, emailId); + break; + case "CreateCustomerPaymentProfile": + CreateCustomerPaymentProfile.run(apiLoginId, transactionKey, customerProfileId); + break; + case "CreateCustomerShippingAddress": + CreateCustomerShippingAddress.run(apiLoginId, transactionKey, customerProfileId); + break; + case "DeleteCustomerPaymentProfile": + DeleteCustomerPaymentProfile.run(apiLoginId, transactionKey, customerProfileId, customerPaymentProfileId); + break; + case "DeleteCustomerProfile": + DeleteCustomerProfile.run(apiLoginId, transactionKey, customerProfileId); + break; + case "DeleteCustomerShippingAddress": + DeleteCustomerShippingAddress.run(apiLoginId, transactionKey, customerProfileId, customerAddressId); + break; + case "GetCustomerPaymentProfile": + GetCustomerPaymentProfile.run(apiLoginId, transactionKey, customerProfileId, customerPaymentProfileId); + break; + case "GetCustomerPaymentProfileList": + GetCustomerPaymentProfileList.run(apiLoginId, transactionKey); + break; + case "GetCustomerProfile": + GetCustomerProfile.run(apiLoginId, transactionKey, customerProfileId); + break; + case "GetCustomerProfileIds": + GetCustomerProfileIds.run(apiLoginId, transactionKey); + break; + case "GetCustomerProfileTransactionList": + customerProfileId = "1811474252"; + GetCustomerProfileTransactionList.run(apiLoginId, transactionKey, customerProfileId); + break; + case "GetCustomerShippingAddress": + GetCustomerShippingAddress.run(apiLoginId, transactionKey, customerProfileId, customerAddressId); + break; + case "GetAcceptCustomerProfilePage": + GetAcceptCustomerProfilePage.run(apiLoginId, transactionKey, customerProfileId); + break; + case "UpdateCustomerProfile": + UpdateCustomerProfile.run(apiLoginId, transactionKey, customerProfileId); + break; + case "UpdateCustomerPaymentProfile": + UpdateCustomerPaymentProfile.run(apiLoginId, transactionKey, customerProfileId, customerPaymentProfileId); + break; + case "UpdateCustomerShippingAddress": + UpdateCustomerShippingAddress.run(apiLoginId, transactionKey, customerProfileId, customerAddressId); + break; + case "ValidateCustomerPaymentProfile": + ValidateCustomerPaymentProfile.run(apiLoginId, transactionKey, customerProfileId, customerPaymentProfileId); + break; + case "PayPalAuthorizeCapture": + AuthorizationAndCapture.run(apiLoginId, transactionKey, amount); + break; + case "PayPalVoid": + Void.run(apiLoginId, transactionKey, transactionId); + break; + case "PayPalAuthorizationOnly": + AuthorizationOnly.run(apiLoginId, transactionKey, amount); + break; + case "PayPalAuthorizeCaptureContinued": + AuthorizationAndCaptureContinued.run(apiLoginId, transactionKey, transactionId, payerId, amount); + break; + case "PayPalAuthorizeOnlyContinued": + AuthorizationOnlyContinued.run(apiLoginId, transactionKey, transactionId, payerId, amount); + break; + case "PayPalCredit": + Credit.run(apiLoginId, transactionKey, transactionId); + break; + case "PayPalGetDetails": + GetDetails.run(apiLoginId, transactionKey, transactionId); + case "PayPalPriorAuthorizationCapture": + PriorAuthorizationCapture.run(apiLoginId, transactionKey, transactionId); + break; + case "UpdateSplitTenderGroup": + UpdateSplitTenderGroup.run(apiLoginId, transactionKey); + break; + case "GetMerchantDetails": + GetMerchantDetails.run(apiLoginId, transactionKey); + break; + case "GetHeldTransactionList": + GetHeldTransactionList.run(apiLoginId, transactionKey); + break; + case "ApproveOrDeclineHeldTransaction": + ApproveOrDeclineHeldTransaction.run(apiLoginId, transactionKey, transactionId); + break; + case "GetAnAcceptPaymentPage": + GetAnAcceptPaymentPage.run(apiLoginId, transactionKey, amount); + break; + case "CreateChasePayTransaction": + CreateChasePayTransaction.run(apiLoginId, transactionKey, amount); + break; + default: + ShowUsage(); + break; + } + } } From 59067bc95140f2bc3a8bcb22ae18206ca8d72328 Mon Sep 17 00:00:00 2001 From: KarthikeyanKumar Date: Thu, 7 Feb 2019 16:58:24 +0530 Subject: [PATCH 152/176] Create ComputeTransHashSHA2.java This is sample code to compute hmac sha 512 for a transaction for Authorize.net --- .../sample/Sha512/ComputeTransHashSHA2.java | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 src/main/java/net/authorize/sample/Sha512/ComputeTransHashSHA2.java diff --git a/src/main/java/net/authorize/sample/Sha512/ComputeTransHashSHA2.java b/src/main/java/net/authorize/sample/Sha512/ComputeTransHashSHA2.java new file mode 100644 index 00000000..2a3a146e --- /dev/null +++ b/src/main/java/net/authorize/sample/Sha512/ComputeTransHashSHA2.java @@ -0,0 +1,99 @@ +package net.authorize.sample.Sha512; + +import java.security.*; +import java.util.Formatter; + +import javax.crypto.Mac; +import javax.crypto.spec.SecretKeySpec; + +public class ComputeTransHashSHA2 { + + public static void main(String[] args) throws Exception { + String signatureKey = "56E529FE6C63D60E545F84686096E6AA01D5E18A119F18A130F7CFB3983104216979E95D84C91BDD382AA0875264A63940A2D0AA5548F6023B4C78A9D52C18DA"; + String transId = "60115868980"; + String apiLogin = "5T9cRn9FK"; + String amount = "15.00"; + //transHashSHA2 represents the computed TransHash2 using SignatureKey for the given transaction + //textToHash is formed by concatenating apilogin id , transId for the given transaction and transaction amount. + // For more details please visit https://developer.authorize.net/support/hash_upgrade/?utm_campaign=19Q2%20MD5%20Hash%20EOL%20Partner&utm_medium=email&utm_source=Eloqua for implementation details. + String transHashSHA2=getHMACSHA512(signatureKey, "^"+ apiLogin+"^"+ transId +"^"+ amount+"^"); + } + + /** + * This is method to generate HMAC512 key for a given signature key and Text to Hash + * @param signatureKey + * @param textToHash + * @return + * @throws Exception + */ + public static String getHMACSHA512(String signatureKey, String textToHash)throws Exception + { + // Check if Key is null or empty + if (signatureKey==null||signatureKey.isEmpty()) + throw new IllegalArgumentException("HMACSHA512: key Parameter cannot be empty."); + //Check if texttoHash is null or empty + if (textToHash==null||textToHash.isEmpty()) + throw new IllegalArgumentException("HMACSHA512: textToHash Parameter cannot be empty."); + + // Signature Key size cannot be less than 2 or odd + if (signatureKey.length() % 2 != 0 || signatureKey.trim().length() < 2) + { + throw new IllegalArgumentException("HMACSHA512: key Parameter cannot be odd or less than 2 characters."); + } + + // Convert Hex string to byte array + byte signatureKeyInByteArray[]=hexStringToByteArray(signatureKey); + // Calculate hmac 512 for the byte array contents and text to hash. + String hashedValue=calculateHMAC(signatureKeyInByteArray,textToHash); + if(hashedValue==null) + throw new NullPointerException("For Signature Key :["+signatureKey+"] And Text To Hash ["+textToHash+"] the generated HMAC512 Key is null .Please contact Authorize.net for more information"); + + return hashedValue.toUpperCase(); + } + + /** + * This is the method to Calculate Hmac sha512 for given signature signatureKey in byte array and text to hash in byte array + * @param signatureKey + * @param textToHash + * @return + * @throws SignatureException + * @throws NoSuchAlgorithmException + * @throws InvalidKeyException + */ + public static String calculateHMAC(byte signatureKey[], String textToHash) + throws SignatureException, NoSuchAlgorithmException, InvalidKeyException + { + SecretKeySpec secretKeySpec = new SecretKeySpec(signatureKey, "HmacSHA512"); + Mac mac = Mac.getInstance("HmacSHA512"); + mac.init(secretKeySpec); + return toHexString(mac.doFinal(textToHash.getBytes())); + } + + /** + * This is the method to convert byte array into hexadecimal string + * @param bytes + * @return hexadecimal string. + */ + private static String toHexString(byte[] bytes) { + Formatter formatter = new Formatter(); + for (byte b : bytes) { + formatter.format("%02x", b); + } + return formatter.toString(); + } + + /** + * This is the method convert hexadecimal string to byte array + * @param str + * @return byte array + */ + public static byte[] hexStringToByteArray(String str) { + int len = str.length(); + byte[] data = new byte[len / 2]; + for (int i = 0; i < len; i += 2) { + data[i / 2] = (byte) ((Character.digit(str.charAt(i), 16) << 4) + + Character.digit(str.charAt(i+1), 16)); + } + return data; + } +} From 7c8c224b8c72f8daeda9c7c1a01a20827d37e233 Mon Sep 17 00:00:00 2001 From: Kaushik Mahato Date: Tue, 5 Mar 2019 12:40:25 +0530 Subject: [PATCH 153/176] Update SDK dependency to 2.0.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bd7423fd..fb12cc2e 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ net.authorize anet-java-sdk - 1.9.9 + 2.0.0 junit From b6d3a14f157d2bc8a49ff0ee211fc6405860c4fb Mon Sep 17 00:00:00 2001 From: Kaushik Date: Tue, 5 Mar 2019 12:55:31 +0530 Subject: [PATCH 154/176] Remove unused imports --- .../CustomerProfiles/CreateCustomerPaymentProfile.java | 8 -------- .../sample/RecurringBilling/CancelSubscription.java | 4 ---- .../sample/RecurringBilling/GetSubscriptionStatus.java | 4 ---- .../sample/RecurringBilling/UpdateSubscription.java | 4 ---- 4 files changed, 20 deletions(-) diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerPaymentProfile.java b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerPaymentProfile.java index f377e88d..ecbbebb3 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerPaymentProfile.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerPaymentProfile.java @@ -4,16 +4,8 @@ import net.authorize.api.contract.v1.*; import net.authorize.api.contract.v1.MerchantAuthenticationType; -import net.authorize.api.controller.base.ApiOperationBase; - -import net.authorize.Transaction; -import net.authorize.api.controller.CreateCustomerProfileController; -import net.authorize.api.controller.CreateCustomerProfileFromTransactionController; import net.authorize.api.controller.CreateCustomerPaymentProfileController; import net.authorize.api.controller.base.ApiOperationBase; -import net.authorize.cim.Result; -import net.authorize.cim.TransactionType; -import net.authorize.cim.ValidationModeType; //author @krgupta public class CreateCustomerPaymentProfile { diff --git a/src/main/java/net/authorize/sample/RecurringBilling/CancelSubscription.java b/src/main/java/net/authorize/sample/RecurringBilling/CancelSubscription.java index 95746019..5e55f8b0 100644 --- a/src/main/java/net/authorize/sample/RecurringBilling/CancelSubscription.java +++ b/src/main/java/net/authorize/sample/RecurringBilling/CancelSubscription.java @@ -1,13 +1,9 @@ package net.authorize.sample.RecurringBilling; -import net.authorize.data.arb.*; -import java.math.BigDecimal; import net.authorize.Environment; -import net.authorize.data.Customer; import net.authorize.api.contract.v1.*; import net.authorize.api.controller.base.ApiOperationBase; import net.authorize.api.controller.ARBCancelSubscriptionController; -import javax.xml.datatype.XMLGregorianCalendar; public class CancelSubscription { diff --git a/src/main/java/net/authorize/sample/RecurringBilling/GetSubscriptionStatus.java b/src/main/java/net/authorize/sample/RecurringBilling/GetSubscriptionStatus.java index 14c89f8b..8492c365 100644 --- a/src/main/java/net/authorize/sample/RecurringBilling/GetSubscriptionStatus.java +++ b/src/main/java/net/authorize/sample/RecurringBilling/GetSubscriptionStatus.java @@ -1,13 +1,9 @@ package net.authorize.sample.RecurringBilling; -import net.authorize.data.arb.*; -import java.math.BigDecimal; import net.authorize.Environment; -import net.authorize.data.Customer; import net.authorize.api.contract.v1.*; import net.authorize.api.controller.base.ApiOperationBase; import net.authorize.api.controller.ARBGetSubscriptionStatusController; -import javax.xml.datatype.XMLGregorianCalendar; public class GetSubscriptionStatus { diff --git a/src/main/java/net/authorize/sample/RecurringBilling/UpdateSubscription.java b/src/main/java/net/authorize/sample/RecurringBilling/UpdateSubscription.java index 04e0c127..266874ba 100644 --- a/src/main/java/net/authorize/sample/RecurringBilling/UpdateSubscription.java +++ b/src/main/java/net/authorize/sample/RecurringBilling/UpdateSubscription.java @@ -1,13 +1,9 @@ package net.authorize.sample.RecurringBilling; -import net.authorize.data.arb.*; -import java.math.BigDecimal; import net.authorize.Environment; -import net.authorize.data.Customer; import net.authorize.api.contract.v1.*; import net.authorize.api.controller.base.ApiOperationBase; import net.authorize.api.controller.ARBUpdateSubscriptionController; -import javax.xml.datatype.XMLGregorianCalendar; public class UpdateSubscription { From 800e75d37ecb54b33f7f2b94e63c541ecb32124f Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Wed, 20 Mar 2019 16:34:35 +0530 Subject: [PATCH 155/176] Updating to latest version of the SDK --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fb12cc2e..b5631847 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ net.authorize anet-java-sdk - 2.0.0 + 2.0.1 junit From 0fb9586ee2e79d3b8f8295d8ccefb848c223c3f1 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Wed, 20 Mar 2019 17:16:46 +0530 Subject: [PATCH 156/176] Removing unused imports of deprecated code --- .../MobileInAppTransactions/CreateAnAcceptTransaction.java | 1 - .../MobileInAppTransactions/CreateAnAndroidPayTransaction.java | 1 - .../MobileInAppTransactions/CreateAnApplePayTransaction.java | 1 - 3 files changed, 3 deletions(-) diff --git a/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAcceptTransaction.java b/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAcceptTransaction.java index 58df0c52..cb0769df 100644 --- a/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAcceptTransaction.java +++ b/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAcceptTransaction.java @@ -2,7 +2,6 @@ import java.math.BigDecimal; import net.authorize.Environment; -import net.authorize.TransactionType; import net.authorize.api.contract.v1.*; import net.authorize.api.controller.CreateTransactionController; import net.authorize.api.controller.base.ApiOperationBase; diff --git a/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAndroidPayTransaction.java b/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAndroidPayTransaction.java index cc7eb6dc..0f1287d0 100644 --- a/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAndroidPayTransaction.java +++ b/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAndroidPayTransaction.java @@ -2,7 +2,6 @@ import java.math.BigDecimal; import net.authorize.Environment; -import net.authorize.TransactionType; import net.authorize.api.contract.v1.*; import net.authorize.api.controller.CreateTransactionController; import net.authorize.api.controller.base.ApiOperationBase; diff --git a/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnApplePayTransaction.java b/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnApplePayTransaction.java index bcce6929..f75feae4 100644 --- a/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnApplePayTransaction.java +++ b/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnApplePayTransaction.java @@ -2,7 +2,6 @@ import java.math.BigDecimal; import net.authorize.Environment; -import net.authorize.TransactionType; import net.authorize.api.contract.v1.*; import net.authorize.api.controller.CreateTransactionController; import net.authorize.api.controller.base.ApiOperationBase; From 63f849e37d36ebb3689bd605d3616c8338865bf2 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Tue, 20 Aug 2019 13:31:14 +0530 Subject: [PATCH 157/176] Update .travis.yml --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 383c89dc..fca8ffae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,7 @@ language: java + +dist: trusty sudo: false From 9a0a57a6eb474d78e6efd5038c6285a0dfc901c0 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Mon, 28 Oct 2019 15:11:38 +0530 Subject: [PATCH 158/176] Fixing proxy settings --- README.md | 10 +++++----- src/main/java/net/authorize/sample/SampleCode.java | 11 ++++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index f11cc20f..80f6db04 100644 --- a/README.md +++ b/README.md @@ -34,14 +34,14 @@ Running SampleCode without a parameter will give you the list of sample names. Please set the JAVA environment proxy using a similar code : ``` - System.setProperty("https.proxyUse", "true"); - System.setProperty("https.proxyHost", "127.0.0.1"); - System.setProperty("https.proxyPort", "3128"); + System.setProperty(Constants.HTTPS_USE_PROXY, "true"); + System.setProperty(Constants.HTTPS_PROXY_HOST, "127.0.0.1"); + System.setProperty(Constants.HTTPS_PROXY_PORT, "8888"); ``` **For using proxy authentication** Please set the JAVA environment proxy credentials using a similar code : ``` - System.setProperty("https.proxyUserName", "exampleUsername"); - System.setProperty("https.proxyPassword", "examplePassword"); + System.setProperty(Constants.HTTPS_PROXY_USERNAME, "exampleUsername"); + System.setProperty(Constants.HTTPS_PROXY_PASSWORD, "examplePassword"); ``` diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index c07a2824..be29938c 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -5,6 +5,7 @@ import java.io.InputStreamReader; import net.authorize.sample.VisaCheckout.*; +import net.authorize.util.Constants; import net.authorize.sample.PaymentTransactions.*; import net.authorize.sample.PayPalExpressCheckout.*; import net.authorize.sample.PayPalExpressCheckout.Void; @@ -152,11 +153,11 @@ private static void RunMethod(String methodName) { // Proxy server settings. // Enable these lines for using Sample Codes behind a proxy server - // System.setProperty("https.proxyUse", "true"); - // System.setProperty("https.proxyHost", "example.proxy.server"); - // System.setProperty("https.proxyPort", "portNumber"); - // System.setProperty("https.proxyUserName", "exampleUsername"); - // System.setProperty("https.proxyPassword", "examplePassword"); +// System.setProperty(Constants.HTTPS_USE_PROXY, "true"); +// System.setProperty(Constants.HTTPS_PROXY_HOST , "example.proxy.server"); +// System.setProperty(Constants.HTTPS_PROXY_PORT, "portNumber"); +// System.setProperty(Constants.HTTPS_PROXY_USERNAME, "exampleUsername"); +// System.setProperty(Constants.HTTPS_PROXY_PASSWORD, "examplePassword"); switch (methodName) { case "DecryptVisaCheckoutData": From 26915a9201b6ebed3b3b5c616107cba72f731ce5 Mon Sep 17 00:00:00 2001 From: Kaushik Mahato Date: Mon, 28 Oct 2019 17:00:53 +0530 Subject: [PATCH 159/176] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 80f6db04..91b398f6 100644 --- a/README.md +++ b/README.md @@ -35,8 +35,8 @@ Running SampleCode without a parameter will give you the list of sample names. Please set the JAVA environment proxy using a similar code : ``` System.setProperty(Constants.HTTPS_USE_PROXY, "true"); - System.setProperty(Constants.HTTPS_PROXY_HOST, "127.0.0.1"); - System.setProperty(Constants.HTTPS_PROXY_PORT, "8888"); + System.setProperty(Constants.HTTPS_PROXY_HOST, "127.0.0.1"); + System.setProperty(Constants.HTTPS_PROXY_PORT, "8888"); ``` **For using proxy authentication** From 097ae9cbb0c3f84aea41820e680acbeca523d26c Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Wed, 4 Mar 2020 12:52:12 +0530 Subject: [PATCH 160/176] Renamed Visa Checkout to Visa SRC --- ...CheckoutTransaction.java => CreateVisaSrcTransaction.java} | 4 ++-- .../{DecryptVisaCheckoutData.java => DecryptVisaSrcData.java} | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename src/main/java/net/authorize/sample/VisaCheckout/{CreateVisaCheckoutTransaction.java => CreateVisaSrcTransaction.java} (98%) rename src/main/java/net/authorize/sample/VisaCheckout/{DecryptVisaCheckoutData.java => DecryptVisaSrcData.java} (99%) diff --git a/src/main/java/net/authorize/sample/VisaCheckout/CreateVisaCheckoutTransaction.java b/src/main/java/net/authorize/sample/VisaCheckout/CreateVisaSrcTransaction.java similarity index 98% rename from src/main/java/net/authorize/sample/VisaCheckout/CreateVisaCheckoutTransaction.java rename to src/main/java/net/authorize/sample/VisaCheckout/CreateVisaSrcTransaction.java index f936546d..c449e173 100644 --- a/src/main/java/net/authorize/sample/VisaCheckout/CreateVisaCheckoutTransaction.java +++ b/src/main/java/net/authorize/sample/VisaCheckout/CreateVisaSrcTransaction.java @@ -20,9 +20,9 @@ // // Run this sample by doing mvn package, // then -// java -jar target/VisaCheckoutTransaction-jar-with-dependencies.jar +// java -jar target/CreateVisaSrcTransaction-jar-with-dependencies.jar // -public class CreateVisaCheckoutTransaction { +public class CreateVisaSrcTransaction { public static ANetApiResponse run(String apiLoginId, String transactionKey) { diff --git a/src/main/java/net/authorize/sample/VisaCheckout/DecryptVisaCheckoutData.java b/src/main/java/net/authorize/sample/VisaCheckout/DecryptVisaSrcData.java similarity index 99% rename from src/main/java/net/authorize/sample/VisaCheckout/DecryptVisaCheckoutData.java rename to src/main/java/net/authorize/sample/VisaCheckout/DecryptVisaSrcData.java index 90f95ce7..d470cb78 100644 --- a/src/main/java/net/authorize/sample/VisaCheckout/DecryptVisaCheckoutData.java +++ b/src/main/java/net/authorize/sample/VisaCheckout/DecryptVisaSrcData.java @@ -10,7 +10,7 @@ import net.authorize.api.contract.v1.MessageTypeEnum; import net.authorize.api.controller.DecryptPaymentDataController; -public class DecryptVisaCheckoutData { +public class DecryptVisaSrcData { public static ANetApiResponse run(String apiLoginId, String transactionKey) { From ca8ead2be430f2780ff57a67c5e33364bf72b998 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Wed, 4 Mar 2020 12:59:33 +0530 Subject: [PATCH 161/176] Renamed Visa Checkout to Visa SRC --- src/main/java/net/authorize/sample/SampleCode.java | 12 ++++++------ .../sample/SampleCodeTest/SampleCodeList.txt | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index be29938c..4fe2225d 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -68,8 +68,8 @@ private static void SelectMethod() { } private static void ShowMethods() { - System.out.println(" DecryptVisaCheckoutData"); - System.out.println(" CreateVisaCheckoutTransaction"); + System.out.println(" DecryptVisaSrcData"); + System.out.println(" CreateVisaSrcTransaction"); System.out.println(" ChargeCreditCard"); System.out.println(" AuthorizeCreditCard"); System.out.println(" RefundTransaction"); @@ -160,11 +160,11 @@ private static void RunMethod(String methodName) { // System.setProperty(Constants.HTTPS_PROXY_PASSWORD, "examplePassword"); switch (methodName) { - case "DecryptVisaCheckoutData": - DecryptVisaCheckoutData.run(apiLoginId, transactionKey); + case "DecryptVisaSrcData": + DecryptVisaSrcData.run(apiLoginId, transactionKey); break; - case "CreateVisaCheckoutTransaction": - CreateVisaCheckoutTransaction.run(apiLoginId, transactionKey); + case "CreateVisaSrcTransaction": + CreateVisaSrcTransaction.run(apiLoginId, transactionKey); break; case "ChargeCreditCard": ChargeCreditCard.run(apiLoginId, transactionKey, amount); diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt b/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt index c794b052..16146d27 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt +++ b/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt @@ -54,5 +54,5 @@ TransactionReporting.GetMerchantDetails 0 1 MobileInAppTransactions.CreateAnApplePayTransaction 0 0 MobileInAppTransactions.CreateAnAndroidPayTransaction 0 0 MobileInAppTransactions.CreateAnAcceptTransaction 0 0 -VisaCheckout.DecryptVisaCheckoutData 0 1 -VisaCheckout.CreateVisaCheckoutTransaction 0 0 +VisaCheckout.DecryptVisaSrcData 0 1 +VisaCheckout.CreateVisaSrcTransaction 0 0 From 88cc556b00990683dfeab289a266b48d08b761c3 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Wed, 4 Mar 2020 13:10:39 +0530 Subject: [PATCH 162/176] Blocking GetCustomerProfileIds call as response exceeds log limit --- .../java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt b/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt index 16146d27..72677915 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt +++ b/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt @@ -11,7 +11,7 @@ CustomerProfiles.UpdateCustomerShippingAddress 1 1 CustomerProfiles.UpdateCustomerProfile 1 1 CustomerProfiles.UpdateCustomerPaymentProfile 1 1 CustomerProfiles.GetCustomerShippingAddress 1 1 -CustomerProfiles.GetCustomerProfileIds 0 1 +CustomerProfiles.GetCustomerProfileIds 0 0 CustomerProfiles.GetCustomerProfile 1 1 CustomerProfiles.GetAcceptCustomerProfilePage 1 1 CustomerProfiles.GetCustomerPaymentProfile 1 1 From d7b6b22d2c562113b6379746bcdf5e4db1215ef3 Mon Sep 17 00:00:00 2001 From: Gabriel B Nongsiej Date: Sun, 20 Sep 2020 20:26:48 +0530 Subject: [PATCH 163/176] Fixing date field --- .../authorize/sample/RecurringBilling/CreateSubscription.java | 2 +- .../RecurringBilling/CreateSubscriptionFromCustomerProfile.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscription.java b/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscription.java index 19d58ade..4c9a76ac 100644 --- a/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscription.java +++ b/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscription.java @@ -41,7 +41,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, shor try { XMLGregorianCalendar startDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(); startDate.setDay(30); - startDate.setMonth(8); + startDate.setMonth(12); startDate.setYear(2020); schedule.setStartDate(startDate); //2020-08-30 } diff --git a/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscriptionFromCustomerProfile.java b/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscriptionFromCustomerProfile.java index 023724a5..7e97c95c 100644 --- a/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscriptionFromCustomerProfile.java +++ b/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscriptionFromCustomerProfile.java @@ -40,7 +40,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, shor try { XMLGregorianCalendar startDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(); startDate.setDay(30); - startDate.setMonth(8); + startDate.setMonth(12); startDate.setYear(2020); schedule.setStartDate(startDate); //2020-08-30 } From b610d072b0ffe5454f24442ee7d9909e6e26f553 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Wed, 10 Mar 2021 16:02:28 +0530 Subject: [PATCH 164/176] Updated data --- .../sample/CustomerProfiles/CreateCustomerProfile.java | 2 +- .../sample/CustomerProfiles/GetCustomerProfile.java | 2 +- .../PaymentTransactions/AuthorizeCreditCard.java | 2 +- .../CaptureFundsAuthorizedThroughAnotherChannel.java | 2 +- .../sample/PaymentTransactions/ChargeCreditCard.java | 2 +- .../PaymentTransactions/ChargeTokenizedCreditCard.java | 2 +- .../PaymentTransactions/CreateChasePayTransaction.java | 2 +- .../sample/RecurringBilling/CreateSubscription.java | 4 ++-- .../CreateSubscriptionFromCustomerProfile.java | 2 +- .../sample/RecurringBilling/UpdateSubscription.java | 2 +- src/main/java/net/authorize/sample/SampleCode.java | 10 +++++----- .../authorize/sample/SampleCodeTest/TestRunner.java | 1 + 12 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfile.java b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfile.java index 96a3a7d0..670985e3 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfile.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfile.java @@ -20,7 +20,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri // Populate the payment data CreditCardType creditCard = new CreditCardType(); creditCard.setCardNumber("4111111111111111"); - creditCard.setExpirationDate("1220"); + creditCard.setExpirationDate("1225"); PaymentType paymentType = new PaymentType(); paymentType.setCreditCard(creditCard); diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerProfile.java b/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerProfile.java index c797ce69..0169c33d 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerProfile.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerProfile.java @@ -20,7 +20,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); GetCustomerProfileRequest apiRequest = new GetCustomerProfileRequest(); - apiRequest.setCustomerProfileId(customerProfileId); + apiRequest.setCustomerProfileId("1929820324"); //customerProfileId); GetCustomerProfileController controller = new GetCustomerProfileController(apiRequest); controller.execute(); diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/AuthorizeCreditCard.java b/src/main/java/net/authorize/sample/PaymentTransactions/AuthorizeCreditCard.java index 60acd464..a3b56f06 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/AuthorizeCreditCard.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/AuthorizeCreditCard.java @@ -37,7 +37,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub PaymentType paymentType = new PaymentType(); CreditCardType creditCard = new CreditCardType(); creditCard.setCardNumber("4242424242424242"); - creditCard.setExpirationDate("0822"); + creditCard.setExpirationDate("0835"); paymentType.setCreditCard(creditCard); // Create the payment transaction object diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/CaptureFundsAuthorizedThroughAnotherChannel.java b/src/main/java/net/authorize/sample/PaymentTransactions/CaptureFundsAuthorizedThroughAnotherChannel.java index 6127e0f1..f8f049b5 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/CaptureFundsAuthorizedThroughAnotherChannel.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/CaptureFundsAuthorizedThroughAnotherChannel.java @@ -35,7 +35,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub CreditCardType cc = new CreditCardType(); cc.setCardNumber("4111111111111111"); - cc.setExpirationDate("2020-12"); + cc.setExpirationDate("2035-12"); PaymentType payment = new PaymentType(); payment.setCreditCard(cc); diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCreditCard.java b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCreditCard.java index ed601009..871ce818 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCreditCard.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCreditCard.java @@ -28,7 +28,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub PaymentType paymentType = new PaymentType(); CreditCardType creditCard = new CreditCardType(); creditCard.setCardNumber("4242424242424242"); - creditCard.setExpirationDate("0822"); + creditCard.setExpirationDate("0835"); paymentType.setCreditCard(creditCard); // Set email address (optional) diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeTokenizedCreditCard.java b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeTokenizedCreditCard.java index 25b507c5..73909a75 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeTokenizedCreditCard.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeTokenizedCreditCard.java @@ -38,7 +38,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub PaymentType paymentType = new PaymentType(); CreditCardType creditCard = new CreditCardType(); creditCard.setCardNumber("4242424242424242"); - creditCard.setExpirationDate("0822"); + creditCard.setExpirationDate("0835"); // Set the token specific info creditCard.setIsPaymentToken(true); creditCard.setCryptogram("EjRWeJASNFZ4kBI0VniQEjRWeJA="); diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/CreateChasePayTransaction.java b/src/main/java/net/authorize/sample/PaymentTransactions/CreateChasePayTransaction.java index c0a4ca97..3627c2ee 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/CreateChasePayTransaction.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/CreateChasePayTransaction.java @@ -36,7 +36,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub PaymentType paymentType = new PaymentType(); CreditCardType creditCard = new CreditCardType(); creditCard.setCardNumber("4111111111111111"); - creditCard.setExpirationDate("2020-12"); + creditCard.setExpirationDate("2035-12"); // Set the token specific info creditCard.setIsPaymentToken(true); creditCard.setCryptogram("EjRWeJASNFZ4kBI0VniQEjRWeJA="); diff --git a/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscription.java b/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscription.java index 4c9a76ac..4107ec3d 100644 --- a/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscription.java +++ b/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscription.java @@ -42,7 +42,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, shor XMLGregorianCalendar startDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(); startDate.setDay(30); startDate.setMonth(12); - startDate.setYear(2020); + startDate.setYear(2021); schedule.setStartDate(startDate); //2020-08-30 } catch(Exception e) { @@ -56,7 +56,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, shor PaymentType paymentType = new PaymentType(); CreditCardType creditCard = new CreditCardType(); creditCard.setCardNumber("4111111111111111"); - creditCard.setExpirationDate("1220"); + creditCard.setExpirationDate("1225"); paymentType.setCreditCard(creditCard); ARBSubscriptionType arbSubscriptionType = new ARBSubscriptionType(); diff --git a/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscriptionFromCustomerProfile.java b/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscriptionFromCustomerProfile.java index 7e97c95c..f9b0e472 100644 --- a/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscriptionFromCustomerProfile.java +++ b/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscriptionFromCustomerProfile.java @@ -41,7 +41,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, shor XMLGregorianCalendar startDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(); startDate.setDay(30); startDate.setMonth(12); - startDate.setYear(2020); + startDate.setYear(2021); schedule.setStartDate(startDate); //2020-08-30 } catch(Exception e) { } diff --git a/src/main/java/net/authorize/sample/RecurringBilling/UpdateSubscription.java b/src/main/java/net/authorize/sample/RecurringBilling/UpdateSubscription.java index 266874ba..a8961db0 100644 --- a/src/main/java/net/authorize/sample/RecurringBilling/UpdateSubscription.java +++ b/src/main/java/net/authorize/sample/RecurringBilling/UpdateSubscription.java @@ -19,7 +19,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri PaymentType paymentType = new PaymentType(); CreditCardType creditCard = new CreditCardType(); creditCard.setCardNumber("4111111111111111"); - creditCard.setExpirationDate("1220"); + creditCard.setExpirationDate("1230"); paymentType.setCreditCard(creditCard); //set profile information diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index 4fe2225d..590eb83c 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -140,13 +140,13 @@ private static void RunMethod(String methodName) { // Update the transactionId with which you want to run the sample code String transactionId = "123456"; - String customerProfileId = "36596285"; - String customerPaymentProfileId = "33086593"; - String customerAddressId = "1873761911"; + String customerProfileId = "1929820324"; + String customerPaymentProfileId = "1841987457"; + String customerAddressId = "901056173"; - String emailId = "test@test.com"; + String emailId = "test@test2021.com"; - String subscriptionId = "2925606"; + String subscriptionId = "326280"; Double amount = 123.45; diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java index 6aa8511e..60ad084a 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java +++ b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java @@ -104,6 +104,7 @@ private static short getDays() public void TestAllSampleCodes() { String fileName = Constants.CONFIG_FILE; + int numRetries = 3; BufferedReader reader = null; From 94db4f89d1291a5ed86e68ae7ed5ab26b430dd4d Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Fri, 26 Mar 2021 00:04:47 +0530 Subject: [PATCH 165/176] Updated JUnit version --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index b5631847..dd36b6a2 100644 --- a/pom.xml +++ b/pom.xml @@ -14,12 +14,12 @@ net.authorize anet-java-sdk - 2.0.1 + 2.0.2 junit junit - 4.8.1 + 4.13.1 From 1597ba1018cdee84d91a0d61a30aae9e187ce62e Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Sun, 4 Apr 2021 22:39:03 +0530 Subject: [PATCH 166/176] Update to latest version --- pom.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index dd36b6a2..a1ea1e48 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ net.authorize anet-java-sdk - 2.0.2 + 2.0.3 junit @@ -26,6 +26,7 @@ maven-compiler-plugin + 3.7.0 1.7 1.7 From 99fb1a2bdd222235a46306266e6e386816e29cd7 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Sun, 19 Dec 2021 00:45:54 +0530 Subject: [PATCH 167/176] Update pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a1ea1e48..b6134c52 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ net.authorize anet-java-sdk - 2.0.3 + 2.0.5 junit From 4273524bee9b099eaa24ea8f746dc78140eb76a6 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Sun, 19 Dec 2021 00:46:08 +0530 Subject: [PATCH 168/176] Update pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b6134c52..a2f941a7 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,7 @@ - 1.9.7 + 2.0.5 4.0.0 net.authorize.sample From 63ada8cbebbdd2ee1c21ec1425db4f4aeec4bc5d Mon Sep 17 00:00:00 2001 From: Gaidin Daishan Date: Wed, 19 Jul 2023 19:23:09 +0530 Subject: [PATCH 169/176] Added CreateGooglePayTransaction --- .../CreateGooglePayTransaction.java | 98 +++++++++++++++++++ .../java/net/authorize/sample/SampleCode.java | 3 + 2 files changed, 101 insertions(+) create mode 100644 src/main/java/net/authorize/sample/MobileInAppTransactions/CreateGooglePayTransaction.java diff --git a/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateGooglePayTransaction.java b/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateGooglePayTransaction.java new file mode 100644 index 00000000..0e605467 --- /dev/null +++ b/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateGooglePayTransaction.java @@ -0,0 +1,98 @@ +package net.authorize.sample.MobileInAppTransactions; + +import net.authorize.Environment; +import net.authorize.api.contract.v1.*; +import net.authorize.api.controller.CreateTransactionController; +import net.authorize.api.controller.base.ApiOperationBase; + +import java.math.BigDecimal; + +public class CreateGooglePayTransaction { + public static ANetApiResponse run(String apiLoginId, String transactionKey, Double amount) { + ApiOperationBase.setEnvironment(Environment.SANDBOX); + + MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType(); + merchantAuthenticationType.setName(apiLoginId); + merchantAuthenticationType.setTransactionKey(transactionKey); + ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); + + OpaqueDataType opaqueData = new OpaqueDataType(); + opaqueData.setDataDescriptor("COMMON.GOOGLE.INAPP.PAYMENT"); + opaqueData.setDataValue("1234567890ABCDEF1111AAAA2222BBBB3333CCCC4444DDDD5555EEEE6666FFFF7777888899990000"); + + PaymentType paymentType = new PaymentType(); + paymentType.setOpaqueData(opaqueData); + + LineItemType lineItem = new LineItemType(); + lineItem.setItemId("1"); + lineItem.setName("vase"); + lineItem.setDescription("Cannes logo"); + lineItem.setQuantity(BigDecimal.valueOf(18)); + lineItem.setUnitPrice(BigDecimal.valueOf(45.00)); + + ArrayOfLineItem lineItems = new ArrayOfLineItem(); + lineItems.getLineItem().add(lineItem); + + ExtendedAmountType tax = new ExtendedAmountType(); + tax.setAmount(BigDecimal.valueOf(amount)); + tax.setName("level2 tax name"); + tax.setDescription("level2 tax"); + + UserField userField = new UserField(); + TransactionRequestType.UserFields userFields = new TransactionRequestType.UserFields(); + + userField.setName("UserDefinedFieldName1"); + userField.setValue("UserDefinedFieldValue1"); + userFields.getUserField().add(userField); + + userField.setName("UserDefinedFieldName2"); + userField.setValue("UserDefinedFieldValue2"); + userFields.getUserField().add(userField); + + TransactionRequestType transactionRequest = new TransactionRequestType(); + transactionRequest.setAmount(BigDecimal.valueOf(amount)); + transactionRequest.setTransactionType(TransactionTypeEnum.AUTH_CAPTURE_TRANSACTION.value()); + transactionRequest.setPayment(paymentType); + + CreateTransactionRequest apiRequest = new CreateTransactionRequest(); + apiRequest.setTransactionRequest(transactionRequest); + + CreateTransactionController controller = new CreateTransactionController(apiRequest); + controller.execute(); + + CreateTransactionResponse response = controller.getApiResponse(); + + if (response!=null) { + // If API Response is ok, go ahead and check the transaction response + if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { + TransactionResponse result = response.getTransactionResponse(); + if (result.getMessages() != null) { + System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId()); + System.out.println("Response Code: " + result.getResponseCode()); + System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode()); + System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription()); + System.out.println("Auth code : " + result.getAuthCode()); + } else { + System.out.println("Failed Transaction."); + if (response.getTransactionResponse().getErrors() != null) { + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } + } + } else { + System.out.println("Failed Transaction."); + if (response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null) { + System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode()); + System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText()); + } else { + System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode()); + System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText()); + } + } + } else { + System.out.println("Null Response."); + } + + return response; + } +} diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index 590eb83c..e2643d77 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -83,6 +83,7 @@ private static void ShowMethods() { System.out.println(" CreateAnApplePayTransaction"); System.out.println(" CreateAnAndroidPayTransaction"); System.out.println(" CreateAnAcceptTransaction"); + System.out.println(" CreateGooglePayTransaction"); System.out.println(" ChargeCustomerProfile"); System.out.println(" CreateSubscription"); System.out.println(" CreateSubscriptionFromCustomerProfile"); @@ -205,6 +206,8 @@ private static void RunMethod(String methodName) { case "CreateAnAcceptTransaction": CreateAnAcceptTransaction.run(apiLoginId, transactionKey); break; + case "CreateGooglePayTransaction": + CreateGooglePayTransaction.run(apiLoginId, transactionKey, amount); case "ChargeCustomerProfile": ChargeCustomerProfile.run(apiLoginId, transactionKey, customerProfileId, customerPaymentProfileId, amount); break; From c9b7033eea2d2f0545acbf9e98d06855669f8b91 Mon Sep 17 00:00:00 2001 From: Gaidin Daishan Date: Wed, 19 Jul 2023 20:24:07 +0530 Subject: [PATCH 170/176] Fixed issues --- .../MobileInAppTransactions/CreateGooglePayTransaction.java | 3 +-- src/main/java/net/authorize/sample/SampleCode.java | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateGooglePayTransaction.java b/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateGooglePayTransaction.java index 0e605467..d8e2c69f 100644 --- a/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateGooglePayTransaction.java +++ b/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateGooglePayTransaction.java @@ -62,8 +62,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub CreateTransactionResponse response = controller.getApiResponse(); - if (response!=null) { - // If API Response is ok, go ahead and check the transaction response + if (response != null) { if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { TransactionResponse result = response.getTransactionResponse(); if (result.getMessages() != null) { diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index e2643d77..e75aa41d 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -208,6 +208,7 @@ private static void RunMethod(String methodName) { break; case "CreateGooglePayTransaction": CreateGooglePayTransaction.run(apiLoginId, transactionKey, amount); + break; case "ChargeCustomerProfile": ChargeCustomerProfile.run(apiLoginId, transactionKey, customerProfileId, customerPaymentProfileId, amount); break; From fd2c11a680da8b7df5a88abc0c4c1873e672dc1d Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Wed, 19 Jul 2023 20:50:21 +0530 Subject: [PATCH 171/176] Corrected CreateGooglePayTransaction --- .../MobileInAppTransactions/CreateGooglePayTransaction.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateGooglePayTransaction.java b/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateGooglePayTransaction.java index d8e2c69f..112c6a0f 100644 --- a/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateGooglePayTransaction.java +++ b/src/main/java/net/authorize/sample/MobileInAppTransactions/CreateGooglePayTransaction.java @@ -53,6 +53,9 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub transactionRequest.setAmount(BigDecimal.valueOf(amount)); transactionRequest.setTransactionType(TransactionTypeEnum.AUTH_CAPTURE_TRANSACTION.value()); transactionRequest.setPayment(paymentType); + transactionRequest.setLineItems(lineItems); + transactionRequest.setTax(tax); + transactionRequest.setUserFields(userFields); CreateTransactionRequest apiRequest = new CreateTransactionRequest(); apiRequest.setTransactionRequest(transactionRequest); From 2b592cb8f6c0a6dd62d18ebfc6f4bfc7a2898e51 Mon Sep 17 00:00:00 2001 From: Gaidin Daishan Date: Thu, 22 Feb 2024 14:44:26 +0530 Subject: [PATCH 172/176] Updated dates used in requests --- pom.xml | 11 +++++++++++ .../CreateCustomerPaymentProfile.java | 2 +- .../CustomerProfiles/CreateCustomerProfile.java | 2 +- .../CreateCustomerProfileFromTransaction.java | 2 +- .../UpdateCustomerPaymentProfile.java | 2 +- .../sample/PaymentTransactions/ChargeCreditCard.java | 4 +++- .../sample/RecurringBilling/CreateSubscription.java | 6 +++--- .../CreateSubscriptionFromCustomerProfile.java | 2 +- .../sample/RecurringBilling/UpdateSubscription.java | 2 +- src/main/java/net/authorize/sample/SampleCode.java | 6 +++--- .../sample/SampleCodeTest/SampleCodeList.txt | 2 +- 11 files changed, 27 insertions(+), 14 deletions(-) diff --git a/pom.xml b/pom.xml index a2f941a7..26c91e27 100644 --- a/pom.xml +++ b/pom.xml @@ -36,6 +36,17 @@ org.apache.maven.plugins maven-shade-plugin 2.4.1 + + false + + + *:* + + **/Log4j2Plugins.dat + + + + package diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerPaymentProfile.java b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerPaymentProfile.java index ecbbebb3..94edc17d 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerPaymentProfile.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerPaymentProfile.java @@ -38,7 +38,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri //credit card details CreditCardType creditCard = new CreditCardType(); creditCard.setCardNumber("4111111111111111"); - creditCard.setExpirationDate("2023-12"); + creditCard.setExpirationDate("2035-12"); creditCard.setCardCode("122"); CustomerPaymentProfileType profile = new CustomerPaymentProfileType(); diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfile.java b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfile.java index 670985e3..8880e1b6 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfile.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfile.java @@ -20,7 +20,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri // Populate the payment data CreditCardType creditCard = new CreditCardType(); creditCard.setCardNumber("4111111111111111"); - creditCard.setExpirationDate("1225"); + creditCard.setExpirationDate("1235"); PaymentType paymentType = new PaymentType(); paymentType.setCreditCard(creditCard); diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfileFromTransaction.java b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfileFromTransaction.java index 7cc3865f..3e3ae284 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfileFromTransaction.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfileFromTransaction.java @@ -32,7 +32,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub CreditCardType creditCard = new CreditCardType(); creditCard.setCardNumber("4111111111111111"); - creditCard.setExpirationDate("0621"); + creditCard.setExpirationDate("0635"); PaymentType paymentType = new PaymentType(); paymentType.setCreditCard(creditCard); diff --git a/src/main/java/net/authorize/sample/CustomerProfiles/UpdateCustomerPaymentProfile.java b/src/main/java/net/authorize/sample/CustomerProfiles/UpdateCustomerPaymentProfile.java index d4ea1554..de859f97 100644 --- a/src/main/java/net/authorize/sample/CustomerProfiles/UpdateCustomerPaymentProfile.java +++ b/src/main/java/net/authorize/sample/CustomerProfiles/UpdateCustomerPaymentProfile.java @@ -30,7 +30,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri //credit card details CreditCardType creditCard = new CreditCardType(); creditCard.setCardNumber("4111111111111111"); - creditCard.setExpirationDate("2023-12"); + creditCard.setExpirationDate("2035-12"); PaymentType paymentType = new PaymentType(); paymentType.setCreditCard(creditCard); diff --git a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCreditCard.java b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCreditCard.java index 871ce818..34e91905 100644 --- a/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCreditCard.java +++ b/src/main/java/net/authorize/sample/PaymentTransactions/ChargeCreditCard.java @@ -9,7 +9,9 @@ import net.authorize.api.controller.base.ApiOperationBase; public class ChargeCreditCard { - + public static void main(String[] args) { + run("5KP3u95bQpv", "346HZ32z3fP4hTG2", 25.00); + } // // Run this sample from command line with: // java -jar target/ChargeCreditCard-jar-with-dependencies.jar diff --git a/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscription.java b/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscription.java index 4107ec3d..920e9e4d 100644 --- a/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscription.java +++ b/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscription.java @@ -42,8 +42,8 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, shor XMLGregorianCalendar startDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(); startDate.setDay(30); startDate.setMonth(12); - startDate.setYear(2021); - schedule.setStartDate(startDate); //2020-08-30 + startDate.setYear(2032); + schedule.setStartDate(startDate); } catch(Exception e) { @@ -56,7 +56,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, shor PaymentType paymentType = new PaymentType(); CreditCardType creditCard = new CreditCardType(); creditCard.setCardNumber("4111111111111111"); - creditCard.setExpirationDate("1225"); + creditCard.setExpirationDate("1235"); paymentType.setCreditCard(creditCard); ARBSubscriptionType arbSubscriptionType = new ARBSubscriptionType(); diff --git a/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscriptionFromCustomerProfile.java b/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscriptionFromCustomerProfile.java index f9b0e472..231b6de6 100644 --- a/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscriptionFromCustomerProfile.java +++ b/src/main/java/net/authorize/sample/RecurringBilling/CreateSubscriptionFromCustomerProfile.java @@ -41,7 +41,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, shor XMLGregorianCalendar startDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(); startDate.setDay(30); startDate.setMonth(12); - startDate.setYear(2021); + startDate.setYear(2032); schedule.setStartDate(startDate); //2020-08-30 } catch(Exception e) { } diff --git a/src/main/java/net/authorize/sample/RecurringBilling/UpdateSubscription.java b/src/main/java/net/authorize/sample/RecurringBilling/UpdateSubscription.java index a8961db0..62243ac7 100644 --- a/src/main/java/net/authorize/sample/RecurringBilling/UpdateSubscription.java +++ b/src/main/java/net/authorize/sample/RecurringBilling/UpdateSubscription.java @@ -19,7 +19,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri PaymentType paymentType = new PaymentType(); CreditCardType creditCard = new CreditCardType(); creditCard.setCardNumber("4111111111111111"); - creditCard.setExpirationDate("1230"); + creditCard.setExpirationDate("1235"); paymentType.setCreditCard(creditCard); //set profile information diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index e75aa41d..70dbfc52 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -141,9 +141,9 @@ private static void RunMethod(String methodName) { // Update the transactionId with which you want to run the sample code String transactionId = "123456"; - String customerProfileId = "1929820324"; - String customerPaymentProfileId = "1841987457"; - String customerAddressId = "901056173"; + String customerProfileId = "918133235"; + String customerPaymentProfileId = "917585361"; + String customerAddressId = "918189891"; String emailId = "test@test2021.com"; diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt b/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt index 72677915..83497fc2 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt +++ b/src/test/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt @@ -54,5 +54,5 @@ TransactionReporting.GetMerchantDetails 0 1 MobileInAppTransactions.CreateAnApplePayTransaction 0 0 MobileInAppTransactions.CreateAnAndroidPayTransaction 0 0 MobileInAppTransactions.CreateAnAcceptTransaction 0 0 -VisaCheckout.DecryptVisaSrcData 0 1 +VisaCheckout.DecryptVisaSrcData 0 0 VisaCheckout.CreateVisaSrcTransaction 0 0 From 1a6f5e1f7912269185cc29dda27b3e7dfa115e34 Mon Sep 17 00:00:00 2001 From: gnongsie Date: Thu, 11 Jul 2024 22:24:28 +0530 Subject: [PATCH 173/176] Checking classpath --- .../sample/SampleCodeTest/TestRunner.java | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java index 60ad084a..92f2f6fa 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java +++ b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java @@ -92,6 +92,7 @@ private static Double getAmount() double d = (double)(1.05 + (450.0 * rgenerator.nextDouble())); DecimalFormat df = new DecimalFormat("#.##"); d = Double.valueOf(df.format(d)); + System.out.println("AMOUNT : " + d); return d; } @@ -109,6 +110,8 @@ public void TestAllSampleCodes() BufferedReader reader = null; + System.out.println(System.getProperty("java.class.path")); + try { reader = new BufferedReader(new FileReader(fileName)); } catch (FileNotFoundException e1) { @@ -183,7 +186,7 @@ public ANetApiResponse InvokeRunMethod(String className) { String fqClassName = "net.authorize.sample." + className; - Class classType = null; + Class classType = null; try { classType = Class.forName(fqClassName); } catch (ClassNotFoundException e1) { @@ -193,28 +196,19 @@ public ANetApiResponse InvokeRunMethod(String className) Method runMethod = null; try { - runMethod = classType.getMethod("run",String.class, String.class); - } catch (NoSuchMethodException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } catch (SecurityException e1) { + runMethod = classType.getMethod("run", String.class, String.class); + } catch (NoSuchMethodException | SecurityException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } - try { + try { return (ANetApiResponse)runMethod.invoke(null, Constants.API_LOGIN_ID, Constants.TRANSACTION_KEY); - } catch (IllegalAccessException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IllegalArgumentException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (InvocationTargetException e) { + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } - return null; + return null; } public ANetApiResponse TestValidateCustomerPaymentProfile() From dbf0135dd15c775c635f7fd5d4176dfb572dd13a Mon Sep 17 00:00:00 2001 From: gnongsie Date: Fri, 12 Jul 2024 13:06:07 +0530 Subject: [PATCH 174/176] Removed testing comments --- .../java/net/authorize/sample/SampleCodeTest/TestRunner.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java index 92f2f6fa..b6551189 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java +++ b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java @@ -92,7 +92,6 @@ private static Double getAmount() double d = (double)(1.05 + (450.0 * rgenerator.nextDouble())); DecimalFormat df = new DecimalFormat("#.##"); d = Double.valueOf(df.format(d)); - System.out.println("AMOUNT : " + d); return d; } @@ -110,8 +109,6 @@ public void TestAllSampleCodes() BufferedReader reader = null; - System.out.println(System.getProperty("java.class.path")); - try { reader = new BufferedReader(new FileReader(fileName)); } catch (FileNotFoundException e1) { From 68db99ee7ed6cfa93cba131360fa4c93c82d026f Mon Sep 17 00:00:00 2001 From: gnongsie Date: Fri, 12 Jul 2024 13:07:40 +0530 Subject: [PATCH 175/176] Upgraded to work on Java 9 and above. --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 26c91e27..ae61d0b0 100644 --- a/pom.xml +++ b/pom.xml @@ -28,8 +28,8 @@ maven-compiler-plugin 3.7.0 - 1.7 - 1.7 + 9 + 9 From 49e50bbf600b7ac2486184f4d0588b1c1e65eff0 Mon Sep 17 00:00:00 2001 From: gnongsie Date: Thu, 19 Sep 2024 13:18:50 +0530 Subject: [PATCH 176/176] Upgrades to latest versions --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ae61d0b0..f456c3e3 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ net.authorize anet-java-sdk - 2.0.5 + 3.0.0 junit