amzn / amazon-payments-magento-2-plugin

Extension to enable Amazon Pay on Magento 2
https://amzn.github.io/amazon-payments-magento-2-plugin/
Apache License 2.0
107 stars 76 forks source link

May not be able to obtain prefectures in Amazon Japan #1167

Closed hryksbt closed 1 year ago

hryksbt commented 1 year ago

What I expected

When AmazonPay is used for payment in Magento, the prefectures correctly registered with AmazonPay should be retrieved from Amazon.

What happened instead

The problem does not occur when "東京都" is set. The problem occurs when "東京", "Tokyo" or "Tokyo-to" is set.

The "東京" or "Tokyo" part is the name of the prefecture. "都" "道" "府" "県" or "-to" "-dou" "-fu(-hu)" "-ken" is the suffix of the prefecture. It appears that Magento can retrieve the prefecture only if the address is registered with Amazon with the prefecture name and suffix entered. For prefectures that cannot be retrieved, the value will be "-" and the payment will fail.

Steps to reproduce the issue

!!!This must be the first AmazonPay purchase on the Magento site to be tested.!!!

  1. Register an address with Amazon Japan using the name of a prefecture that cannot be obtained through AmazonPay.
  2. Add products to the cart in Magento and choose AmazonPay as the payment method.
  3. Log in to Amazon and proceed with payment.
  4. Checkout will be failed.

Your setup

sgabhart22 commented 1 year ago

Hello @hryksbt ,

I'm afraid I haven't been able to reproduce this on a Magento 2.4.5-p1 instance using prefectures other than 東京都 in the Amazon Pay address. I don't see that Magento contains any mapping for Japanese regions/prefectures in the directory_country_region table, so anything that is returned from Amazon for this field should just be directly applied to the region field of the quote address.

That being said, may I ask how you have created the Amazon addresses with prefectures that do not work? I added a couple addresses through the Amazon-hosted page that can be reached by clicking the 'Edit' link in the address card after signing in with Amazon Pay, but the prefecture field is a dropdown; I was unable to get Amazon to store the prefecture as '東京' or 'Tokyo-to', since it seems like the dropdown value always corresponds to '東京都'.

Are you using any other extensions or third-party modules that may be affecting this behavior, e.g. Japanese localization extensions?

Thanks, Spencer

hryksbt commented 1 year ago

Thank you for your reply.

If the address is registered in Magento first, this problem will not occur. When using a new Amazon login in Magento, the address registered in Amazon will be called. Depending on the format of the prefecture at this time, it may not be possible to call the prefecture from Amazon to Magento. Right now, adding addresses in Amazon is a drop-down, so this may not be a problem. However, long-time Amazon users may not necessarily use this format. In those cases, even if the prefecture is registered in Magento, it is not possible to change the prefecture from Magento, so the account will not be able to pay via AmazonPay.

Outlook for iOShttps://aka.ms/o0ukef を入手


差出人: sgabhart22 @.> 送信日•r: Tuesday, January 31, 2023 12:30:17 AM 宛先: amzn/amazon-payments-magento-2-plugin @.> CC: Hiroyuki Shibata @.>; Mention @.> 件名: Re: [amzn/amazon-payments-magento-2-plugin] May not be able to obtain prefectures in Amazon Japan (Issue #1167)

Hello @hryksbthttps://github.com/hryksbt ,

I'm afraid I haven't been able to reproduce this on a Magento 2.4.5-p1 instance using prefectures other than –|京都 in the Amazon Pay address. I don't see that Magento contains any mapping for Japanese regions/prefectures in the directory_country_region table, so anything that is returned from Amazon for this field should just be directly applied to the region field of the quote address.

That being said, may I ask how you have created the Amazon addresses with prefectures that do not work? I added a couple addresses through the Amazon-hosted page that can be reached by clicking the 'Edit' link in the address card after signing in with Amazon Pay, but the prefecture field is a dropdown; I was unable to get Amazon to store the prefecture as '–|京' or 'Tokyo-to', since it seems like the dropdown value always corresponds to '–|京都'.

Are you using any other extensions or third-party modules that may be affecting this behavior, e.g. Japanese localization extensions?

Thanks, Spencer

― Reply to this email directly, view it on GitHubhttps://github.com/amzn/amazon-payments-magento-2-plugin/issues/1167#issuecomment-1408831825, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAS6MIZNWUBSRAWQTS3AOW3WU7NATANCNFSM6AAAAAAUHC5K4M. You are receiving this because you were mentioned.Message ID: @.***>

sgabhart22 commented 1 year ago

Thanks for the background info, @hryksbt ! That makes more sense if we're talking about long-standing Amazon Pay accounts that may have addresses with prefectures that don't agree with the current format Amazon Pay JP provides as options.

Although, I'm still curious about your phrasing '... even if the prefecture is registered in Magento ...': by default, Magento 2.4.5-p1 does not store any JP prefecture mapping, so the Region field is just a free-text field. This means that any prefecture/region returned from Amazon should work.

Are you using any extensions or checkout modifications that add a list of acceptable Japanese prefectures?

Thanks, Spencer

hryksbt commented 1 year ago

Thank @sgabhart22 for your reply too. When we use Magento with Japanese language, we usually use community official language pack. - https://github.com/magento/magento2-jp This has Japanese prefecture data. After install this, Magento's region can change to drop-down prefecture list such as states of US.

Thanks.

sgabhart22 commented 1 year ago

@hryksbt Ok, I'd like to try and see what's possible given the list of prefectures provided by these modules. We may be able to come up with a small patch that could, for example, select the prefecture that contains the prefecture name in the Amazon address (without the suffix, that is). Unless you see some potential problem with that approach; I am not familiar enough with these proper names to know if there's any danger of multiple names in the list provided by the language pack matching prefecture names that may be used in Amazon addresses.

On a slightly unrelated note, it looks like the repository you linked has not been updated in over 2 years. I was unable to successfully install it on both a 2.4.5-p1 and a 2.4.3-p2 instance. Could you confirm the Magento version you're running?

Thanks, Spencer

hryksbt commented 1 year ago

@sgabhart22

We use 2.4.3-p1. It would be a significant improvement just to support both Japanese characters with and without suffixes.

Incidentally, this is also occurring on e-commerce platforms other than Magento, so the spec change on Amazon itself must not have been good.

EX(Japanese article): https://help.thebase.in/hc/ja/articles/900004719866-Amazon-Pay%E3%81%AB%E7%99%BB%E9%8C%B2%E3%81%97%E3%81%A6%E3%81%84%E3%82%8B%E4%BD%8F%E6%89%80%E3%81%8C%E9%81%B8%E6%8A%9E%E3%81%A7%E3%81%8D%E3%81%BE%E3%81%9B%E3%82%93

sgabhart22 commented 1 year ago

Hey @hryksbt ,

Thanks for all the help with this, it does seem like there may have been an oversight in switching to the dropdown format and forcing the prefecture suffix. For what it's worth, the magento2-jp JapaneseAddress module also lists the prefectures with the suffix(es) only, so I'm not entirely sure how the regions were ever matched up correctly with prefectures in Amazon addresses that didn't contain them, but that's slightly beside the point.

I was able to test with the extensions you provided and can see the potential issue, though I wasn't able to recreate exactly; the state/region was simply left blank, not populated with a '-'. The blank forced me to select a proper prefecture before moving on, and did not allow me to continue checkout with an invalid value for that field.

Nonetheless, I created a small patch to the AP module which should compare the prefecture of the Amazon address to the list provided by the CommunityEngineering_JapaneseAddress module and assign the prefecture with suffix to the returned address. I've attached that patch here, please test at your convenience and let me know if you run into any problems!

Thanks, Spencer

gh1167.patch.txt

hryksbt commented 1 year ago

@sgabhart22 Thank you for your quickly patch building. When I check it I will revert to you at here.

sgabhart22 commented 1 year ago

Hello again @hryksbt ,

Just checking in with you to see if you've had a chance to test the patch. Let us know if we can provide anything else, otherwise we'll go ahead and close this issue in the next couple weeks. Thanks!

Spencer

akshitaWaldia commented 1 year ago

Hello @hryksbt

Closing this issue. Feel free to reopen if you are still facing this.

hryksbt commented 1 year ago

Hello, I applied patch but still prefecture field is "-". Do you think you can resolve?

sgabhart22 commented 10 months ago

Hello again @hryksbt ,

Very sorry for the long delay here, I suppose with the issue being closed, this fell by the wayside. Would you be able to provide a database dump and archive of your codebase so we could try and troubleshoot more accurately? I feel like there may be something I'm missing with my setup since I've been unable to recreate the exact issue you're seeing.

Thanks, Spencer