public static IEnumerable <IPaymentMethod> GetCustomerPaymentMethods(GetCustomerPaymentMethodsRequest request, IEnumerable <AutoOrder> autoOrders = null)
        {
            var methods = new List <IPaymentMethod>();

            if (!HttpContext.Current.Request.IsAuthenticated)
            {
                return(methods.AsEnumerable());
            }


            // Get the customer's billing info
            var billing = ExigoDAL.WebService().GetCustomerBilling(new GetCustomerBillingRequest
            {
                CustomerID = request.CustomerID
            });


            if (autoOrders == null)
            {
                // Get the customer's auto orders
                autoOrders = ExigoDAL.GetCustomerAutoOrders(request.CustomerID, includePaymentMethods: false);
            }


            methods.Add(new BankAccount(BankAccountType.Primary)
            {
                BankName      = string.Empty,
                NameOnAccount = billing.BankAccount.NameOnAccount,
                AccountNumber = billing.BankAccount.BankAccountNumberDisplay,
                RoutingNumber = billing.BankAccount.BankRoutingNumber,
                AutoOrderIDs  = autoOrders.Where(c => c.AutoOrderPaymentTypeID == AutoOrderPaymentTypes.DebitCheckingAccount).Select(c => c.AutoOrderID).ToArray(),

                BillingAddress = new Address()
                {
                    Address1 = billing.BankAccount.BillingAddress,
                    City     = billing.BankAccount.BillingCity,
                    State    = billing.BankAccount.BillingState,
                    Zip      = billing.BankAccount.BillingZip,
                    Country  = billing.BankAccount.BillingCountry
                }
            });


            methods.Add(new CreditCard(CreditCardType.Primary)
            {
                NameOnCard      = billing.PrimaryCreditCard.BillingName,
                CardNumber      = billing.PrimaryCreditCard.CreditCardNumberDisplay,
                ExpirationMonth = billing.PrimaryCreditCard.ExpirationMonth,
                ExpirationYear  = billing.PrimaryCreditCard.ExpirationYear,
                AutoOrderIDs    = autoOrders.Where(c => c.AutoOrderPaymentTypeID == AutoOrderPaymentTypes.PrimaryCreditCardOnFile).Select(c => c.AutoOrderID).ToArray(),

                BillingAddress = new Address()
                {
                    Address1 = billing.PrimaryCreditCard.BillingAddress,
                    City     = billing.PrimaryCreditCard.BillingCity,
                    State    = billing.PrimaryCreditCard.BillingState,
                    Zip      = billing.PrimaryCreditCard.BillingZip,
                    Country  = billing.PrimaryCreditCard.BillingCountry
                }
            });


            methods.Add(new CreditCard(CreditCardType.Secondary)
            {
                NameOnCard      = billing.SecondaryCreditCard.BillingName,
                CardNumber      = billing.SecondaryCreditCard.CreditCardNumberDisplay,
                ExpirationMonth = billing.SecondaryCreditCard.ExpirationMonth,
                ExpirationYear  = billing.SecondaryCreditCard.ExpirationYear,
                AutoOrderIDs    = autoOrders.Where(c => c.AutoOrderPaymentTypeID == AutoOrderPaymentTypes.SecondaryCreditCardOnFile).Select(c => c.AutoOrderID).ToArray(),

                BillingAddress = new Address()
                {
                    Address1 = billing.SecondaryCreditCard.BillingAddress,
                    City     = billing.SecondaryCreditCard.BillingCity,
                    State    = billing.SecondaryCreditCard.BillingState,
                    Zip      = billing.SecondaryCreditCard.BillingZip,
                    Country  = billing.SecondaryCreditCard.BillingCountry
                }
            });


            // Filter out invalid or incomplete methods if applicable
            if (request.ExcludeInvalidMethods)
            {
                methods = methods.Where(c => c.IsValid).ToList();
            }
            if (request.ExcludeIncompleteMethods)
            {
                methods = methods.Where(c => c.IsComplete).ToList();
            }
            if (request.ExcludeNonAutoOrderPaymentMethods)
            {
                methods = methods.Where(c => c is IAutoOrderPaymentMethod).ToList();
            }


            return(methods.AsEnumerable());
        }
Esempio n. 2
0
        public static IEnumerable <IPaymentMethod> GetCustomerPaymentMethods(GetCustomerPaymentMethodsRequest request)
        {
            var methods = new List <IPaymentMethod>();

            if (!HttpContext.Current.Request.IsAuthenticated)
            {
                return(methods.AsEnumerable());
            }


            // Get the customer's billing info
            var billing = Exigo.OData().CustomerAccounts
                          .Where(c => c.CustomerID == request.CustomerID)
                          .FirstOrDefault();

            if (billing == null)
            {
                return(methods.AsEnumerable());
            }


            // Get the customer's auto orders
            var autoOrders = GetCustomerAutoOrders(new GetCustomerAutoOrdersRequest
            {
                CustomerID = request.CustomerID
            });


            methods.Add(new BankAccount(ExigoService.BankAccountType.Primary)
            {
                BankName      = string.Empty,
                NameOnAccount = billing.BankNameOnAccount,
                AccountNumber = billing.BankAccountNumber,
                RoutingNumber = billing.BankRoutingNumber,
                AutoOrderIDs  = autoOrders.Where(c => c.AutoOrderProcessTypeID == 3).Select(c => c.AutoOrderID).ToArray(),

                BillingAddress = new Address()
                {
                    Address1 = billing.BankAccountAddress,
                    City     = billing.BankAccountCity,
                    State    = billing.BankAccountState,
                    Zip      = billing.BankAccountZip,
                    Country  = billing.BankAccountCountry
                }
            });


            methods.Add(new CreditCard(CreditCardType.Primary)
            {
                NameOnCard      = billing.PrimaryBillingName,
                CardNumber      = billing.PrimaryCreditCardDisplay,
                ExpirationMonth = billing.PrimaryExpirationMonth,
                ExpirationYear  = billing.PrimaryExpirationYear,
                AutoOrderIDs    = autoOrders.Where(c => c.AutoOrderProcessTypeID == 1).Select(c => c.AutoOrderID).ToArray(),

                BillingAddress = new Address()
                {
                    Address1 = billing.PrimaryBillingAddress,
                    City     = billing.PrimaryBillingCity,
                    State    = billing.PrimaryBillingState,
                    Zip      = billing.PrimaryBillingZip,
                    Country  = billing.PrimaryBillingCountry
                }
            });


            methods.Add(new CreditCard(CreditCardType.Secondary)
            {
                NameOnCard      = billing.SecondaryBillingName,
                CardNumber      = billing.SecondaryCreditCardDisplay,
                ExpirationMonth = billing.SecondaryExpirationMonth,
                ExpirationYear  = billing.SecondaryExpirationYear,
                AutoOrderIDs    = autoOrders.Where(c => c.AutoOrderProcessTypeID == 2).Select(c => c.AutoOrderID).ToArray(),

                BillingAddress = new Address()
                {
                    Address1 = billing.SecondaryBillingAddress,
                    City     = billing.SecondaryBillingCity,
                    State    = billing.SecondaryBillingState,
                    Zip      = billing.SecondaryBillingZip,
                    Country  = billing.SecondaryBillingCountry
                }
            });


            // Filter out invalid or incomplete methods if applicable
            if (request.ExcludeInvalidMethods)
            {
                methods = methods.Where(c => c.IsValid).ToList();
            }
            if (request.ExcludeIncompleteMethods)
            {
                methods = methods.Where(c => c.IsComplete).ToList();
            }
            if (request.ExcludeNonAutoshipPaymentMethods)
            {
                methods = methods.Where(c => c is IAutoOrderPaymentMethod).ToList();
            }


            return(methods.AsEnumerable());
        }
        public static IEnumerable<IPaymentMethod> GetCustomerPaymentMethods(GetCustomerPaymentMethodsRequest request)
        {
            var methods = new List<IPaymentMethod>();
            //if (!HttpContext.Current.Request.IsAuthenticated) return methods.AsEnumerable();

            try
            {
                var billing = new GetCustomerBillingResponse();
                var autoOrders = new List<AutoOrder>();

                // Get the customer's billing info
                billing = Exigo.WebService().GetCustomerBilling(new GetCustomerBillingRequest
                {
                    CustomerID = request.CustomerID
                });

                // Get the customer's auto orders
                autoOrders = GetCustomerAutoOrders(new GetCustomerAutoOrdersRequest
                {
                    CustomerID = request.CustomerID
                }).ToList();

                methods.Add(new CreditCard(CreditCardType.Primary)
                {
                    NameOnCard = billing.PrimaryCreditCard.BillingName,
                    CardNumber = billing.PrimaryCreditCard.CreditCardNumberDisplay,
                    ExpirationMonth = billing.PrimaryCreditCard.ExpirationMonth,
                    ExpirationYear = billing.PrimaryCreditCard.ExpirationYear,
                    AutoOrderIDs = autoOrders.Where(c => c.AutoOrderPaymentTypeID == 1).Select(c => c.AutoOrderID).ToArray(),

                    BillingAddress = new Address()
                    {
                        Address1 = billing.PrimaryCreditCard.BillingAddress,
                        City = billing.PrimaryCreditCard.BillingCity,
                        State = billing.PrimaryCreditCard.BillingState,
                        Zip = billing.PrimaryCreditCard.BillingZip,
                        Country = billing.PrimaryCreditCard.BillingCountry
                    }
                });

                methods.Add(new CreditCard(CreditCardType.Secondary)
                {
                    NameOnCard = billing.SecondaryCreditCard.BillingName,
                    CardNumber = billing.SecondaryCreditCard.CreditCardNumberDisplay,
                    ExpirationMonth = billing.SecondaryCreditCard.ExpirationMonth,
                    ExpirationYear = billing.SecondaryCreditCard.ExpirationYear,
                    AutoOrderIDs = autoOrders.Where(c => c.AutoOrderPaymentTypeID == 2).Select(c => c.AutoOrderID).ToArray(),

                    BillingAddress = new Address()
                    {
                        Address1 = billing.SecondaryCreditCard.BillingAddress,
                        City = billing.SecondaryCreditCard.BillingCity,
                        State = billing.SecondaryCreditCard.BillingState,
                        Zip = billing.SecondaryCreditCard.BillingZip,
                        Country = billing.SecondaryCreditCard.BillingCountry
                    }
                });

                // Filter out invalid or incomplete methods if applicable
                if (request.ExcludeInvalidMethods)
                {
                    methods = methods.Where(c => c.IsValid).ToList();
                }
                if (request.ExcludeIncompleteMethods)
                {
                    methods = methods.Where(c => c.IsComplete).ToList();
                }
                if (request.ExcludeNonAutoOrderPaymentMethods)
                {
                    methods = methods.Where(c => c is IAutoOrderPaymentMethod).ToList();
                }
            }
            catch { }

            return methods.AsEnumerable();
        }