Example #1
0
        public ActionResult SelectPaymentMethod(string paymentmethod, CheckoutPaymentMethodModel model, FormCollection form)
        {
            var customer = _workContext.CurrentCustomer;
            var cart     = customer.GetCartItems();

            if (cart == null || !cart.Any())
            {
                return(RedirectToAction("Index", "Home"));
            }

            //Save payment method
            var paymentMethodKey = form.AllKeys.FirstOrDefault(m => m.StartsWith("payment_method_id", StringComparison.InvariantCultureIgnoreCase));

            if (paymentMethodKey.HasValue())
            {
                var paymentMethodName = form[paymentMethodKey];
                _genericAttributeService.SaveGenericAttribute(customer.Id, "Customer", Contains.SelectedPaymentMethod, paymentMethodName);
            }

            //Save shipping method
            var shippingMethodKey = form.AllKeys.FirstOrDefault(m => m.StartsWith("shipping_rate_id", StringComparison.InvariantCultureIgnoreCase));

            if (shippingMethodKey.HasValue())
            {
                var shippingMethodName = form[shippingMethodKey];
                _genericAttributeService.SaveGenericAttribute(customer.Id, "Customer", Contains.SelectedShippingOption, shippingMethodName);
            }

            return(RedirectToAction("Confirm"));
        }