public ActionResult Index(CheckoutViewModel model) { var cart = cartProvider.GetCart(); var contactDataCollection = contactDataProvider.GetContactData(); ViewBag.CheckVAT = !String.IsNullOrEmpty(vatDataProvider.VatNumber); if (RecaptchaHelper.IsRecaptchaEnabled()) { if (!RecaptchaHelper.IsResponseValid(Request.Form["g-recaptcha-response"])) { ModelState.AddModelError("recaptcha", this.GlobalCommonResource("RecaptchaVerificationFaild")); } } if (cart.IsEmpty()) { ModelState.AddModelError("cart", "Cart is empty"); } else if (contactDataCollection == null) { ModelState.AddModelError("contactData", "Contact data is empty"); } if (ModelState.IsValid) { // Recalculate cart one last time, to make sure e.g. setup fees are still there. cartPricingService.CalculatePricing(cart); var paymentData = new PaymentData { Id = model.SelectedPaymentMethod.Id, PaymentForm = model.SelectedPaymentMethod.Form, SaveCcInfo = model.SelectedPaymentMethod.SupportsPaymentProfile && model.SaveCcInfo, AutoPay = model.SelectedPaymentMethod.SupportsPaymentProfile && model.AutoPay }; var orderContext = new OrderContext(cart, contactDataCollection, paymentData, new object[] { Request }); var result = orderPlacementService.PlaceOrder(orderContext); if (result.RedirectUrl == urlProvider.SuccessUrl) { contactDataProvider.ClearContactData(); cartProvider.ClearCart(); } return(Redirect(result.RedirectUrl)); } if (RecaptchaHelper.IsRecaptchaEnabled()) { ViewBag.RecaptchaEnabled = true; ViewBag.RecaptchaSiteKey = RecaptchaHelper.GetSiteKey(); } ViewData["formHasErrors"] = true; return(View(model)); }
public ActionResult Success() { contactDataProvider.ClearContactData(); cartProvider.ClearCart(); return(View()); }
public ActionResult Index(CheckoutViewModel model) { var cart = cartProvider.GetCart(); var contactDataCollection = contactDataProvider.GetContactData(); ViewBag.CheckVAT = !String.IsNullOrEmpty(vatDataProvider.VatNumber); if (cart.IsEmpty()) { ModelState.AddModelError("cart", "Cart is empty"); } else if (contactDataCollection == null) { ModelState.AddModelError("contactData", "Contact data is empty"); } if (ModelState.IsValid) { // Recalculate cart one last time, to make sure e.g. setup fees are still there. cartPricingService.CalculatePricing(cart); var paymentData = new PaymentData { Id = model.SelectedPaymentMethod.Id, PaymentForm = model.SelectedPaymentMethod.Form, SaveCcInfo = model.SelectedPaymentMethod.SupportsPaymentProfile && model.SaveCcInfo, AutoPay = model.SelectedPaymentMethod.SupportsPaymentProfile && model.AutoPay }; var orderContext = new OrderContext(cart, contactDataCollection, paymentData, new object[] { Request }); var result = orderPlacementService.PlaceOrder(orderContext); if (result.RedirectUrl == urlProvider.SuccessUrl) { contactDataProvider.ClearContactData(); cartProvider.ClearCart(); } return(Redirect(result.RedirectUrl)); } return(View(model)); }