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.
Asked
Active
Viewed 688 times
2
-
What have you tried so far? – Nick Jul 13 '18 at 07:54
-
If the server is unable to receive the response then the remote service will be aware of this and probably abort the transaction. That is assuming the payment is handled server to server. – apokryfos Jul 13 '18 at 07:56
-
I have not tried this issue, as I need to fail or turn off my server, and I don't want to do that. Apart from that my payments are going through fine. – Nitish Patra Jul 13 '18 at 07:56
-
@apokryfos so will the payment gateway refund the money? – Nitish Patra Jul 13 '18 at 07:59
-
Logically it would, but you need to ask the 3rd party directly on that. Again this will not work if payment is handled via a client redirect and then a callback. – apokryfos Jul 13 '18 at 08:19
-
@apokryfos Basically client redirect is my last step, so before that, I am doing my operations. I guess i need to confront the 3rd party guys. Ok Thank you – Nitish Patra Jul 13 '18 at 08:45
1 Answers
2
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
- Client - Capture payment details
- 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.
- Queue service - Request payment status from gateway and update the database
- 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...)

Nuwan Attanayake
- 1,161
- 9
- 20
-
I see, well that's a good suggestion, but even if I run a queue, the payment gateway will send the response to my controller right, not to the queue? – Nitish Patra Jul 13 '18 at 08:48
-
You better not rely on a single payment request itself to get the result as a response(statefull).If you can configure the payment gateway to call separate controller function then you could even omit the queue entirely. – Nuwan Attanayake Jul 13 '18 at 08:54
-
That is where the issue comes in right, even if I make separate controller function, my server would be dead for receiving the response. The logic which you suggested sounds good because I will run my queue in Redis, which will run on another server. The question remains the same, will the payment gateway return the response to more than one endpoints ie caller function and the waiting queue – Nitish Patra Jul 13 '18 at 09:07
-
Yes and No.Some payment gateways will do ie citruspay has a method called "Return URL Response"(Drop Around mode) where you can state a return url to get the result.Also you might required to have revers_proxy to get the response to same domain address but into a separate application(in this case queue service) – Nuwan Attanayake Jul 13 '18 at 09:23
-
@nuwam, That should be really helpful. I need to look into the docs to get more idea into that. – Nitish Patra Jul 13 '18 at 09:33