LemonSqueezy
SaaSBold comes with LemonSqueezy integration for managing subscriptions. This part of the documentation, will show you how to integrate LemonSqueezy into your SaaS boilerplate.
Overview
LemonSqueezy is a user-friendly platform for subscription management. This guide will provide step-by-step instructions for integrating LemonSqueezy, covering store creation, product setup, API key generation, and webhook configuration.
Note
If you want to use another payment provider for integration, skip this step. Instead, follow the Stripe or Paddle guides to integrate subscriptions.
Create a Store
To begin integrating, you need to create a store in LemonSqueezy.
-
Log in to your LemonSqueezy account and go to Dashboard (opens in a new tab).
-
Click on the three dots and select "Create a Store".
Now that you have created the Store, we have the Store ID.
-
Go to Settings > Stores. You will see all your stores listed here. Find the Store ID next to the Store URL.
Copy the Store ID and update the environment variable:
LEMON_SQUEEZY_STORE_ID="YOUR_STORE_ID"
Add Products
Next, we have to add products in our LemonSqueezy store:
-
Go to
Products
and click on the "New Product" button. It will open up a sidebar. -
Fill in the product details and add variants. For this demo, we've added three variants.
-
After creating the product variants, copy the Variant IDs and update the
pricingData.ts
file with these IDs.You can copy the Variant ID from each of the Variants.
Generate API Key
To interact with LemonSqueezy, Now we need an API key. Let's Generate the API Key
-
Go to Settings > API and click on the plus icon to generate an API key.
Copy the API key and update the environment variable:
LEMON_SQUEEZY_API_KEY="YOUR_API_KEY"
Webhook Integration
We’ve created the products and generated the API key. Now, we have to integrate Webhook to save the subscription data on the Database.
-
Go to Settings > Webhook and click on the plus icon, it will open a sidebar like this:
-
Add the webhook URL as follows:
yoursite.com/api/lemon-squeezy/webhook
-
Add Signing Secret: Provide a signing secret of your choice (it could be anything you want).
Copy the secret and update your environment variable:ini LEMON_SQUEEZY_WEBHOOK_SIGNATURE="YOUR_SECRET"
-
Select the actions to be triggered by the webhook. For now, select all actions. You can customize this later.
-
Click the "Save Webhook" button to finalize the integration.
Tips
- Testing: Use LemonSqueezy's test mode to thoroughly test the integration before going live.
- Documentation: Refer to LemonSqueezy’s official documentation for detailed instructions and troubleshooting.
- Security: Ensure that API keys and webhook secrets are stored securely and not exposed.
- Event Selection: Select only the webhook events necessary for your application to minimize unnecessary data processing.
Summary
By following these steps, you will have integrated LemonSqueezy into your SaaSBold boilerplate, enabling seamless subscription management. Be sure to test the integration thoroughly to ensure all functionalities work correctly.