mysqllaravelpayment-gatewayccavenuecitrus-pay

Handle payment response if server crashes?


What happens when I initiate a transaction to say Citrus, or Ccavenue or PayUmoney or any payment gateways, and the money is deducted on the client side and my server fails the time it was about to receive the response, and on the response I need to update a few columns in the DB for that particular client ? How should it be handled?I use Mysql as the database and Laravel.


Solution

  • This could handle by a separate queue service like Laravel Queue(https://laravel.com/docs/5.6/queues)

    Also make sure you have an API to check the payment status.Most of the payment gateways are providing API interface to check the payment status.

    Payment cycle would be as follows

    1. Client - Capture payment details
    2. Client - Request payment from the payment gateway and at the same time add a task to queue service to check the payment status and update your database.
    3. Queue service - Request payment status from gateway and update the database
    4. Client - pick the payment status from the database

    Queue service should be running as a server process isolated from the client application.So your payment cycle won't be break at any outages/delays(network timeouts,server outages,etc...)