laravel / cashier-stripe

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.
https://laravel.com/docs/billing
MIT License
2.37k stars 667 forks source link

[15.x] Fix anchorBillingCycle for subscription checkout #1659

Closed ybert closed 5 months ago

ybert commented 5 months ago

At the moment it is impossible to use newSubsciption builder , add an anchorBillingCycle and create a checkout.

This PR fix this to make this code work :

$checkoutBuilder = $user
            ->newSubscription('default', ['price_yearly'])
            ->anchorBillingCycleOn(Carbon::tomorrow())
            ->noProrate()
            ->checkout();

Before, this code did a checkout but does not add anchorBillingCycle date and proration_behavior to the POST data to stripe as expected here : https://docs.stripe.com/payments/checkout/billing-cycle?ui=stripe-hosted#create-session

It resolves https://github.com/laravel/cashier-stripe/issues/1658