protected void OnPBPOrderOK(object sender, EventArgs e)
 {
     PBPOrderPopupExtender.Hide();
     Response.Redirect("~/Ordering/OrderListView.aspx", true);
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                hyperLinkInvoice.Visible = false;

                if (ShoppingCart != null && !string.IsNullOrWhiteSpace(OrderProvider.GetForeignPPVCountryCode(ShoppingCart.DistributorID, ShoppingCart.CountryCode)))
                {
                    if (ShoppingCart.CartItems.Count > 0 &&
                        ShoppingCart.OrderCategory == ServiceProvider.CatalogSvc.OrderCategoryType.RSO)
                    {
                        if (OrderProvider.IsEligibleReceiptModelSkus(ShoppingCart).Any())
                        {
                            ForeignPPVPopupExtender.Show();
                            var receiptModel = OrderProvider.GetReceiptModel(ShoppingCart);
                            HttpContext.Current.Session["ReceiptModel"] = receiptModel;
                        }
                    }
                }

                //if (HLConfigManager.Configurations.DOConfiguration.InvoiceInOrderConfrimation &&
                //    (null != ShoppingCart && ShoppingCart.OrderCategory != ServiceProvider.CatalogSvc.OrderCategoryType.ETO))
                //{
                //    hyperLinkInvoice.Visible = true;
                //}
                //else
                //{
                //    hyperLinkInvoice.Visible = false;
                //}
                //if (!(OrderProvider.IsEligibleReceiptModelSkus(ShoppingCart).Count() > 0))
                //{
                //    hyperLinkInvoice.Visible = false;
                //}
                if (HLConfigManager.Configurations.DOConfiguration.InvoiceInOrderConfrimation && ShoppingCart != null && string.IsNullOrWhiteSpace(OrderProvider.GetForeignPPVCountryCode(ShoppingCart.DistributorID, ShoppingCart.CountryCode)) &&
                    OrderProvider.IsEligibleReceiptModelSkus(ShoppingCart).Any() &&
                    ShoppingCart.OrderCategory == ServiceProvider.CatalogSvc.OrderCategoryType.RSO)
                {
                    hyperLinkInvoice.Visible = true;
                }
                ClearShoppingCartModuleCache();
                if (IsChina)
                {
                    var ordNumQS = string.Empty;
                    if (ShouldLoadOrderFromSerializedData)
                    {
                        ordNumQS = Request.QueryString["OrderNumber"];
                    }
                    else
                    {
                        ordNumQS = Request.QueryString["OrderId"];
                    }
                    if (!string.IsNullOrEmpty(ordNumQS))
                    {
                        SessionLessInfoManager.Instance.LoadOrderAcknowledgement(SessionInfo, ordNumQS, this.Locale, this.DistributorID);
                    }
                }

                if (!IsPostBack && ShoppingCart != null && ShoppingCart.Totals == null)
                {
                    SessionInfo.UseHMSCalc = HLConfigManager.Configurations.CheckoutConfiguration.UseHMSCalc;
                    ShoppingCart.Calculate();
                }
                (Master as OrderingMaster).SetPageHeader(GetLocalResourceObject("PageHeaderProducts").ToString());
                ContinueShopping.Text = GetLocalResourceObject("ProductCatalogReturn").ToString();
                if (null != ShoppingCart && !string.IsNullOrEmpty(ShoppingCart.EmailAddress))
                {
                    PrimaryEmail = ShoppingCart.EmailAddress;
                }
                if (null != ShoppingCart && ShoppingCart.OrderCategory == ServiceProvider.CatalogSvc.OrderCategoryType.ETO)
                {
                    (Master as OrderingMaster).SetPageHeader(GetLocalResourceObject("PageHeaderEvents").ToString());
                    hdnOrderType.Value       = "ETO";
                    ContinueShopping.Text    = GetLocalResourceObject("EventTicketsReturn").ToString();
                    lnkCreateInvoice.Visible = false;
                }

                //SessionInfo currentSession = SessionInfo.GetSessionInfo(DistributorID, Locale);

                if (SessionInfo != null)
                {
                    var ordernumber = string.Empty;
                    if (!String.IsNullOrEmpty(SessionInfo.OrderNumber))
                    {
                        ordernumber = SessionInfo.OrderNumber;
                    }
                    else if (SessionInfo.SessionLessInfo != null)
                    {
                        ordernumber = SessionInfo.SessionLessInfo.OrderNumber;
                    }

                    if (!string.IsNullOrEmpty(ordernumber))
                    {
                        if (HLConfigManager.Configurations.CheckoutConfiguration.DisplayTransactionTime)
                        {
                            lblTransactiontime.Text = DateUtils.GetCurrentLocalTime(CountryCode).ToString();
                        }
                        lblOrderNumber.Text = getOrderNumber(ordernumber, CountryCode);
                        OrderNumber         = lblOrderNumber.Text;
                        if (ShoppingCart.CustomerOrderDetail != null)
                        {
                            ContinueShopping.Text = GetLocalResourceObject("ReturnToCustomerOrders").ToString();
                            hdnOrderType.Value    = "CustomerOrder";
                            var CountryCO2DO = Settings.GetRequiredAppSetting("CountryCO2DO", string.Empty).Split(',');
                            if (CountryCO2DO.Contains(ShoppingCart.CountryCode))
                            {
                                DisplayInvoiceOptions = false;
                            }
                        }
                        else
                        {
                            DisplayInvoiceOptions = true;
                        }
                    }
                }

                if (HLConfigManager.Configurations.CheckoutConfiguration.FraudControlEnabled && SessionInfo.OrderStatus == SubmitOrderStatus.OrderSubmittedPending)
                {
                    trFControl.Visible = true;
                }

                if (SessionInfo.OrderStatus == SubmitOrderStatus.OrderSubmittedInReview)
                {
                    trFControl.Visible      = true;
                    lblFControlMessage.Text = PlatformResources.GetGlobalResourceString("ErrorMessage", "KountReviewOrder");
                }

                if (ShoppingCart.HoldCheckoutOrder &&
                    ShoppingCart.DeliveryInfo != null && ShoppingCart.DeliveryInfo.Option == ServiceProvider.ShippingSvc.DeliveryOptionType.Pickup)
                {
                    trMPCFraud.Visible = true;
                }

                if (SessionInfo.OrderStatus == SubmitOrderStatus.OrderSubmittedProcessing)
                {
                    trPendingOrder.Visible = true;
                    if (HLConfigManager.Configurations.PaymentsConfiguration.PendingOrderhascontent)
                    {
                        PendingNotification.Visible = true;
                        lblPendingOrder.Visible     = false;
                    }
                    else
                    {
                        PendingNotification.Visible = false;
                        lblPendingOrder.Visible     = true;
                    }
                    trPendingOrderLink.Visible = true;
                    trConfirm.Visible          = false;
                }
                if (HLConfigManager.Configurations.DOConfiguration.IsChina)
                {
                    //if (SessionInfo.OrderStatus == SubmitOrderStatus.OrderSubmitted)
                    //{
                    bool QRCodeDisable = Settings.GetRequiredAppSetting("QRCodeDisable", true);
                    if (!QRCodeDisable)
                    {
                        var cartitems = SessionInfo.ShoppingCart.CartItems;
                        if (cartitems.Count == 0 || string.IsNullOrEmpty(SessionInfo.OrderNumber))
                        {
                            cartitems = SessionInfo.SessionLessInfo.ShoppingCart.CartItems;
                        }
                        foreach (var sku in cartitems)
                        {
                            var skU = Providers.CatalogProvider.GetCatalogItem(sku.SKU, "CN");
                            if (skU.ProductCategory == "ETO")
                            {
                                var Tickets = new MyHerbalife3.Ordering.Providers.MyHLShoppingCart.Ticket
                                {
                                    quantity  = sku.Quantity,
                                    ticketSKU = sku.SKU,
                                };
                                TicketDetails.Add(Tickets);
                            }
                            else
                            {
                                btnQrCodeDownload.Visible = false;
                            }
                        }
                        if (TicketDetails.Count > 0)
                        {
                            string QRCodeUrl = MyHerbalife3.Ordering.Providers.China.OrderProvider.DownloadQRCode(DistributorID, SessionInfo.OrderNumber, DateTime.Now.ToString(), Locale, TicketDetails);

                            if (!string.IsNullOrEmpty(QRCodeUrl))
                            {
                                ViewState["QrCode"] = QRCodeUrl;
                            }
                            else
                            {
                                btnQrCodeDownload.Visible = false;
                            }
                        }
                        else
                        {
                            btnQrCodeDownload.Visible = false;
                        }
                    }
                    else
                    {
                        btnQrCodeDownload.Visible = false;
                    }
                }
                else
                {
                    btnQrCodeDownload.Visible = false;
                }
                //}
                //else
                //{
                //  btnQrCodeDownload.Visible = false;
                //}

                LoadControls();
                if (HLConfigManager.Configurations.DOConfiguration.IsChina && !String.IsNullOrEmpty(SessionInfo.OrderNumber))
                {
                    var response = Providers.China.OrderProvider.GetPBPPaymentServiceDetail(DistributorID, SessionInfo.OrderNumber);
                    if (response != null && response.Status == ServiceProvider.OrderChinaSvc.ServiceResponseStatusType.Success)
                    {
                        if (response.PaymentStatus == "CNPending")
                        {
                            lblPBPMessageTitle.Text  = GetLocalResourceObject("lblPBPMessageTitle").ToString();
                            lblPBPOrderMessage.Text  = string.Format(GetLocalResourceObject("PBPOrderSubmittedResource").ToString(), SessionInfo.OrderNumber);
                            PBPDynamicButtonYes.Text = GetLocalResourceString("OK.Text");
                            PBPOrderPopupExtender.Show();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LoggerHelper.Error(string.Format("Error in Confirm.aspx.cs : Page_Load {0} \n StackTrace {1}", ex.Message, ex.StackTrace));
                closeCart();
            }
            if (string.IsNullOrEmpty(lblOrderNumber.Text))
            {
                OrderNumber             =
                    lblOrderNumber.Text =
                        string.IsNullOrEmpty(Request.QueryString["OrderNumber"])
                        ? string.Empty
                        : Request.QueryString["OrderNumber"];
            }

            if (HLConfigManager.Configurations.CheckoutConfiguration.DisplayTellYourStory)
            {
                (Master as OrderingMaster).gdoNavMidCSS("gdo-nav-mid col-md-12 gdo-nav-mid-confirm-tellstory");
            }
            else
            {
                (Master as OrderingMaster).gdoNavMidCSS("gdo-nav-mid col-md-12 gdo-nav-mid-confirm");
            }

            if (HLConfigManager.Configurations.CheckoutConfiguration.DisplayTellYourStory)
            {
                (Master as OrderingMaster).gdoNavRightCSS("gdo-nav-right col-sm-3 confirm");
            }

            var invoiceEnabledLocales = Settings.GetRequiredAppSetting("InvoiceEnabledLocales", string.Empty);

            if (!string.IsNullOrEmpty(invoiceEnabledLocales) && invoiceEnabledLocales.Contains(Locale))
            {
                dvCreateInvoice.Visible = true;
            }

            if (HLConfigManager.Configurations.PaymentsConfiguration.SendConfirmationEmail)
            {
                try
                {
                    var cmmSVCP = new CommunicationSvcProvider();
                    cmmSVCP.SendEmailConfirmation(OrderNumber, "OrderSubmitted");
                }
                catch (Exception ex)
                {
                    LoggerHelper.Error(string.Format("Error sending confirmation email, order:{0} : {1}", OrderNumber, ex.Message));
                }
            }

            // HAP Updates
            if (HLConfigManager.Configurations.DOConfiguration.AllowDO && SessionInfo.IsHAPMode)
            {
                trSalesConfirm.Visible  = false;
                lblSuccess.Text         = GetLocalResourceObject("lblHapOrderPlacedSuccessResource.Text").ToString();
                lblOrderStatus.Text     = GetLocalResourceObject("lblOrderStatusResource2.Text").ToString();
                dvCreateInvoice.Visible = false;
                dvHapOrderPage.Visible  = true;
                (Master as OrderingMaster).SetRightPanelStyle("display", "none");
            }

            if (HLConfigManager.Configurations.DOConfiguration.IsResponsive && (Master as OrderingMaster).IsMobile())
            {
                (Master as OrderingMaster).divLeftVisibility = true;
            }
            else
            {
                (Master as OrderingMaster).divLeftVisibility = false;
            }

            if (!IsPostBack && HLConfigManager.Configurations.DOConfiguration.AddScriptsForRecommendations && SessionInfo != null &&
                SessionInfo.ShoppingCart != null && ShoppingCart != null && ShoppingCart.Totals != null)
            {
                // Adobe Target - Confirmation Page
                OrderTotals_V01 totals = ShoppingCart.Totals as OrderTotals_V01;
                totalOrder  = totals.ItemsTotal;
                orderNumber = lblOrderNumber.Text;
                skuList     = AdobeTarget_ConvertCartItemsToString(SessionInfo.ShoppingCart.ShoppingCartItems);

                // Salesforce - Confirmation Page
                cartItems = Salesforce_ConvertCartItemsToString(SessionInfo.ShoppingCart.ShoppingCartItems);
            }
        }