コード例 #1
0
        public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey)
        {
            Console.WriteLine("Get A List of Subscriptions Sample");

            ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;

            ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
            {
                name = ApiLoginID,
                ItemElementName = ItemChoiceType.transactionKey,
                Item = ApiTransactionKey,
            };

            var request = new ARBGetSubscriptionListRequest {searchType = ARBGetSubscriptionListSearchTypeEnum.subscriptionActive };    // only gets active subscriptions

            var controller = new ARBGetSubscriptionListController(request);          // instantiate the contoller that will call the service
            controller.Execute();

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

            //validate
            if (response != null && response.messages.resultCode == messageTypeEnum.Ok)
            {
                if (response != null && response.messages.message != null && response.subscriptionDetails != null)
                {
                    Console.WriteLine("Success, " + response.totalNumInResultSet + " Results Returned ");
                }
            }
            else if(response != null)
            {
                Console.WriteLine("Error: " + response.messages.message[0].code + "  " + response.messages.message[0].text);
            }

            return response;
        }
コード例 #2
0
        public void GetSubscriptionSearchCardExpiringThisMonthIssueTest()
        {
            var getSubscriptionList = new ARBGetSubscriptionListRequest()
            {
                searchType = ARBGetSubscriptionListSearchTypeEnum.cardExpiringThisMonth,
            };

            ApiOperationBase <ANetApiRequest, ANetApiResponse> .MerchantAuthentication = CustomMerchantAuthenticationType;
            ApiOperationBase <ANetApiRequest, ANetApiResponse> .RunEnvironment         = TestEnvironment;
            var nullController = new ARBGetSubscriptionListController(getSubscriptionList);

            Assert.IsNull(nullController, "Controller should not be instantiated.");
        }
コード例 #3
0
        private ARBGetSubscriptionListResponse GetSubscriptionListResponse(int limitNo, int offSetNo)
        {
            var getSubscriptionList = new ARBGetSubscriptionListRequest()
            {
                searchType = ARBGetSubscriptionListSearchTypeEnum.subscriptionActive,
                paging     = new Paging()
                {
                    limit  = limitNo,
                    offset = offSetNo
                },
            };

            ApiOperationBase <ANetApiRequest, ANetApiResponse> .MerchantAuthentication = CustomMerchantAuthenticationType;
            ApiOperationBase <ANetApiRequest, ANetApiResponse> .RunEnvironment         = TestEnvironment;
            var arbGetSubscriptionListController = new ARBGetSubscriptionListController(getSubscriptionList);
            var arbGetSubscriptionListResponse   = arbGetSubscriptionListController.ExecuteWithApiResponse();

            return(arbGetSubscriptionListResponse);
        }
コード例 #4
0
        public static void Run(string apiLoginId, string apiTransactionKey)
        {
            Console.WriteLine("Get A List of Subscriptions Sample");

            ApiOperationBase <ANetApiRequest, ANetApiResponse> .RunEnvironment = AuthorizeNet.Environment.SANDBOX;

            ApiOperationBase <ANetApiRequest, ANetApiResponse> .MerchantAuthentication = new merchantAuthenticationType()
            {
                name            = apiLoginId,
                ItemElementName = ItemChoiceType.transactionKey,
                Item            = apiTransactionKey,
            };

            var request = new ARBGetSubscriptionListRequest {
                searchType = ARBGetSubscriptionListSearchTypeEnum.subscriptionActive
            };                                                                       // only gets active subscriptions

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

            controller.Execute();

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

            //validate
            if (response != null && response.messages.resultCode == messageTypeEnum.Ok)
            {
                if (response.messages.message != null && response.subscriptionDetails != null)
                {
                    Console.WriteLine("Success, " + response.totalNumInResultSet + " Results Returned ");
                }
            }
            else
            {
                if (response != null)
                {
                    Console.WriteLine("Error: " + response.messages.message[0].code + "  " + response.messages.message[0].text);
                }
            }
        }
コード例 #5
0
        public void SampleCodeGetSubscriptionList()
        {
            LogHelper.info(Logger, "Sample GetSubscriptionList");

            ApiOperationBase <ANetApiRequest, ANetApiResponse> .MerchantAuthentication = CustomMerchantAuthenticationType;
            ApiOperationBase <ANetApiRequest, ANetApiResponse> .RunEnvironment         = TestEnvironment;

            //create a subscription
            var createRequest = new ARBCreateSubscriptionRequest
            {
                refId        = RefId,
                subscription = ArbSubscriptionOne,
            };

            var createController = new ARBCreateSubscriptionController(createRequest);

            createController.RequestId = Guid.NewGuid();

            createController.Execute();
            var createResponse = createController.GetApiResponse();

            Assert.IsNotNull(createResponse.subscriptionId);
            LogHelper.info(Logger, "Created Subscription: {0}", createResponse.subscriptionId);
            var subscriptionId = createResponse.subscriptionId;

            //get subscription details
            var getRequest = new ARBGetSubscriptionStatusRequest
            {
                refId          = RefId,
                subscriptionId = subscriptionId
            };
            var getController = new ARBGetSubscriptionStatusController(getRequest);
            var getResponse   = getController.ExecuteWithApiResponse();

            Assert.IsNotNull(getResponse.status);
            Logger.info(String.Format("Subscription Status: {0}", getResponse.status));

            //get subscription list that contains only the subscription created above.
            var listRequest = new ARBGetSubscriptionListRequest
            {
                refId      = RefId,
                searchType = ARBGetSubscriptionListSearchTypeEnum.subscriptionActive,
                sorting    = new ARBGetSubscriptionListSorting
                {
                    orderDescending = true,
                    orderBy         = ARBGetSubscriptionListOrderFieldEnum.createTimeStampUTC,
                },
                paging = new Paging
                {
                    limit  = 500,
                    offset = 1,
                },
            };
            var listController = new ARBGetSubscriptionListController(listRequest);
            var listResponse   = listController.ExecuteWithApiResponse();

            LogHelper.info(Logger, "Subscription Count: {0}", listResponse.totalNumInResultSet);
            Assert.IsTrue(0 < listResponse.totalNumInResultSet);

            //validation of list
            var subscriptionsArray = listResponse.subscriptionDetails;

            foreach (var aSubscription in subscriptionsArray)
            {
                Assert.IsTrue(0 < aSubscription.id);
                LogHelper.info(Logger, "Subscription Id: {0}, Status:{1}, PaymentMethod: {2}, Amount: {3}, Account:{4}",
                               aSubscription.id, aSubscription.status, aSubscription.paymentMethod, aSubscription.amount, aSubscription.accountNumber);
            }

            //cancel subscription
            var cancelRequest = new ARBCancelSubscriptionRequest
            {
                merchantAuthentication = CustomMerchantAuthenticationType,
                refId          = RefId,
                subscriptionId = subscriptionId
            };
            var cancelController = new ARBCancelSubscriptionController(cancelRequest);
            var cancelResponse   = cancelController.ExecuteWithApiResponse(TestEnvironment);

            Assert.IsNotNull(cancelResponse.messages);
            Logger.info(String.Format("Subscription Cancelled: {0}", subscriptionId));
        }
コード例 #6
0
        private ARBGetSubscriptionListResponse GetSubscriptionListResponse(int limitNo, int offSetNo)
        {
            var getSubscriptionList = new ARBGetSubscriptionListRequest()
            {
                searchType = ARBGetSubscriptionListSearchTypeEnum.subscriptionActive,
                paging = new Paging()
                {
                    limit = limitNo,
                    offset = offSetNo
                },

            };

            ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = CustomMerchantAuthenticationType;
            ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = TestEnvironment;
            var arbGetSubscriptionListController = new ARBGetSubscriptionListController(getSubscriptionList);
            var arbGetSubscriptionListResponse = arbGetSubscriptionListController.ExecuteWithApiResponse();
            return arbGetSubscriptionListResponse;

        }
コード例 #7
0
        public void GetSubscriptionSearchCardExpiringThisMonthFixTest()
        {
            Random rnd = new Random(DateTime.Now.Millisecond);
            var createSubscription = new ARBSubscriptionType()
            {
                paymentSchedule = new paymentScheduleType
                {
                    interval = new paymentScheduleTypeInterval
                    {
                        length = 8,
                        unit = ARBSubscriptionUnitEnum.months
                    },
                    startDate = DateTime.UtcNow,
                    totalOccurrences = 3,
                },
                amount = 19.29M,

                billTo = new nameAndAddressType
                {
                    address = "1234 Elm St NE",
                    city = "Bellevue",
                    state = "WA",
                    zip = "98007",
                    firstName = "First",
                    lastName = "Last"
                },

                payment = new paymentType
                {
                    Item = new creditCardType
                    {
                        cardCode = "123",
                        cardNumber = "5105105105105100",
                        // cardNumber = "4111111111111111",
                        expirationDate = "102015",
                    }
                },

                customer = new customerType { email = "*****@*****.**", id = "5", },

                order = new orderType { description = string.Format("member monthly {0}", rnd.Next(99999)) },
            };
            var arbCreateSubscriptionController = CreateSubscriptionRequestTest(createSubscription);
            var arbCreateSubscriptionResponse = arbCreateSubscriptionController.ExecuteWithApiResponse();

            if (null == arbCreateSubscriptionResponse)
            {
                throw new ArgumentNullException("arbCreateSubscriptionResponse");
            }

            var getSubscriptionList = new ARBGetSubscriptionListRequest()
            {
                searchType = ARBGetSubscriptionListSearchTypeEnum.cardExpiringThisMonth,

            };

            var arbGetSubscriptionListController = new ARBGetSubscriptionListController(getSubscriptionList);
            var arbGetSubscriptionListResponse = arbGetSubscriptionListController.ExecuteWithApiResponse();

            Assert.IsNotNull(arbGetSubscriptionListResponse);
        }
コード例 #8
0
        public void GetSubscriptionSearchCardExpiringThisMonthIssueTest()
        {
           var getSubscriptionList = new ARBGetSubscriptionListRequest()
                {
                   searchType = ARBGetSubscriptionListSearchTypeEnum.cardExpiringThisMonth,
                    
                };

           ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = CustomMerchantAuthenticationType;
           ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = TestEnvironment;
            var nullController = new ARBGetSubscriptionListController(getSubscriptionList);
            Assert.IsNull( nullController, "Controller should not be instantiated.");
        }
コード例 #9
0
        public void GetSubscriptionSearchCardExpiringThisMonthFixTest()
        {
            Random rnd = new Random(DateTime.Now.Millisecond);
            var    createSubscription = new ARBSubscriptionType()
            {
                paymentSchedule = new paymentScheduleType
                {
                    interval = new paymentScheduleTypeInterval
                    {
                        length = 8,
                        unit   = ARBSubscriptionUnitEnum.months
                    },
                    startDate        = DateTime.UtcNow,
                    totalOccurrences = 3,
                },
                amount = 19.29M,

                billTo = new nameAndAddressType
                {
                    address   = "1234 Elm St NE",
                    city      = "Bellevue",
                    state     = "WA",
                    zip       = "98007",
                    firstName = "First",
                    lastName  = "Last"
                },

                payment = new paymentType
                {
                    Item = new creditCardType
                    {
                        cardCode   = "123",
                        cardNumber = "5105105105105100",
                        // cardNumber = "4111111111111111",
                        expirationDate = "102015",
                    }
                },

                customer = new customerType {
                    email = "*****@*****.**", id = "5",
                },

                order = new orderType {
                    description = string.Format("member monthly {0}", rnd.Next(99999))
                },
            };
            var arbCreateSubscriptionController = CreateSubscriptionRequestTest(createSubscription);
            var arbCreateSubscriptionResponse   = arbCreateSubscriptionController.ExecuteWithApiResponse();

            if (null == arbCreateSubscriptionResponse)
            {
                throw new ArgumentNullException("arbCreateSubscriptionResponse");
            }

            var getSubscriptionList = new ARBGetSubscriptionListRequest()
            {
                searchType = ARBGetSubscriptionListSearchTypeEnum.cardExpiringThisMonth,
            };

            var arbGetSubscriptionListController = new ARBGetSubscriptionListController(getSubscriptionList);
            var arbGetSubscriptionListResponse   = arbGetSubscriptionListController.ExecuteWithApiResponse();

            Assert.IsNotNull(arbGetSubscriptionListResponse);
        }
コード例 #10
0
        public void SampleCodeGetSubscriptionList()
        {
            LogHelper.info(Logger, "Sample GetSubscriptionList");

            ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = CustomMerchantAuthenticationType;
            ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = TestEnvironment;

            //create a subscription
            var createRequest = new ARBCreateSubscriptionRequest
            {
                refId = RefId,
                subscription = ArbSubscriptionOne,
            };

            var createController = new ARBCreateSubscriptionController(createRequest);
            createController.Execute();
            var createResponse = createController.GetApiResponse();
            Assert.IsNotNull(createResponse.subscriptionId);
            LogHelper.info(Logger, "Created Subscription: {0}", createResponse.subscriptionId);
            var subscriptionId = createResponse.subscriptionId;

            //get subscription details
		    var getRequest = new ARBGetSubscriptionStatusRequest
		        {
		            refId = RefId,
		            subscriptionId = subscriptionId
		        };
            var getController = new ARBGetSubscriptionStatusController(getRequest);
            var getResponse = getController.ExecuteWithApiResponse();
		    Assert.IsNotNull(getResponse.status);
		    Logger.info(String.Format("Subscription Status: {0}", getResponse.status));

            //get subscription list that contains only the subscription created above.
	        var listRequest = new ARBGetSubscriptionListRequest
	            {
	                refId = RefId,
	                searchType = ARBGetSubscriptionListSearchTypeEnum.subscriptionActive,
		            sorting = new ARBGetSubscriptionListSorting
		                {
		                    orderDescending = true,
		                    orderBy = ARBGetSubscriptionListOrderFieldEnum.createTimeStampUTC,
		                },
		            paging = new Paging
	                    {
	                        limit = 500, 
                            offset = 1,
	                    },
	            };
            var listController = new ARBGetSubscriptionListController(listRequest);
            var listResponse = listController.ExecuteWithApiResponse();
            LogHelper.info(Logger, "Subscription Count: {0}", listResponse.totalNumInResultSet);
            Assert.IsTrue(0 < listResponse.totalNumInResultSet);

            //validation of list
            var subscriptionsArray = listResponse.subscriptionDetails;
            foreach (var aSubscription in subscriptionsArray)
            {
                Assert.IsTrue(0 < aSubscription.id);
                LogHelper.info(Logger, "Subscription Id: {0}, Status:{1}, PaymentMethod: {2}, Amount: {3}, Account:{4}",
                        aSubscription.id, aSubscription.status, aSubscription.paymentMethod, aSubscription.amount, aSubscription.accountNumber);
            }

            //cancel subscription
            var cancelRequest = new ARBCancelSubscriptionRequest
            {
                merchantAuthentication = CustomMerchantAuthenticationType,
                refId = RefId,
                subscriptionId = subscriptionId
            };
            var cancelController = new ARBCancelSubscriptionController(cancelRequest);
            var cancelResponse = cancelController.ExecuteWithApiResponse(TestEnvironment);
            Assert.IsNotNull(cancelResponse.messages);
            Logger.info(String.Format("Subscription Cancelled: {0}", subscriptionId));
        }
コード例 #11
0
        //public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey)
        //{
        //    Console.WriteLine("Get A List of Subscriptions Sample");

        //    ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNET.Environment.SANDBOX;

        //    ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
        //    {
        //        name = ApiLoginID,
        //        ItemElementName = ItemChoiceType.transactionKey,
        //        Item = ApiTransactionKey,
        //    };

        //    var request = new ARBGetSubscriptionListRequest {searchType = ARBGetSubscriptionListSearchTypeEnum.subscriptionActive };    // only gets active subscriptions

        //    var controller = new ARBGetSubscriptionListController(request);          // instantiate the contoller that will call the service
        //    controller.Execute();

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

        //    //validate
        //    if (response != null && response.messages.resultCode == messageTypeEnum.Ok)
        //    {
        //        if (response != null && response.messages.message != null && response.subscriptionDetails != null)
        //        {
        //            Console.WriteLine("Success, " + response.totalNumInResultSet + " Results Returned ");
        //        }
        //    }
        //    else if(response != null)
        //    {
        //        Console.WriteLine("Error: " + response.messages.message[0].code + "  " + response.messages.message[0].text);
        //    }

        //    return response;
        //}
        public static void GetListOfSubscriptionsExec(String ApiLoginID, String ApiTransactionKey)
        {
            using (CsvReader csv = new CsvReader(new StreamReader(new FileStream(@"../../../CSV_DATA/CreateASubscriptionFromCustomerProfile.csv", FileMode.Open)), true))
            {
                Console.WriteLine("Get A List of Subscriptions Sample");
                int      flag       = 0;
                int      fieldCount = csv.FieldCount;
                string[] headers    = csv.GetFieldHeaders();
                //Append Data
                var item1 = DataAppend.ReadPrevData();
                using (CsvFileWriter writer = new CsvFileWriter(new FileStream(@"../../../CSV_DATA/Outputfile.csv", FileMode.Open)))
                {
                    while (csv.ReadNextRecord())
                    {
                        // Create Instance of Customer Api
                        ApiOperationBase <ANetApiRequest, ANetApiResponse> .RunEnvironment = AuthorizeNET.Environment.SANDBOX;

                        string TestCase_Id = null;

                        string apiLoginID        = null;
                        string apiTransactionKey = null;
                        for (int i = 0; i < fieldCount; i++)
                        {
                            switch (headers[i])
                            {
                            case "apiLoginID":
                                apiLoginID = csv[i];
                                break;

                            case "apiTransactionKey":
                                apiTransactionKey = csv[i];
                                break;

                            case "TestCase_Id":
                                TestCase_Id = csv[i];
                                break;

                            default:
                                break;
                            }
                        }
                        // define the merchant information (authentication / transaction id)
                        ApiOperationBase <ANetApiRequest, ANetApiResponse> .MerchantAuthentication = new merchantAuthenticationType()
                        {
                            name            = apiLoginID,
                            ItemElementName = ItemChoiceType.transactionKey,
                            Item            = apiTransactionKey,
                        };
                        //Write to output file
                        CsvRow row = new CsvRow();
                        try
                        {
                            if (flag == 0)
                            {
                                row.Add("TestCaseId");
                                row.Add("APIName");
                                row.Add("Status");
                                row.Add("TimeStamp");
                                writer.WriteRow(row);
                                flag = flag + 1;
                                //Append Data
                                foreach (var item in item1)
                                {
                                    writer.WriteRow(item);
                                }
                            }
                            var request = new ARBGetSubscriptionListRequest {
                                searchType = ARBGetSubscriptionListSearchTypeEnum.subscriptionActive
                            };                                                                       // only gets active subscriptions

                            var controller = new ARBGetSubscriptionListController(request);          // instantiate the contoller that will call the service
                            controller.Execute();

                            ARBGetSubscriptionListResponse response = controller.GetApiResponse();



                            if (response != null && response.messages.resultCode == messageTypeEnum.Ok &&
                                response.messages.message != null && response.subscriptionDetails != null)
                            {
                                try
                                {
                                    //Assert.AreEqual(response.Id, customerProfileId);
                                    Console.WriteLine("Assertion Succeed! Valid CustomerId fetched.");
                                    CsvRow row1 = new CsvRow();
                                    row1.Add("GLOS_00" + flag.ToString());
                                    row1.Add("GetListOfSubscription");
                                    row1.Add("Pass");
                                    row1.Add(DateTime.Now.ToString("yyyy/MM/dd" + "::" + "HH:mm:ss:fff"));
                                    writer.WriteRow(row1);
                                    //  Console.WriteLine("Success " + TestcaseID + " CustomerID : " + response.Id);
                                    flag = flag + 1;
                                    Console.WriteLine("Success, " + response.totalNumInResultSet + " Results Returned ");
                                }
                                catch
                                {
                                    CsvRow row1 = new CsvRow();
                                    row1.Add("GLOS_00" + flag.ToString());
                                    row1.Add("GetListOfSubscription");
                                    row1.Add("Assertion Failed!");
                                    row1.Add(DateTime.Now.ToString("yyyy/MM/dd" + "::" + "HH:mm:ss:fff"));
                                    writer.WriteRow(row1);
                                    Console.WriteLine("Assertion Failed! Invalid CustomerId fetched.");
                                    flag = flag + 1;
                                }
                            }
                            else
                            {
                                CsvRow row1 = new CsvRow();
                                row1.Add("GLOS_00" + flag.ToString());
                                row1.Add("GetListOfSubscription");
                                row1.Add("Fail");
                                row1.Add(DateTime.Now.ToString("yyyy/MM/dd" + "::" + "HH:mm:ss:fff"));
                                writer.WriteRow(row1);
                                //Console.WriteLine("Assertion Failed! Invalid CustomerId fetched.");
                                flag = flag + 1;
                            }
                        }
                        catch (Exception e)
                        {
                            CsvRow row2 = new CsvRow();
                            row2.Add("GLOS_00" + flag.ToString());
                            row2.Add("GetListOfSubscription");
                            row2.Add("Fail");
                            row2.Add(DateTime.Now.ToString("yyyy/MM/dd" + "::" + "HH:mm:ss:fff"));
                            writer.WriteRow(row2);
                            flag = flag + 1;
                            Console.WriteLine(TestCase_Id + " Error Message " + e.Message);
                        }
                    }
                }
            }
        }