Skip to content

Commit 4c090e9

Browse files
committed
Merge pull request AuthorizeNet#36 from kikmak42/master
Added call request to GetCustomerProfileIds & Fixed GetSettledBatchList
2 parents 4d87734 + 381b957 commit 4c090e9

2 files changed

Lines changed: 44 additions & 16 deletions

File tree

src/main/java/net/authorize/sample/SampleCode.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ private static void ShowMethods()
9292
System.out.println(" UpdateSubscription");
9393
System.out.println(" GetListOfSubscriptions");
9494
System.out.println(" GetBatchStatistics");
95-
//System.out.println(" GetSettledBatchList");
95+
System.out.println(" GetSettledBatchList");
9696
System.out.println(" GetTransactionList");
9797
System.out.println(" GetUnsettledTransactionList");
9898
System.out.println(" GetTransactionDetails");
@@ -104,6 +104,7 @@ private static void ShowMethods()
104104
System.out.println(" DeleteCustomerShippingAddress");
105105
System.out.println(" GetCustomerPaymentProfile");
106106
System.out.println(" GetCustomerProfile");
107+
System.out.println(" GetCustomerProfileIds");
107108
System.out.println(" GetCustomerShippingAddress");
108109
System.out.println(" GetHostedProfilePage");
109110
System.out.println(" UpdateCustomerPaymentProfile");
@@ -188,9 +189,9 @@ private static void RunMethod(String methodName)
188189
case "GetBatchStatistics":
189190
GetBatchStatistics.run(apiLoginId, transactionKey);
190191
break;
191-
/*case "GetSettledBatchList":
192+
case "GetSettledBatchList":
192193
GetSettledBatchList.run(apiLoginId, transactionKey);
193-
break;*/
194+
break;
194195
case "GetTransactionList":
195196
GetTransactionList.run(apiLoginId, transactionKey);
196197
break;
@@ -224,6 +225,9 @@ private static void RunMethod(String methodName)
224225
case "GetCustomerProfile":
225226
GetCustomerProfile.run(apiLoginId, transactionKey);
226227
break;
228+
case "GetCustomerProfileIds":
229+
GetCustomerProfileIds.run(apiLoginId, transactionKey);
230+
break;
227231
case "GetCustomerShippingAddress":
228232
GetCustomerShippingAddress.run(apiLoginId, transactionKey);
229233
break;

src/main/java/net/authorize/sample/TransactionReporting/GetSettledBatchList.java

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,64 @@
11
package net.authorize.sample.TransactionReporting;
22

3+
import java.util.Calendar;
4+
import java.util.GregorianCalendar;
35
import net.authorize.Environment;
46
import net.authorize.api.contract.v1.*;
57
import net.authorize.api.controller.GetSettledBatchListController;
68
import net.authorize.api.controller.base.ApiOperationBase;
9+
import javax.xml.datatype.DatatypeFactory;
710

8-
//author @krgupta
11+
//author @krgupta modified @kikmak42
912
public class GetSettledBatchList {
1013

11-
public static void run(String apiLoginId, String transactionKey) {
14+
public static void run(String apiLoginId, String transactionKey) {
1215

1316
ApiOperationBase.setEnvironment(Environment.SANDBOX);
1417

15-
MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ;
18+
MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType();
1619
merchantAuthenticationType.setName(apiLoginId);
1720
merchantAuthenticationType.setTransactionKey(transactionKey);
1821
ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType);
19-
22+
2023
GetSettledBatchListRequest getRequest = new GetSettledBatchListRequest();
2124
getRequest.setMerchantAuthentication(merchantAuthenticationType);
25+
26+
try {
27+
// Set first settlement date in format (year, month, day)(should not be less that 31 days since last settlement date)
28+
GregorianCalendar pastDate = new GregorianCalendar();
29+
pastDate.add(Calendar.DAY_OF_YEAR, -7);
30+
getRequest.setFirstSettlementDate(DatatypeFactory.newInstance().newXMLGregorianCalendar(pastDate));
31+
32+
// Set last settlement date in format (year, month, day) (should not be greater that 31 days since first settlement date)
33+
GregorianCalendar currentDate = new GregorianCalendar();
34+
getRequest.setLastSettlementDate(DatatypeFactory.newInstance().newXMLGregorianCalendar(currentDate));
35+
36+
} catch (Exception ex) {
37+
System.out.println("Error : while setting dates");
38+
ex.printStackTrace();
39+
}
40+
2241
GetSettledBatchListController controller = new GetSettledBatchListController(getRequest);
2342
controller.execute();
24-
GetSettledBatchListResponse getResponse = new GetSettledBatchListResponse();
25-
if (getResponse!=null) {
43+
GetSettledBatchListResponse getResponse = controller.getApiResponse();
44+
if (getResponse != null) {
2645

27-
if (getResponse.getMessages().getResultCode() == MessageTypeEnum.OK) {
46+
if (getResponse.getMessages().getResultCode() == MessageTypeEnum.OK) {
2847

2948
System.out.println(getResponse.getMessages().getMessage().get(0).getCode());
3049
System.out.println(getResponse.getMessages().getMessage().get(0).getText());
31-
}
32-
else
33-
{
50+
51+
ArrayOfBatchDetailsType batchList = getResponse.getBatchList();
52+
if (batchList != null) {
53+
System.out.println("List of Settled Transaction :");
54+
for (BatchDetailsType batch : batchList.getBatch()) {
55+
System.out.println(batch.getBatchId() + " - " + batch.getMarketType() + " - " + batch.getPaymentMethod() + " - " + batch.getProduct() + " - " + batch.getSettlementState());
56+
}
57+
}
58+
} else {
3459
System.out.println("Failed to get settled batch list: " + getResponse.getMessages().getResultCode());
60+
System.out.println(getResponse.getMessages().getMessage().get(0).getText());
3561
}
3662
}
63+
}
3764
}
38-
}
39-
40-

0 commit comments

Comments
 (0)