Beispiel #1
0
        private List <RuleViolation> ValidateCreditCard(CheckoutViewModel model)
        {
            List <RuleViolation> violations = new List <RuleViolation>();

            if ((!MerchantTribe.Payment.CardValidator.IsCardNumberValid(model.PaymentViewModel.DataCreditCard.CardNumber)))
            {
                violations.Add(new RuleViolation("Credit Card Number", "", "Please enter a valid credit card number", "cccardnumber"));
            }
            MerchantTribe.Payment.CardType cardTypeCheck = MerchantTribe.Payment.CardValidator.GetCardTypeFromNumber(model.PaymentViewModel.DataCreditCard.CardNumber);
            List <CardType> acceptedCards = MTApp.CurrentStore.Settings.PaymentAcceptedCards;

            if (!acceptedCards.Contains(cardTypeCheck))
            {
                violations.Add(new RuleViolation("Card Type Not Accepted", "", "That card type is not accepted by this store. Please use a different card.", "cccardnumber"));
            }

            ValidationHelper.RequiredMinimum(1, "Card Expiration Year", model.PaymentViewModel.DataCreditCard.ExpirationYear, violations, "ccexpyear");
            ValidationHelper.RequiredMinimum(1, "Card Expiration Month", model.PaymentViewModel.DataCreditCard.ExpirationMonth, violations, "ccexpmonth");
            ValidationHelper.Required("Name on Card", model.PaymentViewModel.DataCreditCard.CardHolderName, violations, "cccardholder");

            if (MTApp.CurrentStore.Settings.PaymentCreditCardRequireCVV == true)
            {
                ValidationHelper.RequiredMinimum(3, "Card Security Code", model.PaymentViewModel.DataCreditCard.SecurityCode.Length, violations, "ccsecuritycode");
            }

            return(violations);
        }
        public System.Collections.Generic.List <MerchantTribe.Web.Validation.RuleViolation> GetRuleViolations()
        {
            List <MerchantTribe.Web.Validation.RuleViolation> violations = new List <MerchantTribe.Web.Validation.RuleViolation>();

            // Card Number
            if (CardNumber.StartsWith("****-****-****-"))
            {
            }
            // Ignore for now
            //If paymentId.Trim.Length > 0 Then
            //End If
            //For i As Integer = 0 To thisOrder.Payments.Length - 1
            //    With thisOrder.Payments(i)
            //        If .PaymentType = BVSoftware.BVC.Interfaces.PaymentRecordType.Information Then
            //            If .PaymentMethod = BVSoftware.BVC.Interfaces.PaymentMethod.CreditCard Then
            //                testCardNumber = .CreditCardNumber
            //            End If
            //        End If
            //    End With
            //Next
            else
            {
                CardNumber = MerchantTribe.Payment.CardValidator.CleanCardNumber(CardNumber);
            }

            if ((!MerchantTribe.Payment.CardValidator.IsCardNumberValid(CardNumber)))
            {
                violations.Add(new RuleViolation("Credit Card Number", "", "Please enter a valid credit card number", "cccardnumber"));
            }


            MerchantTribe.Payment.CardType cardTypeCheck = MerchantTribe.Payment.CardValidator.GetCardTypeFromNumber(this.CardNumber);
            List <CardType> acceptedCards = MyPage.MTApp.CurrentStore.Settings.PaymentAcceptedCards;

            if (!acceptedCards.Contains(cardTypeCheck))
            {
                violations.Add(new RuleViolation("Card Type Not Accepted", "", "That card type is not accepted by this store. Please use a different card.", "cccardnumber"));
            }

            ValidationHelper.RequiredMinimum(1, "Card Expiration Year", ExpirationYear, violations, "ccexpyear");
            ValidationHelper.RequiredMinimum(1, "Card Expiration Month", ExpirationMonth, violations, "ccexpmonth");
            ValidationHelper.Required("Name on Card", CardHolderName, violations, "cccardholder");

            if (MyPage.MTApp.CurrentStore.Settings.PaymentCreditCardRequireCVV == true)
            {
                ValidationHelper.RequiredMinimum(3, "Card Security Code", SecurityCode.Length, violations, "ccsecuritycode");
            }

            SetErrorCss(violations);

            return(violations);
        }