protected void btnPaypalExpress_Click(object sender, EventArgs e)
        {
            if ((NopContext.Current.User == null) || (NopContext.Current.User.IsGuest && !CustomerManager.AnonymousCheckoutAllowed))
            {
                string loginURL = SEOHelper.GetLoginPageUrl(true);
                Response.Redirect(loginURL);
            }

            var payPalExpress    = new PayPalExpressPaymentProcessor();
            var ppePaymentMethod = PaymentMethodManager.GetPaymentMethodBySystemKeyword("PayPalExpress");

            if (ppePaymentMethod != null && ppePaymentMethod.IsActive)
            {
                //apply reward points
                CheckoutPaymentMethodControl checkoutPaymentMethodControl = CommonHelper.FindControlRecursive <CheckoutPaymentMethodControl>(this.Page.Controls);
                if (checkoutPaymentMethodControl != null)
                {
                    checkoutPaymentMethodControl.ApplyRewardPoints();
                }

                //payment
                var     cart      = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart);
                decimal?cartTotal = ShoppingCartManager.GetShoppingCartTotal(cart,
                                                                             ppePaymentMethod.PaymentMethodId, NopContext.Current.User);
                if (cartTotal.HasValue && cartTotal.Value > decimal.Zero)
                {
                    string expressCheckoutURL = payPalExpress.SetExpressCheckout(cartTotal.Value,
                                                                                 CommonHelper.GetStoreLocation(false) + "paypalexpressreturn.aspx",
                                                                                 CommonHelper.GetStoreLocation(false));
                    Response.Redirect(expressCheckoutURL);
                }
            }
        }
Beispiel #2
0
        protected void btnPaypalExpress_Click(object sender, EventArgs e)
        {
            if ((NopContext.Current.User == null) || (NopContext.Current.User.IsGuest && !CustomerManager.AnonymousCheckoutAllowed))
            {
                string loginURL = CommonHelper.GetLoginPageURL(true);
                Response.Redirect(loginURL);
            }

            PayPalExpressPaymentProcessor payPalExpress = new PayPalExpressPaymentProcessor();

            //todo pass payment method identifier if paypal express requires additional payment fee
            decimal?cartTotal = ShoppingCartManager.GetShoppingCartTotal(Cart, NopContext.Current.User);

            if (cartTotal.HasValue)
            {
                string expressCheckoutURL = payPalExpress.SetExpressCheckout(cartTotal.Value,
                                                                             CommonHelper.GetStoreLocation(false) + "PaypalExpressReturn.aspx",
                                                                             CommonHelper.GetStoreLocation(false) + "Default.aspx");
                Response.Redirect(expressCheckoutURL);
            }
        }
Beispiel #3
0
        protected void btnPaypalExpress_Click(object sender, EventArgs e)
        {
            if ((NopContext.Current.User == null) || (NopContext.Current.User.IsGuest && !CustomerManager.AnonymousCheckoutAllowed))
            {
                string loginURL = SEOHelper.GetLoginPageUrl(true);
                Response.Redirect(loginURL);
            }

            var payPalExpress    = new PayPalExpressPaymentProcessor();
            var ppePaymentMethod = PaymentMethodManager.GetPaymentMethodBySystemKeyword("PayPalExpress");

            if (ppePaymentMethod != null && ppePaymentMethod.IsActive)
            {
                decimal?cartTotal = ShoppingCartManager.GetShoppingCartTotal(cart,
                                                                             ppePaymentMethod.PaymentMethodId, NopContext.Current.User, false);
                if (cartTotal.HasValue)
                {
                    string expressCheckoutURL = payPalExpress.SetExpressCheckout(cartTotal.Value,
                                                                                 CommonHelper.GetStoreLocation(false) + "paypalexpressreturn.aspx",
                                                                                 CommonHelper.GetStoreLocation(false));
                    Response.Redirect(expressCheckoutURL);
                }
            }
        }