File size: 4,102 Bytes
d705bb5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | # Deployment Plan β Clerk Auth + Dodo Payments
## Merge Order
**PR #1812 first, then PR #2024.** Dodo billing functions depend on Clerk auth being registered in Convex.
1. Merge `feat/better-auth` β `main` (PR #1812)
2. Rebase `dodo_payments` on updated `main`, resolve conflicts
3. Merge `dodo_payments` β `main` (PR #2024)
---
## Environment Variables
### Clerk Auth (PR #1812)
All values from **Clerk Dashboard β API Keys** ([dashboard.clerk.com](https://dashboard.clerk.com))
| Variable | Set in | Value |
|----------|--------|-------|
| `VITE_CLERK_PUBLISHABLE_KEY` | **Vercel** | Clerk Dashboard β API Keys β Publishable Key (`pk_live_...`) |
| `CLERK_SECRET_KEY` | **Vercel** (secret) | Clerk Dashboard β API Keys β Secret Key (`sk_live_...`) |
| `CLERK_JWT_ISSUER_DOMAIN` | **Vercel** | Your Clerk app domain, e.g. `https://worldmonitor.clerk.accounts.dev` |
#### Clerk Dashboard Setup
1. **JWT Template**: Create a template named **`convex`** with custom claim: `{ "plan": "{{user.public_metadata.plan}}" }`
2. **Pro users**: Set `public_metadata.plan` to `"pro"` on test users to verify premium access
3. **Sign-in methods**: Configure email OTP (or whichever methods you want) under User & Authentication
---
### Dodo Payments (PR #2024)
API key + webhook secret from **Dodo Dashboard** ([app.dodopayments.com](https://app.dodopayments.com))
| Variable | Set in | Value |
|----------|--------|-------|
| `DODO_API_KEY` | **Convex Dashboard** | Dodo β Settings β API Keys |
| `DODO_PAYMENTS_ENVIRONMENT` | **Convex Dashboard** | `test_mode` or `live_mode` |
| `DODO_PAYMENTS_WEBHOOK_SECRET` | **Convex Dashboard** | Dodo β Developers β Webhooks β signing secret |
| `DODO_WEBHOOK_SECRET` | **Convex Dashboard** | Same value as above |
| `VITE_DODO_ENVIRONMENT` | **Vercel** | `test_mode` or `live_mode` (must match server-side) |
| `VITE_CONVEX_URL` | **Vercel** | Convex Dashboard β Settings β Deployment URL (`https://xxx.convex.cloud`) |
#### Dodo Dashboard Setup
1. **Webhook endpoint**: Create a webhook pointing to `https://<convex-deployment>.convex.site/dodo/webhook`
2. **Events to subscribe**: `subscription.active`, `subscription.renewed`, `subscription.on_hold`, `subscription.cancelled`, `subscription.expired`, `subscription.plan_changed`, `payment.succeeded`, `payment.failed`, `refund.succeeded`, `refund.failed`, `dispute.*`
3. **Products**: Ensure product IDs match the seed data in `convex/payments/seedProductPlans.ts` β run `seedProductPlans` mutation after deploy
---
## Deployment Steps
### Step 1 β Merge PR #1812 (Clerk Auth)
```
1. Set Clerk env vars on Vercel (all 3)
2. Create Clerk JWT template named "convex"
3. Merge feat/better-auth β main
4. Deploy to Vercel
5. Verify: Sign in works, Pro user sees premium panels, bearer tokens appear on premium API routes
```
### Step 2 β Merge PR #2024 (Dodo Payments)
```
1. Set Dodo env vars on Convex Dashboard (4 vars)
2. Set Dodo + Convex env vars on Vercel (2 vars)
3. Rebase dodo_payments on main, resolve conflicts
4. Merge dodo_payments β main
5. Deploy to Vercel + Convex
6. Run seedProductPlans mutation in Convex Dashboard
7. Create webhook endpoint in Dodo Dashboard
8. Verify: Checkout flow β webhook β entitlements granted β panels unlock
```
### Post-Deploy Verification
- [ ] Anonymous user sees locked premium panels
- [ ] Clerk sign-in works (email OTP or configured method)
- [ ] Pro user (`public_metadata.plan: "pro"`) sees unlocked panels + data loads
- [ ] Dodo test checkout (`4242 4242 4242 4242`) creates subscription
- [ ] Webhook fires β subscription + entitlements appear in Convex Dashboard
- [ ] Billing portal opens from Settings
- [ ] Desktop API key flow still works unchanged
---
## Summary
| Where | Variables to set |
|-------|-----------------|
| **Vercel** | `VITE_CLERK_PUBLISHABLE_KEY`, `CLERK_SECRET_KEY`, `CLERK_JWT_ISSUER_DOMAIN`, `VITE_DODO_ENVIRONMENT`, `VITE_CONVEX_URL` |
| **Convex Dashboard** | `DODO_API_KEY`, `DODO_PAYMENTS_ENVIRONMENT`, `DODO_PAYMENTS_WEBHOOK_SECRET`, `DODO_WEBHOOK_SECRET` |
|