Skip to main content

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​

MethodEndpointDescription
GET/paymentsList payment history for the account
GET/invoicesList invoices (paginated with limit/offset)
POST/checkout-linkGenerate a checkout URL (body: { plan_id })
GET/subscription/statusGet the account's current subscription status
POST/subscription/cancelCancel the subscription
POST/subscription/resumeUndo a scheduled cancellation
GET/subscription/portal-urlGet the gateway's hosted billing portal URL
POST/account/upgradeSwitch to a different plan on an active subscription

Master payment endpoints​

MethodEndpointDescription
GET/master/paymentsView all payment records across all accounts

Supported gateways​

GatewayMonthlyWebhooks
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.