Skip to content
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

Merged
merged 24 commits into from
Aug 23, 2024

Conversation

Sidsector9
Copy link
Member

@Sidsector9 Sidsector9 commented Jul 25, 2024

All Submissions:

  • Does your code follow the WooCommerce Sniffs variant of WordPress coding standards?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully run tests with your changes locally?
  • Will this change require new documentation or changes to existing documentation?

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

Fix - Cancelling Google Pay on checkout shows validation errors.

@vikrampm1 vikrampm1 added this to the Future Release milestone Jul 25, 2024
Copy link
Contributor

@peterwilsoncc peterwilsoncc left a 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

assets/blocks/digital-wallets/content.js Outdated Show resolved Hide resolved
assets/blocks/digital-wallets/content.js Outdated Show resolved Hide resolved
@Sidsector9
Copy link
Member Author

@peterwilsoncc I've fixed the issues you pointed, requesting a re-review.

Copy link
Contributor

@peterwilsoncc peterwilsoncc left a 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

locked

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]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}, [applePayRef]);
}, [applePayRef, applePay]);

}, [payments, paymentRequest]);

useEffect(() => {
if (!applePayRef?.current) {
Copy link
Contributor

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.

Suggested change
if (!applePayRef?.current) {
if (!applePayRef?.current || !applePay) {

Copy link
Member Author

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.

Copy link
Contributor

@peterwilsoncc peterwilsoncc left a 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

@Sidsector9 Sidsector9 force-pushed the fix/143 branch 2 times, most recently from 6a2c425 to b0eed44 Compare August 5, 2024 04:25
@qasumitbagthariya
Copy link
Contributor

QA Update ✅


I have verified this PR in the fix/143 branch has been fixed and is functioning as intended.

I tested the following on this branch:

  • Google Pay at checkout page ✅
  • Validation errors are not shown ✅

Testing Environment

  • WordPress: 6.6.1
  • Theme: Storefront 4.6.0
  • Theme: Twenty Twenty-Four 1.2
  • WooCommerce - 9.1.4
  • PHP: 8.0.30
  • Web Server: Nginx 1.20.2
  • Browser: Chrome
  • OS: macOS Ventura 13.3
  • Branch: fix/143
Screen.Recording.2024-08-05.at.3.43.24.PM.mov

Steps to Test- As mentioned in the PR description.
Test Results - It is working as expected.
Functional Demo / Screencast -
Special Notes - Ready for code review (Woo)
Testing Document status:
Cases related to this Issue/PR are added to the Critical Flow Wiki pages:

  • Yes
  • Not Required/Applicable for this PR

@vikrampm1
Copy link
Contributor

@Mayisha this PR is ready for your review!

Copy link

@Mayisha Mayisha left a 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.
Screenshot 2024-08-07 at 4 24 08 PM
  • 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.

try {
await payments.googlePay(paymentRequest);
const __googlePay = await payments.googlePay(paymentRequest);
await __googlePay.attach(googlePayRef.current, {
Copy link

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);

Copy link

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?

async function handlePaymentProcessing() {
let response = { type: emitResponse.responseTypes.SUCCESS };

if (!tokenResult) {
Copy link

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?

Copy link
Member Author

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

Copy link

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.

@qasumitbagthariya
Copy link
Contributor

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

  • WordPress: 6.6.1
  • Theme: Storefront 4.6.0
  • Theme: Twenty Twenty-Four 1.2
  • WooCommerce - 9.1.4
  • PHP: 8.0.30
  • Web Server: Nginx 1.20.2
  • Browser: Chrome
  • OS: macOS Ventura 13.3
  • Branch: smoke-testing

Next Step- Ready to Merge 🚀

@vikrampm1 vikrampm1 modified the milestones: Future Release, 4.8.0 Aug 23, 2024
@vikrampm1 vikrampm1 marked this pull request as ready for review August 23, 2024 15:10
@vikrampm1 vikrampm1 merged commit dcab786 into trunk Aug 23, 2024
6 checks passed
@vikrampm1 vikrampm1 deleted the fix/143 branch August 23, 2024 15:11
@vikrampm1 vikrampm1 mentioned this pull request Aug 23, 2024
20 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[#133 followup] Cancelling Google Pay on checkout shows validation errors.
5 participants