laravel / cashier-stripe

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

Trial date not being set from Plan from Stripe #691

Closed paulcanning closed 5 years ago

paulcanning commented 5 years ago

I made a new plan in Stripe, giving it a 30 day trial period.

I have then subscribed a user to this plan, and whilst the subscription table now has a new record, it's missing the trial_ends_at date.

I see in the docs I can set the number of trial days, but surely that defeats the purpose of setting it in Stripe?

Which one takes precedence? If my plan in Stripe is set to 30 days, and I set it to 10 or even 60 in Laravel, which one is actually used?

What am I missing?

driesvints commented 5 years ago

Trial dates in Cashier take precedence over Stripe trial days because Cashier allows you to work with a trial period without a credit card up front. That's why a custom way of working with trial days was built in. You should just leave your trial days on plans untouched when creating them.

When a subscription is created, the trial_ends_at parameter on the subscription will be set from whatever trial days you're passing with the trialUntil or trialDays methods.

driesvints commented 5 years ago

I've sent in a PR to add a note about this to the docs: https://github.com/laravel/docs/pull/5271

ghost commented 5 years ago

So if I make a price plan on Stripe with no trial set, and I set one in Cashier, how does it know when to bill the customer?

If it subscribes the customer to that plan in Stripe, its going to start billing them right away?

driesvints commented 5 years ago

So if I make a price plan on Stripe with no trial set, and I set one in Cashier, how does it know when to bill the customer?

Like I said above, it overwrites the trial_ends_at parameter when it creates a subscription. See https://stripe.com/docs/api/subscriptions/create#create_subscription-trial_end

ghost commented 5 years ago

@driesvints sorry, so just to be clear, even if a plan has a trial period set, individual customers can have a custom trial period? (ignoring Cashier, is this something that Stripe does?)

driesvints commented 5 years ago

@paul-gene the trial_ends_at parameter is meant to overwrite the plan's trial period so each subscription can have its custom trial ending. So basically, yes.

ghost commented 5 years ago

Thank you for clarifying :)

tquiroga commented 5 years ago

Could Cashier not have a method trialFromPlan() ? Stripe sets trial_from_plan to false by default, it means you will always need to specify it in the code... I would like to be able to use the one I set straight on Stripe and avoid to have to go change my ENV variables...

driesvints commented 5 years ago

@tquiroga this isn't supported unfortunately.

tquiroga commented 5 years ago

@driesvints That could be easily added I believe and would allow people to not have to match their code with what they set in Stripe.

Bronco84 commented 4 years ago

So if I understand this correctly, the skipTrial method is for existing subscriptions that have a trial_ends_at parameter already filled to remove it for whatever reason.

I was a bit confused at first. I assumed the default behavior of cashier was to honor any existing default trial period in the stripe plan it is about to use and I could use that method to skip the trial. Perhaps it could be included in the notes? Took me a minute to realize that was happening. Especially because it mentions this bit...

"When using the trialDays method, Cashier will overwrite any default trial period configured for the plan in Stripe."

This should probably be changed to explain cashier will not use any default trial period whether trialDays method is used or not. And it only honors the trialDays or trialUntil method for defining a trial period.