In Magento 2, I am using brain-tree credit card payment method on live site. Sometimes it shows error, unable to place an order, please try after sometimes but I want to know exact error on front end side about that transaction declined. I want error handling for Braintree credit card payment so that it makes easy to know the reason behind failed payment.
1 Answer
As far as I know, Magento 2 use Ajax to handle this task.
We should take a look at file:
vendor/magento/module-checkout/view/frontend/web/js/model/place-order.js
return storage.post(
serviceUrl, JSON.stringify(payload)
).fail(
function (response) {
errorProcessor.process(response, messageContainer);
fullScreenLoader.stopLoader();
}
);
So, we need to override this file or the errorProcessor.process()
- vendor/magento/module-checkout/view/frontend/web/js/model/error-processor.js
handler. We can alert the error message.