Polar.sh (Payments)
Webhooks Integration
Sync successful payments with your Supabase database.
When a user successfully pays on the Polar checkout page, Polar needs to tell your Supabase database: "Hey, this user is now a Premium member!" We do this using Webhooks.
1. Setup the Webhook Secret
- In your Polar dashboard, go to Settings > Developer > Webhooks.
- Click Add Endpoint.
- Enter your Supabase Edge Function URL (we provide the function in the
supabase/functions/polar-webhookfolder). It should look like this:https://your-project.supabase.co/functions/v1/polar-webhook - Select the events you want to listen to. We recommend:
order.created(For one-time purchases)subscription.createdsubscription.updatedsubscription.canceled
- Save the endpoint.
- Polar will generate a Webhook Secret. Copy it.
2. Add the Secret to Supabase
Now, you need to give this secret to your Supabase project so it can verify that incoming requests are actually coming from Polar.sh.
- Open your terminal in your project root.
- Run the following Supabase CLI command to set the secret securely:
npx supabase secrets set POLAR_WEBHOOK_SECRET=your_secret_from_polar- Deploy your edge function:
npx supabase functions deploy polar-webhookYour app is now fully ready to process payments and automatically upgrade users in your database!
