Lemonsqueezy
The kit comes with a webhook that you can configure on Lemonsqueezy to notify the app about multiple events of the payments such as orders, subscription events.
Configure Keys
You need to configure the webhook
and the API key
on Lemonsqueezy. Webhook
is used to listen to the payment events and the API key
is used to make requests to the Lemonsqueezy API.
Webhook
- Login to Lemonsqueezy dashboard
- Go to
Settings
>Webhooks
section on Lemonsqueezy dashboard - Click on the
+
icon to add a new webhook - Use
<you-app-host>/api/payment-webhook/lemonsqueezy
as theCallback URL
- Generate a random
Secret
and paste it in theSecret
field - Select all the events
- Save the webhook
- Set the secret in the
LEMONSQUEEZY_WEBHOOK_SECRET
environment variable in the.env
file
API Key
- Go to
Settings
>API
section on Lemonsqueezy dashboard - Click on the
+
icon to make a new API key - Give it a name and generate the key
- Set the key in the
LEMONSQUEEZY_API_KEY
environment variable in the.env
file
Map User Plans
You need to map the user plans to the products on Lemonsqueezy. This is done in the src/api/payment-webhook/lemonsqueezy.ts
file. An example shown below.
import {
Plan,
PLAN_LTD,
PLAN_MONTHLY,
} from "@/components/UserPlan";
const productIdPlanMap: Record<number, Plan> = {
404105: PLAN_LTD,
404106: PLAN_MONTHLY,
};
That should be all you need to do. You can customize the webhook from src/api/payment-webhook/lemonsqueezy.ts
file if you want.