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

Region data with translated region not loaded with express checkout #1226

Open
dimitriBouteille opened this issue Nov 6, 2023 · 1 comment

Comments

@dimitriBouteille
Copy link
Contributor

dimitriBouteille commented Nov 6, 2023

Hi,

I am setting up Amazon Pay on a Japanese store. When I load the information via the graphQl checkoutSessionDetails query, I see that when the region is translated, the region information is not returned.

Here is a result of the query checkoutSessionDetails:

{
    "data": {
        "amazonPayCheckoutSessionDetailsV2": {
            "payment": "Visa ****1111 (Amazon Pay)",
            "shipping": {
                "city": "目黒区下目黒",
                "firstname": "テスト姓名二",
                "lastname": " ",
                "street": [
                    "1-8-1"
                ],
                "company": "",
                "telephone": "0312345678",
                "region": "Tokyo",
                "region_id": 621,
                "region_code": "13",
                "email": "XXX",
                "postcode": "1530064",
                "country_id": "JP"
            },
            "billing": {
                "city": "サンプル",
                "firstname": "東京太郎",
                "lastname": " ",
                "street": [
                    "目黒区下目黒1-8-1 テスト住所2"
                ],
                "company": "",
                "telephone": "0312345678",
                "region": "東京都",
                "region_id": null,
                "region_code": null,
                "email": "XXX",
                "postcode": "153-0064",
                "country_id": "JP"
            }
        }
    }
}

For the delivery address no problem, because Tokyo is the default translation. For the billing address, the region 東 京 都 exits well but this is the translated version of Tokyo.

Default translation in directory_country_region table :

Capture d’écran du 2023-11-06 17-41-31

These are the addresses configured in Amazon :

Capture d’écran du 2023-11-06 17-54-52

What happened instead

Region information is not loaded and an error occurs when saving the billing address (regionIdは必須項目です。)

Steps to reproduce the issue

⚠️ To reproduce the bug, you must import the translations for the JP store in table directory_country_region_name : region_names.csv

  • Start express Amazon Pay Checkout
  • Select shipping address with region with default translation (ie: Tokyo)
  • Select billing address with translated region (ie: 東京都)
  • Try execute checkoutSessionDetails

Normally the billing address has no region_id / region_code.

Your setup

  • Magento version: 2.4.5-p5
  • Amazon Pay Extension Version: 5.16.0

Fix proposal

This function should be improved \Amazon\Pay\Helper\Address::getRegionData() :

  • First, load region by code
  • If no region find, try load with default translation
  • if no region find, try load with translated region name with current store locale
@sgabhart22
Copy link
Contributor

Hi @dimitriBouteille ,

Does your store have any Japanese language packs or similar extensions installed, or simply the CSV data you provided in the directory_country_region_name table? I think your proposed solution seems very sound, but I would like to test it out locally and make sure there are no other areas where the prefecture/region translation should be addressed.

Thanks,
Spencer

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

No branches or pull requests

2 participants