How can I check a payment process failed while ordering in Magento 2?
I want to set some logic if payment failed during order placing. Payment can be done from any payment method like PayPal, debit card, etc.
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.Sign up to join this community
When any payment method from Magento is called it gathers the transaction information back from the payment module using
rest/default/V1/carts/mine/payment-information API, this can be seen the network tab of any browser's console. You can check the response code and response of the specific request to determine whether the payment was successful or not.
For advanced debugging ofcource, you'll have set up an Xdebug trace or add a logger in payment method's model class. But, for the general purpose, you will also get the error message too in case an exception has occurred during the transaction.