Exemple #1
0
        public async Task <ActionResult> SetPaymentMethodsJson(string paymentMethodCode)
        {
            await _cartBuilder.GetOrCreateNewTransientCartAsync(WorkContext.CurrentStore, WorkContext.CurrentCustomer, WorkContext.CurrentLanguage, WorkContext.CurrentCurrency);

            var paymentMethods = await _cartApi.CartModuleGetPaymentMethodsAsync(WorkContext.CurrentCart.Id);

            var paymentMethod = paymentMethods.FirstOrDefault(pm => pm.GatewayCode == paymentMethodCode);

            if (paymentMethod != null)
            {
                await _cartBuilder.AddPaymentAsync(paymentMethod.ToWebModel());

                await _cartBuilder.SaveAsync();
            }

            return(Json(null, JsonRequestBehavior.AllowGet));
        }