Beispiel #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);
                }
            }
        }
        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);
                }
            }

        }
        //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);
                        }
                    }
                }
            }
        }
Beispiel #4
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);
        }
Beispiel #5
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);
        }
Beispiel #6
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);
        }
Beispiel #7
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);
                }
            }
        }