Handle Stripe webhook events to sync subscription status with Clerk
checkout.session.completedclient_reference_idstripeCustomerId, stripeSubscriptionId, and subscriptionStatus in organization metadatacustomer.subscription.updatedsubscriptionStatus in Clerk user metadata"active" for active or trialing subscriptions"inactive" for other statescustomer.subscription.deletedsubscriptionStatus to "cancelled" in Clerk user metadata"success" when the webhook was processed successfully| Status | Description |
|---|---|
| 400 | Invalid payload or invalid Stripe signature |
https://searchcompany-main.up.railway.app/webhooks/stripecheckout.session.completedcustomer.subscription.updatedcustomer.subscription.deletedSTRIPE_WEBHOOK_SECRET environment variable| Variable | Description |
|---|---|
STRIPE_API_KEY | Stripe API secret key |
STRIPE_WEBHOOK_SECRET | Webhook signing secret from Stripe Dashboard |
CLERK_SECRET_KEY | Clerk secret key for updating user/org metadata |