@icy anvil
I figured out a workaround to test future subscription invoices. Also seems like a good way to get all customers on the same payment schedule.
- Create the subscription
- Save it in your database
- Update that subscription to a trial for the following month
- Go into Stripe dashboard and end the subscription trial
- Capture the
charge.succeeded and invoice.payment_succeeded with webhook & CLI
Here are the steps: (Working in Laravel / PHP)
/*
* Creating the UNIX Timestamp.
* This will grab today's date and make a UNIX Timestamp for the following month on the 1st
*/
$this->now = Carbon::now()->setTimezone('America/Chicago');
$this->firstOfNextMonthUnix = Carbon::parse($this->now)->addMonth()->startOfMonth()->setTime(8, 0, 0, 0)->timestamp;
/*
* Creating the Subscription In STRIPE.
* This will charge the full price of the subscription immediately
*/
$subscriptionStripe = $stripe->subscriptions->create([
'customer' => auth()->user()->stripe_id,
'default_payment_method' => $paymentMethod->id,
'items' => $items,
'metadata' => [],
]);
/*
* Add the newly create subscription in your database.
*/
$subscription = Subscription::create([
'stripe_id' => $subscriptionStripe->id,
'stripe_payment_method_id' => $paymentMethod->id,
// etc...
]);
/*
* Update the Subscription
* This will update the subscription to a trial
* The next invoice will end on the 1st day of the following month
*/
\Stripe\Subscription::update($subscription->stripe_id, [
'default_payment_method' => $subscription->stripe_payment_method_id,
'trial_end' => $this->firstOfNextMonthUnix,
'proration_behavior' => 'none',
]);
Now you can go into your Stripe dashboard or use CLI and update the subscription trial to end now.
This will allow you to test for the next months subscription