Closed haelbichalex closed 2 years ago
Hello @haelbichalex ,
Thank you for raising the issue, you've brought up a couple of interesting points here. First, I think it would make sense to wrap the response(s) from completeCheckoutSession
as you said, both for consistency and the convenience of accessing returned values by key instead of position when using the API. Second, the return type of int
in the docblock causes a curious behavior when returning an array that contains an object (a \Magento\Framework\Phrase
as error message here) via Magento's web API.
The remediation wouldn't be overly invasive, but it might affect some merchants currently using the endpoints in PWA setups, causing them to handle new response formats. We'll discuss some options and let you know what we come up with. Thanks again!
Spencer
Hello again @haelbichalex ,
We're currently reviewing a solution that will return the failure messages as pre-translated strings instead of Magento Phrase objects. This will keep the current implementation backwards compatible for PWA merchants who are already using the API, improve error messages for new and existing PWA merchants, and also not affect the standard frontend behavior for payment error messages.
You can find the PR here, please feel free to test from this branch (or with the attached patch file) and let us know if it's helpful!
Thanks, Spencer
Hi @haelbichalex ,
Curious if you've had the chance to test the changes from the previously provided PR/patch? We're planning on including it in an upcoming release, and it would be great to know if the changes worked OK for you!
Thanks, Spencer
Hi @sgabhart22 ,
sorry for the late answer, I was busy fixing some other things with our integration first.
I installed the patch and everything seems to work just fine, the API returns the desired error messages 👍 Waiting for a new release now 🙂
Regards, Alex
@haelbichalex Glad to hear it! There should be a new one coming sooner rather than later, but we'll let you know again once it's live.
Hi @haelbichalex , the new release (5.13.0) is live : https://github.com/amzn/amazon-payments-magento-2-plugin/releases/tag/5.13.0 please reopen this issue in case you have any further problems.
Thanks a lot Best Christian
What I expected
I expect to get a real error message when using a declined credit card or similar.
What happened instead
When using the
/V1/amazon-checkout-session/:amazonSessionId/complete
endpoint, I get an error from Magento when I should get an error from the module instead.The
completeCheckoutSession
method returns the result array directly, instead of wrapping it in another array, compared to most other methods in theCheckoutSessionManagement
class. Also the method has a return type ofint
, which is not correct as far as I understand.Steps to reproduce the issue
complete
endpoint with thecartId
andamazonSessionId
Your setup