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>Webhookssection on Lemonsqueezy dashboard - Click on the
+icon to add a new webhook - Use
<you-app-host>/api/payment-webhook/lemonsqueezyas theCallback URL - Generate a random
Secretand paste it in theSecretfield - Select all the events
- Save the webhook
- Set the secret in the
LEMONSQUEEZY_WEBHOOK_SECRETenvironment variable in the.envfile
API Key
- Go to
Settings>APIsection 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_KEYenvironment variable in the.envfile
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.