How do I get notified using a API call when a payment is successful or failed?
Instamojo notifies a customer using webhook and custom redirect URL.
Webhook- It is an asynchronous POST call from Instamojo server to the URL mentioned by the merchant. Webhook URL needs to be a public URL. You may not be able to test it on a local environment. For more details please refer to the article on Webhook
Custom Redirect URL- After every successful or failed transaction, Instamojo redirects to the URL configured during a payment request. While redirection Instamojo appends the payment id and payment request id to the custom redirect URL. Now you can use this payment id and payment request id and using a GET request fetch all the details pertaining to that transaction.
You can then update your database with the details you have fetched.