This tutorial takes you through the steps to offer free trials in your app using Lemon Squeezy and its API.
How to offer free trials in your SaaS application
There are two typical ways to offer your customer free trials in your app.
1. No payment required
The first allows access for a certain time period after sign up, and then prompts the user to sign up to a plan once the trial period ends.
This is perhaps the most common option. For this to work you need to track each user's trial period in your local data. Then, once the trial period ends, you should prompt your users to sign up to a paid subscription. This is when you would send the user to a Lemon Squeezy-powered checkout.
This method usually means higher sign up rates (no friction to get signed up) and a lower trial-to-paid conversion rate (more, less-qualified signups).
2. Payment required
The second option is to capture the payment details of a customer as they sign up to your product, and onto a subscription with a free trial.
During the sign up flow, users would be shown a checkout and they would have to input their payment details to be gain access to the product.
The subscription they would be signed up for would have a free trial baked in and would charge the customer automatically when the trial period ends, unless the subscription is cancelled before that date.
This method usually means lower sign up rates (the payment request puts some users off signing up) and a higher trial-to-paid conversion rate (the people who have signed up are more likely to continue).
How to set up free trials without a payment
For this method, most of the logic happens in your application.
One way to do this is to save a "trial end" date in your user objects. For example take today's date, add your trial length, then save it into your database.
Then you should check against that trial end date whenever the user visits your app to determine if the user has access. If they visit after their trial end date, you could show them a modal window or force them to your billing pages using a redirect.
In Lemon Squeezy, you would need to create a regular subscription product without a free trial. When the user needs to start paying for access, create a checkout and then use webhooks to sync the subscription data to your application.
There are detailed examples for building an API integration in our Developer guide.
A benefit of this method is that it gives you some added flexibility to offer custom trial lengths to different users as you can easily tweak the "trial end" date value.
How to set up free trials with payment required
This method requires you to charge your customers as they sign up to your product. The free trial period is part of an active subscription rather than a period of free access controlled by your app.
This is how you can set up free trials using Lemon Squeezy products.
1. Create subscription products with trials
First, create a subscription product with a free trial in Lemon Squeezy.
You can do this by enabling the "Subscription has free trial?" option in the product editing panel.
You have the option to create trials for a certain number of days, weeks, months or years.
In Lemon Squeezy, you can set a different trial length for each product or variant in your store, giving you a lot of flexibility in how you offer trials for your different subscription plans.
2. Set up free trials in your app
Now you have your products in Lemon Squeezy, you need to build an API+webhooks integration into your app. Read our Developer guide if you haven't done this step already.
For an app offering free trials with a payment, you should present the customer with a checkout just after signup, so you get them set up on a trial subscription as soon as possible.
When a customer signs up to a product with a trial, Lemon Squeezy captures their payment method and delays the first payment until the end date of the trial. The
trial_ends_at value found in Subscription objects (available in both the API and sent in subscription-related webhooks) can be used in your app to display to your users when their trial ends.
Using webhooks or the API, you should save the
status of your subscriptions to know if your customer has access to your application. Access should be allowed for subscriptions with a status of
past_due, and optionally
Make sure to subscribe to
subscription_updated webhook events so you can save the
status value if it ever changes.
status will be
on_trial during a trial period and then change to
active if the first payment is captured,
past_due if the first payment fails, or
cancelled if the customer cancels the subscription during the trial period.