Phase 14, part 3: Stripe's events
/billing/stripe takes Stripe's webhooks, signatures checked, each event handled once, and keeps each team's subscription up to date: checkout, its status, seats and period, failed and paid invoices, cancellation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3255,6 +3255,23 @@ Checkout; both are off until set.
|
||||
cancelling). Admins see the plan without the payment details or the
|
||||
buttons.
|
||||
|
||||
**Part 3 built 2026-11-26.**
|
||||
- `POST /billing/stripe` takes Stripe's events: its `Stripe-Signature`
|
||||
checked (HMAC-SHA256 of the timestamp and body, with
|
||||
`SUPERMARKET_STRIPE_WEBHOOK_SECRET`; within 5 minutes; either of two
|
||||
signatures while a secret is rolled). Each event is handled once
|
||||
(`stripe_events`), whichever copy it reaches; a failure answers 500, so
|
||||
Stripe sends it again.
|
||||
- Followed: `checkout.session.completed` (the team's customer and
|
||||
subscription), `customer.subscription.created`, `.updated` and
|
||||
`.deleted` (status, people paid for, the period's end, the trial's end;
|
||||
`unpaid` and `incomplete` count as past due), `invoice.payment_failed`
|
||||
and `invoice.paid`. Falling past due notes when; catching up forgets it.
|
||||
Customers that aren't a team's (another product on the same Stripe
|
||||
account) are left alone. Each change goes in the team's audit log.
|
||||
- Stripe's dashboard needs the endpoint `https://<domain>/billing/stripe`
|
||||
with those events.
|
||||
|
||||
#### Order
|
||||
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user