public ActionResult Checkout(Payment Payment) { if (new CartBusiness { UserKey = Session.GetUserKey() }.GetCurrentCartCount() <= 0) { var ex = new HttpException(400, ""); ex.Data["ErrType"] = Globals.ERRTYPES.CART_CARTEMPTY; throw ex; } var orderBusiness = new OrderBusiness(); var currentOrder = orderBusiness.GetIncompleteOrder(Session.GetUserKey()); if (currentOrder == null) { var ex = new HttpException(404, ""); ex.Data["ErrType"] = Globals.ERRTYPES.ORDER_NOTFOUND; throw ex; } decimal ItemsTotal; decimal ShippingPrice; decimal OrderTotal; orderBusiness.CalculateOrderSummary(out ItemsTotal, out ShippingPrice, out OrderTotal, currentOrder); if (OrderTotal != Payment.AmountPaid) { var ex = new HttpException(400, ""); ex.Data["ErrType"] = Globals.ERRTYPES.CHECKOUT_PAYMENTERROR; throw ex; } orderBusiness.Checkout(Payment, currentOrder); // order completed, SEND E-MAIL return RedirectToAction("CheckoutComplete", currentOrder); }
public ActionResult Checkout() { if (new CartBusiness { UserKey = Session.GetUserKey() }.GetCurrentCartCount() <= 0) { var ex = new HttpException(400, ""); ex.Data["ErrType"] = Globals.ERRTYPES.CART_CARTEMPTY; throw ex; } var orderBusiness = new OrderBusiness(); var currentOrder = orderBusiness.GetIncompleteOrder(Session.GetUserKey()); if (currentOrder == null) { var ex = new HttpException(404, ""); ex.Data["ErrType"] = Globals.ERRTYPES.ORDER_NOTFOUND; throw ex; } decimal ItemsTotal; decimal ShippingPrice; decimal OrderTotal; orderBusiness.CalculateOrderSummary(out ItemsTotal, out ShippingPrice, out OrderTotal, currentOrder); return View(new CheckoutViewModel { Order = currentOrder, ItemsTotal = ItemsTotal, ShippingPrice = ShippingPrice, OrderTotal = OrderTotal }); }