public static void Run(String ApiLoginID, String ApiTransactionKey) { Console.WriteLine("Get settled batch list sample"); ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX; // define the merchant information (authentication / transaction id) ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType() { name = ApiLoginID, ItemElementName = ItemChoiceType.transactionKey, Item = ApiTransactionKey, }; //Get a date 1 week in the past var firstSettlementDate = DateTime.Today.Subtract(TimeSpan.FromDays(31)); //Get today's date var lastSettlementDate = DateTime.Today; Console.WriteLine("First settlement date: {0} Last settlement date:{1}", firstSettlementDate, lastSettlementDate); var request = new getSettledBatchListRequest(); request.firstSettlementDate = firstSettlementDate; request.lastSettlementDate = lastSettlementDate; request.includeStatistics = true; // instantiate the controller that will call the service var controller = new getSettledBatchListController(request); controller.Execute(); // get the response from the service (errors contained if any) var response = controller.GetApiResponse(); if (response.messages.resultCode == messageTypeEnum.Ok) { if (response.batchList == null) return; foreach (var batch in response.batchList) { Console.WriteLine("Batch Id: {0}", batch.batchId); Console.WriteLine("Batch settled on (UTC): {0}", batch.settlementTimeUTC); Console.WriteLine("Batch settled on (Local): {0}", batch.settlementTimeLocal); Console.WriteLine("Batch settlement state: {0}", batch.settlementState); Console.WriteLine("Batch market type: {0}", batch.marketType); Console.WriteLine("Batch product: {0}", batch.product); foreach (var statistics in batch.statistics) { Console.WriteLine( "Account type: {0} Total charge amount: {1} Charge count: {2} Refund amount: {3} Refund count: {4} Void count: {5} Decline count: {6} Error amount: {7}", statistics.accountType, statistics.chargeAmount, statistics.chargeCount, statistics.refundAmount, statistics.refundCount, statistics.voidCount, statistics.declineCount, statistics.errorCount); } } } else { Console.WriteLine("Error: " + response.messages.message[0].code + " " + response.messages.message[0].text); } }
public void MockgetSettledBatchListTest() { //define all mocked objects as final var mockController = GetMockController<getSettledBatchListRequest, getSettledBatchListResponse>(); var mockRequest = new getSettledBatchListRequest { merchantAuthentication = new merchantAuthenticationType {name = "mocktest", Item = "mockKey", ItemElementName = ItemChoiceType.transactionKey}, }; var batchDetailsType = new batchDetailsType[] { new batchDetailsType { batchId = "1234", } }; var mockResponse = new getSettledBatchListResponse { refId = "1234", sessionToken = "sessiontoken", batchList = batchDetailsType, }; var errorResponse = new ANetApiResponse(); var results = new List<String>(); const messageTypeEnum messageTypeOk = messageTypeEnum.Ok; SetMockControllerExpectations<getSettledBatchListRequest, getSettledBatchListResponse, getSettledBatchListController>( mockController.MockObject, mockRequest, mockResponse, errorResponse, results, messageTypeOk); mockController.MockObject.Execute(AuthorizeNet.Environment.CUSTOM); //mockController.MockObject.Execute(); // or var controllerResponse = mockController.MockObject.ExecuteWithApiResponse(AuthorizeNet.Environment.CUSTOM); var controllerResponse = mockController.MockObject.GetApiResponse(); Assert.IsNotNull(controllerResponse); Assert.IsNotNull(controllerResponse.batchList); LogHelper.info(Logger, "getSettledBatchList: Details:{0}", controllerResponse.batchList); }
public static void getSettledBatchListRequest(getSettledBatchListRequest argument) { if (null != argument) { if (argument.includeStatistics) { argument.includeStatisticsSpecified = true; } if (DateTime.MinValue != argument.firstSettlementDate) { argument.firstSettlementDateSpecified = true; } if (DateTime.MinValue != argument.lastSettlementDate) { argument.lastSettlementDateSpecified = true; } } }