# Stripe

Used by the [build playbook](https://www.ihatereading.lol/build.md) on ihatereading.lol.

### Stripe

Kind: payments

Official links:

- [Stripe Dashboard](https://dashboard.stripe.com)
- [API keys](https://dashboard.stripe.com/apikeys)
- [Webhooks](https://dashboard.stripe.com/webhooks)
- [Checkout Sessions](https://docs.stripe.com/payments/checkout/how-checkout-works)
- [Create a Checkout Session API](https://docs.stripe.com/api/checkout/sessions/create)
- [stripe npm](https://www.npmjs.com/package/stripe)
- [Stripe CLI (local webhooks)](https://docs.stripe.com/stripe-cli)
- [Test cards](https://docs.stripe.com/testing#cards)

npm packages:

- `stripe`

API keys:

- `STRIPE_SECRET_KEY`: https://dashboard.stripe.com/apikeys → Secret key (sk_test_… locally, sk_live_… in prod). Server only.
- `NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY`: Same page → Publishable key (pk_test_…). Only if you use Stripe.js; Checkout redirect can skip it.
- `STRIPE_WEBHOOK_SECRET`: https://dashboard.stripe.com/webhooks → Add endpoint → Signing secret (whsec_…). Locally: stripe listen --forward-to localhost:3000/api/webhooks/stripe

Setup:

```
1. https://dashboard.stripe.com → sign up, stay in Test mode
2. Developers → API keys → STRIPE_SECRET_KEY
3. Create Checkout Session: mode=payment, line_items price_data.unit_amount = bid cents, metadata.pending_id
4. Success URL: {SITE}/success?checkout_id={pending_id}
5. Webhook endpoint: {SITE}/api/webhooks/stripe event checkout.session.completed
6. Local: stripe listen --forward-to localhost:3000/api/webhooks/stripe → STRIPE_WEBHOOK_SECRET
7. Test card: 4242 4242 4242 4242
```


All platforms: https://www.ihatereading.lol/build/platforms.md
