As far as i understand from your question and comment you want to implement payumoney as payment gateway.
So both payumoney and instamojo use concept of webhook.
for webhook
https://www.payumoney.com/dev-guide/development/general.html
There is no direct way to handle that situation.Moreover now days server failure is a rare case ,if are using some standard web server.
There is a indirect way for that use
Transaction Status Api
https://www.payumoney.com/dev-guide/apireference.html#operation/getPaymentResponseUsingPOST
Call transaction status Api , to get status of payment
Note: If your user lost their net connectivity after payment ,it will not effect any thing.As after payment is done ,situation is handle by GateWay server and your server.