Let me break down the issue as per my understanding so we make sure I'm answering the correct question;
You have a system that has a wallet feature.
This wallet needs to hold some money and make the money unavailable to be paid out (hold status)
Then after 14 days, the money gets paid automatically without any interaction.
If I'm correct, then keep reading the answer below. If i'm not, correct me with a comment and I'll update my answer accordingly.
Answer:
We will create a new table. Let's call it pending_payments
. It'll have the following information: user_id
, payment_amount
, pay_at
That table will hold information about pending payments and to which user they should be paid as well as the amount and the date it should be paid at.
We'll have a Laravel job that can be automated ( read this for more information: https://laravel.com/docs/9.x/scheduling) which will do the following:
a. Run daily on a specific time. Let's say at 13:00
daily for ease.
b. It'll check the pending_payments
table for payments that should be paid today.
c. Pay them ( which means run whatever function/task you have to run in order to process the payment).
d. On a successful payment, remove the row from pending_payments
table. And on a failure payment, log the error and insert the row again with a later date to be retried again later.
That's it.