Beispiel #1
0
 public static void ARBUpdateSubscriptionRequest(ARBUpdateSubscriptionRequest request)
 {
     if (null != request)
     {
         ARBSubscriptionType(request.subscription);
     }
 }
Beispiel #2
0
        public void MockARBUpdateSubscriptionTest()
        {
            //define all mocked objects as final
            var mockController = GetMockController <ARBUpdateSubscriptionRequest, ARBUpdateSubscriptionResponse>();
            var mockRequest    = new ARBUpdateSubscriptionRequest
            {
                merchantAuthentication = new merchantAuthenticationType {
                    name = "mocktest", Item = "mockKey", ItemElementName = ItemChoiceType.transactionKey
                },
            };
            var mockResponse = new ARBUpdateSubscriptionResponse
            {
                refId        = "1234",
                sessionToken = "sessiontoken",
            };

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

            SetMockControllerExpectations <ARBUpdateSubscriptionRequest, ARBUpdateSubscriptionResponse, ARBUpdateSubscriptionController>(
                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);
        }
Beispiel #3
0
        /// <summary>
        /// Fill in the given request with test data used to update the subscription.
        /// </summary>
        /// <param name="payment">The payment object.</param>
        private static ARBUpdateSubscriptionRequest PopulateUpdateSubscriptionRequest(CreditCardPayment payment)
        {
            ARBUpdateSubscriptionRequest request = new ARBUpdateSubscriptionRequest();

            PaymentPlan plan = (PaymentPlan)payment.Parent.Parent;

            ARBSubscriptionType sub        = new ARBSubscriptionType();
            creditCardType      creditCard = new creditCardType();

            request.subscriptionId = payment.AuthorizationCode;

            // update the subscription information
            creditCard.cardNumber     = payment.CreditCardNumber;
            creditCard.expirationDate = String.Format("{0:d4}-{1:d2}", payment.ExpirationYear, payment.ExpirationMonth);              // required format for API is YYYY-MM
            sub.payment      = new paymentType();
            sub.payment.Item = creditCard;

            // Find the address
            OrderAddress address = null;

            foreach (OrderAddress a in plan.OrderAddresses)
            {
                if (a.Name == payment.BillingAddressId)
                {
                    address = a;
                    break;
                }
            }

            sub.billTo           = new nameAndAddressType();
            sub.billTo.firstName = address.FirstName;
            sub.billTo.lastName  = address.LastName;

            sub.amount          = GetSumInUSD(payment.Amount, plan.BillingCurrency);
            sub.amountSpecified = true;

            sub.order = new orderType();
            sub.order.invoiceNumber = plan.OrderGroupId.ToString();

            sub.customer       = new customerType();
            sub.customer.email = address.Email;

            request.subscription = sub;

            return(request);
        }
        /// <summary>
        /// Update an existing ARB subscription using the subscription ID returned by the create.
        /// </summary>
        public ARBUpdateSubscriptionResponse UpdateSubscription(ARBUpdateSubscriptionRequest updateSubscriptionRequest)
        {
            // Populate the authentication information
            PopulateMerchantAuthentication((ANetApiRequest)updateSubscriptionRequest);
            ValidateUpdateSubscribtionParameters(updateSubscriptionRequest);

            // The response type will normally be ARBUpdateSubscriptionResponse.
            // However, in the case of an error such as an XML parsing error, the response
            //   type will be ErrorResponse.

            object response = ProcessRequest(updateSubscriptionRequest);

            // process response. If there are any errors, exception will be thrown.
            CheckResponseForErrors(response);

            return((ARBUpdateSubscriptionResponse)response);
        }
        public static ANetApiResponse Run(string ApiLoginID, string ApiTransactionKey, string subscriptionId)
        {
            Console.WriteLine("Update Subscription Sample");

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

            paymentScheduleType schedule = new paymentScheduleType
            {
                startDate        = DateTime.Now.AddDays(1), // start date should be tomorrow
                totalOccurrences = 9999                     // 999 indicates no end date
            };

            #region Payment Information
            var creditCard = new creditCardType
            {
                cardNumber     = "4111111111111111",
                expirationDate = "0718"
            };

            //standard api call to retrieve response
            paymentType cc = new paymentType {
                Item = creditCard
            };
            #endregion

            nameAndAddressType addressInfo = new nameAndAddressType()
            {
                firstName = "Calvin",
                lastName  = "Brown"
            };

            customerProfileIdType customerProfile = new customerProfileIdType()
            {
                customerProfileId        = "1232312",
                customerPaymentProfileId = "2132132",
                customerAddressId        = "1233432"
            };

            ARBSubscriptionType subscriptionType = new ARBSubscriptionType()
            {
                amount          = 35.55m,
                paymentSchedule = schedule,
                billTo          = addressInfo,
                payment         = cc
                                  //You can pass a profile to update subscription
                                  //,profile = customerProfile
            };

            //Please change the subscriptionId according to your request
            var request = new ARBUpdateSubscriptionRequest {
                subscription = subscriptionType, subscriptionId = subscriptionId
            };
            var controller = new ARBUpdateSubscriptionController(request);
            controller.Execute();

            ARBUpdateSubscriptionResponse response = controller.GetApiResponse();

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

            return(response);
        }
Beispiel #6
0
        public async Task <ITransactionResponse> UpdateSubscription(ICustomerPayment customerPayment)
        {
            var transactionResponse = new TransactionResponse();

            var task = Task.Run(() =>
            {
                if (Convert.ToBoolean(string.IsNullOrEmpty(ConfigurationManager.AppSettings["AuthNetIsProduction"]) ? "false" : ConfigurationManager.AppSettings["AuthNetIsProduction"]))
                {
                    ApiOperationBase <ANetApiRequest, ANetApiResponse> .RunEnvironment = AuthorizeNet.Environment.PRODUCTION;
                }
                else
                {
                    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 subscription
                var subscriptionRequest = new ARBGetSubscriptionRequest {
                    subscriptionId = customerPayment.SubscriptionId
                };

                var controllerSubscription = new ARBGetSubscriptionController(subscriptionRequest);          // instantiate the contoller that will call the service
                controllerSubscription.Execute();

                ARBGetSubscriptionResponse subscriptionResponse = controllerSubscription.GetApiResponse();   // get the response from the service (errors contained if any)

                //validate
                if (subscriptionResponse != null && subscriptionResponse.messages.resultCode == messageTypeEnum.Ok)
                {
                    if (subscriptionResponse.subscription != null)
                    {
                        //Do nothing
                    }
                }
                else if (subscriptionResponse != null)
                {
                    if (subscriptionResponse.messages.message.Length > 0)
                    {
                        transactionResponse.IsSuccess = false;

                        System.Diagnostics.Debug.WriteLine("Error: " + subscriptionResponse.messages.message[0].code + "  " + subscriptionResponse.messages.message[0].text);

                        transactionResponse.Messages = new TransactionResponseMessage[] { new TransactionResponseMessage()
                                                                                          {
                                                                                              Code = subscriptionResponse.messages.message[0].code, Description = subscriptionResponse.messages.message[0].text
                                                                                          } };
                    }
                }
                else
                {
                    if (controllerSubscription.GetErrorResponse().messages.message.Length > 0)
                    {
                        transactionResponse.IsSuccess = false;

                        System.Diagnostics.Debug.WriteLine("Error: " + subscriptionResponse.messages.message[0].code + "  " + subscriptionResponse.messages.message[0].text);

                        transactionResponse.Messages = new TransactionResponseMessage[] { new TransactionResponseMessage()
                                                                                          {
                                                                                              Code = subscriptionResponse.messages.message[0].code, Description = subscriptionResponse.messages.message[0].text
                                                                                          } };
                    }
                }

                var currentSubscription = subscriptionResponse.subscription;

                var creditCard = new creditCardType
                {
                    cardNumber     = customerPayment.CardNumber,
                    expirationDate = customerPayment.ExpirationDate,
                    cardCode       = customerPayment.CardCode
                };

                var billingAddress = new nameAndAddressType
                {
                    company   = customerPayment.Company,
                    firstName = customerPayment.FirstName,
                    lastName  = customerPayment.LastName,
                    address   = customerPayment.Address,
                    city      = customerPayment.City,
                    zip       = customerPayment.Zip
                };

                //standard api call to retrieve response
                var paymentType = new paymentType {
                    Item = creditCard
                };

                ARBSubscriptionType subscriptionType = new ARBSubscriptionType()
                {
                    billTo  = billingAddress,
                    payment = paymentType
                };

                var request = new ARBUpdateSubscriptionRequest {
                    subscription = subscriptionType, subscriptionId = customerPayment.SubscriptionId
                };

                // instantiate the contoller that will call the service
                var controller = new ARBUpdateSubscriptionController(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 != null && response.messages.message != null)
                    {
                        System.Diagnostics.Debug.WriteLine("Success");

                        transactionResponse.Errors    = null;
                        transactionResponse.IsSuccess = true;
                        transactionResponse.Messages  = null;
                    }
                    else
                    {
                        transactionResponse.IsSuccess = false;
                    }
                }
                else if (response != null && response.messages.message != null)
                {
                    transactionResponse.IsSuccess = false;

                    System.Diagnostics.Debug.WriteLine("Error: " + response.messages.message[0].code + "  " + response.messages.message[0].text);

                    transactionResponse.Messages = new TransactionResponseMessage[] { new TransactionResponseMessage()
                                                                                      {
                                                                                          Code = response.messages.message[0].code, Description = response.messages.message[0].text
                                                                                      } };
                }

                return(response);
            });

            await task;

            return(transactionResponse);
        }
Beispiel #7
0
        public static void Run(String ApiLoginID, String ApiTransactionKey, string RefID, string subscriptionID)
        {
            Console.WriteLine("Update Subscription Sample");

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

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

            paymentScheduleType schedule = new paymentScheduleType
            {
                startDate        = DateTime.Now.AddDays(1), // start date should be tomorrow
                totalOccurrences = 9999                     // 999 indicates no end date
            };

            #region Payment Information
            var creditCard = new creditCardType
            {
                cardNumber     = "4111111111111111",
                expirationDate = "0718"
            };

            //standard api call to retrieve response
            paymentType cc = new paymentType {
                Item = creditCard
            };
            #endregion

            nameAndAddressType addressInfo = new nameAndAddressType()
            {
                firstName = "Calvin",
                lastName  = "Brown"
            };

            ARBSubscriptionType subscriptionType = new ARBSubscriptionType()
            {
                amount          = 35.55m,
                paymentSchedule = schedule,
                billTo          = addressInfo,
                payment         = cc
            };

            var request = new ARBUpdateSubscriptionRequest {
                refId = RefID, subscription = subscriptionType, subscriptionId = "2323"
            };

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

            ARBUpdateSubscriptionResponse 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)
                {
                    Console.WriteLine("Success, RefID Code : " + response.refId);
                }
            }
            else
            {
                Console.WriteLine("Error: " + response.messages.message[0].code + "  " + response.messages.message[0].text);
            }
        }
        /// <summary>
        /// Checks the length of strings in the request and corrects it when needed.
        /// </summary>
        /// <param name="request"></param>
        private void ValidateUpdateSubscribtionParameters(ARBUpdateSubscriptionRequest request)
        {
            if (request.subscription != null)
            {
                if (!String.IsNullOrEmpty(request.subscription.name) && request.subscription.name.Length > 50)
                {
                    request.subscription.name = request.subscription.name.Substring(0, 50);
                }

                if (request.subscription.customer != null)
                {
                    if (!String.IsNullOrEmpty(request.subscription.customer.id) && request.subscription.customer.id.Length > 20)
                    {
                        request.subscription.customer.id = request.subscription.customer.id.Substring(0, 20);
                    }

                    if (!String.IsNullOrEmpty(request.subscription.customer.email) && request.subscription.customer.email.Length > 255)
                    {
                        request.subscription.customer.email = request.subscription.customer.email.Substring(0, 255);
                    }

                    if (!String.IsNullOrEmpty(request.subscription.customer.phoneNumber) && request.subscription.customer.phoneNumber.Length > 25)
                    {
                        request.subscription.customer.phoneNumber = request.subscription.customer.phoneNumber.Substring(0, 25);
                    }

                    if (!String.IsNullOrEmpty(request.subscription.customer.faxNumber) && request.subscription.customer.faxNumber.Length > 25)
                    {
                        request.subscription.customer.faxNumber = request.subscription.customer.faxNumber.Substring(0, 25);
                    }
                }

                if (request.subscription.order != null)
                {
                    if (!String.IsNullOrEmpty(request.subscription.order.invoiceNumber) && request.subscription.order.invoiceNumber.Length > 20)
                    {
                        request.subscription.order.invoiceNumber = request.subscription.order.invoiceNumber.Substring(0, 20);
                    }

                    if (!String.IsNullOrEmpty(request.subscription.order.description) && request.subscription.order.description.Length > 255)
                    {
                        request.subscription.order.description = request.subscription.order.description.Substring(0, 255);
                    }
                }

                if (request.subscription.billTo != null)
                {
                    if (!String.IsNullOrEmpty(request.subscription.billTo.firstName) && request.subscription.billTo.firstName.Length > 50)
                    {
                        request.subscription.billTo.firstName = request.subscription.billTo.firstName.Substring(0, 50);
                    }

                    if (!String.IsNullOrEmpty(request.subscription.billTo.lastName) && request.subscription.billTo.lastName.Length > 50)
                    {
                        request.subscription.billTo.lastName = request.subscription.billTo.lastName.Substring(0, 50);
                    }

                    if (!String.IsNullOrEmpty(request.subscription.billTo.company) && request.subscription.billTo.company.Length > 50)
                    {
                        request.subscription.billTo.company = request.subscription.billTo.company.Substring(0, 50);
                    }

                    if (!String.IsNullOrEmpty(request.subscription.billTo.address) && request.subscription.billTo.address.Length > 60)
                    {
                        request.subscription.billTo.address = request.subscription.billTo.address.Substring(0, 60);
                    }

                    if (!String.IsNullOrEmpty(request.subscription.billTo.city) && request.subscription.billTo.city.Length > 40)
                    {
                        request.subscription.billTo.city = request.subscription.billTo.city.Substring(0, 40);
                    }

                    if (!String.IsNullOrEmpty(request.subscription.billTo.state) && request.subscription.billTo.state.Length > 2)
                    {
                        request.subscription.billTo.state = request.subscription.billTo.state.Substring(0, 2);
                    }

                    if (!String.IsNullOrEmpty(request.subscription.billTo.zip) && request.subscription.billTo.zip.Length > 20)
                    {
                        request.subscription.billTo.zip = request.subscription.billTo.zip.Substring(0, 20);
                    }

                    if (!String.IsNullOrEmpty(request.subscription.billTo.country) && request.subscription.billTo.country.Length > 60)
                    {
                        request.subscription.billTo.country = request.subscription.billTo.country.Substring(0, 60);
                    }
                }

                if (request.subscription.shipTo != null)
                {
                    if (!String.IsNullOrEmpty(request.subscription.shipTo.firstName) && request.subscription.shipTo.firstName.Length > 50)
                    {
                        request.subscription.shipTo.firstName = request.subscription.shipTo.firstName.Substring(0, 50);
                    }

                    if (!String.IsNullOrEmpty(request.subscription.shipTo.lastName) && request.subscription.shipTo.lastName.Length > 50)
                    {
                        request.subscription.shipTo.lastName = request.subscription.shipTo.lastName.Substring(0, 50);
                    }

                    if (!String.IsNullOrEmpty(request.subscription.shipTo.company) && request.subscription.shipTo.company.Length > 50)
                    {
                        request.subscription.shipTo.company = request.subscription.shipTo.company.Substring(0, 50);
                    }

                    if (!String.IsNullOrEmpty(request.subscription.shipTo.address) && request.subscription.shipTo.address.Length > 60)
                    {
                        request.subscription.shipTo.address = request.subscription.shipTo.address.Substring(0, 60);
                    }

                    if (!String.IsNullOrEmpty(request.subscription.shipTo.city) && request.subscription.shipTo.city.Length > 40)
                    {
                        request.subscription.shipTo.city = request.subscription.shipTo.city.Substring(0, 40);
                    }

                    if (!String.IsNullOrEmpty(request.subscription.shipTo.state) && request.subscription.shipTo.state.Length > 40)
                    {
                        request.subscription.shipTo.state = request.subscription.shipTo.state.Substring(0, 40);
                    }

                    if (!String.IsNullOrEmpty(request.subscription.shipTo.zip) && request.subscription.shipTo.zip.Length > 20)
                    {
                        request.subscription.shipTo.zip = request.subscription.shipTo.zip.Substring(0, 20);
                    }

                    if (!String.IsNullOrEmpty(request.subscription.shipTo.country) && request.subscription.shipTo.country.Length > 60)
                    {
                        request.subscription.shipTo.country = request.subscription.shipTo.country.Substring(0, 60);
                    }
                }
            }
        }
Beispiel #9
0
        //public static ANetApiResponse Run(string ApiLoginID, string ApiTransactionKey, string subscriptionId)
        //{
        //    Console.WriteLine("Update Subscription Sample");

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

        //    paymentScheduleType schedule = new paymentScheduleType
        //    {
        //        startDate = DateTime.Now.AddDays(1),      // start date should be tomorrow
        //        totalOccurrences = 9999                          // 999 indicates no end date
        //    };

        //    #region Payment Information
        //    var creditCard = new creditCardType
        //    {
        //        cardNumber = "4111111111111111",
        //        expirationDate = "0718"
        //    };

        //    //standard api call to retrieve response
        //    paymentType cc = new paymentType { Item = creditCard };
        //    #endregion

        //    nameAndAddressType addressInfo = new nameAndAddressType()
        //    {
        //        firstName = "Calvin",
        //        lastName = "Brown"
        //    };

        //    customerProfileIdType customerProfile = new customerProfileIdType()
        //    {
        //        customerProfileId = "1232312",
        //        customerPaymentProfileId = "2132132",
        //        customerAddressId = "1233432"
        //    };

        //    ARBSubscriptionType subscriptionType = new ARBSubscriptionType()
        //    {
        //        amount = 35.55m,
        //        paymentSchedule = schedule,
        //        billTo = addressInfo,
        //        payment = cc
        //        //You can pass a profile to update subscription
        //        //,profile = customerProfile
        //    };

        //    //Please change the subscriptionId according to your request
        //    var request = new ARBUpdateSubscriptionRequest { subscription = subscriptionType, subscriptionId = subscriptionId };
        //    var controller = new ARBUpdateSubscriptionController(request);
        //    controller.Execute();

        //    ARBUpdateSubscriptionResponse response = controller.GetApiResponse();

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

        //    return response;
        //}
        public static void UpdateSubscriptionExec(String ApiLoginID, String ApiTransactionKey)
        {
            using (CsvReader csv = new CsvReader(new StreamReader(new FileStream(@"../../../CSV_DATA/CancleASubscription.csv", FileMode.Open)), true))
            {
                Console.WriteLine("Update Subscription 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;
                        // define the merchant information (authentication / transaction id)
                        ApiOperationBase <ANetApiRequest, ANetApiResponse> .MerchantAuthentication = new merchantAuthenticationType()
                        {
                            name            = ApiLoginID,
                            ItemElementName = ItemChoiceType.transactionKey,
                            Item            = ApiTransactionKey,
                        };
                        string subscriptionId           = null;
                        string TestCase_Id              = null;
                        string firstName                = null;
                        string lastName                 = null;
                        string customerProfileId        = null;
                        string customerPaymentProfileId = null;
                        string customerAddressId        = null;
                        string amount = null;
                        for (int i = 0; i < fieldCount; i++)
                        {
                            switch (headers[i])
                            {
                            case "subscriptionId":
                                subscriptionId = csv[i];
                                break;

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

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

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

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

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

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

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

                            default:
                                break;
                            }
                        }
                        //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);
                                }
                            }

                            //response = instance.GetCustomer(customerId, authorization);
                            paymentScheduleType schedule = new paymentScheduleType
                            {
                                startDate        = DateTime.Now.AddDays(1), // start date should be tomorrow
                                totalOccurrences = 9999                     // 999 indicates no end date
                            };

                            #region Payment Information
                            var creditCard = new creditCardType
                            {
                                cardNumber     = "4111111111111111",
                                expirationDate = "0718"
                            };

                            //standard api call to retrieve response
                            paymentType cc = new paymentType {
                                Item = creditCard
                            };
                            #endregion

                            nameAndAddressType addressInfo = new nameAndAddressType()
                            {
                                firstName = firstName,
                                lastName  = lastName
                            };

                            customerProfileIdType customerProfile = new customerProfileIdType()
                            {
                                customerProfileId        = customerProfileId,
                                customerPaymentProfileId = customerPaymentProfileId,
                                customerAddressId        = customerAddressId
                            };

                            ARBSubscriptionType subscriptionType = new ARBSubscriptionType()
                            {
                                amount          = Convert.ToDecimal(amount),
                                paymentSchedule = schedule,
                                billTo          = addressInfo,
                                payment         = cc
                                                  //You can pass a profile to update subscription
                                                  //,profile = customerProfile
                            };

                            //Please change the subscriptionId according to your request
                            var request = new ARBUpdateSubscriptionRequest {
                                subscription = subscriptionType, subscriptionId = subscriptionId
                            };
                            var controller = new ARBUpdateSubscriptionController(request);
                            controller.Execute();

                            ARBUpdateSubscriptionResponse response = controller.GetApiResponse();
                            if (response != null && response.messages.resultCode == messageTypeEnum.Ok &&
                                response.messages.message != null)
                            {
                                try
                                {
                                    //Assert.AreEqual(response.Id, customerProfileId);
                                    Console.WriteLine("Assertion Succeed! Valid CustomerId fetched.");
                                    CsvRow row1 = new CsvRow();
                                    row1.Add("UAS_00" + flag.ToString());
                                    row1.Add("UpdateASubscription");
                                    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, RefID Code : " + response.refId);
                                }
                                catch
                                {
                                    CsvRow row1 = new CsvRow();
                                    row1.Add("UAS_00" + flag.ToString());
                                    row1.Add("UpdateASubscription");
                                    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("UAS_00" + flag.ToString());
                                row1.Add("UpdateASubscription");
                                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("UAS_00" + flag.ToString());
                            row2.Add("UpdateASubscription");
                            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);
                        }
                    }
                }
            }
        }