public SetAccountCheckingRequest(BankAccount account)
        {
            NameOnAccount     = account.NameOnAccount;
            BankName          = account.BankName;
            BankAccountNumber = account.AccountNumber;
            BankRoutingNumber = account.RoutingNumber;
            BankAccountType   = ExigoWebService.BankAccountType.CheckingPersonal;

            BillingAddress = account.BillingAddress.AddressDisplay;
            BillingCity    = account.BillingAddress.City;
            BillingState   = account.BillingAddress.State;
            BillingZip     = account.BillingAddress.Zip;
            BillingCountry = account.BillingAddress.Country;
        }
 public DebitBankAccountOnFileRequest(BankAccount account)
 {
 }
        public ActionResult SaveBankAccount(BankAccount account)
        {
            account = Exigo.SetCustomerBankAccount(Identity.Customer.CustomerID, account);

            return RedirectToAction("PaymentMethodList");
        }
        public ActionResult AddBankAccount()
        {
            var model = new BankAccount();
            model.Type = ExigoService.BankAccountType.New;
            model.BillingAddress = new Address()
            {
                Country = GlobalSettings.Company.Address.Country
            };

            return View("ManageBankAccount", model);
        }
        // Direct Deposit
        public static BankAccount GetDirectDeposit(int customerID)
        {
            var account = new BankAccount();

            try
            {
                var context = Exigo.WebService();

                var result = context.GetAccountDirectDeposit(new GetAccountDirectDepositRequest
                {
                    CustomerID = customerID
                });

                if (result.Result.Status == ResultStatus.Success)
                {
                    account.AccountNumber = result.BankAccountNumberDisplay;
                    account.NameOnAccount = result.NameOnAccount;
                    account.BankName = result.BankName;
                    account.RoutingNumber = result.BankRoutingNumber;

                    account.BillingAddress.Address1 = result.BankAddress;
                    account.BillingAddress.City = result.BankCity;
                    account.BillingAddress.State = result.BankState;
                    account.BillingAddress.Country = result.BankCountry;
                    account.BillingAddress.Zip = result.BankZip;
                }
                // We are seperating out swiftCode/Iban so in order to keep everything else the same we are simply pulling back the account routing number, and account number and setting them to their proper fields.

                if (account.AccountNumber.IsNullOrEmpty())
                {
                    account.AccountNumber = result.Iban;
                    account.RoutingNumber = result.SwiftCode;
                }
            }
            catch
            {

            }

            return account;
        }
        public static bool SetDirectDeposit(int customerID, BankAccount account, MarketName CurrentMarket)
        {
            try
            {
                var context = Exigo.WebService();
                var request = new SetAccountDirectDepositRequest{
                       CustomerID = customerID,
                        NameOnAccount = account.NameOnAccount,
                        BankName = account.BankName,

                        DepositAccountType = DepositAccountType.Checking,

                        BankAddress = account.BillingAddress.Address1,
                        BankCity = account.BillingAddress.City,
                        BankState = account.BillingAddress.State,
                        BankCountry = account.BillingAddress.Country,
                        BankZip = account.BillingAddress.Zip

                };
                if (CurrentMarket == MarketName.UnitedStates)
                {
                    request.BankRoutingNumber = account.RoutingNumber;
                    request.BankAccountNumber = account.AccountNumber;
                }
                // We are seperating out swiftCode/Iban so in order to keep everything else the same we are simply pulling back the account routing number, and account number and setting them to their proper fields.
                else
                {
                    request.SwiftCode = account.RoutingNumber;
                    request.Iban = account.AccountNumber;
                }

                var result = context.SetAccountDirectDeposit(request);

                Exigo.WebService().UpdateCustomer(new UpdateCustomerRequest
                {
                    CustomerID = customerID,
                    PayableType = PayableType.DirectDeposit
                });
            }
            catch
            {
                return false;
            }

            return true;
        }
        public static BankAccount SetCustomerBankAccount(int customerID, BankAccount account, ExigoService.BankAccountType type)
        {
            // New bank accounts
            if (type == ExigoService.BankAccountType.New)
            {
                return SaveNewCustomerBankAccount(customerID, account);
            }

            // Save the bank account
            var request = new SetAccountCheckingRequest
            {
                CustomerID = customerID,

                BankName = account.BankName,
                BankAccountNumber = account.AccountNumber,
                BankRoutingNumber = account.RoutingNumber,
                BankAccountType = Common.Api.ExigoWebService.BankAccountType.CheckingPersonal,

                NameOnAccount = account.NameOnAccount,
                BillingAddress = account.BillingAddress.AddressDisplay,
                BillingCity = account.BillingAddress.City,
                BillingState = account.BillingAddress.State,
                BillingZip = account.BillingAddress.Zip,
                BillingCountry = account.BillingAddress.Country
            };
            var response = Exigo.WebService().SetAccountChecking(request);

            return account;
        }
 public static BankAccount SetCustomerBankAccount(int customerID, BankAccount account)
 {
     return SetCustomerBankAccount(customerID, account, account.Type);
 }
        public static BankAccount SaveNewCustomerBankAccount(int customerID, BankAccount account)
        {
            // Get the bank accounts on file
            var bankAccountsOnFile = GetCustomerPaymentMethods(new GetCustomerPaymentMethodsRequest
            {
                CustomerID = customerID,
                ExcludeInvalidMethods = true
            }).Where(c => c is BankAccount).Select(c => (BankAccount)c);

            // Do we have any empty slots? If so, save this bank account to the next available slot
            if (!bankAccountsOnFile.Any(c => c.Type == ExigoService.BankAccountType.Primary))
            {
                account.Type = ExigoService.BankAccountType.Primary;
                return SetCustomerBankAccount(customerID, account);
            }

            // If not, try to save it to a bank account slot that does not have any autoOrders bound to it.
            if (!bankAccountsOnFile.Where(c => c.Type == ExigoService.BankAccountType.Primary).Single().IsUsedInAutoOrders)
            {
                account.Type = ExigoService.BankAccountType.Primary;
                return SetCustomerBankAccount(customerID, account);
            }

            // If no autoOrder-free slots exist, don't save it.
            return account;
        }
        public ActionResult UseBankAccount(BankAccount newBankAccount, bool billingSameAsShipping = false)
        {
            if (billingSameAsShipping)
            {
                var address = PropertyBag.ShippingAddress;

                newBankAccount.BillingAddress = new Address
                {
                    Address1 = address.Address1,
                    Address2 = address.Address2,
                    City = address.City,
                    State = address.State,
                    Zip = address.Zip,
                    Country = address.Country
                };
            }

            // Verify that the card is valid
            if (!newBankAccount.IsValid)
            {
                return new JsonNetResult(new
                {
                    success = false
                });
            }
            else
            {
                // Save the bank account to the customer's account if applicable
                if (LogicProvider.IsAuthenticated())
                {
                    var paymentMethodsOnFile = Exigo.GetCustomerPaymentMethods(new GetCustomerPaymentMethodsRequest
                    {
                        CustomerID = Identity.Customer.CustomerID,
                        ExcludeIncompleteMethods = true,
                        ExcludeInvalidMethods = true,
                        ExcludeNonAutoOrderPaymentMethods = true
                    }).Where(c => c is BankAccount).Select(c => c as BankAccount);

                    if (paymentMethodsOnFile.FirstOrDefault() == null)
                    {
                        Exigo.SetCustomerBankAccount(Identity.Customer.CustomerID, newBankAccount);
                    }
                }

                return UsePaymentMethod(newBankAccount);
            }
        }
Exemple #11
0
 public static BankAccount SetCustomerBankAccount(int customerID, BankAccount account)
 {
     return(SetCustomerBankAccount(customerID, account, account.Type));
 }