Search code examples
laravelstripe-paymentslaravel-cashier

How can i add trial period when update subscription plan?


I am currently using Cashier (Stripe) to the Plan subscription. I am currently using $this->subscription->swapAndInvoice($this->selected->stripe_plan_id); like this to change the subscription plan. Here i want to know how can i add trial period (7days) when i change subscription plan? If anyone have any idea? please give your thoughts.


Solution

  • This doesn't appear to be an optional parameter directly in the swapAndInvoice function, but you should be able to update the subscription immediately before the swap to add a trial:

    $subscription->extendTrial(
      now()->addDays(7)
    );
    

    The docs say that if a trial exists, it will be preserved:

    If the user is on trial, the trial period will be maintained.