protected void btnNextStep_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                try
                {
                    PayPalExpressPaymentProcessor payPalExpress = new PayPalExpressPaymentProcessor();
                    string token = CommonHelper.QueryString("token");
                    PaypalPayer payer = payPalExpress.GetExpressCheckout(token);
                    if (string.IsNullOrEmpty(payer.PayerID))
                        throw new NopException("Payer ID is not set");

                    PaymentInfo paymentInfo = new PaymentInfo();

                    PaymentMethod paypalExpressPaymentMethod = PaymentMethodManager.GetPaymentMethodBySystemKeyword("PayPalExpress");

                    paymentInfo.PaymentMethodId = paypalExpressPaymentMethod.PaymentMethodId;
                    paymentInfo.BillingAddress = NopContext.Current.User.BillingAddress;
                    paymentInfo.ShippingAddress = NopContext.Current.User.ShippingAddress;
                    paymentInfo.PaypalPayerId = payer.PayerID;
                    paymentInfo.PaypalToken = token;
                    paymentInfo.CustomerLanguage = NopContext.Current.WorkingLanguage;
                    paymentInfo.CustomerCurrency = NopContext.Current.WorkingCurrency;

                    int orderId = 0;
                    string result = OrderManager.PlaceOrder(paymentInfo, NopContext.Current.User, out orderId);

                    Order order = OrderManager.GetOrderById(orderId);
                    if (!String.IsNullOrEmpty(result))
                    {
                        lConfirmOrderError.Text = Server.HtmlEncode(result);
                        btnNextStep.Visible = false;
                        return;
                    }
                    else
                        PaymentManager.PostProcessPayment(order);
                    Response.Redirect("~/checkoutcompleted.aspx");
                }
                catch (Exception exc)
                {
                    LogManager.InsertLog(LogTypeEnum.OrderError, exc.Message, exc);
                    lConfirmOrderError.Text = Server.HtmlEncode(exc.ToString());
                    btnNextStep.Visible = false;
                }
            }
        }
        protected override void OnInit(EventArgs e)
        {
            PayPalExpressPaymentProcessor payPalExpress = new PayPalExpressPaymentProcessor();
            try
            {
                token = CommonHelper.QueryString("token");
                payer = payPalExpress.GetExpressCheckout(token);
                if (string.IsNullOrEmpty(payer.PayerID))
                    throw new NopException("Payer ID is not set");

                OrderSummaryControl.VendorId = int.Parse(payer.VendorId);
                OrderSummaryControl.BindData();
            }
            catch (Exception Ex)
            {
                LogService.InsertLog(LogTypeEnum.OrderError, Ex.Message, String.Empty);
            }
            finally
            {
                base.OnInit(e);
            }
        }