I'm creating subscription with Laravel Cashier (Stripe). I would like to set it up so regardless of what day of the month the user subscribes, it charges them the FULL amount immediately and then sets the anchor date for the 1st of every three months after that.
For example, someone who subscribes on March 8th would follow the following payment intervals:
I have tried this, but it is still prorating the first charge:
$anchor = Carbon::now()->addMonths(3);
$anchor = $anchor->startOfMonth();
$subscription = $request->user()
->newSubscription('default', 'price_id')
->anchorBillingCycleOn($anchor->startOfDay())
->noProrate()
->create($request->paymentMethod);
Any help is appreciated!
You also need to set backdate_start_date
(see api ref) to the 1st of the current month in your request to create a Subscription. One thing to be aware of is that using this will mean the start_date
and creation_date
of your subscription will no longer be the same - the start_date
will be the same as backdated start date you specify.
Referencing the example you already gave - if you were to create a Subscription on March 8th you would want to set billing_cycle_anchor
to June 1st (which your code is already doing) and backdate_start_date
to March 1st (which you'll need to add). This will immediately create an invoice for the amount of time between March 1st and June 1st, with the next invoice being created on June 1st. Stripe's documentation talks about this here.
The above information is more general to Stripe rather than Laravel cashier. In order to set billing_cycle_anchor
with Laravel cashier your request should look something like this:
$subscription = $request->user()
->newSubscription('default', 'price_id')
->anchorBillingCycleOn($anchor->startOfDay())
->noProrate()
->create($request->paymentMethod, [], ['backdate_start_date' => {{BACKDATED_START_DATE}},]);