示例#1
0
 /// <summary>
 /// Creates a new batch from a stats response
 /// </summary>
 public static Batch NewFromResponse(getBatchStatisticsResponse batch)
 {
     return(new Batch {
         ID = batch.batchDetails.batchId,
         PaymentMethod = batch.batchDetails.paymentMethod,
         SettledOn = batch.batchDetails.settlementTimeUTC,
         State = batch.batchDetails.settlementState,
         Charges = Charge.NewFromStat(batch.batchDetails.statistics)
     });
 }
示例#2
0
        /// <summary>
        /// Creates a new batch from a stats response
        /// </summary>
        public static List <Batch> NewFromResponse(getBatchStatisticsResponse batch)
        {
            var result = new List <Batch>();

            if (null != batch && null != batch.batch)
            {
                foreach (var item in batch.batch)
                {
                    result.Add(new Batch
                    {
                        Charges       = Charge.NewFromStat(item.statistics),
                        ID            = item.batchId,
                        PaymentMethod = item.paymentMethod,
                        SettledOn     = item.settlementTimeUTC,
                        State         = item.settlementState,
                        MarketType    = item.marketType,
                        Product       = item.product
                    });
                }
            }
            return(result);
        }
示例#3
0
        public void MockgetBatchStatisticsTest()
        {
            //define all mocked objects as final
            var mockController = GetMockController <getBatchStatisticsRequest, getBatchStatisticsResponse>();
            var mockRequest    = new getBatchStatisticsRequest
            {
                merchantAuthentication = new merchantAuthenticationType {
                    name = "mocktest", Item = "mockKey", ItemElementName = ItemChoiceType.transactionKey
                },
            };
            var batchDetaisType = new batchDetailsType
            {
                batchId = "1234",
            };
            var mockResponse = new getBatchStatisticsResponse
            {
                refId        = "1234",
                sessionToken = "sessiontoken",
                batch        = batchDetaisType,
            };

            var errorResponse = new ANetApiResponse();
            var results       = new List <String>();
            const messageTypeEnum messageTypeOk = messageTypeEnum.Ok;

            SetMockControllerExpectations <getBatchStatisticsRequest, getBatchStatisticsResponse, getBatchStatisticsController>(
                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.batch);
            LogHelper.info(Logger, "getBatchStatistics: Details:{0}", controllerResponse.batch);
        }