Accepting payments and setting up a paywall
Settings -> Webhooks
and add a new Webhook
Add a new webhook to LemonSqueezy
https://yourwebsite.com/api/payments/lemonsqueezy
& select all events.
LEMON_SQUEEZY_WEBHOOK_SECRET
to your .env
file.
Select all events & specify your LEMON_SQUEEZY_WEBHOOK_SECRET
app/api/payments/lemonsqueezy/route.ts
you’ll find an API route that handles both one-time-payments and subscriptions from LemonSqueezy.
It will do the following:
LEMON_SQUEEZY_WEBHOOK_SECRET
variant_id
profiles
table
purchase
column of the matching user in the profiles
table based on the logic you specify in the webhook. Feel free to add any logic here you’ll use in your app to handle page access.purchases
table with a new entrypurchases
table should already exist if you followed the Quick Setup guide and ran the Supabase migrations using the CLI:
supabase/migrations/20240000000007_purchases.sql
Make sure RLS is turned on. We don’t need to add any rules as we’ll be using the service key for to interact with this table.
app/api/payments/lemonsqueezy/route.ts
to add more credits after a succesfull purchase.
purchase
column having
a specific value. This allows for handling lifetime access systems or
subscriptions.toolConfig.ts
).PaymentModal
component.