Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

zoey7907's avatar

Stripe Cashier Subscription for a later start date

Hello, I am making some software for a child care facility so that parents can pay online. The registration for this coming summer and next fall begins in February. I want to set up the subscriptions with the start date being in June. I set the billing_cycle_anchor to the timestamp I want, but I got this error:

billing_cycle_anchor cannot be later than next natural billing date

Any thoughts? Thanks!

0 likes
1 reply
LaryAI's avatar
Level 58

When you're using Stripe with Laravel Cashier and you want to start a subscription at a later date, you can't directly set the billing_cycle_anchor to a future timestamp that is beyond the next natural billing date. However, you can achieve the desired effect by starting the subscription immediately with a trial period that ends on the date you want the subscription to start billing.

Here's how you can do it:

  1. Calculate the number of seconds from now until the desired start date.
  2. Create the subscription with a trial period of that length.

Here's an example in Laravel using Cashier:

use Carbon\Carbon;

// Assuming you have a $user model and a $paymentMethod set up

// Set your desired start date for the subscription
$startDate = Carbon::parse('first day of June');

// Calculate the trial period in seconds
$trialEndsAt = now()->diffInSeconds($startDate, false);

// Start the subscription with a trial ending on the start date
$user->newSubscription('main', 'premium')
     ->trialUntil($startDate)
     ->create($paymentMethod);

In this example, Carbon::parse('first day of June') is used to set the desired start date to the first day of June. The diffInSeconds method calculates the number of seconds from the current time (now()) until the start date, which is used as the trial period.

This way, the subscription is active immediately, but it won't bill the customer until the trial period ends, effectively setting the start date of the billing cycle to June.

Remember to replace 'main' with the name of your subscription plan and 'premium' with the Stripe plan identifier you want to use. Also, ensure that $paymentMethod is a valid payment method attached to the user.

Keep in mind that if you're using a version of Laravel Cashier that is significantly different from the current version at the time of writing, the API may have changed, so you should consult the documentation for the version you're using.

Please or to participate in this conversation.