Reputation: 2994
In my controller method,
Once all the payment details are validated for format,
We initiate the payment.
Now, on initiation of this (and every other) payment, I need to schedule a Controller call in 15 min with parameters (payment gateway token) to check if the payment was completed..else dismiss it.
Now, I can use a cron every minute to check for payments made 15 minutes back. But running a one time scheduled call would put less effort and pressure on system than running a cron every minute endlessly.
I explored the options in laravel like queuing or task scheduling. But none of it is one-time call (task scheduling) or queuing in x minutes.
Is there something that I am missing or some feature in laravel on similar grounds for the given requirement?
Upvotes: 1
Views: 2198
Reputation: 73
I would personally create a ValidatePaymentJob, which you call in your controller method like this:
public function validatePaymentDetails()
{
//Logic for validation the payment details goes up here
dispatch(new ValidatePaymentJob($all, $needed, $parameters))
->delay(Carbon::now()->addMinutes(x));
}
Then in your ValidatePaymentJob you can make a call to your payment provider to check if the payment was successful or not. You could even pass your transaction object with it and set a succeeded property to true.
You can check out the docs for Jobs here
Upvotes: 2