public ActionResult CompleteCheckout(CheckoutViewModel model) { ActionResult actionResult; if (EnsureLoggedOnUser(out actionResult)) return actionResult; var checkoutViewModel = new CheckoutViewModel(); var loggedInUser = Session.GetLoggedInUser(); try { using (var repository = RepositoryFactory.GetInstance(Session)) { var userPurchases = FindPurchasesForUser(repository).ToArray(); var userHistoricalPurchases = repository.FindHistoricalUserPurchases(Session.GetLoggedInUser().ObjectId).ToArray(); var worldId = new WorldContentTypeRetriver(HttpContext, repository).GetWorldContentTypeId(); string paymentUrl; checkoutViewModel = GetCheckoutViewModel(userPurchases, repository); checkoutViewModel.PurchaseFor = model.PurchaseFor; SetBundleClips(userPurchases, checkoutViewModel, repository); var currencyRetriver = new CurrencyRetriver(HttpContext, Session, repository); var sessionState = new SessionState(); var indexUrl = HttpContext.Request.Url.ToString().ToLower().Replace("completecheckout", "index") + string.Format("/?purchaseFor={0}", model.PurchaseFor); var expressCheckoutManager = new ExpressCheckoutManager(indexUrl); var logic = new CheckoutLogic(repository, currencyRetriver, sessionState, expressCheckoutManager); logic.ExecuteCompleteCheckout(loggedInUser, checkoutViewModel, worldId, userHistoricalPurchases, out paymentUrl); if (!string.IsNullOrEmpty(paymentUrl)) { return Redirect(paymentUrl); } } } catch { checkoutViewModel.ErrorMessage = Strings.GetLocalizedString(Strings.ShoppingCartPaymentFailure); } return View("Index", checkoutViewModel); }