3

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.

2

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.

  • Thanks for guiding.Can you please tell me where I can set my code in which module in which class path of that file where put my code to detect. – Shubhajay Das May 1 at 6:22
  • It depends on the specific payment method you want to debug. You asked a general question above so I gave a general answer. – Vivek Kumar May 1 at 6:47
  • i am using paypal but did't get where to detect if it failed – Shubhajay Das May 1 at 6:48
  • Did you get any message in the network tab of dev console? – Vivek Kumar May 1 at 6:49
  • Also check system and exception log after placing the order – Vivek Kumar May 1 at 6:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.