New:New releases:CLIcreate-clubedge-app v0.49.1·Clubedge Starter v0.32.0

Clubedge Starter Docs

Payments

Subscriptions with Stripe Checkout and the customer portal, behind one PaymentProvider interface.

Choose with --payments stripe or --payments none (default). Payments need an auth module. On a React + Vite frontend with an API, the Hono and FastAPI APIs implement Stripe: see A frontend and its API.

The plans users can buy are in apps/web/src/config/plans.ts, with the app's own ids. The dashboard's billing card offers checkout for each plan, then shows the subscription and opens billing management. Server code reads a user's plan with getBilling().subscriptionFor(userId) and isEntitled from @/server/payments, and the subscriptions table keeps it in sync through the provider's webhook at /api/webhooks/payments.

Stripe

Stripe runs checkout and billing management. In test mode:

Copy the secret key from the dashboard's API keys into STRIPE_SECRET_KEY.

Create a recurring price for each plan and put its id in STRIPE_PRICE_<PLAN>, such as STRIPE_PRICE_PRO.

Forward webhooks to your machine with the Stripe CLI, and put the signing secret it prints in STRIPE_WEBHOOK_SECRET:

stripe listen --forward-to localhost:3000/api/webhooks/payments

Turn on the customer portal in the dashboard's billing settings, so "Manage billing" works.

The result, with a pro plan:

apps/web/.env.local
STRIPE_SECRET_KEY=sk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...
STRIPE_PRICE_PRO=price_...

In production, add a webhook endpoint for https://<your-domain>/api/webhooks/payments with these events, and use its signing secret:

  • checkout.session.completed
  • customer.subscription.created, .updated, .deleted, .paused, and .resumed

Every webhook's signature is verified, each event is applied once, and subscription events read the subscription's current state from Stripe, so retried or out-of-order deliveries are safe.

A frontend and its API

With the Hono API (Starter v0.25.0 or newer) and the FastAPI API (Starter v0.26.0 or newer), the API runs billing, and the React + Vite dashboard has the same billing card:

  • The plans are in apps/api/src/config/plans.ts with Hono and apps/api/src/clubedge_api/plans.py with FastAPI, and the API serves them at /api/billing. Checkout and the portal send the user back to FRONTEND_URL.
  • Hono's code reads a user's plan with getBilling().subscriptionFor(await getUserProfileId(user)) and isEntitled, from @/server/payments and @/server/users. FastAPI's code checks it with has_active_subscription(await ensure_user_id(user)), from clubedge_api.payments and clubedge_api.users, or reads it with find_subscription and is_entitled.
  • FastAPI uses the same tables as Hono, those of packages/payments, which pnpm db:migrate and the image's node migrate.mjs apply.
  • The Stripe variables go in apps/api/.env.local, and on the API's service in production.
  • Stripe calls the frontend, which forwards /api/webhooks/payments to the API with the body untouched, so the API stays private. stripe listen --forward-to localhost:3000/api/webhooks/payments works as above, and the production endpoint is https://<your-frontend>/api/webhooks/payments.

With an active subscription, the settings page refuses to delete the account: the user cancels it with "Manage billing" first.

A mobile app or a native app has no billing card: app stores require their own in-app purchases for digital goods, so subscriptions stay on the website.

A project without a website has no payments: checkout and the customer portal send users back to the website's pages, so the CLI refuses --payments stripe there.

Another provider

Payments go through the provider-neutral PaymentProvider interface in packages/payments. To use another provider, implement that interface in a new package and return it from apps/web/src/server/payments.ts (apps/api/src/server/payments.ts with the Hono API); billing logic, the tables, the routes, and the billing card stay the same.

With the FastAPI API, the PaymentProvider protocol is in apps/api/src/clubedge_api/payments.py. Implement it in a new module, and in server.py, build its Billing in place of stripe_billing (from payments_stripe.py).

How is this guide?