public ActionResult CartSummary() { List<HiLToysDataModel.Cart> products = new List<HiLToysDataModel.Cart>(); CartApplicationService cartApplicationService = new CartApplicationService(); CartViewModel cartViewModel = new CartViewModel(); var Cart = ShoppingCartActions.GetCart(); cartViewModel.Cart.CartID = Cart.ShoppingCartId; cartViewModel = cartApplicationService.GetCarts(Cart.ShoppingCartId); if (cartViewModel.Cart.CartTotal < 1) Session["payment_amt"] = null; else Session["payment_amt"] = cartViewModel.Cart.CartTotal; cartViewModel = cartApplicationService.GetCartCount(cartViewModel); ViewData["CartCount"] = cartViewModel.Cart.Count; return PartialView("CartSummary"); }
public bool ShortcutExpressCheckout(string amt, ref string token, ref string retMsg) { if (bSandbox) { pEndPointURL = pEndPointURL_SB; host = host_SB; } string returnURL = "http://ethiohilecomvctoysapp2017.apphb.com/Checkout/CheckoutReview"; string cancelURL = "http://ethiohilecomvctoysapp2017.apphb.com/Checkout/CheckoutCancel"; NVPCodec encoder = new NVPCodec(); encoder["METHOD"] = "SetExpressCheckout"; encoder["RETURNURL"] = returnURL; encoder["CANCELURL"] = cancelURL; encoder["BRANDNAME"] = "HiLEco MVC Toys Sample Application 2015"; encoder["PAYMENTREQUEST_0_AMT"] = amt; encoder["PAYMENTREQUEST_0_ITEMAMT"] = amt; encoder["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale"; encoder["PAYMENTREQUEST_0_CURRENCYCODE"] = "USD"; // Get the Shopping Cart Products CartApplicationService cartApplicationService = new CartApplicationService(); var Cart = ShoppingCartActions.GetCart(); // string CartID = Cart.GetCartId(this.HttpContext); string CartID = ""; CartID = Cart.ShoppingCartId; CartViewModel cartViewModel = new CartViewModel(); cartViewModel=cartApplicationService.GetCarts(CartID); int i = 0; foreach (var item in cartViewModel.Carts) { if (item.CartID != "") { encoder["L_PAYMENTREQUEST_0_NAME" + i] = item.ProductName.ToString(); encoder["L_PAYMENTREQUEST_0_AMT" + i] = item.UnitPrice.ToString(); encoder["L_PAYMENTREQUEST_0_QTY" + i] = item.Quantity.ToString(); } i++; } string pStrrequestforNvp = encoder.Encode(); string pStresponsenvp = HttpCall(pStrrequestforNvp); NVPCodec decoder = new NVPCodec(); decoder.Decode(pStresponsenvp); string strAck = decoder["ACK"].ToLower(); if (strAck != null && (strAck == "success" || strAck == "successwithwarning")) { token = decoder["TOKEN"]; string ECURL = "https://" + host + "/cgi-bin/webscr?cmd=_express-checkout" + "&token=" + token; retMsg = ECURL; return true; } else { retMsg = "ErrorCode=" + decoder["L_ERRORCODE0"] + "&" + "Desc=" + decoder["L_SHORTMESSAGE0"] + "&" + "Desc2=" + decoder["L_LONGMESSAGE0"]; return false; } }
// // GET: /Carts/ public ActionResult Index() { CartApplicationService cartApplicationService = new CartApplicationService(); var Cart = ShoppingCartActions.GetCart(); string CartID = Cart.ShoppingCartId; CartViewModel cartViewModel = new CartViewModel(); cartViewModel = cartApplicationService.GetCarts(CartID); if (cartViewModel.Cart.CartTotal < 1) Session["payment_amt"] = null; else Session["payment_amt"] = cartViewModel.Cart.CartTotal; return View("Index", cartViewModel); }