# Setup_Stripe.md — Stripe Billing + Cal.com for MAGGie Pro

Owner guide to finish wiring payments after the code scaffolding is in place.

**Live site:** https://maggie-pro.netlify.app  
**Stripe account id (in secrets):** `STRIPE_ACCOUNT_ID` (your `acct_…`)

```
  [ pricing.html ] --POST /api/create-checkout--> [ Stripe Checkout (Billing) ]
                                                         |
                                                         v
                                              subscription + 14-day trial (Pro)

  [ coaches.html#book ] --Cal.com URL--> [ Cal.com ] --Stripe plugin--> paid appointments
```

---

## 1) Secrets already defined

Local file: `secrets/maggie.env` (gitignored). Mirror the same keys on **maggie-pro** in Netlify → Environment variables.

| Variable | Purpose |
|----------|---------|
| `STRIPE_ACCOUNT_ID` | Your Stripe account (`acct_…`) — already set locally |
| `STRIPE_SECRET_KEY` | Secret key (`sk_test_…` / `sk_live_…`) |
| `STRIPE_PUBLISHABLE_KEY` | Publishable key (`pk_…`) — optional for Checkout redirect flow |
| `STRIPE_WEBHOOK_SECRET` | Signing secret for `/api/stripe-webhook` |
| `STRIPE_PORTAL_CONFIGURATION_ID` | Customer Portal config (`bpc_…`) — manage billing UI |
| `STRIPE_PRICE_PRO_MONTHLY` | Price id for $19/mo |
| `STRIPE_PRICE_PRO_ANNUAL` | Price id for $182/yr |
| `STRIPE_PRICE_COACHING_MONTHLY` | Price id for $49/mo |
| `STRIPE_PRICE_COACHING_ANNUAL` | Price id for $470/yr |
| `SITE_URL` | `https://maggie-pro.netlify.app` |
| `CAL_COM_BOOKING_URL` | e.g. `https://cal.com/you/coaching` |
| `CAL_COM_EMBED` | `1` to show iframe on coaches page |

---

## 2) Create Stripe Products + Prices

1. Open [Stripe Dashboard → Products](https://dashboard.stripe.com/products) (test mode first).
2. Create **Pro** — recurring:
   - Monthly **$19 USD** → copy `price_…` → `STRIPE_PRICE_PRO_MONTHLY`
   - Yearly **$182 USD** → `STRIPE_PRICE_PRO_ANNUAL`
3. Create **Pro + Check-in** (Stripe product may still be named “Coaching”) — recurring:
   - Monthly **$49** → `STRIPE_PRICE_COACHING_MONTHLY`
   - Yearly **$470** → `STRIPE_PRICE_COACHING_ANNUAL`
   - Consumer copy: brief coach **check-ins** + self-coaching in-app — **not** full coaching (see pricing.html).
4. Developers → API keys → copy secret + publishable into secrets / Netlify env.
5. Confirm the dashboard account matches `STRIPE_ACCOUNT_ID`.

Trial: Checkout sets **14 days** in code for Pro plans (`create-checkout.mts`). You do not need a separate “trial product”.

**Academic (.edu) semester:** see [`Setup_Edu.md`](./Setup_Edu.md) — cardless $0 stress-test product (auto-created), cohort codes, `/edu` portal.

---

## 3) Webhook

- [x] Endpoint created: `we_1U1MoPFV5n5EMgsgAcXaD2OG`
- [x] URL: `https://maggie-pro.netlify.app/api/stripe-webhook`
- [x] Events: `checkout.session.completed`, `customer.subscription.*`, `invoice.paid`, `invoice.payment_failed`
- [x] `STRIPE_WEBHOOK_SECRET` saved locally + on Netlify (secret)

---

## 4) Cal.com + Stripe (paid coaching + journal workflow)

1. Create Cal.com **event types** for your coaching menu (e.g. 45-min, 60-min, 90-min) with **your** prices.
2. In Cal.com: **Apps → Stripe** — connect the same Stripe account (`acct_…`).
3. Enable payment / deposit on each paid event type.
4. Copy a public booking link → `CAL_COM_BOOKING_URL` (can be a team/user page that lists all event types).
5. **Journal share after booking** (required for the check-in / coaching prep flow):
   - Event type → **Advanced → Redirect on booking** (or Confirmation email link) to:  
     `https://maggie-pro.netlify.app/share-journal.html?source=cal&coachEmail=YOU@YOURDOMAIN.com`  
   - Optional: append `&bookingUid={{BOOKING_UID}}` if your Cal plan supports template variables in redirects.
   - Clients open that page, consent, then **Copy for Cal.com notes** (paste into the booking’s additional notes) or **Email coach**.
   - Coaches can also send a request anytime:  
     `https://maggie-pro.netlify.app/share-journal.html?source=request&coachEmail=YOU@YOURDOMAIN.com&coachName=YourName`
6. Redeploy; open https://maggie-pro.netlify.app/coaches.html#book — embed + button should resolve.

**Positioning reminder:** Stripe plan `coaching-*` is sold to members as **Pro + Check-in** ($49) — brief accountability check-ins + self-coaching in-app. Full coaching = Cal.com tiers you price.

---

## 5) Deploy env to maggie-pro

Set the variables on site `maggie-pro` (not only maggie-tenacity), then:

```powershell
cd S:\projects\MAGGie
npx netlify deploy --prod --site 29754705-5581-421b-b746-72f92a6d8152 --dir=pro --functions=netlify/functions
```

Smoke test:

- `GET /api/commerce-config` → `stripe.configured: true`
- Pricing CTA → Stripe Checkout
- Coaches `#book` → Cal.com

---

## 6) Checklist

- [x] Code: `/api/create-checkout`, `/api/commerce-config`, `/api/stripe-webhook`
- [x] Pricing CTAs call Stripe Checkout
- [x] Coaches page Cal.com mount
- [x] `STRIPE_ACCOUNT_ID` in local secrets + Netlify
- [x] Live `STRIPE_SECRET_KEY` + four Price IDs (live mode verified)
- [x] Products live: `prod_V1OpfJxTNTozrS` (Pro), `prod_V1Ou1X2PxtM915` (Coaching)
- [x] Webhook endpoint + secret on Netlify
- [ ] `CAL_COM_BOOKING_URL` set + Stripe app enabled in Cal.com
- [ ] Rotate live secret key (was pasted in chat) after cutover
- [ ] End-to-end live checkout with a real card (small charge / cancel after trial)

`Setup_Square.md` remains as historical Squarespace notes; **Stripe + Cal.com is the active path.**
