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 address fields mapping for Google Pay and UAE addresses #3432

Merged
merged 5 commits into from
Sep 16, 2024

Conversation

annemirasol
Copy link
Contributor

@annemirasol annemirasol commented Sep 11, 2024

Fixes #3430

Changes proposed in this Pull Request:

When using Google Pay with a UAE shipping address, we get the error Shipping Town / City is a required field. on checkout. This is because Google Pay stores the emirate in "region", which gets mapped to the "state" field in WooCommerce. For UAE, WooCommerce expects the emirate to be stored in the "city" field.

This PR adds an address field mapping step on the checkout form data if the shipping or billing country is UAE. The approach is similar to a corrective step that we do for Apple Pay and HK.

Testing instructions

  1. Add a UAE address in your Google Pay account: https://payments.google.com/gp/w/u/0/home/addressbook
    • For example: PO Box 12345, Abu Dhabi, United Arab Emirates
  2. Make sure you are NOT in the Google Pay API Test Cards allowlist: https://groups.google.com/g/googlepay-test-mode-stub-data
    • If you are in the allowlist Google group, you will have access to the test address data set only, which does not include UAE.
  3. Make sure test mode is enabled in Stripe, to avoid actual charges: wp-admin/admin.php?page=wc-settings&tab=checkout&section=stripe&panel=settings
  4. As a shopper, add a product to your cart, and go to checkout.
    • Important: Make sure the shipping and biling form fields are clear. If they are pre-populated (due to autofill), clear them out first. Reason: We have added behavior in Fix required fields breaking Google Pay and Apple pay #2886 to pull in data from the checkout form for required fields. If you have been testing with a different address that has a city, this may get pulled in.
  5. Click the "Buy with Google Pay" button to open the modal.
  6. Make sure to choose the UAE address as the shipping address.
  7. Click Pay.
  8. Before fix: Notice the payment fails with the error "Shipping Town / City is a required field."
  9. Fixed: Your order should succeed. Verify that it shows the correct shipping address.

Before: Checkout fails because the "city" field is empty.
Screenshot 2024-09-10 at 3 52 12 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 marked this pull request as ready for review September 11, 2024 16:44
@annemirasol annemirasol self-assigned this Sep 11, 2024
@annemirasol annemirasol requested review from a team, james-allan and imodouglas and removed request for a team September 11, 2024 16:44
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.

Changes look good. I verified the bug on a fresh JN site:
Screenshot 2024-09-16 at 2 10 00 PM

I confirmed it's fixed on this PR.


I noticed while reviewing this PR that there's a function below (normalize_state()), it does some remapping of these fields too -- it includes the fix for the Hong Kong bug with Apple Pay you referenced in the PR description. It then has a more general mapping of Apple Pay Google Pay state codes to WC versions.

At some point we may want to centralise these mappings, normalisations and corrections of the data but for now this looks fine.

@annemirasol annemirasol merged commit 7f20b58 into develop Sep 16, 2024
35 checks passed
@annemirasol annemirasol deleted the fix/3430-fix-google-pay-uae-address branch September 16, 2024 23:57
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.

Checkout fails when using Google Pay with UAE shipping address
2 participants