|
| 1 | +package net.authorize.sample.TransactionReporting; |
| 2 | + |
| 3 | +import java.util.List; |
| 4 | + |
| 5 | +import net.authorize.Environment; |
| 6 | +import net.authorize.api.contract.v1.*; |
| 7 | +import net.authorize.api.controller.GetTransactionListForCustomerController; |
| 8 | +import net.authorize.api.controller.base.ApiOperationBase; |
| 9 | + |
| 10 | +//author @akashah |
| 11 | +public class GetCustomerProfileTransactionList{ |
| 12 | + |
| 13 | + public static ANetApiResponse run(String apiLoginId, String transactionKey, String customerProfileId) { |
| 14 | + ApiOperationBase.setEnvironment(Environment.SANDBOX); |
| 15 | + |
| 16 | + MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ; |
| 17 | + merchantAuthenticationType.setName(apiLoginId); |
| 18 | + merchantAuthenticationType.setTransactionKey(transactionKey); |
| 19 | + ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType); |
| 20 | + |
| 21 | + |
| 22 | + GetTransactionListForCustomerRequest getRequest = new GetTransactionListForCustomerRequest(); |
| 23 | + getRequest.setMerchantAuthentication(merchantAuthenticationType); |
| 24 | + getRequest.setCustomerProfileId(customerProfileId); |
| 25 | + |
| 26 | + Paging paging = new Paging(); |
| 27 | + paging.setLimit(100); |
| 28 | + paging.setOffset(1); |
| 29 | + |
| 30 | + getRequest.setPaging(paging); |
| 31 | + |
| 32 | + TransactionListSorting sorting = new TransactionListSorting(); |
| 33 | + sorting.setOrderBy(TransactionListOrderFieldEnum.ID); |
| 34 | + sorting.setOrderDescending(true); |
| 35 | + |
| 36 | + getRequest.setSorting(sorting); |
| 37 | + |
| 38 | + GetTransactionListForCustomerController controller = new GetTransactionListForCustomerController(getRequest); |
| 39 | + controller.execute(); |
| 40 | + |
| 41 | + GetTransactionListResponse getResponse = controller.getApiResponse(); |
| 42 | + if (getResponse!=null) { |
| 43 | + ArrayOfTransactionSummaryType transactions = getResponse.getTransactions(); |
| 44 | + List<TransactionSummaryType> list = transactions.getTransaction(); |
| 45 | + |
| 46 | + for(TransactionSummaryType summary : list) |
| 47 | + { |
| 48 | + System.out.println(summary.getFirstName()); |
| 49 | + System.out.println(summary.getTransId()); |
| 50 | + System.out.println(summary.getSettleAmount()); |
| 51 | + System.out.println(summary.getSubmitTimeLocal()); |
| 52 | + } |
| 53 | + |
| 54 | + if (getResponse.getMessages().getResultCode() == MessageTypeEnum.OK) { |
| 55 | + System.out.println(getResponse.getMessages().getMessage().get(0).getCode()); |
| 56 | + System.out.println(getResponse.getMessages().getMessage().get(0).getText()); |
| 57 | + } |
| 58 | + else |
| 59 | + { |
| 60 | + System.out.println("Failed to get transaction list: " + getResponse.getMessages().getResultCode()); |
| 61 | + } |
| 62 | + } |
| 63 | + return getResponse; |
| 64 | + |
| 65 | + } |
| 66 | +} |
0 commit comments