Maybe due to our configuration (maybe due to M2), error messages are not printed anymore in Onepage checkout.
- It's a simple case of throwing a
\LocalizedException
duringcapture()
for reason X. That results in a 400 response for the/V1/carts/mine/payment-information
request. All good. - M2 creates a JSON out of that exception, with a
message
property, which is then handled here. Superb. - The error message is then pushed onto an error message container here. Omg, brilliant.
- Then nothing happens, what.
I was expecting the error message to be printed. Mind you, the above behaviour was tracked down with a JS debugger, I'm not assuming it happens.
Trying to fix this, I've stumbled upon \Magento\Framework\Message\ManagerInterface
. Using that in my capture()
method, it correctly added another message which this time was fetched with that customer/section/load
request I dearly hate. And, although the messages
property of the response was what I wanted, I still couldn't see my message appear.
Ok...
Then I saw that, for checkout only, M2 removes the messages container in favour of UI Components. It was too simple, you see. They had to put JSON in HTML through a PHP-parsed XML.
If I put back that message block, the message is finally showing, hooray. But I don't think M2 devs removed that block by mistake.
Do any of you know how exactly the JS message container does its job? Who triggers its rendering?