Would it work to theoretically create a table that stores all the future charges and then schedule a task that runs every minute to see if it is time to charge a user's model?
User::charge('500')
Does the following logic make any sense?
I think I am not fully grasping some of the concepts, because it appears to me that if I use the below and the Stripe customer exists, the card would never get updated even if they chose to pay with a different card?
private function singleCharge($when)
{
try {
$customer = $this->user->asStripeCustomer();
if (! $customer) {
$customer = $this->user->createAsStripeCustomer(request('stripeToken')['token']['id'], [
'email' => request('stripeData')['email']
]);
}
} catch (\Exception $e) {
return response()->json(['status' => $e->getMessage()], 422);
}
// create the charge in Stripe
try {
$this->user->charge($this->price['orderTotal'] * 100, [
'description' => 'Single Charge - Order ID: '.$order->id.', Restaurant: '.$this->restaurant['name'],
'metadata' => $metaData,
]);
} catch (\Exception $e) {
return response()->json(['status' => $e->getMessage()], 422);
}
}
Any advice would be greatly appreciated!
Thanks!!