Setup LemonSqueezy
Prerequisites
- Create a Lemon Squeezy account and a Store.
Setup
The LemonSqueezy integration has three main components:
- Creating a product and variants
- Setting up a webhook
- Enable API
At the end of the setup you should fill the .env
file like this:
You should be able to add the KEY_LEMON_SQUEEZY_STORE_ID
. You can find it at https://app.lemonsqueezy.com/settings/stores
next to the store URL (copy the ID without the hash!)
Creating a product
A product in LemonSqueezy can be a single payment option or a subscription with variants (e.g weekly, monthly, etc..).
-
New product
-
Fill the name and description
-
Select pricing model (single or subscription)
-
If you select subscription:
- Skip the pricing section for now.
- Under “Variants” click “Add Variant”
- Define your variant name and price (e.g Weekly)
- Save and add other variatns if you want
-
If you select single payment. Fill the pricing info.
-
Ignore the rest of options and save the product.
-
Copy the product ID (dropdown menu) and save it in your
.env
file.
Setting up a WebHook
-
Click the ’+’ button
-
Use your deployed Firebase Function URL
-
You can define a secret and check it matches in the function (ignored by default)
-
Select the event types based on your product type:
- order_created (mandatory)
- subscription_created
- subscription_updated
- subscription_payment_succeeded
-
Save webhook.
Setting up LemonSqueezy API
Go to https://app.lemonsqueezy.com/settings/api and create an API key. Then save it to the .env
file.
After that you can deploy the Firebase functions with the new credentials and automatically fill the Firestore
payments collection by calling the items_updated
event: