# PocketBI Stripe Setup

This is a buyer-ready Stripe setup guide. No Stripe account, products, prices, customer records, payment history, or revenue are included with the PocketBI codebase/domain sale.

## What is already in the repo

- Optional serverless checkout endpoint files under `api/billing/`.
- Optional Stripe webhook handler for entitlement updates.
- Client UI that keeps checkout/premium behavior disabled unless buyer-owned server-side environment variables are configured.
- `.env.example` with placeholder-only values.

## Security rules

- Never commit real Stripe keys.
- Never expose `STRIPE_SECRET_KEY`, `STRIPE_WEBHOOK_SECRET`, or `SUPABASE_SERVICE_ROLE_KEY` to browser JavaScript, static HTML, meta tags, window variables, or frontend runtime config.
- Rotate any key that appears in commits, screenshots, logs, or chat.
- Use Stripe test mode first.

## Buyer setup steps

1. Create or use a buyer-owned Stripe account.
2. Create products/prices, for example:
   - PocketBI Pro Monthly
   - PocketBI Pro Annual
   - PocketBI Founding Lifetime
3. Copy the Stripe **Price IDs** (`price_...`) into hosting environment variables.
4. Set `STRIPE_SECRET_KEY` only in hosting/serverless environment variables.
5. Configure the webhook endpoint and set `STRIPE_WEBHOOK_SECRET`.
6. Configure buyer-owned Supabase if entitlement persistence is desired.
7. Test end-to-end in Stripe test mode before using live keys.

## Required variables

- `STRIPE_SECRET_KEY`
- `STRIPE_WEBHOOK_SECRET`
- `STRIPE_PRICE_PRO_MONTHLY`
- `STRIPE_PRICE_PRO_ANNUAL`
- `STRIPE_PRICE_FOUNDING`
- `APP_URL`
- `PAYMENTS_ALLOWED_ORIGINS`
- `SUPABASE_URL`
- `SUPABASE_SERVICE_ROLE_KEY`

## Important behavior

Core PocketBI features do not require Stripe. Stripe only matters for optional paid plan checkout and entitlement sync. If the variables are missing, payments remain inactive and the local-first app continues to work. Test checkout calls the serverless endpoint; the frontend never reads or validates Stripe secret keys.
