public ActionResult FetchAutoOrderEditPaymentMethodModule(int autoorderid) { var model = new AutoOrderPaymentViewModel(); var customerID = Identity.Customer.CustomerID; var autoOrderTypeID = 0; // Get our payment type so we know which card to show as selected when the payment module loads up - Mike M. var task = Task.Factory.StartNew(() => { autoOrderTypeID = Exigo.OData().AutoOrders.Where(c => c.CustomerID == customerID && c.AutoOrderID == autoorderid).FirstOrDefault().AutoOrderPaymentTypeID; }); model.AutoorderID = autoorderid; model.PaymentMethods = Exigo.GetCustomerPaymentMethods(new GetCustomerPaymentMethodsRequest { CustomerID = customerID, ExcludeIncompleteMethods = true }); Task.WaitAll(task); // Auto Order Payment Type: 1 Primary Card on File, 2 Secondary Card on File model.SelectedCardType = (autoOrderTypeID == 1) ? CreditCardType.Primary : CreditCardType.Secondary; string html = RenderPartialViewToString("displaytemplates/autoordereditpaymentmethod", model); return(new JsonNetResult(new { success = true, module = html })); }
private void InflateManageAutoOrderViewModel(int customerID, IMarket market, IOrderConfiguration configuration, ref ManageAutoOrderViewModel viewModel) { viewModel.AvailableStartDates = Enumerable.Range(1, 27).Select(day => { var date = new DateTime(DateTime.Now.Year, DateTime.Now.Month, day).BeginningOfDay(); if (date < DateTime.Now.BeginningOfDay()) { date = date.AddMonths(1); } return(date); }).OrderBy(d => d.Day).ToList(); viewModel.AvailableProducts = Exigo.GetItems(new ExigoService.GetItemsRequest() { Configuration = configuration, LanguageID = Utilities.GetUserLanguage(Request).LanguageID, CategoryID = configuration.CategoryID, PriceTypeID = PriceTypes.Wholesale, IncludeChildCategories = true, IncludeDynamicKitChildren = false }).ToList(); viewModel.AvailablePaymentMethods = Exigo.GetCustomerPaymentMethods(customerID) .Where(p => p.IsValid) .Where(p => p is IAutoOrderPaymentMethod) .ToList(); if (viewModel.AvailablePaymentMethods != null && viewModel.AvailablePaymentMethods.Count() == 1) { viewModel.NewCreditCard.Type = CreditCardType.Secondary; } }
public ActionResult Index() { var model = new BackofficeSubscriptionsViewModel(); // Get the customer's subscriptions model.Subscriptions = Exigo.GetCustomerSubscriptions(CurrentCustomerID).ToList(); // If we have any expired subscriptions, we need to calculate how much they are going to cost to catch them up today if (model.Subscriptions.Where(c => c.SubscriptionID == Subscriptions.BackofficeFeatures).FirstOrDefault() == null || model.Subscriptions.Where(c => c.SubscriptionID == Subscriptions.BackofficeFeatures).Any(s => s.IsExpired)) { var customer = Exigo.GetCustomer(Identity.Current.CustomerID); if (customer.CreatedDate >= DateTimeExtensions.ToCST(DateTime.Now.AddMinutes(-30)) && customer.CustomerTypeID == CustomerTypes.Associate) { var cookie = new HttpCookie(GlobalSettings.Backoffices.MonthlySubscriptionCookieName); cookie.Value = "true"; cookie.Expires = DateTime.Now.AddMinutes(15); HttpContext.Response.Cookies.Add(cookie); return(RedirectToAction("Index", "Dashboard")); } // Set up our request to get the order totals on the subscriptions that are required var request = new OrderCalculationRequest(); // We pull the customer's addresses first, if there are none we calculate with the corp address var customerAddresses = Exigo.GetCustomerAddresses(CurrentCustomerID); var address = (customerAddresses.Count() > 0 && customerAddresses.Where(c => c.IsComplete == true).Count() > 0) ? customerAddresses.Where(c => c.IsComplete == true).FirstOrDefault() : GlobalSettings.Company.Address; // Find which subscriptions are expired and add the appropriate items to those where needed var itemsToCalculate = new List <ShoppingCartItem>(); itemsToCalculate.Add(new ShoppingCartItem { ItemCode = GlobalSettings.Backoffices.MonthlySubscriptionItemCode, Quantity = 1 }); model.PaymentMethods = Exigo.GetCustomerPaymentMethods(new GetCustomerPaymentMethodsRequest { CustomerID = CurrentCustomerID, ExcludeIncompleteMethods = true, ExcludeInvalidMethods = true }); request.Configuration = OrderConfiguration; request.Address = address; request.Items = itemsToCalculate; request.ShipMethodID = OrderConfiguration.DefaultShipMethodID; //82774 Ivan S. 11/24/2016 //The Commissions page was displaying an OOPS error when clicking on it, because //we were not passing in the CustomerID, and it was generating a null exception //Therefore I added this line of code: request.CustomerID = Identity.Current.CustomerID; model.OrderCalcResponse = Exigo.CalculateOrder(request); } return(View(model)); }
public ActionResult PaymentMethodList() { var model = Exigo.GetCustomerPaymentMethods(new GetCustomerPaymentMethodsRequest { CustomerID = Identity.Current.CustomerID, ExcludeIncompleteMethods = true }); return(View(model)); }
public ActionResult ManageCreditCard(CreditCardType type) { var model = Exigo.GetCustomerPaymentMethods(Identity.Current.CustomerID) .Where(c => c is CreditCard && ((CreditCard)c).Type == type) .FirstOrDefault(); // Clear out the card number ((CreditCard)model).CardNumber = ""; return(View("ManageCreditCard", model)); }
public ActionResult UseBankAccountOnFile(ExigoService.BankAccountType type) { var paymentMethod = Exigo.GetCustomerPaymentMethods(new GetCustomerPaymentMethodsRequest { CustomerID = Identity.Current.CustomerID, ExcludeIncompleteMethods = true, ExcludeInvalidMethods = true }).Where(c => c is BankAccount && ((BankAccount)c).Type == type).FirstOrDefault(); return(UsePaymentMethod(paymentMethod)); }
public ActionResult UseCreditCardOnFile(CreditCardType type) { var paymentMethod = Exigo.GetCustomerPaymentMethods(new GetCustomerPaymentMethodsRequest { CustomerID = Identity.Current.CustomerID, ExcludeIncompleteMethods = true, ExcludeInvalidMethods = true }).Where(c => c is CreditCard && ((CreditCard)c).Type == type).FirstOrDefault(); return(UsePaymentMethod(paymentMethod)); }
public ActionResult ManageBankAccount(ExigoService.BankAccountType type) { var model = Exigo.GetCustomerPaymentMethods(Identity.Current.CustomerID) .Where(c => c is BankAccount && ((BankAccount)c).Type == type) .FirstOrDefault(); // Clear out the account number ((BankAccount)model).AccountNumber = ""; return(View("ManageBankAccount", model)); }
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.Current.CustomerID, ExcludeIncompleteMethods = true, ExcludeInvalidMethods = true, ExcludeNonAutoOrderPaymentMethods = true }).Where(c => c is BankAccount).Select(c => c as BankAccount); if (paymentMethodsOnFile.FirstOrDefault() == null) { Exigo.SetCustomerBankAccount(Identity.Current.CustomerID, newBankAccount); } } return(UsePaymentMethod(newBankAccount)); } }
public ActionResult Payment() { var model = ShoppingViewModelFactory.Create <PaymentMethodsViewModel>(PropertyBag); model.PaymentMethods = Exigo.GetCustomerPaymentMethods(new GetCustomerPaymentMethodsRequest { CustomerID = Identity.Current.CustomerID, ExcludeIncompleteMethods = true, ExcludeInvalidMethods = true }); model.Addresses = Exigo.GetCustomerAddresses(Identity.Current.CustomerID) .Where(c => c.IsComplete) .Select(c => c as ShippingAddress); return(View("Payment", model)); }
public ActionResult Payment() { var model = ShoppingViewModelFactory.Create <PaymentMethodsViewModel>(PropertyBag); if (Identity.Customer != null) { model.PaymentMethods = Exigo.GetCustomerPaymentMethods(new GetCustomerPaymentMethodsRequest { CustomerID = Identity.Customer.CustomerID, ExcludeIncompleteMethods = true, ExcludeInvalidMethods = true }); model.Addresses = Exigo.GetCustomerAddresses(Identity.Customer.CustomerID) .Where(c => c.IsComplete) .Select(c => c as ShippingAddress); } ViewBag.HasAutoOrderItems = ShoppingCart.Items.Count(c => c.Type == ShoppingCartItemType.AutoOrder) > 0; return(View("Payment", model)); }
public ActionResult UseBankAccountOnFile(ExigoService.BankAccountType type) { if (Identity.Customer != null) { var paymentMethod = Exigo.GetCustomerPaymentMethods(new GetCustomerPaymentMethodsRequest { CustomerID = Identity.Customer.CustomerID, ExcludeIncompleteMethods = true, ExcludeInvalidMethods = true }).Where(c => c is BankAccount && ((BankAccount)c).Type == type).FirstOrDefault(); return(UsePaymentMethod(paymentMethod)); } else { return(new JsonNetResult(new { success = false, message = Resources.Common.YourSessionHasExpired })); } }
public ActionResult ManageAutoOrder(int id, ManageAutoOrderViewModel viewModel) { var customerID = Identity.Customer.CustomerID; var apiRequests = new List <ApiRequest>(); var customer = Exigo.GetCustomer(customerID); var market = GlobalSettings.Markets.AvailableMarkets.Where(c => c.Countries.Contains(Identity.Customer.Country)).FirstOrDefault(); var configuration = market.GetConfiguration().AutoOrders; var warehouseID = configuration.WarehouseID; var isExistingAutoOrder = id != 0; var paymentMethods = Exigo.GetCustomerPaymentMethods(new GetCustomerPaymentMethodsRequest() { CustomerID = Identity.Customer.CustomerID, ExcludeIncompleteMethods = true }); // Remove all items that have no quantity. viewModel.AutoOrder.Details = viewModel.AutoOrder.Details.Where(d => d.Quantity > 0).ToList(); if (!viewModel.AutoOrder.Details.Any()) { ModelState.AddModelError("Result", "Please select at least one product for your Auto Order."); } if (ModelState.Keys.Contains("Result")) { InflateManageAutoOrderViewModel(customerID, market, configuration, ref viewModel); return(View(viewModel)); } // Save New Credit Card var isUsingNewCard = viewModel.AutoOrder.AutoOrderPaymentTypeID == 0; var hasPrimaryCard = paymentMethods.Where(v => v.IsComplete).Count() > 0; if (isUsingNewCard) { var saveCCRequest = new SetAccountCreditCardTokenRequest(viewModel.NewCreditCard); // If there is one or more available payment type, save the card in the secondary card slot if (hasPrimaryCard) { saveCCRequest.CreditCardAccountType = AccountCreditCardType.Secondary; viewModel.AutoOrder.AutoOrderPaymentTypeID = AutoOrderPaymentTypes.SecondaryCreditCardOnFile; } else { viewModel.AutoOrder.AutoOrderPaymentTypeID = AutoOrderPaymentTypes.PrimaryCreditCardOnFile; } saveCCRequest.CustomerID = customerID; apiRequests.Add(saveCCRequest); } // Prepare the auto order var autoOrder = viewModel.AutoOrder; var createAutoOrderRequest = new CreateAutoOrderRequest(autoOrder) { PriceType = configuration.PriceTypeID, WarehouseID = warehouseID, Notes = !string.IsNullOrEmpty(autoOrder.Notes) ? autoOrder.Notes : string.Format("Created with the API Auto-Delivery manager at \"{0}\" on {1:u} at IP {2} using {3} {4} ({5}).", Request.Url.AbsoluteUri, DateTime.Now.ToUniversalTime(), GlobalUtilities.GetClientIP(), HttpContext.Request.Browser.Browser, HttpContext.Request.Browser.Version, HttpContext.Request.Browser.Platform), CustomerID = customerID }; apiRequests.Add(createAutoOrderRequest); try { // Process the transaction var transaction = new TransactionalRequest { TransactionRequests = apiRequests.ToArray() }; var response = Exigo.WebService().ProcessTransaction(transaction); return(RedirectToAction("AutoOrderList", new { success = "1" })); } catch (Exception ex) { ModelState.AddModelError("Result", "We were unable to save your Auto-Delivery: " + ex.Message); InflateManageAutoOrderViewModel(customerID, market, configuration, ref viewModel); return(View(viewModel)); } }
public ActionResult RenewSubscription(CreditCard creditcard) { var shipMethodID = OrderConfiguration.DefaultShipMethodID; // Will call or free option, since this is a virtual order var customerID = CurrentCustomerID; var requests = new List <ApiRequest>(); var items = new List <ShoppingCartItem>(); var paymonthly = true; var card = new CreditCard(); if (creditcard.Type != CreditCardType.New) { card = Exigo.GetCustomerPaymentMethods(new GetCustomerPaymentMethodsRequest { CustomerID = Identity.Current.CustomerID, ExcludeIncompleteMethods = true, ExcludeInvalidMethods = true }).Where(c => c is CreditCard && ((CreditCard)c).Type == creditcard.Type).FirstOrDefault().As <CreditCard>(); } else { card = creditcard; } try { // Determine which items we need to add to the order we are creating and assemble our order request if (paymonthly) { items.Add(new ShoppingCartItem { ItemCode = GlobalSettings.Backoffices.MonthlySubscriptionItemCode, Quantity = 1 }); } // We pull the customer's addresses first, if there are none we calculate with the corp address var customerAddresses = Exigo.GetCustomerAddresses(CurrentCustomerID); var address = (customerAddresses.Count() > 0 && customerAddresses.Where(c => c.IsComplete).Count() > 0) ? customerAddresses.Where(c => c.IsComplete).FirstOrDefault().As <ShippingAddress>() : new ShippingAddress(GlobalSettings.Company.Address); var OrderRequest = new CreateOrderRequest(OrderConfiguration, shipMethodID, items, address) { CustomerID = customerID }; requests.Add(OrderRequest); // Then next step is adding the credit card payment and account update request if (!card.IsTestCreditCard && !Request.IsLocal) { if (card.Type == CreditCardType.New) { requests.Add(new ChargeCreditCardTokenRequest(card)); requests.Add(new SetAccountCreditCardTokenRequest(card) { CustomerID = customerID, CreditCardAccountType = AccountCreditCardType.Primary }); } else { requests.Add(new ChargeCreditCardTokenOnFileRequest(card)); } } else { OrderRequest.OrderStatus = OrderStatusType.Shipped; } // Process the transaction var transactionRequest = new TransactionalRequest(); transactionRequest.TransactionRequests = requests.ToArray(); var transactionResponse = Exigo.WebService().ProcessTransaction(transactionRequest); if (transactionResponse.Result.Status != ResultStatus.Success) { //throw new Exception(transactionResponse.Result.Errors.ToString()); throw new Exception("Transaction failed"); } else { var httpContext = System.Web.HttpContext.Current; var cookie = httpContext.Request.Cookies[GlobalSettings.Backoffices.MonthlySubscriptionCookieName]; if (cookie != null) { cookie.Expires = DateTime.Now.AddMinutes(30); Response.Cookies.Set(cookie); } else { cookie = new HttpCookie(GlobalSettings.Backoffices.MonthlySubscriptionCookieName); cookie.Value = "true"; cookie.Expires = DateTime.Now.AddMinutes(30); Response.Cookies.Add(cookie); httpContext.Response.Cookies.Add(cookie); //Invalidate the customer subscription cache HttpRuntime.Cache.Remove(string.Format("exigo.customersubscriptions.{0}-{1}", customerID, Subscriptions.BackofficeFeatures)); } } return(new JsonNetResult(new { success = true })); } catch (Exception ex) { return(new JsonNetResult(new { success = false, message = ex.Message })); } }