feat(billing): Stripe-Code vollständig (Checkout, Portal, Webhooks) — Keys später

- /checkout: Subscription-Session (Karte), Customer-Wiederverwendung, locale de,
  Metadata auf Session+Subscription. TWINT bewusst weg (Stripe: nur Einmalzahlung).
- /portal: Stripe Customer Portal (kündigen/Karte/Rechnungen); Mock → /konto/.
- Webhook: + customer.subscription.updated (Status/Periode spiegeln, Instanz
  sperren/reaktivieren) + invoice.payment_failed (→ past_due).
- .env.example: Stripe-Setup-Anleitung; ADMIN_EMAIL→ADMIN_PASSWORD korrigiert.

Alles MOCK-fähig (CHANGE-ME → kein echtes Stripe). Echt-Test erst mit Keys.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-05-31 12:29:55 +02:00
parent 6471221dec
commit fb89094b63
2 changed files with 78 additions and 8 deletions
+15 -6
View File
@@ -13,18 +13,27 @@ PUBLIC_BASE_URL=http://localhost:8787
# ═══ Auth ═══
# JWT-Signatur-Secret für HOST-Kundenkonten. openssl rand -hex 32
JWT_SECRET=CHANGE-ME-min-32-zeichen
# Konto mit dieser E-Mail wird automatisch Admin (Betreiber-Bereich /admin).
ADMIN_EMAIL=karim@gabrielevarano.ch
# Passwort für den Betreiber-Bereich (/admin), getrennt von Kundenkonten.
ADMIN_PASSWORD=CHANGE-ME-admin-passwort
# ═══ Postgres (eigene HOST-DB, GETRENNT von Kunden-Rapport-Daten) ═══
DATABASE_URL=postgres://rapport_host:rapport_host@localhost:55432/rapport_host
# ═══ Stripe ═══
# Test-Mode-Keys (sk_test_… / pk_test_…) für lokale Entwicklung.
# Live-Keys (sk_live_…) erst in Produktion. Test-Karten: 4242 4242 4242 4242
# ═══ Stripe ═══ (solange CHANGE-ME → MOCK-Modus, kein echtes Geld)
# Setup wenn du so weit bist:
# 1. Stripe-Account, Test-Modus aktivieren
# 2. Entwickler → API-Keys: Secret Key (sk_test_…) → STRIPE_SECRET_KEY
# 3. Produkte: 3 Stück mit je 1 wiederkehrendem Preis (CHF/Monat) →
# Price-IDs (price_…) unten eintragen
# 4. Webhook auf https://DEINE-URL/api/billing/webhook, Events:
# checkout.session.completed, customer.subscription.updated,
# customer.subscription.deleted, invoice.payment_failed
# → Signing Secret (whsec_…) → STRIPE_WEBHOOK_SECRET
# Lokal testen: stripe listen --forward-to localhost:8787/api/billing/webhook
# TWINT: Stripe unterstützt es nur für Einmalzahlung, nicht Abos → Abo läuft
# über Karte; TWINT später als separater Einmal-Checkout.
STRIPE_SECRET_KEY=sk_test_CHANGE-ME
STRIPE_WEBHOOK_SECRET=whsec_CHANGE-ME
# Price-IDs aus dem Stripe-Dashboard (ein Recurring-Price pro Plan).
STRIPE_PRICE_SOLO=price_CHANGE-ME
STRIPE_PRICE_STUDIO=price_CHANGE-ME
STRIPE_PRICE_BUSINESS=price_CHANGE-ME