private void BindPaymentMethod()
        {
            CheckPanel.Visible      = false;
            CreditCardPanel.Visible = false;
            SaveButton.Visible      = false;
            PaymentMethod method = GetSelectedMethod();

            if (method != null)
            {
                switch (method.PaymentInstrumentType)
                {
                case PaymentInstrumentType.AmericanExpress:
                    ShowCreditCardForm(method.Name, 4, false);
                    break;

                case PaymentInstrumentType.Discover:
                case PaymentInstrumentType.JCB:
                case PaymentInstrumentType.MasterCard:
                case PaymentInstrumentType.Visa:
                case PaymentInstrumentType.Maestro:
                case PaymentInstrumentType.SwitchSolo:
                case PaymentInstrumentType.VisaDebit:
                    ShowCreditCardForm(method.Name, 3, method.IsIntlDebitCard());
                    break;

                case PaymentInstrumentType.Check:
                    ShowCheckForm();
                    break;
                }
            }
        }
        private bool CustomValidation()
        {
            bool hasErrors = false;

            //if intl instructions are visible, we must validate additional rules
            if (trIntlInstructions.Visible)
            {
                PaymentMethod m = PaymentMethodDataSource.Load(AlwaysConvert.ToInt(CardType.SelectedValue));
                if (m != null)
                {
                    if (m.IsIntlDebitCard())
                    {
                        // INTERNATIONAL DEBIT CARD, ISSUE NUMBER OR START DATE REQUIRED
                        bool invalidIssueNumber = (!Regex.IsMatch(IssueNumber.Text, "\\d{1,2}"));
                        bool invalidStartDate = ((StartDateMonth.SelectedIndex == 0) || (StartDateYear.SelectedIndex == 0));
                        if (invalidIssueNumber && invalidStartDate)
                        {
                            IntlDebitValidator1.IsValid = false;
                            IntlDebitValidator2.IsValid = false;
                            hasErrors = true;
                        }
                        // CHECK START DATE IS IN PAST
                        int selYear = AlwaysConvert.ToInt(StartDateYear.SelectedValue);
                        int curYear = DateTime.Now.Year;
                        if (selYear > curYear)
                        {
                            StartDateValidator1.IsValid = false;
                            hasErrors = true;
                        }
                        else if (selYear == curYear)
                        {
                            int selMonth = AlwaysConvert.ToInt(StartDateMonth.SelectedValue);
                            int curMonth = DateTime.Now.Month;
                            if (selMonth > curMonth)
                            {
                                StartDateValidator1.IsValid = false;
                                hasErrors = true;
                            }
                        }
                    }
                    else
                    {
                        // CREDIT CARD, CVV IS REQUIRED
                        if (!Regex.IsMatch(SecurityCode.Text, "\\d{3,4}"))
                        {
                            SecurityCodeValidator2.IsValid = false;
                            hasErrors = true;
                        }
                    }
                }
            }

            return !hasErrors;
        }
        private bool CustomValidation()
        {
            bool hasErrors = false;

            if (trAmount.Visible)
            {
                decimal amount    = AlwaysConvert.ToDecimal(Request.Form[Amount.UniqueID]);
                decimal maxAmount = AlwaysConvert.ToDecimal(this.MaxPaymentAmount.LSCurrencyFormat("lc"));
                if (amount <= 0 || (maxAmount > 0 && amount > maxAmount))
                {
                    CustomValidator invalidAmount = new CustomValidator();
                    invalidAmount.ValidationGroup = this.ValidationGroup;
                    invalidAmount.Text            = "*";
                    invalidAmount.ErrorMessage    = "Invalid amount.  Payment must be greater than zero and no more than " + MaxPaymentAmount.LSCurrencyFormat("lc") + ".";
                    invalidAmount.IsValid         = false;
                    phAmount.Controls.Add(invalidAmount);
                    hasErrors = true;
                }
            }

            //if intl instructions are visible, we must validate additional rules
            if (trIntlInstructions.Visible)
            {
                PaymentMethod m = PaymentMethodDataSource.Load(AlwaysConvert.ToInt(CardType.SelectedValue));
                if (m != null)
                {
                    if (m.IsIntlDebitCard())
                    {
                        // INTERNATIONAL DEBIT CARD, ISSUE NUMBER OR START DATE REQUIRED
                        bool invalidIssueNumber = (!Regex.IsMatch(IssueNumber.Text, "\\d{1,2}"));
                        bool invalidStartDate   = ((StartDateMonth.SelectedIndex == 0) || (StartDateYear.SelectedIndex == 0));
                        if (invalidIssueNumber && invalidStartDate)
                        {
                            IntlDebitValidator1.IsValid = false;
                            IntlDebitValidator2.IsValid = false;
                            hasErrors = true;
                        }
                        // CHECK START DATE IS IN PAST
                        int selYear = AlwaysConvert.ToInt(StartDateYear.SelectedValue);
                        int curYear = DateTime.Now.Year;
                        if (selYear > curYear)
                        {
                            StartDateValidator1.IsValid = false;
                            hasErrors = true;
                        }
                        else if (selYear == curYear)
                        {
                            int selMonth = AlwaysConvert.ToInt(StartDateMonth.SelectedValue);
                            int curMonth = DateTime.Now.Month;
                            if (selMonth > curMonth)
                            {
                                StartDateValidator1.IsValid = false;
                                hasErrors = true;
                            }
                        }
                    }
                    else
                    {
                        // CREDIT CARD, CVV IS REQUIRED
                        if (!Regex.IsMatch(SecurityCode.Text, "\\d{3,4}"))
                        {
                            SecurityCodeValidator2.IsValid = false;
                            hasErrors = true;
                        }
                    }
                }
            }

            return(!hasErrors);
        }