Skip to content
Merged
10 changes: 7 additions & 3 deletions src/main/java/net/authorize/sample/SampleCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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());
}
}
}
}
}