feat(story-5.3): add Stripe webhook subscription lifecycle handlers

- Add migration 125: subscription_current_period_end column
- Add PLAN_LIMITS config (free/pro_monthly/pro_yearly token + pages limits)
- Add subscription webhook handlers: created/updated/deleted, invoice payment
- Handle checkout.session.completed for subscription mode separately from PAYG
- Idempotency: subscription_id + status + plan_id + period_end guard
- pages_limit upgraded on activation, gracefully downgraded on cancel
- Token reset on subscription_create and subscription_cycle billing events
- Period_end forward-only guard against out-of-order webhook delivery

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Vonic 2026-04-15 00:43:07 +07:00
parent 07a4bc3fc3
commit 20c4f128bb
7 changed files with 381 additions and 27 deletions

View file

@ -35,7 +35,7 @@
# - Dev moves story to 'review', then runs code-review (fresh context, different LLM recommended)
generated: 2026-04-13T02:50:25+07:00
last_updated: 2026-04-14T17:00:00+07:00
last_updated: 2026-04-15T00:14:00+07:00
project: SurfSense
project_key: NOKEY
tracking_system: file-system
@ -68,6 +68,6 @@ development_status:
epic-5: in-progress
5-1-pricing-plan-selection-ui: done
5-2-stripe-payment-integration: done
5-3-stripe-webhook-sync: ready-for-dev
5-3-stripe-webhook-sync: done
5-4-usage-tracking-rate-limit-enforcement: ready-for-dev
epic-5-retrospective: optional