Esempio n. 1
0
        public static void Run(String ApiLoginID, String ApiTransactionKey)
        {
            Console.WriteLine("CreateCustomerPaymentProfile Sample");
            ApiOperationBase <ANetApiRequest, ANetApiResponse> .RunEnvironment         = AuthorizeNet.Environment.SANDBOX;
            ApiOperationBase <ANetApiRequest, ANetApiResponse> .MerchantAuthentication = new merchantAuthenticationType()
            {
                name            = ApiLoginID,
                ItemElementName = ItemChoiceType.transactionKey,
                Item            = ApiTransactionKey,
            };

            var bankAccount = new bankAccountType
            {
                accountNumber = "01245524321",
                routingNumber = "000000204",
                accountType   = bankAccountTypeEnum.checking,
                echeckType    = echeckTypeEnum.WEB,
                nameOnAccount = "test",
                bankName      = "Bank Of America"
            };

            paymentType echeck = new paymentType {
                Item = bankAccount
            };

            customerPaymentProfileType echeckPaymentProfile = new customerPaymentProfileType();

            echeckPaymentProfile.payment = echeck;

            var request = new createCustomerPaymentProfileRequest
            {
                customerProfileId = "35772885",
                paymentProfile    = echeckPaymentProfile,
                validationMode    = validationModeEnum.none
            };

            //Prepare Request
            var controller = new createCustomerPaymentProfileController(request);

            controller.Execute();

            //Send Request to EndPoint
            createCustomerPaymentProfileResponse response = controller.GetApiResponse();

            if (response != null && response.messages.resultCode == messageTypeEnum.Ok)
            {
                if (response != null && response.messages.message != null)
                {
                    Console.WriteLine("Success, createCustomerPaymentProfileID : " + response.customerPaymentProfileId);
                }
            }
            else
            {
                Console.WriteLine("Error: " + response.messages.message[0].code + "  " + response.messages.message[0].text);
                if (response.messages.message[0].code == "E00039")
                {
                    Console.WriteLine("Duplicate ID: " + response.customerPaymentProfileId);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Adds a bank account profile to the user and returns the profile ID
        /// </summary>
        /// <returns></returns>
        public string AddECheckBankAccount(string profileID, BankAccount bankAccount, Address billToAddress)
        {
            var req = new createCustomerPaymentProfileRequest();

            req.customerProfileId      = profileID;
            req.paymentProfile         = new customerPaymentProfileType();
            req.paymentProfile.payment = new paymentType();

            var bankAcct = new bankAccountType()
            {
                accountTypeSpecified = bankAccount.accountTypeSpecified,
                accountType          = (bankAccountTypeEnum)Enum.Parse(typeof(bankAccountTypeEnum), bankAccount.accountType.ToString(), true),
                routingNumber        = bankAccount.routingNumber,
                accountNumber        = bankAccount.accountNumber,
                nameOnAccount        = bankAccount.nameOnAccount,
                bankName             = bankAccount.bankName,
                echeckTypeSpecified  = bankAccount.echeckTypeSpecified,
                echeckType           = (echeckTypeEnum)Enum.Parse(typeof(echeckTypeEnum), bankAccount.echeckType.ToString(), true)
            };

            req.paymentProfile.payment.Item = bankAcct;

            if (billToAddress != null)
            {
                req.paymentProfile.billTo = billToAddress.ToAPIType();
            }

            req.validationModeSpecified = true;
            req.validationMode          = this._mode;

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

            return(response.customerPaymentProfileId);
        }
        public void MockcreateCustomerPaymentProfileTest()
        {
            //define all mocked objects as final
            var mockController = GetMockController <createCustomerPaymentProfileRequest, createCustomerPaymentProfileResponse>();
            var mockRequest    = new createCustomerPaymentProfileRequest
            {
                merchantAuthentication = new merchantAuthenticationType {
                    name = "mocktest", Item = "mockKey", ItemElementName = ItemChoiceType.transactionKey
                },
            };
            var mockResponse = new createCustomerPaymentProfileResponse
            {
                refId                    = "1234",
                sessionToken             = "sessiontoken",
                customerPaymentProfileId = "1234",
                validationDirectResponse = "mockValidation",
            };

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

            SetMockControllerExpectations <createCustomerPaymentProfileRequest, createCustomerPaymentProfileResponse, createCustomerPaymentProfileController>(
                mockController.MockObject, mockRequest, mockResponse, errorResponse, results, messageTypeOk);
            mockController.MockObject.Execute(AuthorizeNet.Environment.CUSTOM);
            //mockController.MockObject.Execute();
            // or var controllerResponse = mockController.MockObject.ExecuteWithApiResponse(AuthorizeNet.Environment.CUSTOM);
            var controllerResponse = mockController.MockObject.GetApiResponse();

            Assert.IsNotNull(controllerResponse);

            Assert.IsNotNull(controllerResponse.customerPaymentProfileId);
            LogHelper.info(Logger, "createCustomerPaymentProfile: Details:{0}", controllerResponse.customerPaymentProfileId);
        }
Esempio n. 4
0
        /// <summary>
        /// Adds a credit card profile to the user and returns the profile ID
        /// </summary>
        /// <returns></returns>
        public string AddCreditCard(string profileID, string cardNumber, int expirationMonth, int expirationYear, string cardCode, Address billToAddress)
        {
            var req = new createCustomerPaymentProfileRequest();


            req.customerProfileId      = profileID;
            req.paymentProfile         = new customerPaymentProfileType();
            req.paymentProfile.payment = new paymentType();

            var card = new creditCardType();

            card.cardCode                   = cardCode;
            card.cardNumber                 = cardNumber;
            card.expirationDate             = string.Format("{0}-{1}", expirationYear.ToString(), expirationMonth.ToString());
            req.paymentProfile.payment.Item = card;

            if (billToAddress != null)
            {
                req.paymentProfile.billTo = billToAddress.ToAPIType();
            }


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

            return(response.customerPaymentProfileId);
        }
Esempio n. 5
0
 public static void createCustomerPaymentProfileRequest(createCustomerPaymentProfileRequest request)
 {
     if (null != request)
     {
         if (0 <= (int)request.validationMode)
         {
             request.validationModeSpecified = true;
         }
     }
 }
Esempio n. 6
0
        /// <summary>
        /// Adds a credit card profile to the user and returns the profile ID
        /// </summary>
        /// <returns></returns>
        public string AddCreditCard(string profileID, string cardNumber, int expirationMonth, int expirationYear, string cardCode, Address billToAddress)
        {
            // Get the expiration date.

            DateTime dt; // = DateTime.Parse(expirationMonth.ToString() + "-1-" + expirationYear.ToString());

            if (!CommonFunctions.ParseDateTime(expirationYear, expirationMonth, 1, out dt))
            {
                throw new Exception("Invalid credit card expiration date");
            }

            DateTime expDate  = new DateTime(dt.Year, dt.Month, 1).AddMonths(1).AddDays(-1);
            string   sExpDate = expDate.ToString("yyyy-MM");

            // Make sure the card has not expired.
            if (expDate <= DateTime.Now)
            {
                throw new Exception("The credit card expiration date \"" + sExpDate + "\" is expired.");
            }

            var req = new createCustomerPaymentProfileRequest();


            req.customerProfileId      = profileID;
            req.paymentProfile         = new customerPaymentProfileType();
            req.paymentProfile.payment = new paymentType();

            var card = new creditCardType();

            if (!String.IsNullOrEmpty(cardCode))
            {
                card.cardCode = cardCode;
            }
            card.cardNumber                 = cardNumber;
            card.expirationDate             = sExpDate;
            req.paymentProfile.payment.Item = card;

            if (billToAddress != null)
            {
                req.paymentProfile.billTo = billToAddress.ToAPIType();
            }

            req.validationModeSpecified = true;
            req.validationMode          = this._mode;

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

            return(response.customerPaymentProfileId);
        }
        /// <summary>
        /// Adds a credit card profile to the user and returns the profile ID
        /// </summary>
        /// <returns></returns>
        public String AddCreditCard(String profileID, PaymentCard paymentCard, Address billingAddress)
        {
            // Make sure the card has not expired.
            if (paymentCard.ExpirationDate <= DateTime.Now)
            {
                throw new Exception("The payment-card expiration date \"" + paymentCard.ExpirationDate.ToExpirationDateString() + "\" is expired.");
            }

            var req = new createCustomerPaymentProfileRequest();

            req.customerProfileId      = profileID;
            req.paymentProfile         = new customerPaymentProfileType();
            req.paymentProfile.payment = new paymentType();

            req.paymentProfile.payment.Item = paymentCard.Get_creditCardType();

            req.paymentProfile.billTo = billingAddress.ToAPIType();

            req.validationMode = this._mode;

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

            return(response.customerPaymentProfileId);
        }
        //public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey, string customerProfileId)
        //{
        //    Console.WriteLine("CreateCustomerPaymentProfile Sample");
        //    ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNET.Environment.SANDBOX;
        //    ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
        //    {
        //        name            = ApiLoginID,
        //        ItemElementName = ItemChoiceType.transactionKey,
        //        Item            = ApiTransactionKey,
        //    };

        //    var bankAccount = new bankAccountType
        //    {
        //        accountNumber = "01245524321",
        //        routingNumber = "000000204",
        //        accountType = bankAccountTypeEnum.checking,
        //        echeckType = echeckTypeEnum.WEB,
        //        nameOnAccount = "test",
        //        bankName = "Bank Of America"
        //    };

        //    paymentType echeck = new paymentType {Item = bankAccount};

        //    var billTo = new customerAddressType
        //    {
        //        firstName = "John",
        //        lastName = "Snow"
        //    };
        //    customerPaymentProfileType echeckPaymentProfile = new customerPaymentProfileType();
        //    echeckPaymentProfile.payment = echeck;
        //    echeckPaymentProfile.billTo = billTo;

        //    var request = new createCustomerPaymentProfileRequest
        //    {
        //        customerProfileId = customerProfileId,
        //        paymentProfile = echeckPaymentProfile,
        //        validationMode = validationModeEnum.none
        //    };

        //    //Prepare Request
        //    var controller = new createCustomerPaymentProfileController(request);
        //    controller.Execute();

        //     //Send Request to EndPoint
        //    createCustomerPaymentProfileResponse response = controller.GetApiResponse();
        //    if (response != null && response.messages.resultCode == messageTypeEnum.Ok)
        //    {
        //        if (response != null && response.messages.message != null)
        //        {
        //            Console.WriteLine("Success, createCustomerPaymentProfileID : " + response.customerPaymentProfileId);
        //        }
        //    }
        //    else
        //    {
        //        Console.WriteLine("Error: " + response.messages.message[0].code + "  " + response.messages.message[0].text);
        //        if (response.messages.message[0].code == "E00039")
        //        {
        //            Console.WriteLine("Duplicate ID: " + response.customerPaymentProfileId);
        //        }
        //    }

        //    return response;

        //}

        public static void CreateCustomerPaymentProfileExec(String ApiLoginID, String ApiTransactionKey)
        {
            using (CsvReader csv = new CsvReader(new StreamReader(new FileStream(@"../../../CSV_DATA/CreateCustomerPaymentProfile.csv", FileMode.Open)), true))
            {
                Console.WriteLine("CreateCustomerPaymentProfile 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;
                        ApiOperationBase <ANetApiRequest, ANetApiResponse> .MerchantAuthentication = new merchantAuthenticationType()
                        {
                            name            = ApiLoginID,
                            ItemElementName = ItemChoiceType.transactionKey,
                            Item            = ApiTransactionKey,
                        };

                        var bankAccount = new bankAccountType
                        {
                            accountNumber = "01245524321",
                            routingNumber = "000000204",
                            accountType   = bankAccountTypeEnum.checking,
                            echeckType    = echeckTypeEnum.WEB,
                            nameOnAccount = "test",
                            bankName      = "Bank Of America"
                        };

                        paymentType echeck = new paymentType {
                            Item = bankAccount
                        };

                        var billTo = new customerAddressType
                        {
                            firstName = "John",
                            lastName  = "Snow"
                        };
                        customerPaymentProfileType echeckPaymentProfile = new customerPaymentProfileType();
                        echeckPaymentProfile.payment = echeck;
                        echeckPaymentProfile.billTo  = billTo;


                        string customerProfileId = 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;

                            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 request = new createCustomerPaymentProfileRequest
                            {
                                customerProfileId = customerProfileId,
                                paymentProfile    = echeckPaymentProfile,
                                validationMode    = validationModeEnum.none
                            };
                            //Prepare Request
                            var controller = new createCustomerPaymentProfileController(request);
                            controller.Execute();

                            //Send Request to EndPoint
                            createCustomerPaymentProfileResponse response = controller.GetApiResponse();
                            //var 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 customerProfileId fetched.");
                                    CsvRow row1 = new CsvRow();
                                    row1.Add("CCPP_00" + flag.ToString());
                                    row1.Add("CreateCustomerPaymentProfile");
                                    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, createCustomerPaymentProfileID : " + response.customerPaymentProfileId);
                                }
                                catch
                                {
                                    CsvRow row1 = new CsvRow();
                                    row1.Add("CCPP_00" + flag.ToString());
                                    row1.Add("CreateCustomerPaymentProfile");
                                    row1.Add("Fail");
                                    row1.Add(DateTime.Now.ToString("yyyy/MM/dd" + "::" + "HH:mm:ss:fff"));
                                    writer.WriteRow(row1);
                                    Console.WriteLine("Assertion Failed! Invalid CustomerPaymentProfile fetched.");
                                    flag = flag + 1;
                                }
                                /*******************/
                                //if (response.messages.message != null)
                                //{
                                //    Console.WriteLine("Success, createCustomerPaymentProfileID : " + response.customerPaymentProfileId);
                                //}
                            }
                            else
                            {
                                //Console.WriteLine("Error: " + response.messages.message[0].code + "  " + response.messages.message[0].text);
                                CsvRow row1 = new CsvRow();
                                row1.Add("CCPP_00" + flag.ToString());
                                row1.Add("CreateCustomerPaymentProfile");
                                row1.Add("Fail");
                                row1.Add(DateTime.Now.ToString("yyyy/MM/dd" + "::" + "HH:mm:ss:fff"));
                                writer.WriteRow(row1);
                                //Console.WriteLine("Assertion Failed! Invalid CustomerPaymentProfile fetched.");
                                flag = flag + 1;
                                //if (response.messages.message[0].code == "E00039")
                                //{
                                //    Console.WriteLine("Duplicate ID: " + response.customerPaymentProfileId);
                                //}
                            }

                            //return response;
                        }
                        catch (Exception e)
                        {
                            CsvRow row2 = new CsvRow();
                            row2.Add("CCPP_00" + flag.ToString());
                            row2.Add("CreateCustomerPaymentProfile");
                            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);
                        }
                    }
                }
            }
        }
Esempio n. 9
0
        public static ANetApiResponse Run(string ApiLoginID, string ApiTransactionKey, string customerProfileId)
        {
            Console.WriteLine("Create Customer Payment Profile Sample");

            // set whether to use the sandbox environment, or production enviornment
            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 bankAccount = new bankAccountType
            {
                accountNumber = "01245524321",
                routingNumber = "000000204",
                accountType   = bankAccountTypeEnum.checking,
                echeckType    = echeckTypeEnum.WEB,
                nameOnAccount = "test",
                bankName      = "Bank Of America"
            };

            paymentType echeck = new paymentType {
                Item = bankAccount
            };

            var billTo = new customerAddressType
            {
                firstName = "John",
                lastName  = "Snow"
            };
            customerPaymentProfileType echeckPaymentProfile = new customerPaymentProfileType();

            echeckPaymentProfile.payment = echeck;
            echeckPaymentProfile.billTo  = billTo;

            var request = new createCustomerPaymentProfileRequest
            {
                customerProfileId = customerProfileId,
                paymentProfile    = echeckPaymentProfile,
                validationMode    = validationModeEnum.none
            };

            // 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)
            createCustomerPaymentProfileResponse response = controller.GetApiResponse();

            // validate response
            if (response != null)
            {
                if (response.messages.resultCode == messageTypeEnum.Ok)
                {
                    if (response.messages.message != null)
                    {
                        Console.WriteLine("Success! Customer Payment Profile ID: " + response.customerPaymentProfileId);
                    }
                }
                else
                {
                    Console.WriteLine("Customer Payment Profile Creation Failed.");
                    Console.WriteLine("Error Code: " + response.messages.message[0].code);
                    Console.WriteLine("Error message: " + response.messages.message[0].text);
                    if (response.messages.message[0].code == "E00039")
                    {
                        Console.WriteLine("Duplicate Payment Profile ID: " + response.customerPaymentProfileId);
                    }
                }
            }
            else
            {
                if (controller.GetErrorResponse().messages.message.Length > 0)
                {
                    Console.WriteLine("Customer Payment Profile Creation Failed.");
                    Console.WriteLine("Error Code: " + response.messages.message[0].code);
                    Console.WriteLine("Error message: " + response.messages.message[0].text);
                }
                else
                {
                    Console.WriteLine("Null Response.");
                }
            }

            return(response);
        }
Esempio n. 10
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);
        }
Esempio n. 11
0
        public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey, string customerProfileId)
        {
            //Console.WriteLine("CreateCustomerPaymentProfile Sample");
            ApiOperationBase <ANetApiRequest, ANetApiResponse> .RunEnvironment         = AuthorizeNet.Environment.SANDBOX;
            ApiOperationBase <ANetApiRequest, ANetApiResponse> .MerchantAuthentication = new merchantAuthenticationType()
            {
                name            = ApiLoginID,
                ItemElementName = ItemChoiceType.transactionKey,
                Item            = ApiTransactionKey,
            };
            bankAccountType bankAccount;

            bankAccount = LouACH.DataBaseTransactions.DataBase.ReadBankData();
            //var bankAccount = new bankAccountType
            //{
            //    accountNumber = "01245524321",
            //    routingNumber = "000000204",
            //    accountType = bankAccountTypeEnum.checking,
            //    echeckType = echeckTypeEnum.WEB,
            //    nameOnAccount = "test",
            //    bankName = "Bank Of America"
            //};

            paymentType echeck = new paymentType {
                Item = bankAccount
            };

            var billTo = new customerAddressType
            {
                firstName = "John",
                lastName  = "Snow"
            };
            customerPaymentProfileType echeckPaymentProfile = new customerPaymentProfileType();

            echeckPaymentProfile.payment = echeck;
            echeckPaymentProfile.billTo  = billTo;

            var request = new createCustomerPaymentProfileRequest
            {
                customerProfileId = customerProfileId,
                paymentProfile    = echeckPaymentProfile,
                validationMode    = validationModeEnum.none
            };

            //Prepare Request
            var controller = new createCustomerPaymentProfileController(request);

            controller.Execute();

            //Send Request to EndPoint
            createCustomerPaymentProfileResponse response = controller.GetApiResponse();

            if (response != null && response.messages.resultCode == messageTypeEnum.Ok)
            {
                if (response != null && response.messages.message != null)
                {
                    //Console.WriteLine("Success, createCustomerPaymentProfileID : " + response.customerPaymentProfileId);
                    LouACH.Main.theOutput = "Successfully created Profile with Transaction ID: " + response.customerPaymentProfileId;
                }
            }
            else
            {
                // Console.WriteLine("Error: " + response.messages.message[0].code + "  " + response.messages.message[0].text);
                if (response.messages.message[0].code == "E00039")
                {
                    //Console.WriteLine("Duplicate ID: " + response.customerPaymentProfileId);
                    LouACH.Main.theOutput = "Error: " + response.messages.message[0].code + "  " + response.messages.message[0].text;
                }
            }

            return(response);
        }
Esempio n. 12
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);
                }
            }
        }