# Checkout API

Serverless Stripe Checkout integration for the Agentic Engineering course.

## Deploy

### Cloudflare Worker (recommended)

```bash
npm install -g wrangler
cd api
wrangler deploy checkout.js --name checkout-api
wrangler secret put STRIPE_SECRET_KEY
```

### Vercel

```bash
cd api
vercel deploy --prod
vercel secrets add STRIPE_SECRET_KEY sk_live_...
```

### Standalone

```bash
export STRIPE_SECRET_KEY="sk_live_..."
node checkout.js
# Listens on port 8787
```

## Price IDs

Create these products in Stripe Dashboard, then update `site/checkout.md` with the real price IDs:

| Product | Amount | Stripe Price ID |
|---------|--------|----------------|
| Self-Paced | $97 | `price_self_paced` → replace with real ID |
| Enterprise | $199 | `price_enterprise` → replace with real ID |
| Cohort | $247 | `price_cohort` → replace with real ID |

## How It Works

1. User clicks "Buy" → redirected to `/checkout?plan=self-paced`
2. Frontend calls `/api/checkout` with the price ID
3. API creates a Stripe Checkout Session
4. User is redirected to Stripe's hosted checkout page
5. After payment, user is redirected to `/checkout/success`
