5. Update Webhooks
Point Stripe webhooks to BillStack for automatic event routing and data sync
How Webhooks Work in BillStack
BillStack provides a per-team webhook endpoint that receives all Stripe events:
https://your-billstack.com/api/webhooks/stripe/{teamId}When a Stripe event arrives:
- BillStack verifies the
stripe-signatureheader using your webhook secret - The stripe-sync-engine syncs the raw event data into your team's isolated schema
- BillStack's webhook processor routes the event to the correct project based on customer metadata
- Project-level tables (customers, subscriptions, invoices) are updated automatically
- The event is recorded in the
webhookEventstable for idempotency
Supported Events
BillStack processes these Stripe webhook events:
| Event Type | What BillStack Does |
|---|---|
checkout.session.completed | Creates/updates subscription, converts referrals |
customer.created | Syncs customer to team schema |
customer.updated | Updates customer data |
customer.deleted | Marks customer as deleted |
customer.subscription.created | Creates subscription record, converts pending referrals |
customer.subscription.updated | Updates subscription status and details |
customer.subscription.deleted | Marks subscription as canceled |
invoice.paid | Updates invoice records |
invoice.payment_failed | Updates invoice status |
payment_intent.succeeded | Records payment |
payment_intent.payment_failed | Records failure |
product.created / updated | Syncs product data |
price.created / updated | Syncs price data |
charge.succeeded / failed | Records charge data |
Step 1: Get Your Webhook URL
curl https://your-billstack.com/api/billstack/teams/{teamId}/stripe/webhook-url \
-H "Cookie: <session-cookie>"Response:
{
"webhookUrl": "https://your-billstack.com/api/webhooks/stripe/team_abc123",
"instructions": "Add this URL as an endpoint in your Stripe Dashboard"
}Step 2: Configure in Stripe Dashboard
- Go to Stripe Dashboard > Developers > Webhooks
- Click Add endpoint
- Paste your BillStack webhook URL
- Select all events (or at minimum the events listed above)
- Click Add endpoint
- Copy the signing secret (
whsec_...) shown after creation
Step 3: Update the Webhook Secret
If you used a placeholder webhook secret during Step 1: Connect Stripe, update it now:
curl -X POST https://your-billstack.com/api/billstack/teams/{teamId}/stripe/connect \
-H "Content-Type: application/json" \
-H "Cookie: <session-cookie>" \
-d '{
"secretKey": "sk_live_...",
"publishableKey": "pk_live_...",
"webhookSecret": "whsec_actual_secret_from_stripe"
}'Step 4: Disable Your Old Webhook Endpoint
Once BillStack is receiving events:
- Go back to Stripe Dashboard > Webhooks
- Find your old webhook endpoint (the one pointing to your SaaS app directly)
- Click ... > Disable (don't delete yet — keep it as a safety net)
Verifying Webhooks
Trigger a test event from the Stripe Dashboard:
- Go to your webhook endpoint in Stripe
- Click Send test webhook
- Select an event type (e.g.,
customer.created) - Click Send test webhook
Then verify the event was processed:
curl https://your-billstack.com/api/billstack/teams/{teamId}/projects/{projectId}/analytics \
-H "Authorization: Bearer bs_..."The webhookStats field in the analytics response shows total, processed, and failed event counts.
Keeping Your Old Webhooks (Transitional)
During migration, you can run both webhook endpoints simultaneously:
- Keep your old endpoint active
- Add the BillStack endpoint as a second endpoint
- Stripe sends events to both
- Once you've verified BillStack handles everything correctly, disable the old one
This allows a gradual transition with zero downtime.
Next Step
With webhooks configured, set up the customer portal to replace Stripe's hosted portal.