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 missing error message in Express Payments #3423

Merged
merged 4 commits into from
Sep 10, 2024

Conversation

annemirasol
Copy link
Contributor

@annemirasol annemirasol commented Sep 6, 2024

When the shopper is using Express Payment, e.g. GooglePay, and the order creation fails due to account creation errors, the error message is not displayed. (see Screenshots 1 and 2)

The empty error message is caused by firstChild returning a text node (i.e. \n) when retrieving the error message from WooCommerce. To fix this, we use firstElementChild to ensure we get the first Element node.

Fixes #2430

Changes proposed in this Pull Request:

  • Use firstElementChild when retrieving the error message from WooCommerce, to ensure we get an Element node.

Testing instructions

(As the merchant, on any browser)

  1. Enable Apple Pay/Google Pay: wp-admin/admin.php?page=wc-settings&tab=checkout&section=stripe&panel=methods
  2. Disable guest checkout, but allow customers to create an account during checkout and on the My Accounts page (See Screenshot 4): wp-admin/admin.php?page=wc-settings&tab=account

(As the shopper, on a Chrome browser)

  1. Add a product to your cart and go to checkout.
  2. Make sure you can see the Google Pay button in the checkout page:
    • You need to be running on a publicly accessible server, or you need to have local tunneling setup (e.g. ngrok, Jurassic Tube)
    • In the same browser, you need to be logged in to a Google Pay account that has a payment method added: pay.google.com
    • To avoid accidental charges on your real cards, join the Google Pay API Test Cards allowlist, using the same Google account for your shopper's Google Pay: https://groups.google.com/g/googlepay-test-mode-stub-data
  3. On a separate tab, register your Google Pay email address with the store, using the "My account" page in /my-account. You may skip this if your email is already registered.
  4. Important: log out. If you do not see the "Log out" link, refresh the "My account" page.
  5. Go back to checkout, and click the Google Pay button. A modal with fake test data (test credit cards and billing info) should pop up. (See Screenshot 1)
  6. Click "Pay".
  7. You should get a generic message at the bottom saying "There was an error processing your order."
  8. Close the modal.
  9. You should see a red box above the Google Pay button, with an error message saying, "An account is already registered with your email address. Please log in."

Screenshots

Screenshot 1: Google Pay modal with generic error.
Screenshot 2024-09-06 at 12 24 47 PM

^-^-^-^-^-^-^-^-^
Screenshot 2: After dismissing the Google Pay modal, we see the error box with an empty message.
Screenshot 2024-09-06 at 12 13 25 PM

^-^-^-^-^-^-^-^-^
Screenshot 3: Fixed error box
Screenshot 2024-09-06 at 12 12 50 PM

^-^-^-^-^-^-^-^-^
Screenshot 4: Account settings setup for the store
Screenshot 2024-09-06 at 1 29 59 PM


  • Covered with tests (or have a good reason not to test in description ☝️)
  • Added changelog entry in both changelog.txt and readme.txt (or does not apply)
  • Tested on mobile (or does not apply)

Post merge

@annemirasol annemirasol self-assigned this Sep 6, 2024
@annemirasol annemirasol marked this pull request as ready for review September 6, 2024 19:53
@annemirasol annemirasol requested review from a team and wjrosa and removed request for a team September 6, 2024 19:53
@wjrosa wjrosa requested review from a team and james-allan and removed request for wjrosa and a team September 9, 2024 13:33
Copy link
Contributor

@james-allan james-allan left a comment

Choose a reason for hiding this comment

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

Nice work @annemirasol!

I confirmed the error on the public version of Stripe:

Google Pay Apple Pay

Screenshot 2024-09-10 at 5 33 37 PM
Empty error box when displaying error after Google Pay

Screenshot 2024-09-10 at 5 36 44 PM
Empty error box when displaying error after Apple Pay

After uploading a zip of this branch I confirmed the fix.

Google Pay Apple Pay
Screenshot 2024-09-10 at 5 42 39 PM Screenshot 2024-09-10 at 5 45 43 PM

While the screenshots above were tested on the cart page, I also confirmed that the error messages weren't inadvertently impacted on the checkout and single product page too. 👍

@annemirasol annemirasol merged commit 95e885b into develop Sep 10, 2024
35 checks passed
@annemirasol annemirasol deleted the fix/2430-unclear-express-payment-error branch September 10, 2024 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Google Pay not recognizing existing user account on checkout.
2 participants