private void CreateChildControlsTree()
        {
            PaymentMethod paymentMethod = null;

            if (NopContext.Current.User != null)
            {
                PaymentMethodCollection paymentMethods = PaymentMethodManager.GetAllPaymentMethods();
                if (paymentMethods.Count == 1)
                {
                    paymentMethod = paymentMethods[0];
                }
                else
                {
                    paymentMethod = NopContext.Current.User.LastPaymentMethod;
                }
            }
            if (paymentMethod != null)
            {
                Control child = null;
                child = base.LoadControl(paymentMethod.UserTemplatePath);
                this.PaymentInfoPlaceHolder.Controls.Add(child);
            }
            else
            {
                Response.Redirect("~/CheckoutPaymentMethod.aspx");
            }
        }
예제 #2
0
        protected void BindGrid()
        {
            CountryCollection       countryCollection       = CountryManager.GetAllCountries();
            PaymentMethodCollection paymentMethodCollection = PaymentMethodManager.GetAllPaymentMethods(null, false);

            if (countryCollection.Count == 0)
            {
                lblMessage.Text = GetLocaleResourceString("Admin.PaymentMethodsFilterControl.NoCountryDefined");
            }
            if (paymentMethodCollection.Count == 0)
            {
                lblMessage.Text = GetLocaleResourceString("Admin.PaymentMethodsFilterControl.NoPaymentMethodDefined");
            }

            List <PaymentMethodCountryMappingHelperClass> dt = new List <PaymentMethodCountryMappingHelperClass>();

            foreach (Country country in countryCollection)
            {
                PaymentMethodCountryMappingHelperClass map1 = new PaymentMethodCountryMappingHelperClass();
                map1.CountryId   = country.CountryId;
                map1.CountryName = country.Name;
                map1.Restrict    = new Dictionary <int, bool>();

                foreach (PaymentMethod paymentMethod in paymentMethodCollection)
                {
                    map1.Restrict.Add(paymentMethod.PaymentMethodId, PaymentMethodManager.DoesPaymentMethodCountryMappingExist(paymentMethod.PaymentMethodId, country.CountryId));
                }

                dt.Add(map1);
            }

            gvPaymentMethodCountryMap.DataSource = dt;
            gvPaymentMethodCountryMap.DataBind();
        }
예제 #3
0
        public void SaveInfo()
        {
            if (Page.IsValid)
            {
                try
                {
                    PaymentMethodCollection paymentMethodCollection = PaymentMethodManager.GetAllPaymentMethods(null, false);
                    foreach (GridViewRow row in gvPaymentMethodCountryMap.Rows)
                    {
                        foreach (PaymentMethod paymentMethod in paymentMethodCollection)
                        {
                            CheckBox    cbRestrict  = row.FindControl(String.Format("cbRestrict_{0}", paymentMethod.PaymentMethodId)) as CheckBox;
                            HiddenField hfCountryId = row.FindControl(String.Format("hfCountryId_{0}", paymentMethod.PaymentMethodId)) as HiddenField;

                            int countryId = Int32.Parse(hfCountryId.Value);

                            if (cbRestrict.Checked)
                            {
                                PaymentMethodManager.CreatePaymentMethodCountryMapping(paymentMethod.PaymentMethodId, countryId);
                            }
                            else
                            {
                                PaymentMethodManager.DeletePaymentMethodCountryMapping(paymentMethod.PaymentMethodId, countryId);
                            }
                        }
                    }

                    Response.Redirect("PaymentMethods.aspx");
                }
                catch (Exception exc)
                {
                    ProcessException(exc);
                }
            }
        }
예제 #4
0
        public void SaveInfo()
        {
            var paymentMethods = PaymentMethodManager.GetAllPaymentMethods(null, false);

            foreach (GridViewRow row in gvPaymentMethodCountryMap.Rows)
            {
                foreach (PaymentMethod paymentMethod in paymentMethods)
                {
                    CheckBox    cbRestrict  = row.FindControl(String.Format("cbRestrict_{0}", paymentMethod.PaymentMethodId)) as CheckBox;
                    HiddenField hfCountryId = row.FindControl(String.Format("hfCountryId_{0}", paymentMethod.PaymentMethodId)) as HiddenField;
                    if (cbRestrict == null || hfCountryId == null)
                    {
                        return;
                    }

                    int countryId = Int32.Parse(hfCountryId.Value);

                    if (cbRestrict.Checked)
                    {
                        PaymentMethodManager.CreatePaymentMethodCountryMapping(paymentMethod.PaymentMethodId, countryId);
                    }
                    else
                    {
                        if (PaymentMethodManager.DoesPaymentMethodCountryMappingExist(paymentMethod.PaymentMethodId, countryId))
                        {
                            PaymentMethodManager.DeletePaymentMethodCountryMapping(paymentMethod.PaymentMethodId, countryId);
                        }
                    }
                }
            }
        }
예제 #5
0
        protected void BuildColumnsDynamically()
        {
            gvPaymentMethodCountryMap.Columns.Clear();

            TemplateField tfAction = new TemplateField();

            tfAction.ItemTemplate   = new NopGridViewCustomTemplate(DataControlRowType.DataRow, "CountryName", "String");
            tfAction.HeaderTemplate = new NopGridViewCustomTemplate(DataControlRowType.Header, GetLocaleResourceString("Admin.PaymentMethodsFilterControl.Grid.CountryName"), "String");
            gvPaymentMethodCountryMap.Columns.Add(tfAction);

            StringBuilder scriptBuilder = new StringBuilder();

            scriptBuilder.Append("$(document).ready(function() {");
            foreach (PaymentMethod paymentMethod in PaymentMethodManager.GetAllPaymentMethods(null, false))
            {
                TemplateField tf = new TemplateField();
                tf.ItemTemplate   = new NopGridViewCustomTemplate(DataControlRowType.DataRow, "Restrict", "Checkbox", paymentMethod.PaymentMethodId);
                tf.HeaderTemplate = new NopGridViewCustomTemplate(DataControlRowType.Header, paymentMethod.Name, "String", paymentMethod.PaymentMethodId);
                gvPaymentMethodCountryMap.Columns.Add(tf);

                scriptBuilder.AppendFormat("$('.cbSelectAll_{0} input').bind('click', function() {{ $('.cbRestrict_{0} input').each(function() {{ this.checked = $('.cbSelectAll_{0} input')[0].checked; }}) }});", paymentMethod.PaymentMethodId);
                //scriptBuilder.AppendFormat("$('.cbRestrict_{0} input').bind('click', function() {{ if (this.checked == false) $('.cbSelectAll_{0} input')[0].checked = false; }});", paymentMethod.PaymentMethodId);
            }
            scriptBuilder.Append("});");

            string script = scriptBuilder.ToString();

            Page.ClientScript.RegisterClientScriptBlock(GetType(), script.GetHashCode().ToString(), script, true);
        }
예제 #6
0
        void BindGrid()
        {
            PaymentMethodCollection paymentMethodCollection = PaymentMethodManager.GetAllPaymentMethods();

            gvPaymentMethods.DataSource = paymentMethodCollection;
            gvPaymentMethods.DataBind();
        }
예제 #7
0
        void BindGrid()
        {
            var paymentMethods = PaymentMethodManager.GetAllPaymentMethods();

            gvPaymentMethods.DataSource = paymentMethods;
            gvPaymentMethods.DataBind();
        }
예제 #8
0
        protected void BuildColumnsDynamically()
        {
            gvPaymentMethodCountryMap.Columns.Clear();

            TemplateField tfAction = new TemplateField();

            tfAction.ItemTemplate   = new NopGridViewCustomTemplate(DataControlRowType.DataRow, "CountryName", "String");
            tfAction.HeaderTemplate = new NopGridViewCustomTemplate(DataControlRowType.Header, GetLocaleResourceString("Admin.PaymentMethodsFilterControl.Grid.CountryName"), "String");
            gvPaymentMethodCountryMap.Columns.Add(tfAction);

            PaymentMethodCollection paymentMethodCollection = PaymentMethodManager.GetAllPaymentMethods(null, false);

            foreach (PaymentMethod paymentMethod in paymentMethodCollection)
            {
                TemplateField tf = new TemplateField();
                tf.ItemTemplate   = new NopGridViewCustomTemplate(DataControlRowType.DataRow, "Restrict", "Checkbox", paymentMethod.PaymentMethodId);
                tf.HeaderTemplate = new NopGridViewCustomTemplate(DataControlRowType.Header, paymentMethod.Name, "String");
                gvPaymentMethodCountryMap.Columns.Add(tf);
            }
        }
예제 #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if ((NopContext.Current.User == null) || (NopContext.Current.User.IsGuest && !CustomerManager.AnonymousCheckoutAllowed))
            {
                string loginURL = CommonHelper.GetLoginPageURL(true);
                Response.Redirect(loginURL);
            }

            Cart = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart);
            IndividualOrderCollection indOrders = IndividualOrderManager.GetCurrentUserIndividualOrders();

            if (Cart.Count == 0 && indOrders.Count == 0)
            {
                Response.Redirect("~/ShoppingCart.aspx");
            }

            if (!Page.IsPostBack)
            {
                PaymentMethodCollection paymentMethods             = PaymentMethodManager.GetAllPaymentMethods();
                PaymentMethod           paypalExpressPaymentMethod = null;
                foreach (PaymentMethod pm in paymentMethods)
                {
                    if (pm.SystemKeyword == "PayPalExpress")
                    {
                        paypalExpressPaymentMethod = pm;
                    }
                }
                PaymentMethod googleCheckoutPaymentMethod = null;
                foreach (PaymentMethod pm in paymentMethods)
                {
                    if (pm.SystemKeyword == "GoogleCheckout")
                    {
                        googleCheckoutPaymentMethod = pm;
                    }
                }

                bool hasButtonMethods = false;
                if (paypalExpressPaymentMethod != null && paypalExpressPaymentMethod.IsActive)
                {
                    hasButtonMethods = true;
                }

                PaymentMethodCollection boundPaymentMethods = new PaymentMethodCollection();
                foreach (PaymentMethod pm in paymentMethods)
                {
                    if (pm != paypalExpressPaymentMethod && pm != googleCheckoutPaymentMethod)
                    {
                        boundPaymentMethods.Add(pm);
                    }
                }

                if (boundPaymentMethods.Count == 0)
                {
                    if (hasButtonMethods)
                    {
                        phSelectPaymentMethod.Visible = false;
                        phNoPaymentMethods.Visible    = false;
                    }
                    else
                    {
                        phSelectPaymentMethod.Visible = false;
                        phNoPaymentMethods.Visible    = true;
                    }
                }
                else if (boundPaymentMethods.Count == 1)
                {
                    if (hasButtonMethods)
                    {
                        phSelectPaymentMethod.Visible = true;
                        phNoPaymentMethods.Visible    = false;
                        dlPaymentMethod.DataSource    = boundPaymentMethods;
                        dlPaymentMethod.DataBind();
                    }
                    else
                    {
                        phSelectPaymentMethod.Visible = false;
                        phNoPaymentMethods.Visible    = false;
                        NopContext.Current.User       = CustomerManager.SetLastPaymentMethodID(NopContext.Current.User.CustomerID, paymentMethods[0].PaymentMethodID);
                        Response.Redirect("~/CheckoutConfirm.aspx");
                    }
                }
                else
                {
                    phSelectPaymentMethod.Visible = true;
                    phNoPaymentMethods.Visible    = false;
                    dlPaymentMethod.DataSource    = boundPaymentMethods;
                    dlPaymentMethod.DataBind();
                }
            }

            divAdditionalPaymentInfo.Visible = Request["OrderId"] != null;
        }
예제 #10
0
        public void BindData()
        {
            //reward points
            if (OrderManager.RewardPointsEnabled && !this.Cart.IsRecurring)
            {
                int     rewardPointsBalance    = NopContext.Current.User.RewardPointsBalance;
                decimal rewardPointsAmountBase = OrderManager.ConvertRewardPointsToAmount(rewardPointsBalance);
                decimal rewardPointsAmount     = CurrencyManager.ConvertCurrency(rewardPointsAmountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
                if (rewardPointsAmount > decimal.Zero)
                {
                    string rewardPointsAmountStr = PriceHelper.FormatPrice(rewardPointsAmount, true, false);
                    cbUseRewardPoints.Text  = GetLocaleResourceString("Checkout.UseRewardPoints", rewardPointsBalance, rewardPointsAmountStr);
                    pnlRewardPoints.Visible = true;
                }
                else
                {
                    pnlRewardPoints.Visible = false;
                }
            }
            else
            {
                pnlRewardPoints.Visible = false;
            }

            //payment methods
            int?filterByCountryId = null;

            if (NopContext.Current.User.BillingAddress != null && NopContext.Current.User.BillingAddress.Country != null)
            {
                filterByCountryId = NopContext.Current.User.BillingAddress.CountryId;
            }

            bool hasButtonMethods    = false;
            var  boundPaymentMethods = new PaymentMethodCollection();
            var  paymentMethods      = PaymentMethodManager.GetAllPaymentMethods(filterByCountryId);

            foreach (var pm in paymentMethods)
            {
                switch (pm.PaymentMethodType)
                {
                case PaymentMethodTypeEnum.Unknown:
                case PaymentMethodTypeEnum.Standard:
                {
                    if (!Cart.IsRecurring || PaymentManager.SupportRecurringPayments(pm.PaymentMethodId) != RecurringPaymentTypeEnum.NotSupported)
                    {
                        boundPaymentMethods.Add(pm);
                    }
                }
                break;

                case PaymentMethodTypeEnum.Button:
                {
                    //PayPal Express is placed here as button
                    if (pm.SystemKeyword == "PayPalExpress")
                    {
                        if (!Cart.IsRecurring || PaymentManager.SupportRecurringPayments(pm.PaymentMethodId) != RecurringPaymentTypeEnum.NotSupported)
                        {
                            hasButtonMethods = true;
                        }
                    }
                }
                break;

                default:
                    break;
                }
            }

            if (boundPaymentMethods.Count == 0)
            {
                if (hasButtonMethods)
                {
                    phSelectPaymentMethod.Visible  = false;
                    pnlPaymentMethodsError.Visible = false;

                    //no reward points in this case
                    pnlRewardPoints.Visible = false;
                }
                else
                {
                    phSelectPaymentMethod.Visible  = false;
                    pnlPaymentMethodsError.Visible = true;
                    lPaymentMethodsError.Text      = GetLocaleResourceString("Checkout.NoPaymentMethods");

                    //no reward points in this case
                    pnlRewardPoints.Visible = false;
                }
            }
            else if (boundPaymentMethods.Count == 1)
            {
                phSelectPaymentMethod.Visible  = true;
                pnlPaymentMethodsError.Visible = false;
                dlPaymentMethod.DataSource     = boundPaymentMethods;
                dlPaymentMethod.DataBind();
            }
            else
            {
                phSelectPaymentMethod.Visible  = true;
                pnlPaymentMethodsError.Visible = false;
                dlPaymentMethod.DataSource     = boundPaymentMethods;
                dlPaymentMethod.DataBind();
            }
        }