stripe-samples / firebase-subscription-payments

Example web client for the `firestore-stripe-subscriptions` Firebase Extension using Stripe Checkout and the Stripe Customer Portal.
https://stripe-subs-ext.web.app/
MIT License
289 stars 78 forks source link

Product - Pricing - Trials not working #17

Closed atnegrete closed 3 years ago

atnegrete commented 3 years ago

Bug report

Describe the bug

The "Trial Days" from the Product Price is being ignored.

Per the docs: By default, the trial period days that you’ve specified on the pricing plan will be applied to the checkout session

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Go to Stripep and create a Product and Assign a Price with Trial Days
  2. Create a subscription with this Product & Price
  3. No trial days are applied.

Expected behavior

Subscription is created with trial days from the pricing.

Additional context

Could this be the issue? image

cjavilla-stripe commented 3 years ago

Thanks for the bug report. We'll take a look. In the mean time, you might try setting subscription_data.trial_period_days on the session.

https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-subscription_data-trial_period_days

atnegrete commented 3 years ago

@cjavilla-stripe Thanks for the quick response!

I added the following to the checkout_session

 subscription_data: {
          trial_period_days: 30,
        },

I did several attempts, but nothing on the checkout displays that there is a trial, and when I check on Stripe Dashboard there is no trial applied.

cjavilla-stripe commented 3 years ago

Can you share a Checkout session ID or request ID so we can take a look in the logs?

atnegrete commented 3 years ago

I have a sub I'd, I can get a checkout session when I get off work today.

sub_IYkuP9JG4aW82u

atnegrete commented 3 years ago

@cjavilla-stripe I have a checkout sesion id WkwmozNNRV9d9eAwJJEi

cjavilla-stripe commented 3 years ago

Thanks @atnegrete,

For that subscription, it seems that trial_from_plan was set to false when the checkout session was created. Can you share the code you're using for the checkout session creation?

I believe you'll want:

trial_from_plan: true,
atnegrete commented 3 years ago

@cjavilla-stripe I misunderstood the trial_from_plan field, I thought stripe would automatically handle not giving the trial again...! Closing.. thanks!!

Closing as it's otherwise a dup of https://github.com/stripe/stripe-firebase-extensions/issues/105