-
Notifications
You must be signed in to change notification settings - Fork 7
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
fix/143: Cancelling Google Pay on checkout shows validation errors #188
Conversation
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've added some notes inline.
I am getting a JavaScript error for Apple Pay in Safari so the payment form fails to open but have yet to figure out the cause.
For Google Pay in Safari it re-introduces a bug that was fixed earlier in which the entire page is redirected to the Google Pay form. I tried to find the commit in which it was fixed but without success
Screen.Recording.2024-07-26.at.1.38.23.PM.mov
@peterwilsoncc I've fixed the issues you pointed, requesting a re-review. |
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 is working great, I've made a suggestion inline to prevent the Apple button displaying in non-Safari Browsers.
The one bug I am seeing with Apple Pay is when there are no cards defined. If I cancel the payment attempt, the Apple and Google Pay buttons remain locked.
I suspect a different event is fired for cancelled payment requests as opposed to invalid requests. I think this might be an existing bug so if it is, I'd recommend opening a follow up ticket rather than letting it block you on this one
The validation error fixes are looking great and working as expected. Nice work.
applePayRef.current.style.cssText += `-apple-pay-button-style: ${color};`; | ||
applePayRef.current.style.display = 'block'; | ||
applePayRef.current.classList.add(`wc-square-wallet-button-${color}`); | ||
}, [applePayRef]); |
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.
}, [applePayRef]); | |
}, [applePayRef, applePay]); |
}, [payments, paymentRequest]); | ||
|
||
useEffect(() => { | ||
if (!applePayRef?.current) { |
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.
Required with above suggestion to ensure the Apple Pay button is only shown in Safari.
if (!applePayRef?.current) { | |
if (!applePayRef?.current || !applePay) { |
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.
@peterwilsoncc I've added these suggestions.
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.
Thanks Sid, this looks good and is working as expected.
Testing notes
In Safari, checkout page (blocks):
- Click Apple Pay button
- Cancel
- Validation errors are not shown (as expected)
- Click Google Pay button
- Cancel
- Validation errors are not shown (as expected)
- Click Apple Pay button
- Proceed through payment
- Order processed as expected
- Re-order, return to checkout
- Click Google Pay button
- Proceed through payment
- Order processed as expected
In Safari, cart page (blocks)
- Click Apple Pay button
- Cancel
- Click Google Pay button
- Cancel
- Click Apple Pay button
- Proceed through payment
- Order processed as expected
- Re-order, return to cart
- Click Google Pay button
- Proceed through payment
- Order processed as expected
In Chrome, checkout page (blocks):
- Apple Pay button not shown
- Click Google Pay button
- Cancel
- Validation errors are not shown (as expected)
- Click Google Pay button
- Proceed through payment
- Order processed as expected
In Chrome, cart page (blocks)
- Apple Pay button not shown
- Click Google Pay button
- Cancel
- Click Google Pay button
- Proceed through payment
- Order processed as expected
6a2c425
to
b0eed44
Compare
QA Update ✅I have verified this PR in the I tested the following on this branch:
Testing Environment
Screen.Recording.2024-08-05.at.3.43.24.PM.movSteps to Test- As mentioned in the PR description.
|
@Mayisha this PR is ready for your review! |
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.
Changes look good to me and it fixed the original issue.
- I can reproduce the issue in
trunk
. When I cancel Google Pay on the block checkout page, it triggers the form validation.
- In this branch canceling Google Pay does not trigger the form validation on the block checkout page.
I just marked a few lines in my comment below which look like typos to me.
src/blocks/digital-wallets/hooks.js
Outdated
try { | ||
await payments.googlePay(paymentRequest); | ||
const __googlePay = await payments.googlePay(paymentRequest); | ||
await __googlePay.attach(googlePayRef.current, { |
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.
await payments.googlePay(paymentRequest);
is twice here.
try { | ||
await payments.applePay(paymentRequest); | ||
const __applePay = await payments.applePay(paymentRequest); | ||
|
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.
await payments.applePay(paymentRequest)
is also called twice similar to googlePay
. Is this intentional?
src/blocks/digital-wallets/hooks.js
Outdated
async function handlePaymentProcessing() { | ||
let response = { type: emitResponse.responseTypes.SUCCESS }; | ||
|
||
if (!tokenResult) { |
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 this check going to work as we are already returning from line 212
above for the same condition?
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.
Thanks for catching these, I've made the changes in 33a8a84
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.
Thanks @Sidsector9 for the update. The PR is already approved.
I have tested this branchagain and confirmed that
- Canceling Google Pay does not trigger the form validation on the block checkout page.
- I can successfully purchase a product with Google Pay.
Regression / Smoke Test Report ✅Tested with Archive File created via "php woorelease.phar build repo_URL" (Composer version 2.5.5, npm version 8.19.4, node version 16.20.0) Status- Working expected with Plugin Archive/Zip file same as fix specific branch. Testing Environment
Next Step- Ready to Merge 🚀 |
All Submissions:
Changes proposed in this Pull Request:
Closes #143
This PR does 2 things:
Steps to test the changes in this Pull Request:
Test Digital Wallets features.
Changelog entry