Payments

Payments

The payment module uses a shared paymentService contract with either Creem or Stripe selected during generation. Product pages and credit logic consume normalized checkout, subscription, and webhook events.

Confirm the selection

Check adapters.payment in nextdevtpl.generated.json:

SelectionVariablesSignature header
payment:creemCREEM_API_KEY, CREEM_WEBHOOK_SECRETcreem-signature
payment:stripeSTRIPE_SECRET_KEY, STRIPE_WEBHOOK_SECRETstripe-signature

Both use the shared endpoint:

https://your-domain.com/api/webhooks/payment

Main code

PathPurpose
src/core/services/payment.tsShared payment types and capabilities
src/adapters/paymentCreem or Stripe implementation
src/services/payment.tsSelected payment instance
src/features/payment/actions.tsCheckout Server Actions
src/app/api/webhooks/payment/route.tsShared signature and event handling
src/config/payment.tsProducts and price IDs
src/config/subscription-plan.tsPlan allowances

Production steps

  1. Create products and prices in the provider dashboard.
  2. Add price IDs to NEXT_PUBLIC_PRICE_* variables and plan configuration.
  3. Configure the API key and webhook secret.
  4. Point the webhook to /api/webhooks/payment.
  5. Test subscription, cancellation, renewal, and one-time payment flows.
  6. Confirm duplicate webhooks do not grant credits twice.
pnpm test:run -- src/test/adapters/payment.test.ts
pnpm test:run -- src/test/payment

See Credits for ledger behavior and Service Adapters for provider replacement.

On this page