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 671 forks source link

Add `Conditionable` trait to subscription builder #1573

Closed maartenpaauw closed 11 months ago

maartenpaauw commented 12 months ago

Example code:

return $tenant->newSubscription($plan, $priceId)
    ->allowPromotionCodes()
    ->when($trailDays, fn (SubscriptionBuilder $builder) => $builder->trialUntil(Carbon::now()->endOfDay()->addDays($trialDays)))
    ->collectTaxIds()
    ->checkout([
        'success_url' => Dashboard::getUrl(),
        'cancel_url' => Dashboard::getUrl(),
    ])
    ->redirect();