Пример #1
0
        public IActionResult PaymentMethodsList()
        {
            var paymentHandlers = _pluginAccountant.GetActivePlugins(typeof(IPaymentHandlerPlugin));
            var models          = paymentHandlers.Select(x => new { Id = x.SystemName, x.Name }).ToList();

            return(R.Success.With("paymentMethods", models).WithGridResponse(paymentHandlers.Count, 1, paymentHandlers.Count).Result);
        }
Пример #2
0
        public IActionResult ShippingInfo()
        {
            if (!CanCheckout(out Cart cart))
            {
                return(RedirectToRoute(RouteNames.Home));
            }
            //is shipping required?
            var shippingRequired = CartHelper.IsShippingRequired(cart);

            if (!shippingRequired)
            {
                return(RedirectToRoute(RouteNames.CheckoutPayment));
            }
            if (cart.BillingAddressId == 0 || cart.ShippingAddressId == 0)
            {
                return(R.Fail.With("error", T("The address details were not provided")).Result);
            }

            //find available shipping methods
            var shippingHandlers = _pluginAccountant.GetActivePlugins(typeof(IShipmentHandlerPlugin))
                                   .Where(x => x.LoadPluginInstance <IShipmentHandlerPlugin>().IsMethodAvailable(cart)).ToList();

            if (!shippingHandlers.Any())
            {
                cart.ShippingMethodName = ApplicationConfig.UnavailableMethodName;
                _cartService.Update(cart);
                //there are no shipping handlers, may be it's being manually handled by store owner
                return(RedirectToRoute(RouteNames.CheckoutPayment));
            }
            var shippingModels = shippingHandlers.Select(x =>
            {
                var model = new ShippingMethodModel()
                {
                    SystemName   = x.SystemName,
                    Description  = x.Description,
                    FriendlyName = x.Name
                };

                return(model);
            })
                                 .ToList();

            return(R.Success
                   .With("shippingMethods", shippingModels)
                   .With("shippingRequired", true)
                   .Result);
        }