Payments
Prime abstracts payment processing behind a gateway factory — you configure one gateway and the entire codebase works the same regardless of provider.
Active gateway
Set in demo-server/.env:
PAYMENT_GATEWAY=lemonsqueezy # or stripe
See Lemon Squeezy Setup and Subscriptions for full configuration.
Payment flow
User clicks Upgrade
→ POST /checkout-link (creates session with gateway)
→ User redirected to hosted checkout page
→ User completes payment
→ Gateway fires webhook → POST /webhooks/lemonsqueezy (or /stripe)
→ Account upgraded, subscription IDs stored
The checkout response is returned flat (not wrapped in data): { checkoutUrl, expiresAt, sessionId, clientToken, plan, gateway, interval }.
Accounts that already have an active subscription change plans with POST /account/upgrade instead — see Subscriptions for the upgrade flow.
API endpoints
| Method | Endpoint | Description |
|---|---|---|
GET | /payments | List payment history for the account |
GET | /invoices | List invoices (paginated with limit/offset) |
POST | /checkout-link | Generate a checkout URL (body: { plan_id }) |
GET | /subscription/status | Get the account's current subscription status |
POST | /subscription/cancel | Cancel the subscription |
POST | /subscription/resume | Undo a scheduled cancellation |
GET | /subscription/portal-url | Get the gateway's hosted billing portal URL |
POST | /account/upgrade | Switch to a different plan on an active subscription |
Master payment endpoints
| Method | Endpoint | Description |
|---|---|---|
GET | /master/payments | View all payment records across all accounts |
Supported gateways
| Gateway | Monthly | Webhooks |
|---|---|---|
| Lemon Squeezy | ✓ | ✓ |
| Stripe | ✓ | ✓ |
Each gateway is implemented as a class in demo-server/services/paymentGateways/ extending BaseGateway, with a common interface covering checkout, cancel, resume, changePlan, portal, invoices and webhook parsing. Switching is a one-line env var change plus that gateway's price IDs and webhook registration.
See Lemon Squeezy Setup for the current Stripe caveats before enabling it in production.