Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set up free trial payment option? #321

Open
Akshath-Nagulapally opened this issue Mar 28, 2024 · 4 comments
Open

How to set up free trial payment option? #321

Akshath-Nagulapally opened this issue Mar 28, 2024 · 4 comments

Comments

@Akshath-Nagulapally
Copy link

Hi, In the db autofill I see a free trial option for any user who is "trialing". This is a very important feature for my app in specific. It is not detailed in the readme.md file how to set up a free trial for any customer before they start using the product so I was wondering how it is meant to be set up?

@Akshath-Nagulapally Akshath-Nagulapally changed the title How to set up free trial? How to set up free trial payment option? Mar 28, 2024
@szymonhernik
Copy link

bump. i think there is lack of coherence between the stripe docs and the template atm. from my understanding you can't set up trial_period_days in Stripe anymore, and the functions in the starter use these values to calculate calculateTrialEndUnixTimestamp. can anyone help to clarify?

@Akshath-Nagulapally
Copy link
Author

oh I see. Though that could be true, I tried setting up the stripe trial period and it did work and reflect in the DB. How recent was this change to stripe as I tried doing this 3 days after started this thread.

@fullstackwebdev
Copy link

oh I see. Though that could be true, I tried setting up the stripe trial period and it did work and reflect in the DB. How recent was this change to stripe as I tried doing this 3 days after started this thread.

are you saying it works now? was it a missing stripe event or code base?

@szymonhernik
Copy link

szymonhernik commented Apr 17, 2024

Here is a step by step guide for you. Hope it helps.

TO DO to add trial

  • in admin.ts change TRIAL_PERIOD_DAYS to number of days
    • push changes
  • on price update (in Stripe) this should update the price with that value
    • you can test it by adding new price or editting an existing one
    • listen to webhooks for price.updated event
    • to check if the trial_period_days on price has been updated console.log prices -> it should return trial_period_days: 7 (or any other number you set up)
  • now you will work with the stripe/server.ts file. when creating stripe checkout session you will want to make sure the console.log that is already there (Trial end: ...) will console log correct UnixTimestamp (result of calculateTrialEndUnixTimestamp called later when setting params on recurring payment)
    • it should return something like 'Trial end: 1714042027' when you click Subscribe on the price you added or edited before and in the stripe checkout page it should give you some info on the left about the trial being set up, for example "Tryout Basic: 7 days for free. Next 5,00 eur per month"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants