예제 #1
0
 public static void customerPaymentProfileExType(customerPaymentProfileExType request)
 {
     if (null != request)
     {
         customerPaymentProfileType(request);
         paymentType(request.payment);
     }
 }
        /// <summary>
        /// Creates an API object, ready to send to AuthNET servers.
        /// </summary>
        /// <returns></returns>
        public customerPaymentProfileExType ToAPI()
        {
            var result = new customerPaymentProfileExType();

            result.billTo = this.BillingAddress.ToAPIType();
            result.customerPaymentProfileId = this.ProfileID;

            if (!String.IsNullOrEmpty(this.DriversLicenseNumber))
            {
                result.driversLicense             = new driversLicenseType();
                result.driversLicense.dateOfBirth = this.DriversLicenseDOB;
                result.driversLicense.number      = this.DriversLicenseNumber;
                result.driversLicense.state       = this.DriversLicenseState;
            }

            if (this.IsBusiness)
            {
                result.customerType = customerTypeEnum.business;
            }
            else
            {
                result.customerType = customerTypeEnum.individual;
            }
            result.customerTypeSpecified = true;

            if (!String.IsNullOrEmpty(this.CardNumber))
            {
                var card = new creditCardType();
                card.cardCode       = this.CardCode;
                card.cardNumber     = this.CardNumber;
                card.expirationDate = this.CardExpiration;

                // edit by rcreecy
                if (result.payment == null)
                {
                    result.payment = new paymentType();
                }
                // end edit by rcreecy

                result.payment.Item = card;
            }
            if (!String.IsNullOrEmpty(this.TaxID))
            {
                result.taxId = this.TaxID;
            }
            return(result);
        }
예제 #3
0
        /// <summary>
        /// Creates an API object, ready to send to AuthNET servers.
        /// </summary>
        /// <returns></returns>
        public customerPaymentProfileExType ToAPI()
        {
            var result = new customerPaymentProfileExType();

            if (null != this.BillingAddress)
            {
                result.billTo = this.BillingAddress.ToAPIType();
            }

            result.customerPaymentProfileId = this.ProfileID;

            if (!String.IsNullOrEmpty(this.DriversLicenseNumber))
            {
                result.driversLicense             = new driversLicenseType();
                result.driversLicense.dateOfBirth = this.DriversLicenseDOB;
                result.driversLicense.number      = this.DriversLicenseNumber;
                result.driversLicense.state       = this.DriversLicenseState;
            }

            if (this.IsBusiness)
            {
                result.customerType = customerTypeEnum.business;
            }
            else
            {
                result.customerType = customerTypeEnum.individual;
            }
            result.customerTypeSpecified = true;

            result.payment = new paymentType();
            if (!String.IsNullOrEmpty(this.CardNumber) && (this.CardNumber.Trim().Length > 0))
            {
                var card = new creditCardType();
                card.cardCode       = this.CardCode;
                card.cardNumber     = this.CardNumber;
                card.expirationDate = this.CardExpiration;
                result.payment.Item = card;
            }
            else if ((this.eCheckBankAccount != null) && !String.IsNullOrEmpty(this.eCheckBankAccount.accountNumber) && (this.eCheckBankAccount.accountNumber.Trim().Length > 0))
            {
                var bankAccount = new bankAccountType()
                {
                    accountTypeSpecified = this.eCheckBankAccount.accountTypeSpecified,
                    accountType          = (bankAccountTypeEnum)Enum.Parse(typeof(bankAccountTypeEnum), this.eCheckBankAccount.accountType.ToString(), true),
                    routingNumber        = this.eCheckBankAccount.routingNumber,
                    accountNumber        = this.eCheckBankAccount.accountNumber,
                    nameOnAccount        = this.eCheckBankAccount.nameOnAccount,
                    echeckTypeSpecified  = this.eCheckBankAccount.echeckTypeSpecified,
                    echeckType           = (echeckTypeEnum)Enum.Parse(typeof(echeckTypeEnum), this.eCheckBankAccount.echeckType.ToString(), true),
                    bankName             = this.eCheckBankAccount.bankName,
                    checkNumber          = this.eCheckBankAccount.checkNumber
                };
                result.payment.Item = bankAccount;
            }

            if (!String.IsNullOrEmpty(this.TaxID))
            {
                result.taxId = this.TaxID;
            }
            return(result);
        }
        public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey, string customerProfileId, string customerPaymentProfileId)
        {
            Console.WriteLine("Update Customer payment profile 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 creditCard = new creditCardType
            {
                cardNumber     = "4111111111111111",
                expirationDate = "0718"
            };

            //===========================================================================
            // NOTE:  For updating just the address, not the credit card/payment data
            //        you can pass the masked values returned from
            //        GetCustomerPaymentProfile or GetCustomerProfile
            //        E.g.
            //                * literal values shown below
            //===========================================================================

            /*var creditCard = new creditCardType
             * {
             *  cardNumber = "XXXX1111",
             *  expirationDate = "XXXX"
             * };*/

            var paymentType = new paymentType {
                Item = creditCard
            };

            var paymentProfile = new customerPaymentProfileExType
            {
                billTo = new customerAddressType
                {
                    // change information as required for billing
                    firstName   = "John",
                    lastName    = "Doe",
                    address     = "123 Main St.",
                    city        = "Bellevue",
                    state       = "WA",
                    zip         = "98004",
                    country     = "USA",
                    phoneNumber = "000-000-000",
                },
                payment = paymentType,
                customerPaymentProfileId = customerPaymentProfileId
            };

            var request = new updateCustomerPaymentProfileRequest();

            request.customerProfileId = customerProfileId;
            request.paymentProfile    = paymentProfile;
            request.validationMode    = validationModeEnum.liveMode;


            // instantiate the controller that will call the service
            var controller = new updateCustomerPaymentProfileController(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)
            {
                Console.WriteLine(response.messages.message[0].text);
            }
            else if (response != null)
            {
                Console.WriteLine("Error: " + response.messages.message[0].code + "  " +
                                  response.messages.message[0].text);
            }

            return(response);
        }
        public static void Run(String ApiLoginID, String ApiTransactionKey)
        {
            Console.WriteLine("Update Customer payment profile 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 creditCard = new creditCardType
            {
                cardNumber     = "4111111111111111",
                expirationDate = "0718"
            };

            var paymentType = new paymentType {
                Item = creditCard
            };

            var paymentProfile = new customerPaymentProfileExType
            {
                billTo = new customerAddressType
                {
                    // change information as required for billing
                    firstName   = "John",
                    lastName    = "Doe",
                    address     = "123 Main St.",
                    city        = "Bellevue",
                    state       = "WA",
                    zip         = "98004",
                    country     = "USA",
                    phoneNumber = "000-000-000",
                },
                payment = paymentType,
                customerPaymentProfileId = "33093910"
            };

            var request = new updateCustomerPaymentProfileRequest();

            request.customerProfileId = "36605093";
            request.paymentProfile    = paymentProfile;
            request.validationMode    = validationModeEnum.liveMode;


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

            controller.Execute();

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

            if (response.messages.resultCode == messageTypeEnum.Ok)
            {
                Console.WriteLine(response.messages.message[0].text);
            }
            else
            {
                Console.WriteLine("Error: " + response.messages.message[0].code + "  " +
                                  response.messages.message[0].text);
            }
        }
예제 #6
0
        public async Task <ITransactionResponse> UpdateCustomerPaymentProfile(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,
                };

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

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

                var paymentProfile = new customerPaymentProfileExType
                {
                    billTo = new customerAddressType
                    {
                        // change information as required for billing
                        company   = customerPayment.Company,
                        firstName = customerPayment.FirstName,
                        lastName  = customerPayment.LastName,
                        address   = customerPayment.Address,
                        city      = customerPayment.City,
                        zip       = customerPayment.Zip,
                        email     = customerPayment.Email
                    },
                    payment = paymentType,
                    customerPaymentProfileId = customerPayment.CustomerPaymentProfileId
                };

                var request = new updateCustomerPaymentProfileRequest();
                request.customerProfileId = customerPayment.CustomerProfileId;
                request.paymentProfile    = paymentProfile;
                request.validationMode    = validationModeEnum.liveMode;

                // instantiate the controller that will call the service
                var controller = new updateCustomerPaymentProfileController(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(response.messages.message[0].text);

                        transactionResponse.IsSuccess = true;
                    }
                    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);
        }
예제 #7
0
        //public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey, string customerProfileId, string customerPaymentProfileId)
        //{
        //    Console.WriteLine("Update Customer payment profile 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 creditCard = new creditCardType
        //    {
        //        cardNumber = "4111111111111111",
        //        expirationDate = "0718"
        //    };

        //    //===========================================================================
        //    // NOTE:  For updating just the address, not the credit card/payment data
        //    //        you can pass the masked values returned from
        //    //        GetCustomerPaymentProfile or GetCustomerProfile
        //    //        E.g.
        //    //                * literal values shown below
        //    //===========================================================================
        //    /*var creditCard = new creditCardType
        //    {
        //        cardNumber = "XXXX1111",
        //        expirationDate = "XXXX"
        //    };*/

        //    var paymentType = new paymentType { Item = creditCard };

        //    var paymentProfile = new customerPaymentProfileExType
        //    {
        //        billTo = new customerAddressType
        //        {
        //            // change information as required for billing
        //            firstName = "John",
        //            lastName = "Doe",
        //            address = "123 Main St.",
        //            city = "Bellevue",
        //            state = "WA",
        //            zip = "98004",
        //            country = "USA",
        //            phoneNumber = "000-000-000",
        //        },
        //        payment = paymentType,
        //        customerPaymentProfileId = customerPaymentProfileId
        //    };

        //    var request = new updateCustomerPaymentProfileRequest();
        //    request.customerProfileId = customerProfileId;
        //    request.paymentProfile = paymentProfile;
        //    request.validationMode = validationModeEnum.liveMode;


        //    // instantiate the controller that will call the service
        //    var controller = new updateCustomerPaymentProfileController(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)
        //    {
        //        Console.WriteLine(response.messages.message[0].text);
        //    }
        //    else if (response != null)
        //    {
        //        Console.WriteLine("Error: " + response.messages.message[0].code + "  " +
        //                          response.messages.message[0].text);
        //    }

        //    return response;
        //}

        public static void UpdateCustomerPaymentProfileExec(String ApiLoginID, String ApiTransactionKey)
        {
            using (CsvReader csv = new CsvReader(new StreamReader(new FileStream(@"../../../CSV_DATA/UpdateCustomerPaymentProfile.csv", FileMode.Open)), true))
            {
                Console.WriteLine("Update Customer payment profile 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())
                    {
                        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 creditCard = new creditCardType
                        {
                            cardNumber     = "4111111111111111",
                            expirationDate = "0718"
                        };

                        //===========================================================================
                        // NOTE:  For updating just the address, not the credit card/payment data
                        //        you can pass the masked values returned from
                        //        GetCustomerPaymentProfile or GetCustomerProfile
                        //        E.g.
                        //                * literal values shown below
                        //===========================================================================

                        /*var creditCard = new creditCardType
                         * {
                         *  cardNumber = "XXXX1111",
                         *  expirationDate = "XXXX"
                         * };*/
                        string customerProfileId        = null;
                        string customerPaymentProfileId = null;
                        string TestCaseId = null;

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

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

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

                            default:
                                break;
                            }
                        }
                        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 paymentType = new paymentType {
                                Item = creditCard
                            };

                            var paymentProfile = new customerPaymentProfileExType
                            {
                                billTo = new customerAddressType
                                {
                                    // change information as required for billing
                                    firstName   = "John",
                                    lastName    = "Doe",
                                    address     = "123 Main St.",
                                    city        = "Bellevue",
                                    state       = "WA",
                                    zip         = "98004",
                                    country     = "USA",
                                    phoneNumber = "000-000-000",
                                },
                                payment = paymentType,
                                customerPaymentProfileId = customerPaymentProfileId
                            };

                            var request = new updateCustomerPaymentProfileRequest();
                            request.customerProfileId = customerProfileId;
                            request.paymentProfile    = paymentProfile;
                            request.validationMode    = validationModeEnum.liveMode;


                            // instantiate the controller that will call the service
                            var controller = new updateCustomerPaymentProfileController(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)
                            {
                                Console.WriteLine(response.messages.message[0].text);
                                /*****************************/
                                try
                                {
                                    //Assert.AreEqual(response.Id, customerProfileId);
                                    Console.WriteLine("Assertion Succeed! Valid CustomerPaymentProfile updated.");
                                    CsvRow row1 = new CsvRow();
                                    row1.Add("UCPP_00" + flag.ToString());
                                    row1.Add("UpdateCustomerPaymentProfile");
                                    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;
                                }
                                catch
                                {
                                    CsvRow row1 = new CsvRow();
                                    row1.Add("UCPP_00" + flag.ToString());
                                    row1.Add("UpdateCustomerPaymentProfile");
                                    row1.Add("Assertion Failed!");
                                    row1.Add(DateTime.Now.ToString("yyyy/MM/dd" + "::" + "HH:mm:ss:fff"));
                                    writer.WriteRow(row1);
                                    Console.WriteLine("Assertion Failed! Invalid CustomerPaymentProfile updated.");
                                    flag = flag + 1;
                                }
                                /*******************/
                            }
                            else
                            {
                                CsvRow row1 = new CsvRow();
                                row1.Add("UCPP_00" + flag.ToString());
                                row1.Add("UpdateCustomerPaymentProfile");
                                row1.Add("Fail");
                                row1.Add(DateTime.Now.ToString("yyyy/MM/dd" + "::" + "HH:mm:ss:fff"));
                                writer.WriteRow(row1);
                                Console.WriteLine("Assertion Failed! Invalid CustomerPaymentProfile updated.");
                                flag = flag + 1;
                            }
                        }
                        //else if (response != null)
                        //{
                        //    Console.WriteLine("Error: " + response.messages.message[0].code + "  " +
                        //                      response.messages.message[0].text);
                        //}

                        //return response;
                        catch (Exception e)
                        {
                            CsvRow row2 = new CsvRow();
                            row2.Add("UCPP_00" + flag.ToString());
                            row2.Add("UpdateCustomerPaymentProfile");
                            row2.Add("Fail");
                            row2.Add(DateTime.Now.ToString("yyyy/MM/dd" + "::" + "HH:mm:ss:fff"));
                            writer.WriteRow(row2);
                            flag = flag + 1;
                            Console.WriteLine(TestCaseId + " Error Message " + e.Message);
                        }
                    }
                }
            }
        }
예제 #8
0
        public string UpdateCust(CardInfoViewModel data)
        {
            string message = string.Empty;

            try
            {
                ApiOperationBase <ANetApiRequest, ANetApiResponse> .RunEnvironment = AuthorizeNet.Environment.PRODUCTION;
                // define the merchant information (authentication / transaction id)
                ApiOperationBase <ANetApiRequest, ANetApiResponse> .MerchantAuthentication = new merchantAuthenticationType()
                {
                    name            = data.ANET_ApiLoginID,
                    ItemElementName = ItemChoiceType.transactionKey,
                    Item            = data.ANET_ApiTransactionKey,
                };
                if (data.addPayment.CCID)
                {
                    var creditCard = new creditCardType
                    {
                        cardNumber     = data.addnewcard.x_card_num,
                        expirationDate = data.addnewcard.x_exp_code,
                    };
                    // standard api call to retrieve response
                    paymentType cc = new paymentType {
                        Item = creditCard
                    };

                    customerPaymentProfileExType ccPaymentProfile = new customerPaymentProfileExType();
                    ccPaymentProfile.payment = cc;

                    var request = new createCustomerPaymentProfileRequest();
                    request.paymentProfile    = ccPaymentProfile;
                    request.customerProfileId = data.customerProfile_Id;

                    // instantiate the controller that will call the service
                    var controller = new createCustomerPaymentProfileController(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)
                    {
                        //Console.WriteLine(response.messages.message[0].text);
                    }
                    else if (response != null)
                    {
                        //Console.WriteLine("Error: " + response.messages.message[0].code + "  " +
                        //                  response.messages.message[0].text);
                        message = response.messages.message[0].text;
                    }
                }
                else if (data.addPayment.BAccount)
                {
                    var bankAccount = new bankAccountType
                    {
                        accountNumber = data.addPayment.PayAdd_account_num,
                        routingNumber = data.addPayment.ABA_Routing_num,
                        accountType   = bankAccountTypeEnum.checking,
                        echeckType    = echeckTypeEnum.WEB,
                        nameOnAccount = data.addPayment.PayAdd_name_on_acc,
                        bankName      = data.addPayment.PayAdd_bank_name
                    };
                    paymentType echeck = new paymentType {
                        Item = bankAccount
                    };

                    customerPaymentProfileType echeckPaymentProfile = new customerPaymentProfileType();
                    echeckPaymentProfile.payment = echeck;

                    var request = new createCustomerPaymentProfileRequest();
                    request.paymentProfile    = echeckPaymentProfile;
                    request.customerProfileId = data.customerProfile_Id;

                    // instantiate the controller that will call the service
                    var controller = new createCustomerPaymentProfileController(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)
                    {
                        //Console.WriteLine(response.messages.message[0].text);
                    }
                    else if (response != null)
                    {
                        //Console.WriteLine("Error: " + response.messages.message[0].code + "  " +
                        //                  response.messages.message[0].text);
                        message = response.messages.message[0].text;
                    }
                }
                else
                {
                    message = "Some Error ouccerd Please try again!!!";
                }
            }
            catch
            {
            }
            return(message);
        }
예제 #9
0
        public void cardAdd(CardInfoViewModel data)
        {
            //Console.WriteLine("Update customer profile sample");

            ApiOperationBase <ANetApiRequest, ANetApiResponse> .RunEnvironment = AuthorizeNet.Environment.PRODUCTION;
            // define the merchant information (authentication / transaction id)
            ApiOperationBase <ANetApiRequest, ANetApiResponse> .MerchantAuthentication = new merchantAuthenticationType()
            {
                name            = data.ANET_ApiLoginID,
                ItemElementName = ItemChoiceType.transactionKey,
                Item            = data.ANET_ApiTransactionKey,
            };
            if (data.addnewcard.CCAddCard)
            {
                var creditCard = new creditCardType
                {
                    cardNumber     = data.addnewcard.x_card_num,
                    expirationDate = data.addnewcard.x_exp_code
                };

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

                customerPaymentProfileExType ccPaymentProfile = new customerPaymentProfileExType();
                ccPaymentProfile.payment = cc;

                var request = new createCustomerPaymentProfileRequest();
                request.paymentProfile    = ccPaymentProfile;
                request.customerProfileId = data.customerProfile_Id;

                // instantiate the controller that will call the service
                var controller = new createCustomerPaymentProfileController(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)
                {
                    Console.WriteLine(response.messages.message[0].text);
                }
                else if (response != null)
                {
                    Console.WriteLine("Error: " + response.messages.message[0].code + "  " +
                                      response.messages.message[0].text);
                }
            }
            else if (data.addnewcard.BankAddCard)
            {
                var bankAccount = new bankAccountType
                {
                    accountNumber = data.addnewcard.x_name_account_num,
                    routingNumber = data.addnewcard.x_aba_rout_num,
                    accountType   = bankAccountTypeEnum.checking,
                    echeckType    = echeckTypeEnum.WEB,
                    nameOnAccount = data.addnewcard.x_name_on_account,
                    bankName      = data.addnewcard.x_bank_name
                };

                paymentType echeck = new paymentType {
                    Item = bankAccount
                };


                customerPaymentProfileExType ccPaymentProfile = new customerPaymentProfileExType();
                ccPaymentProfile.payment = echeck;

                var request = new createCustomerPaymentProfileRequest();
                request.paymentProfile    = ccPaymentProfile;
                request.customerProfileId = data.customerProfile_Id;

                // instantiate the controller that will call the service
                var controller = new createCustomerPaymentProfileController(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)
                {
                    Console.WriteLine(response.messages.message[0].text);
                }
                else if (response != null)
                {
                    Console.WriteLine("Error: " + response.messages.message[0].code + "  " +
                                      response.messages.message[0].text);
                }
            }
        }