From cbf07d1b88cc87e617fa615007a650f6683bcff9 Mon Sep 17 00:00:00 2001 From: wjames111 Date: Mon, 9 Dec 2024 17:20:43 -0500 Subject: [PATCH] Fixes error, validators are not defined. --- .../existingPaymentMethods.component.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/app/checkout/step-2/existingPaymentMethods/existingPaymentMethods.component.js b/src/app/checkout/step-2/existingPaymentMethods/existingPaymentMethods.component.js index 0883f5241..823346e05 100644 --- a/src/app/checkout/step-2/existingPaymentMethods/existingPaymentMethods.component.js +++ b/src/app/checkout/step-2/existingPaymentMethods/existingPaymentMethods.component.js @@ -59,20 +59,22 @@ class ExistingPaymentMethodsController { waitForFormInitialization () { const unregister = this.$scope.$watch('$ctrl.creditCardPaymentForm.securityCode', () => { if (this.creditCardPaymentForm && this.creditCardPaymentForm.securityCode) { - this.switchPayment() unregister() this.addCvvValidators() + this.switchPayment() } }) } addCvvValidators () { this.$scope.$watch('$ctrl.creditCardPaymentForm.securityCode.$viewValue', (number) => { - this.creditCardPaymentForm.securityCode.$validators.minLength = cruPayments.creditCard.cvv.validate.minLength - this.creditCardPaymentForm.securityCode.$validators.maxLength = cruPayments.creditCard.cvv.validate.maxLength + if (this.selectedPaymentMethod?.['card-type']) { + this.creditCardPaymentForm.securityCode.$validators.minLength = cruPayments.creditCard.cvv.validate.minLength + this.creditCardPaymentForm.securityCode.$validators.maxLength = cruPayments.creditCard.cvv.validate.maxLength - this.enableContinue({ $event: cruPayments.creditCard.cvv.validate.minLength(number) && cruPayments.creditCard.cvv.validate.maxLength(number) }) - this.selectedPaymentMethod.cvv = number + this.enableContinue({ $event: cruPayments.creditCard.cvv.validate.minLength(number) && cruPayments.creditCard.cvv.validate.maxLength(number) }) + this.selectedPaymentMethod.cvv = number + } }) }