Files
Komediruzecki 6e4d1f6b3a chore(billing): harden Stripe webhook + finish go-live wiring (CR-11/12/13)
Billing stays inert (/api/billing/* -> 501) until keys are set; this makes the code production-ready
so dev can go live by just adding values.

- Idempotency: every event id is recorded in stripe_events (migration 0009); a redelivery is a no-op.
  Ordering: a per-customer users.stripe_event_at watermark drops stale/out-of-order events, so a late
  subscription.updated can't resurrect a canceled plan (CR-12).
- Dunning grace: past_due keeps the paid plan; only canceled/unpaid/incomplete_expired drop to free
  (CR-13). Also handle customer.subscription.created.
- current_period_end read from the subscription item with a top-level fallback; pin
  Stripe-Version 2024-06-20 on outbound calls (CR-11).
- Checkout/portal return to .../#settings, and ?billing=success lands on the Billing tab.
- wrangler.jsonc + .dev.vars.example stub the per-tier Price vars (STRIPE_SECRET_KEY /
  STRIPE_WEBHOOK_SECRET are secrets). Full steps + "what I need" checklist in billing-setup.md.
2026-06-30 00:54:29 +02:00

23 lines
1.2 KiB
Plaintext

# Copy to `.dev.vars` for local `wrangler dev` (gitignored). Set real values.
# Production secrets are set with `wrangler secret put NAME` instead.
APP_ENV="development" # drops the Secure cookie flag so http://localhost works
JWT_SECRET="dev-only-change-me" # HMAC key for session JWTs + OAuth state
GOOGLE_CLIENT_ID="PLACEHOLDER.apps.googleusercontent.com"
GOOGLE_CLIENT_SECRET="dev-google-client-secret"
CORS_ORIGIN="http://localhost:3800"
# Optional — Cloudflare Turnstile secret. Unset = captcha gate disabled. Set this AND the frontend
# VITE_TURNSTILE_SITE_KEY to enforce the captcha on the register/login/forgot endpoints.
# TURNSTILE_SECRET="dev-turnstile-secret"
# Optional — Stripe billing (use TEST-mode values locally). Unset → /api/billing/* returns 501.
# Secrets:
# STRIPE_SECRET_KEY="sk_test_..."
# STRIPE_WEBHOOK_SECRET="whsec_..." # from `stripe listen` or a test webhook endpoint
# Per-tier Price ids (vars, not secret — fine to keep here for local dev):
# STRIPE_PRICE_BASIC_MONTHLY="price_..."
# STRIPE_PRICE_BASIC_ANNUAL="price_..."
# STRIPE_PRICE_ADVANCED_MONTHLY="price_..."
# STRIPE_PRICE_ADVANCED_ANNUAL="price_..."
# STRIPE_PRICE_ULTIMATE_MONTHLY="price_..."
# STRIPE_PRICE_ULTIMATE_ANNUAL="price_..."