Webhooks
TurboStack provides webhook endpoints for handling events from Polar.sh.Configuration
Add your webhook secret to.env:
Handled Events
| Event | Handler |
|---|---|
order.created | Creates order record |
order.paid | Provisions access, sends confirmation |
order.refunded | Revokes access |
subscription.created | Creates subscription record |
subscription.updated | Updates subscription status |
subscription.canceled | Revokes premium access |
checkout.created | Logs checkout start |
product.created/updated | Syncs product data |
customer.created/updated | Syncs customer data |
Customizing Handlers
Editapps/backend/src/services/polar.service.ts to add your business logic:
Testing Webhooks
Local Development
Use a tool like ngrok to expose your local server:Send Test Events
Polar dashboard allows sending test webhook events to verify your integration.Security
Webhooks are verified using HMAC signatures. ThevalidateWebhookEvent function automatically verifies the signature before processing any event.