Exemple #1
0
        public void MockgetTransactionListForCustomerTest()
        {
            //define all mocked objects as final
            var mockController = GetMockController <getTransactionListForCustomerRequest, getTransactionListForCustomerResponse>();
            var mockRequest    = new getTransactionListForCustomerRequest
            {
                merchantAuthentication = new merchantAuthenticationType()
                {
                    name = "mocktest", Item = "mockKey", ItemElementName = ItemChoiceType.transactionKey
                },
            };
            var mockResponse = new getTransactionListForCustomerResponse
            {
                refId        = "1234",
                sessionToken = "sessiontoken",
                Yyyyy        = Yyyy,
            };

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

            SetMockControllerExpectations <getTransactionListForCustomerRequest, getTransactionListForCustomerResponse, getTransactionListForCustomerController>(
                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.Yyyyy);
            LogHelper.info(Logger, "getTransactionListForCustomer: Details:{0}", controllerResponse.Yyyyy);
        }
        /// <summary>
        /// Returns all transaction for a Customer Profile
        /// </summary>
        public List <Transaction> GetCustomerTransactionList(string customerProfileId)
        {
            var req = new getTransactionListForCustomerRequest
            {
                customerProfileId = customerProfileId
            };

            var response = (getTransactionListForCustomerResponse)_gateway.Send(req);

            return(Transaction.NewListFromResponse(response.transactions));
        }
        /// <summary>
        /// Returns all transactions for a given customerProfileId
        /// </summary>
        public List <Transaction> GetTransactionList(string customerProfileId, string customerPaymentProfileId)
        {
            var request = new getTransactionListForCustomerRequest();

            request.customerProfileId        = customerProfileId;
            request.customerPaymentProfileId = customerPaymentProfileId;

            var response = (getTransactionListResponse)_gateway.Send(request);

            return(Transaction.NewListFromResponse(response.transactions));
        }
        public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey, string customerProfileId)
        {
            Console.WriteLine("Get transaction 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,
            };

            var request = new getTransactionListForCustomerRequest();

            request.customerProfileId = "1811474252";

            // instantiate the controller that will call the service
            var controller = new getTransactionListForCustomerController(request);

            controller.Execute();

            // get the response from the service (errors contained if any)
            var response = controller.GetApiResponse();

            if (response != null && response.messages.resultCode == messageTypeEnum.Ok)
            {
                if (response.transactions == null)
                {
                    return(response);
                }

                foreach (var transaction in response.transactions)
                {
                    Console.WriteLine("Transaction Id: {0}", transaction.transId);
                    Console.WriteLine("Submitted on (Local): {0}", transaction.submitTimeLocal);
                    Console.WriteLine("Status: {0}", transaction.transactionStatus);
                    Console.WriteLine("Settle amount: {0}", transaction.settleAmount);
                }
            }
            else if (response != null)
            {
                Console.WriteLine("Error: " + response.messages.message[0].code + "  " +
                                  response.messages.message[0].text);
            }

            return(response);
        }
Exemple #5
0
        public static decimal Run(String ApiLoginID, String ApiTransactionKey, string customerProfileId)
        {
            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,
            };

            var request = new getTransactionListForCustomerRequest();

            request.customerProfileId = customerProfileId;

            // instantiate the controller that will call the service
            var controller = new getTransactionListForCustomerController(request);

            controller.Execute();

            // get the response from the service (errors contained if any)
            var response = controller.GetApiResponse();

            decimal totalAmount = 0;

            if (response != null && response.messages.resultCode == messageTypeEnum.Ok)
            {
                if (response.transactions == null)
                {
                    return(0);
                }


                foreach (var transaction in response.transactions)
                {
                    totalAmount += transaction.settleAmount;
                }
            }


            return(totalAmount);
        }