void GetCartTotals(CartTotalsMessage result, ShoppingCart localCart = null)
 {
     if (localCart == null)
     {
         localCart = ShoppingCart.GetCart(this.HttpContext);
     }
     localCart.CalcTax();
     result.Tax      = localCart.Tax;
     result.Shipping = localCart.Shipping;
     result.Discount = localCart.Discount;
     result.Total    = localCart.Total;
 }
        public JsonResult ShippingDetails(ShippingDetails details)
        {
            var result = new CartTotalsMessage();

            try
            {
                var localCart = ShoppingCart.GetCart(this.HttpContext);
                localCart.Shipping = details.Amount;
                GetCartTotals(result, localCart);
            }
            catch (Exception e)
            {
                result.Error = e.Message;
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }