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
109 stars 77 forks source link

Issue: Unable to Complete Amazon Pay Checkout with Downloadable/Virtual Products #1246

Open congrallion opened 2 months ago

congrallion commented 2 months ago

What I expected

Checkout to complete successfully using Amazon Pay.

What happened instead

Error message: "Unable to complete Amazon Pay checkout." Error Log: [2024-09-20T04:55:49.261284+00:00] amazonClientLogger.ERROR: Unable to place order for quoteId 70711: Please check the billing address information. "firstname" is required. Enter and try again. "lastname" is required. Enter and try again. "street" is required. Enter and try again. "city" is required. Enter and try again. "telephone" is required. Enter and try again. "postcode" is required. Enter and try again. "countryId" is required. Enter and try again. [] []

Steps to reproduce the issue

  1. Log in as a customer with a default address.
  2. Add a downloadable/virtual product to the cart.
  3. Proceed to checkout (/checkout page) and select Amazon Pay as the payment method.

Your setup

sgabhart22 commented 1 month ago

Hello @congrallion ,

Thanks for raising the issue, we did have a little bit of refactoring of the frontend code as part of the 5.17 release, and it looks like proper handling of the APB + virtual cart scenario may have been lost. I'm attaching a patch here which should ensure all addresses are properly set in all Pay Now and Express Checkout scenarios. Please let us know if you continue to experience issues!

gh-1246.patch.txt

Thanks again, Spencer

congrallion commented 1 month ago

Hi Spencer,

Thank you for the prompt response and for providing the patch. Unfortunately, after applying the patch, the issue still persists. The error message remains the same when attempting to complete the checkout using Amazon Pay with a virtual cart.

[2024-09-24T03:06:44.940513+00:00] amazonClientLogger.DEBUG: getCheckoutSession <-  [1,"1e8d6da9-cca8-40ff-89dc-bd316622c2cc"] []
[2024-09-24T03:06:45.315661+00:00] amazonClientLogger.ERROR: Unable to place order for quoteId 70711: Please check the billing address information. "firstname" is required. Enter and try again. "lastname" is required. Enter and try again. "street" is required. Enter and try again. "city" is required. Enter and try again. "telephone" is required. Enter and try again. "postcode" is required. Enter and try again. "countryId" is required. Enter and try again. [] []
[2024-09-24T03:06:45.315825+00:00] amazonClientLogger.ERROR: Unable to complete Amazon Pay checkout. Unable to place order with quote id: 70711 [] []
[2024-09-24T03:06:45.315960+00:00] amazonClientLogger.ERROR: Unable to complete Amazon Pay checkout. Unable to complete Amazon Pay checkout. [] []

Please let us know if there’s anything else we can try or if additional information is needed.

Thanks again for your help! Best regards

sgabhart22 commented 1 month ago

Hi @congrallion ,

Because the vast majority of the changes in the patch affected frontend/JS code, could you please make sure you've redeployed static content and that no cached files are being served? It would appear the original amazon-button.js script was still being used from those log entries.

Thanks, Spencer

congrallion commented 1 month ago

Hi @sgabhart22 Thank you for the suggestion. We reviewed the patch and noticed that it couldn't be applied as expected due to the slash in the path. ('vendor/amzn/amazon-pay-magento-2-module' instead of 'vendor/amzn/amazon-pay/magento-2-module') The problem was solved after applying the modified patch (thank you for the fix), but it raised another issue.

In the checkout step (#payment), sometimes the address shows an 'Update' button. This happens randomly (usually occurs if we reload the page). Then the error occurs each time we click the Amazon Pay button unless we first click the 'Update Address' button. (Please check the video recording below.)

Screencast from 30-09-2024 10:40:00.webm

Suggestion: Could you please add some validation to 'Amazon Pay' to show a message if the address is not populated, or disable the button like the PO payment (image below)?

image

Thanks.

sgabhart22 commented 1 month ago

Hello again @congrallion ,

Sorry for the malformed path in the previous patch... And for the subsequent problem you're seeing, I wasn't able to reliably recreate it, but did still see similarly odd behavior. I've revised the patch a bit to avoid directly manipulating address data on the frontend, and disable the AP if billing address data is missing. Please let me know if this seems to work better!

gh-1246-v2.patch.txt

Thanks, Spencer