diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index 233fae1d..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"); @@ -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"); @@ -187,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; @@ -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; diff --git a/src/main/java/net/authorize/sample/TransactionReporting/GetSettledBatchList.java b/src/main/java/net/authorize/sample/TransactionReporting/GetSettledBatchList.java index b420cac2..3a7fd72c 100644 --- a/src/main/java/net/authorize/sample/TransactionReporting/GetSettledBatchList.java +++ b/src/main/java/net/authorize/sample/TransactionReporting/GetSettledBatchList.java @@ -1,40 +1,64 @@ package net.authorize.sample.TransactionReporting; +import java.util.Calendar; +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 +//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 = 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 = 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 = new GetSettledBatchListResponse(); - if (getResponse!=null) { + GetSettledBatchListResponse getResponse = controller.getApiResponse(); + 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()); - } - else - { + + 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 { System.out.println("Failed to get settled batch list: " + getResponse.getMessages().getResultCode()); + System.out.println(getResponse.getMessages().getMessage().get(0).getText()); } } + } } -} - -