-
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. |
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 am getting this error message when trying to continue to step 3.
TypeError: Cannot read properties of undefined (reading 'cvv')
at Step2Controller.onPaymentFormStateChange (step-2.component.js:114:74)
at Step2Controller.submit (step-2.component.js:75:10)
I also get an error message when trying to submit the checkout.
{"error":"Invalid Data"}
In my incognito window, I get an error that prevents me from moving from Step 2 to Step 3. But this could just be my local.
Error tokenizing credit card
@@ -117,7 +120,7 @@ class Step2Controller { | |||
} | |||
|
|||
isContinueDisabled () { | |||
if (this.selectedPaymentMethod?.['card-type'] && typeof this.isCvvValid !== 'undefined' && !this.isCvvValid) { | |||
if (this.selectedPaymentMethod?.['card-type'] && !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.
Is it no longer returning as undefined
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.
It doesn't appear to be, so I just removed the condition.
@@ -109,14 +110,19 @@ class Step2Controller { | |||
this.changeStep({ newStep: 'review' }) | |||
this.onStateChange({ state: 'submitted' }) | |||
this.paymentFormState = 'success' | |||
} else if ($event.state === 'submitted') { | |||
this.orderService.storeCardSecurityCode(this.selectedPaymentMethod.cvv, this.selectedPaymentMethod.self.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.
Change the test to be like the below. Adding the line self.controller.selectedPaymentMethod = { cvv: '123', self: { uri: 'uri'} }
it('should update paymentFormState if transitioning to a different state', () => {
self.controller.paymentFormState = 'unsubmitted'
self.controller.selectedPaymentMethod = { cvv: '123', self: { uri: 'uri'} }
self.controller.onPaymentFormStateChange({ state: 'submitted' })
expect(self.controller.paymentFormState).toEqual('submitted')
})
|
This makes sense. Ignore that comment. |
'{"/paymentmethods/crugive/giydsnjqgi=":"456","/paymentmethods/crugive/giydsnjqgy=":"321"}' | ||
'{"/paymentinstruments/orders/crugive/hfsdoylfhbswk…4tmljug5qtqllcg44wcljvhezgcntcmvtdeojwgy=":"456"}' |
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.
Note that both of these show possibilities of reality.
@rguinee I'd be curious to hear your design perspective on a good way of showing the security code here as well. I'm thinking inline label/input instead of stacked and not quite so tall. |
Are we requiring they enter it again on a saved card for security purposes? |
Correct |
const storage = JSON.parse(this.sessionStorage.getItem('cvv')) || '' | ||
this.creditCardPaymentForm.securityCode.$setViewValue(storage) | ||
this.creditCardPaymentForm.securityCode.$render() | ||
this.sessionStorage.removeItem('cvv') |
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.
We don't want to clear this from session storage here, as this is what is sent to the server.
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 here was my thinking; this only gets removed on switchPayment
, which only happens previously to cvv getting added to storage. So if we remove it here it just gets added again once you proceed to the next step. From testing session storage appears to always hold the correct cvv
key/value at the final step which I believe is where it gets sent to the server. The primary reason for deleting the session storage here is to only set it once, which will keep it from adding the stored cvv to the cvv field every time switchPayment
is called. I could be missing something though, I could always try to come up with a different way to keep cvv
getting set everytime.
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.
In my testing, it cleared right after I edited the existing payment method and entering the CVV there. It got copied to the text box but then removed from session storage.
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.
hmm okay I must have missed something.
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 when you get to the final step. The stored cvv isn't present?
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.
Ah, I see what you're saying. It does get added back after hitting continue. We need to test that on the single step BCO branch as well to see how that behaves.
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.
Good call, I did not to think to check branded that could be problematic.
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, it looks like switchPayment
is called when hitting Continue
on 2 step branded checkout and when hitting Submit
on single step branded checkout. So this will definitely need to change in some way.
|
Do you envision that being below the selected payment method or the full list? I think the former. |
Exactly @wrandall22. They could have multiple card payment methods, so we would show below the selected option the sec code verification input. There are other considerations to make here. Is it validated when 3 or 4 digits are entered and can show success or error response? Does it have it be submitted and if incorrect the errors appear after page reloads? |
The validation is there and it shows in real time, not after submit (unless the back-end finds issues with the card verification with TSYS) |
b9a9e63
to
7988984
Compare
7988984
to
6a2f32f
Compare
@rguinee @wrandall22 Ryan is the image you shared what we want to go with? I can get started styling it, but I don't want to jump the gun if you guys are still deciding on what works/looks best. |
.give-modal-content, .branded-checkout { | ||
.credit-card-cvv-label { | ||
text-transform: uppercase; | ||
font-weight: 500; |
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.
On my local, this is being overwritten by the bold above.
display: block; | ||
margin-bottom: 4px; | ||
&::after { | ||
content: '*'; |
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.
On my local, this is being overwritten by the :
above.
Seems like the styling is working locally now, for some reason the changes aren't reflected on staging. Not sure if there's a cacheing issue. |
OKR: Implement real-time CVV validation on all transactions for Give App