public ActionResult SubmitButton() { var cart = _payPalExpressCheckoutService.GetCart(); if (!cart.Any()) { return(RedirectToRoute("ShoppingCart")); } var checkoutAttributesXml = _genericAttributeService.GetAttribute <string>(_workContext.CurrentCustomer, NopCustomerDefaults.CheckoutAttributes, _storeContext.CurrentStore.Id); var scWarnings = _shoppingCartService.GetShoppingCartWarnings(cart, checkoutAttributesXml, true); if (scWarnings.Any()) { TempData[Defaults.CheckoutErrorMessageKey] = string.Join("<br />", scWarnings); return(RedirectToRoute("ShoppingCart")); } var cartProductIds = cart.Select(ci => ci.ProductId).ToArray(); var downloadableProductsRequireRegistration = _customerSettings.RequireRegistrationForDownloadableProducts && _productService.HasAnyDownloadableProduct(cartProductIds); if (_customerService.IsGuest(_workContext.CurrentCustomer) && (!_orderSettings.AnonymousCheckoutAllowed || downloadableProductsRequireRegistration)) { return(Challenge()); } return(Redirect(_payPalRedirectionService.ProcessSubmitButton(cart, TempData))); }
public IViewComponentResult Invoke() { var cart = _payPalExpressCheckoutService.GetCart(); if (cart.Count == 0) { return(Content(string.Empty)); } if (!_orderProcessingService.ValidateMinOrderSubtotalAmount(cart)) { return(Content(string.Empty)); } var filterByCountryId = 0; var billingAddress = _addressService.GetAddressById(_workContext.CurrentCustomer.BillingAddressId ?? 0); if (_addressSettings.CountryEnabled && billingAddress?.CountryId != null) { filterByCountryId = billingAddress.CountryId.Value; } var plugin = _paymentPluginManager.LoadPluginBySystemName("Payments.PayPalExpressCheckout"); if (plugin == null || _paymentPluginManager.GetRestrictedCountryIds(plugin).Contains(filterByCountryId)) { return(Content(string.Empty)); } var model = new PaymentInfoModel { ButtonImageLocation = Defaults.CheckoutButtonImageUrl }; return(View("~/Plugins/Payments.PayPalExpressCheckout/Views/PaymentInfo.cshtml", model)); }