-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updates hideCvv flag for edit payment methods and new payment methods. #1109
base: master
Are you sure you want to change the base?
Conversation
@wrandall22 I'm having some difficulty with this one. I need to validate that the CVV is correct when paying with a saved card. I added a save payment method that is essentially just ripped from creditCardForm.component.js. I haven’t been able to get it working though which isn't surprising seeing as I'm not entirely sure what all is going on in that code block. Do you have any pointers for me/is this the right way of going about it? |
So, there are a few things.
|
@wrandall22 thank you this is really helpful. One question, do we only need the validators on the CVV? I would assume we need to ensure the CVV is also correct for the given credit card before allowing them to move forward. That was what I was trying to accomplish with the savePayment method, although it didn't appear to be working. |
The CVV is the only thing being entered, so is the only thing being validated in this situation. That validation can live in the directive. |
Ahh okay that makes things a bit easier. |
65c4157
to
64cfd40
Compare
Great work on this PR! Just a note: before merging with staging, can you run |
Removing the |
It seems like it wasn't just you, there were some other changes from other PRs that caused staging to fail being deployed. |
@dr-bizz thanks that make me feel better. Sorry about that, I didn't realize it was causing issues. It's not quite ready for staging either. |
You can turn it into a draft PR until it's ready if you want. |
It's all good. This is where amplify previews would come in handy |
@wrandall22 is this more what you had in mind? Do you know where else the directive needs to be used apart from |
Hey Will, thanks for working on this. I was more thinking of putting this part of the HTML in the directive:
Then using it in both |
@wrandall22 is this a little more what you had in mind? I was initially trying to validate within the directive itself, but it ended up being easier to just use the directive for the template and use the validators that were already in place. |
Yep, this is the direction I was thinking. |
@wrandall22 okay great! I'll fix it up. |
929aa54
to
24cde89
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got part way through the review, this is a good start. I'm going to play around a little bit with the directive locally as well.
src/app/profile/payment-methods/payment-method/payment-method.component.js
Outdated
Show resolved
Hide resolved
src/common/components/paymentMethods/creditCardForm/creditCardForm.component.js
Outdated
Show resolved
Hide resolved
src/app/checkout/step-2/existingPaymentMethods/existingPaymentMethods.component.js
Outdated
Show resolved
Hide resolved
src/app/checkout/step-2/existingPaymentMethods/existingPaymentMethods.component.js
Outdated
Show resolved
Hide resolved
Thanks @wrandall22! I'll get started on these changes. |
1e72548
to
c4717db
Compare
if (this.selectedPaymentMethod?.['card-type'] && this.creditCardPaymentForm?.securityCode) { | ||
const selectedUri = this.selectedPaymentMethod.self.uri | ||
const storage = JSON.parse(this.sessionStorage.getItem('storedCvvs')) | ||
const getSelectedCvv = storage ? storage[Object.keys(storage).filter((item) => item === selectedUri)] : false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you use ''
instead of false
you don't need the conditional below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh nice I like that!
|
||
it('should add securityCode viewValue from sessionStorage', () => { | ||
self.controller.creditCardPaymentForm.securityCode.$viewValue = '123' | ||
self.controller.selectedPaymentMethod = { 'card-type': 'Visa', self: { type: 'cru.creditcards.named-credit-card', uri: '/paymentmethods/crugive/giydsnjqgi=' }, selectAction: 'some uri' } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is a bit too long, let's break it up to multiple lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for thinking the error on the checkout. I have review the code again and made some comments, but they are only small things.
I did test the security code on the checkout and found it didn't matter what value I added, it always allowed me to continue. Should that be the case, or are you just taking the input on step 2, and then checking it when the user submits the checkout?
@@ -116,7 +116,10 @@ class Step2Controller { | |||
} | |||
} | |||
|
|||
getContinueDisabled () { | |||
isContinueDisabled () { | |||
if (this.selectedPaymentMethod?.['card-type'] && typeof this.isCvvValid !== 'undefined' && !this.isCvvValid) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so if isCvvValid is undefined we enable the continue button?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it that if there are no CC to ensure they are valid, we don't disable the button, so the user isn't blocked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see on line 129 we ensure a payment method is selected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may be able to take that out now but initially I added typeof this.isCvvValid !== 'undefined'
so that it's not disabled before enableContinue gets called.
}) | ||
|
||
describe('existing credit card used', () => { | ||
it('should return true when cvv is invalid', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could write it as should disable continue when cvv is invalid
to make the test name quicker to understand, without the dev having to look at the test itself to understand what is is testing to return true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same could be saids for the ones below as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, I'll update these test names.
expect(self.controller.isContinueDisabled()).toBe(false) | ||
}) | ||
|
||
it('should return false when cvv is invalid', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woudl you have a Cvv when you enter your bank details?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a cvv for new credit cards but not for new bank accounts. The this.selectedPaymentMethod?.['card-type’]
in the isContinueDisabled
conditional should ensure continue isn’t disabled for bank accounts. Line 346 should have the tests for this.
@dr-bizz Thanks for looking it over again! and yes, we're just taking the input on step 2, and then checking it when the user submits the checkout. The only issue with this is it never get's saved to session storage which Bill pointed out. I have a commit that should fix this issue. |
OKR: Implement real-time CVV validation on all transactions for Give App