stripe-paymentssubscriptiontrial

How to handle re-subscription to a Stripe plan with a trial period?


What happens if a customer re-subscribes to a plan that has a trial period?

To be more precise:

  1. A customer subscribes to a plan with a 30 day trial period.
  2. When this trial period ends, the customer decides to cancel the subscription.
  3. The customer later re-subscribes to the plan.

Will they have access to the trial days again?

How am I able to determine if the user has already consumed the trial period so I can process their re-subscription without a trial period?


Solution

  • My solution:

    I check if the customer has a cancelled subscription for this plan. If it's the case, I create a subscription with trial_end to 'now':

    if len(stripe.Subscription.list(status='canceled', customer=stripe_customer_id, plan=plan_id)['data']) > 0:
        stripe.Subscription.create(
            customer=stripe_customer_id,
            plan=plan_id,
            trial_end='now')     
    else:                
        stripe.Subscription.create(
            customer=stripe_customer_id,
            plan=plan_id)