Data flow

Stripe Checkout & webhooks

ArticlePaywall redirects to Stripe Checkout. Webhook checkout.session.completed records purchases or subscriptions in MySQL.

sequenceDiagram
    participant R as Reader
    participant FE as ArticlePaywall
    participant API as FastAPI
    participant Stripe as Stripe
    participant WH as Webhook
    participant DB as MySQL
    R->>FE: Unlock
    FE->>API: POST /monetization/checkout/article
    API->>Stripe: Create session
    API-->>FE: checkout_url
    Stripe->>WH: session.completed
    WH->>DB: Payment + purchase

Dev without STRIPE_SECRET_KEY: instant ledger purchase (development only). Production requires Stripe keys when PAYMENTS_ENABLED=true.

Webhook URL: POST {BACKEND_URL}/api/v1/monetization/stripe/webhook