Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            trAmount.Visible = this.AllowAmountEntry;
            DisableAutoComplete();

            // PREVENT DOUBLE POSTING
            StringBuilder submitScript = new StringBuilder();

            submitScript.Append("if(document.getElementById('" + FormIsSubmitted.ClientID + "').value==1 || Page_ClientValidate('CreditCard') == false) { return false; } ");
            submitScript.Append("this.disabled = true; ");
            submitScript.Append("document.getElementById('" + FormIsSubmitted.ClientID + "').value=1;");
            //GetPostBackEventReference obtains a reference to a client-side script function that causes the server to post back to the page.
            submitScript.Append(Page.ClientScript.GetPostBackEventReference(CreditCardButton, string.Empty));
            submitScript.Append(";");
            submitScript.Append("return false;");
            this.CreditCardButton.Attributes.Add("onclick", submitScript.ToString());

            if (Page.IsPostBack)
            {
                // VALIDATE IF CORRECT PAYMENT METHOD TYPE IS SELECTED
                PaymentMethod paymentMethod = PaymentMethodDataSource.Load(AlwaysConvert.ToInt(CardType.SelectedValue));
                if (paymentMethod != null)
                {
                    // INITIALIZE SELECTED CARD TYPE FOR VALIDATION
                    PaymentInstrumentType paymentInstrumentType = paymentMethod.PaymentInstrumentType;
                    CardNumberValidator1.AcceptedCardType = paymentInstrumentType.ToString();
                }
            }
        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (AbleContext.Current.Store.Settings.EnablePaymentProfilesStorage)
            {
                if (!Page.IsPostBack && !_user.IsAnonymous)
                {
                    var profiles = _user.PaymentProfiles
                                   .Where(p => (!p.LastDayOfExpiry.HasValue || p.LastDayOfExpiry > LocaleHelper.LocalNow) &&
                                          PaymentGatewayDataSource.GetPaymentGatewayIdByClassId(p.GatewayIdentifier) > 0)
                                   .ToDictionary(p => p.Id, p => string.Format("{0} ending in {1}", p.InstrumentType, p.ReferenceNumber));

                    if (profiles.Count > 0)
                    {
                        CardPH.Visible     = false;
                        ProfilesPH.Visible = true;
                        profiles.Add(-1, "Add New Payment");
                        ProfilesList.Items.Clear();
                        foreach (var profile in profiles)
                        {
                            ProfilesList.Items.Add(new ListItem()
                            {
                                Text = profile.Value, Value = profile.Key.ToString()
                            });
                        }
                        ListItem item = ProfilesList.Items.FindByValue(_user.Settings.DefaultPaymentProfileId.ToString());
                        if (item != null)
                        {
                            item.Selected = true;
                        }
                    }
                    else
                    {
                        CardPH.Visible     = true;
                        ProfilesPH.Visible = false;
                    }
                }

                CardType.AutoPostBack = true;
            }

            // UPDATE MAX PAYMENT AMOUNT TO ORDER TOTAL IF NO VALUE IS SPECIFIED
            if (this.MaxPaymentAmount == 0)
            {
                this.MaxPaymentAmount = AbleContext.Current.User.Basket.Items.TotalPrice();
            }

            if (Page.IsPostBack)
            {
                // VALIDATE IF CORRECT PAYMENT METHOD TYPE IS SELECTED
                PaymentMethod paymentMethod = PaymentMethodDataSource.Load(AlwaysConvert.ToInt(CardType.SelectedValue));
                if (paymentMethod != null)
                {
                    // INITIALIZE SELECTED CARD TYPE FOR VALIDATION
                    PaymentInstrumentType paymentInstrumentType = paymentMethod.PaymentInstrumentType;
                    CardNumberValidator1.AcceptedCardType = paymentInstrumentType.ToString();
                }
            }
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                // LOAD INSTRUMENT SELECT BOX
                List <ListItem> tempItems = new List <ListItem>();
                foreach (object enumItem in Enum.GetValues(typeof(PaymentInstrumentType)))
                {
                    PaymentInstrumentType instrument = ((PaymentInstrumentType)enumItem);
                    switch (instrument)
                    {
                    case PaymentInstrumentType.Check:
                    case PaymentInstrumentType.Discover:
                    case PaymentInstrumentType.JCB:
                    case PaymentInstrumentType.Mail:
                    case PaymentInstrumentType.MasterCard:
                    case PaymentInstrumentType.PayPal:
                    case PaymentInstrumentType.Visa:
                    case PaymentInstrumentType.Amazon:
                        tempItems.Add(new ListItem(instrument.ToString(), ((short)instrument).ToString()));
                        break;

                    case PaymentInstrumentType.AmericanExpress:
                        tempItems.Add(new ListItem("American Express", ((short)instrument).ToString()));
                        break;

                    case PaymentInstrumentType.DinersClub:
                        if (ShowIntlPaymentMethods)
                        {
                            tempItems.Add(new ListItem("Diner's Club", ((short)instrument).ToString()));
                        }
                        break;

                    case PaymentInstrumentType.PhoneCall:
                        tempItems.Add(new ListItem("Phone Call", ((short)instrument).ToString()));
                        break;

                    case PaymentInstrumentType.SwitchSolo:
                        if (ShowIntlPaymentMethods)
                        {
                            tempItems.Add(new ListItem("Switch/Solo", ((short)instrument).ToString()));
                        }
                        break;

                    case PaymentInstrumentType.VisaDebit:
                        if (ShowIntlPaymentMethods)
                        {
                            tempItems.Add(new ListItem("Visa Debit (Delta/Electron)", ((short)instrument).ToString()));
                        }
                        break;

                    case PaymentInstrumentType.Maestro:
                        if (ShowIntlPaymentMethods)
                        {
                            tempItems.Add(new ListItem(instrument.ToString(), ((short)instrument).ToString()));
                        }
                        break;

                    case PaymentInstrumentType.PurchaseOrder:
                        tempItems.Add(new ListItem("Purchase Order", ((short)instrument).ToString()));
                        break;

                    case PaymentInstrumentType.CreditCard:
                        tempItems.Add(new ListItem("Credit Card", ((short)instrument).ToString()));
                        break;
                    }
                    tempItems.Sort(delegate(ListItem x, ListItem y) { return(x.Text.CompareTo(y.Text)); });
                    PaymentInstrumentList.Items.Clear();
                    PaymentInstrumentList.Items.Add(new ListItem(string.Empty));
                    PaymentInstrumentList.Items.AddRange(tempItems.ToArray());
                }
                // LOAD GATEWAY SELECT BOX
                GatewayList.Items.Add(new ListItem("", ""));
                foreach (PaymentGateway gateway in AbleContext.Current.Store.PaymentGateways)
                {
                    if (IsAssignableGateway(gateway))
                    {
                        GatewayList.Items.Add(new ListItem(gateway.Name, gateway.Id.ToString()));
                    }
                }
                //GROUP RESTRICTION
                UseGroupRestriction.SelectedIndex = 0;
                BindGroups();
            }

            // trAllowSubscriptionPayments.Visible = AbleContext.Current.Store.Settings.ROCreateNewOrdersEnabled;
            refStar.Visible   = !AbleContext.Current.Store.Settings.ROCreateNewOrdersEnabled;
            refStarTr.Visible = refStar.Visible;
        }
Esempio n. 4
0
        protected void BindPaymentInstrumentList(PaymentMethod _PaymentMethod)
        {
            PaymentInstrumentList.SelectedIndex = -1;
            PaymentInstrumentList.Items.Clear();
            // LOAD INSTRUMENT SELECT BOX
            List <ListItem> tempItems = new List <ListItem>();

            foreach (object enumItem in Enum.GetValues(typeof(PaymentInstrumentType)))
            {
                PaymentInstrumentType instrument = ((PaymentInstrumentType)enumItem);
                switch (instrument)
                {
                case PaymentInstrumentType.Check:
                case PaymentInstrumentType.Discover:
                case PaymentInstrumentType.JCB:
                case PaymentInstrumentType.Mail:
                case PaymentInstrumentType.MasterCard:
                case PaymentInstrumentType.PayPal:
                case PaymentInstrumentType.Visa:
                case PaymentInstrumentType.Amazon:
                    tempItems.Add(new ListItem(instrument.ToString(), ((short)instrument).ToString()));
                    break;

                case PaymentInstrumentType.AmericanExpress:
                    tempItems.Add(new ListItem("American Express", ((short)instrument).ToString()));
                    break;

                case PaymentInstrumentType.DinersClub:
                    if (ShowIntlPaymentMethods)
                    {
                        tempItems.Add(new ListItem("Diner's Club", ((short)instrument).ToString()));
                    }
                    break;

                case PaymentInstrumentType.PhoneCall:
                    tempItems.Add(new ListItem("Phone Call", ((short)instrument).ToString()));
                    break;

                case PaymentInstrumentType.SwitchSolo:
                    if (ShowIntlPaymentMethods)
                    {
                        tempItems.Add(new ListItem("Switch/Solo", ((short)instrument).ToString()));
                    }
                    break;

                case PaymentInstrumentType.VisaDebit:
                    if (ShowIntlPaymentMethods)
                    {
                        tempItems.Add(new ListItem("Visa Debit (Delta/Electron)", ((short)instrument).ToString()));
                    }
                    break;

                case PaymentInstrumentType.Maestro:
                    if (ShowIntlPaymentMethods)
                    {
                        tempItems.Add(new ListItem(instrument.ToString(), ((short)instrument).ToString()));
                    }
                    break;

                case PaymentInstrumentType.PurchaseOrder:
                    tempItems.Add(new ListItem("Purchase Order", ((short)instrument).ToString()));
                    break;

                case PaymentInstrumentType.CreditCard:
                    tempItems.Add(new ListItem("Credit Card", ((short)instrument).ToString()));
                    break;
                }
                tempItems.Sort(delegate(ListItem x, ListItem y) { return(x.Text.CompareTo(y.Text)); });
                PaymentInstrumentList.Items.Clear();
                PaymentInstrumentList.Items.Add(new ListItem(string.Empty));
                PaymentInstrumentList.Items.AddRange(tempItems.ToArray());
            }
            ListItem item = PaymentInstrumentList.Items.FindByValue(_PaymentMethod.PaymentInstrumentId.ToString());

            if (item != null)
            {
                PaymentInstrumentList.SelectedIndex = PaymentInstrumentList.Items.IndexOf(item);
            }
        }