Closed webr closed 1 year ago
Hello @webr ,
The returned checkoutSessionConfig
object appears to be in the right format from what you posted; the payloads are typically strings, but it looks like all the other keys are standard JSON. Would you have a staging site available where we could take a closer look at the button rendering issue?
Thanks, Spencer
@sgabhart22 Thanks for your reply Spencer.
Funnily enough I've just checked an old dev site (which is still on Magento 2.4.0) and the same thing is happening there. Could I share this and the production URL privately?
The reason I thought the checkoutSessionConfig
object wasn't formatted correctly is because the console explicitly logged it as a string while it logged buttonConfig
as an object:
All that is happening between the 2 points of logging is the setting of object values such as merchantId: checkoutSessionConfig['merchant_id']
leading me to believe the checkoutSessionConfig
object cannot be read as intended.
@webr Not a problem! And that is odd, certainly seems like something else may be to blame besides the upgrade. And yes, we can add you to our internal ticket for this issue and we can continue discussion there. Are you comfortable sharing an email here that we can use to add you to our Jira project? If not, you can email me directly at spencer@beargroup.com.
And that makes sense as well, I've had my share of confusion over the 'helpful formatting' the console sometimes displays. But I'd say you've drawn a fair conclusion. Looks like something is preventing the values returned by the /config call from being correctly translated into the payload used to render the button. At any rate, let us know how you'd like to proceed with communication and we'll be happy to help investigate.
Thanks, Spencer
Thanks Spencer, have just sent an email.
Closing this issue as the problem has been identified as originating from a linebreak introduced in the Amazon Pay SDK for PHP library, causing the content type of the JSON response to actually be interpreted as text/html:
For anyone else that may run into this issue, a new version of the SDK has now been released; the changes are included in version 2.5.2 of the Amazon Pay API SDK for PHP. Updating should resolve the integration issues with the Magento module.
Hi,
Since upgrading to Magento 2.4.5-p1 from 2.4.2, the Amazon Pay button on our shopping cart page fails to load:
Checking the developer console it tells us:
I added some console logging to
vendor/amzn/amazon-pay-magento-2-module/view/frontend/web/js/amazon-button.js
to see what was in the options object, and found thatcheckoutSessionConfig
appears to be seen as a string rather than an object:This then means that all the values in the
buttonConfig
object are not set properly and are instead undefined, leading to the error seen in the console and on the frontend.