Payments
Stripe subscriptions on the edge, checkout, a billing portal, and signature-verified webhooks.
Note
Payments requires the auth module, subscriptions are tied to a user. The CLI selects it for you automatically.
What you get
- Typed oRPC procedures (
createCheckoutSession,createPortalSession, andgetSubscription) all behindrequireAuth - A webhook at
/api/stripe/webhookthat verifies signatures and upserts each user's subscription row - A
/billingpage that starts checkout and links to the Stripe customer portal
Edge-native Stripe
There's no Node runtime on Workers, so the module uses Stripe's fetch-based HTTP client and the Web Crypto SubtleCrypto provider to verify webhook signatures asynchronously, no node_compat required.
ts
Setup
- Create a recurring price in Stripe and copy its id into
STRIPE_PRICE_ID. - Add
STRIPE_SECRET_KEY(use ask_test_…key while developing). - Forward webhooks locally and copy the signing secret into
STRIPE_WEBHOOK_SECRET.
bash
Tip
Without a Stripe key the checkout endpoints stay dormant, so the rest of the app still builds and runs. See Deployment for the production webhook setup.