// GET: Checkout public ActionResult Index(string message) { ActionResult actionResult; if (EnsureLoggedOnUser(out actionResult)) return actionResult; using (var repository = RepositoryFactory.GetInstance(Session)) { var userPurchases = FindPurchasesForUser(repository).ToArray(); var checkoutViewModel = GetCheckoutViewModel(userPurchases, repository); checkoutViewModel.ErrorMessage = message; string payerId; string paymentId; var ppsuccess = HttpContext.Request["ppsuccess"] != null && HttpContext.Request["ppsuccess"].ToLower() == "true"; var ppcancel = HttpContext.Request["ppcancel"] != null && HttpContext.Request["ppcancel"].ToLower() == "true"; ; var currencyRetriver = new CurrencyRetriver(HttpContext, Session, repository); var sessionState = new SessionState(); var expressCheckoutManager = new ExpressCheckoutManager(); var checkoutLogic = new CheckoutLogic(repository, currencyRetriver, sessionState, expressCheckoutManager); try { if (ppsuccess && PaymentParamsExist(out payerId, out paymentId)) { checkoutLogic.ExecutePayment(payerId, paymentId, checkoutViewModel, Session.GetLoggedInUser()); } else if (ppcancel) { checkoutLogic.CancelPayment(checkoutViewModel); } } catch (Exception ex) { BL.DomainServices.Log.LoggerFactory.GetLogger().LogError(ex); checkoutViewModel.ErrorMessage = Strings.GetLocalizedString(Strings.ShoppingCartPaymentFailure); } return View(checkoutViewModel); } }