public RedirectToRouteResult Checkout(PaymentViewModel paymentData) { //Authorize payment if (_paymentProcessor.AuthorizePayment(paymentData)) { Cart cart = ExtractCartFromCookie(); var userID = User.Identity.IsAuthenticated ? _usersRepository.FindByEmail(paymentData.EmailAddress).Id : Consts.anonymousUserID; _ordersRepository.CreateOrder(cart, userID); Response.Cookies.Remove(Consts.cartCookieName); } else { //display error } return RedirectToRoute("Default", new { controller = "Store", action = "Index" }); }
public bool AuthorizePayment(PaymentViewModel paymentData) { if (paymentData.CreditCardValidUntil < DateTime.Now) return false; return true; }