billing improvements

This commit is contained in:
Evan Jarrett
2026-05-18 22:10:20 -05:00
parent 63909aaca0
commit ecd689a7e1
12 changed files with 1146 additions and 39 deletions
+7 -4
View File
@@ -158,17 +158,20 @@ stripe trigger customer.subscription.deleted
## Webhook Events
The appview billing manager handles these Stripe events:
The canonical list of subscribed events lives in `pkg/billing/events.go` as the
`SubscribedEvents` slice. Use it when configuring a Stripe Dashboard webhook
endpoint or auditing an existing one.
| Event | Action |
|-------|--------|
| `checkout.session.completed` | Create/update subscription, set tier |
| `checkout.session.completed` | No-op (subscription.created does the tier work) |
| `customer.subscription.created` | Set crew tier from price ID |
| `customer.subscription.updated` | Update crew tier if price changed |
| `customer.subscription.updated` | Update tier; handles `past_due` (keep), `unpaid` / `incomplete_expired` (downgrade), `incomplete` (await) |
| `customer.subscription.paused` | Downgrade to free tier |
| `customer.subscription.resumed` | Restore tier from subscription price |
| `customer.subscription.deleted` | Downgrade to free tier |
| `invoice.payment_failed` | Log warning (tier unchanged until canceled) |
| `invoice.payment_failed` | Log only (Stripe Smart Retries handle retry + customer email) |
| `charge.dispute.created` | Log only (Stripe emails the account owner by default) |
## Plankowners (Grandfathering)