Payments
Charge your customers for your product. This page connects Settings › Plans and Settings › Billing to a payment provider.
Two kinds of payments
- Your customers paying you (this page). The plan a workspace is on, its seats, cards and receipts, in Settings › Plans and Settings › Billing.
- Your users invoicing their own customers. The Invoices editor, Balances and Transactions are CRM records, like contracts. They're stored in your database (see Database); sending them is covered in Email.
What the billing screens show
| Screen | Today |
|---|---|
| Settings › Plans | Free, Pro ($29 per seat per month, less when billed yearly) and Enterprise (contact sales). Changing plan asks to confirm, then switches in the app. |
| Settings › Billing | Upcoming bill, current plan and seats, invoice information, billing history and payment methods: saved cards, a default card and an Add card form. |
Plans and prices are demo data in src/lib/data/admin.ts. Change them to your own before you create anything in a payment provider.
Connect a payment provider
Choose a provider. Stripe, Polar and Paddle are examples; some, like Polar and Paddle, also handle sales tax for you as the merchant of record.
Create products and prices that match Settings › Plans: per seat, monthly and yearly.
Start checkout on the server. When someone picks a plan, a Server Action creates a checkout session for their workspace and sends them to the provider's payment page.
Let webhooks update your database. The provider calls a Route Handler when a checkout completes or a subscription changes or ends; check the signature, then save the workspace's plan, seats and status.
Have Settings › Billing read the plan and history from your database, and send people to the provider's customer portal to change cards or download receipts.
Rules for real payments
Never trust the browser for payment status. A plan only changes when a verified webhook says so, and every paid feature checks the plan on the server.
- Don't collect card numbers yourself. Replace the demo Add card form with the provider's checkout, card fields or customer portal, so card details never touch your server.
- Keep keys and webhook secrets in server environment variables, and use test mode until everything works end to end.
- Get a technical review before you take real payments.