Stripe is the default payment provider. This page covers the Codapult-specific setup steps.
API Keys
Get your keys from the Stripe Dashboard:
STRIPE_SECRET_KEY="sk_test_..."
STRIPE_WEBHOOK_SECRET="whsec_..."
Use test keys (sk_test_*) during development. Switch to live keys (sk_live_*) when going to production.
Test Mode
In test mode, use Stripe test card numbers:
| Card Number | Scenario |
|---|---|
4242 4242 4242 4242 | Successful payment |
4000 0000 0000 3220 | 3D Secure authentication |
4000 0000 0000 9995 | Declined payment |
Webhook Setup
Codapult's Stripe webhook endpoint is POST /api/webhooks/stripe.
Local Development
Use the Stripe CLI to forward events to your local server:
stripe listen --forward-to http://localhost:3000/api/webhooks/stripe
The CLI prints a webhook signing secret (whsec_...) — copy it to STRIPE_WEBHOOK_SECRET in .env.local.
Production
- Go to Stripe Dashboard → Webhooks
- Add endpoint:
https://your-app.com/api/webhooks/stripe - Select the events listed below
- Copy the signing secret to
STRIPE_WEBHOOK_SECRET
Handled Events
| Stripe Event | Codapult Action |
|---|---|
checkout.session.completed | Records completed checkout only; not proof of subscription payment |
checkout.session.async_payment_succeeded | Process a delayed payment after Stripe confirms it |
invoice.paid | Process confirmed invoice payment |
customer.subscription.created | Record provider subscription status and link it to the user |
customer.subscription.updated | Update provider subscription status |
customer.subscription.paused | Record provider-paused status |
customer.subscription.resumed | Restore provider-reported subscription status |
customer.subscription.deleted | Cancel and deactivate subscription |
Select all events listed above in the Stripe webhook endpoint. Checkout metadata is copied to the Stripe subscription so lifecycle events can reliably link the subscription to the local user and plan. Codapult grants recurring access from the provider's subscription status, not from checkout completion alone. All deliveries are logged in the webhook_delivery table.
Subscription pause uses Stripe's pause_collection with invoices kept as drafts. The subscription's provider status remains active; Codapult recognizes the pause setting separately and blocks product access until collection is resumed.
Stripe Connect
For marketplace features, Codapult supports Stripe Connect. Your platform can collect an application fee on transactions:
STRIPE_CONNECT_FEE_PERCENT=10 # 10% platform fee
The server-side fee and the Connect dashboard UI are both read value via env.payments.stripe.connectFeePercent from src/config/env.ts.
The Connect integration handles onboarding, account creation, and fee collection. Manage connected accounts from the admin panel.
Going Live Checklist
- Switch from
sk_test_*tosk_live_*keys - Create a production webhook pointing to your live URL
- Update
STRIPE_WEBHOOK_SECRETwith the production signing secret - Verify webhook events are being received (check
webhook_deliverytable) - Configure the Stripe Customer Portal in Stripe Settings → Customer Portal
For the full Stripe documentation, see docs.stripe.com.