Quick Start

Get a working stripe402 server running in 5 minutes.

Stripe Dashboard Setup

Before running any example that creates PaymentMethods from card details (headless clients, the create-pm script, or AI agents), you must enable a Stripe dashboard setting:

  1. Enable "Publishable key card tokenization"

  2. Save

This is required because stripe402 supports programmatic, machine-to-machine payments where there is no browser UI. Card details are sent directly to Stripe's servers (never to the API server), so this is safe. See Creating Payment Methods for a detailed explanation.

Note: Browser-based clients using Stripe.js Elements do not need this setting.

Option 1: Docker Compose (Easiest)

The example app includes a Docker Compose setup with Redis, PostgreSQL, and the example server:

# Clone the repo
git clone https://github.com/stripe402/stripe402.git
cd stripe402

# Copy the example env file and add your Stripe test keys
cp apps/example/.env.example apps/example/.env
# Edit apps/example/.env with your keys from https://dashboard.stripe.com/test/apikeys

# Start everything
docker compose up -d

# Test a free endpoint
curl http://localhost:3000/api/health
# => {"status":"ok"}

# Test a paid endpoint (returns 402)
curl -i http://localhost:3000/api/joke
# => HTTP/1.1 402 Payment Required
# => payment-required: <base64 JSON>

To stop:

Option 2: Minimal Server

Create a stripe402 server from scratch:

1. Install dependencies

2. Create the server

3. Run it

4. Test it

Minimal Client

Next Steps

Last updated