public async Task<JsonResult> SetShippingMethod(Address address, string shippingMethodId)
        {
            if (string.IsNullOrEmpty(shippingMethodId))
            {
                return Json(new { errorMessage = T("You did not set shipping method").Text });
            }

            if (!ModelState.IsValid)
            {
                return Json(new { errorMessage = GetModelErrorMessage(ModelState) });
            }

            var customerId = GetCustomerId(HttpContext, Settings.AnonymousCookieId);

            var checkout = await _shoppingCartService.GetCheckoutAsync(Settings.StoreId, customerId);
            var shippingMethods = await _shoppingCartService.GetShippingMethodsAsync(checkout.Id);

            var shippingMethod = shippingMethods.FirstOrDefault(sm => sm.Keyword.Equals(shippingMethodId, StringComparison.OrdinalIgnoreCase));
            if (shippingMethod == null)
            {
                return Json(new { errorMessage = T("Selected shipping method was not found").Text });
            }

            checkout.ShippingAddress = address;
            checkout.ShippingMethodId = shippingMethodId;

            await _shoppingCartService.UpdateCheckoutAsync(checkout);

            checkout = await _shoppingCartService.GetCheckoutAsync(Settings.StoreId, customerId);

            return Json(new { checkout = checkout });
        }
        public async Task<JsonResult> SetPaymentMethod(Address address, string paymentMethodId)
        {
            if (string.IsNullOrEmpty(paymentMethodId))
            {
                return Json(new { errorMessage = T("You did not set payment method").Text });
            }

            if (!ModelState.IsValid)
            {
                return Json(new { errorMessage = GetModelErrorMessage(ModelState) });
            }

            var customerId = GetCustomerId(HttpContext, Settings.AnonymousCookieId);

            var checkout = await _shoppingCartService.GetCheckoutAsync(Settings.StoreId, customerId);
            var paymentMethods = await _shoppingCartService.GetPaymentMethodsAsync(checkout.Id);

            var paymentMethod = paymentMethods.FirstOrDefault(sm => sm.Keyword.Equals(paymentMethodId, StringComparison.OrdinalIgnoreCase));
            if (paymentMethod == null)
            {
                return Json(new { errorMessage = T("Selected payment method was not found").Text });
            }

            if (paymentMethod.Type.Equals("PreparedForm", StringComparison.OrdinalIgnoreCase) ||
                paymentMethod.Type.Equals("Stardard", StringComparison.OrdinalIgnoreCase))
            {
                return Json(new { errorMessage = T(string.Format("{0} payment method is not supported for this demo", paymentMethod.Name)).Text });
            }

            checkout.BillingAddress = address;
            checkout.PaymentMethodId = paymentMethodId;

            await _shoppingCartService.UpdateCheckoutAsync(checkout);

            checkout = await _shoppingCartService.GetCheckoutAsync(Settings.StoreId, customerId);

            return Json(new { checkout = checkout });
        }