0. Environment Check
Detect environment mismatch first. Before any Stripe operations:
```bash
~/.claude/skills/stripe/scripts/detect-environment.sh
```
This compares your app's STRIPE_SECRET_KEY account with CLI profiles. If mismatched, resources created via CLI won't be visible to your app.
Fix mismatches:
- Use correct CLI profile:
stripe -p sandbox or stripe -p production - Or update
.env.local to match your CLI account
1. Audit
Spawn the auditor. Use the stripe-auditor subagent for deep parallel analysis. It examines:
- Configuration (env vars on all deployments, cross-platform parity)
- Webhook health (endpoints registered, URL returns non-3xx, pending_webhooks = 0)
- Subscription logic (trial handling, access control, idempotency)
- Security (no hardcoded keys, secrets not logged)
- Business model compliance (single tier, trial honored on upgrade)
- Subscription management UX (settings page, billing history, portal integration)
Run automated checks:
```bash
~/.claude/skills/stripe/scripts/stripe_audit.sh
```
Research first. Before assuming current patterns are correct, check Stripe docs for current best practices. Use Gemini. What was right last year may be deprecated.
2. Plan
From audit findings, build a complete remediation plan. Don't just list issuesโplan the fixes.
For each finding:
- Configuration issues โ Fix directly (env vars, dashboard settings)
- Code issues โ Delegate to Codex with clear specs
- Design issues โ May require rethinking approach, consult
stripe-design
Prioritize:
- Critical โ Blocks checkout or causes payment failures
- High โ Security issues, data integrity problems
- Medium โ Missing UX, suboptimal patterns
3. Execute
Fix everything. Don't stop at a report.
Configuration fixes (do directly):
```bash
# Missing env var
npx convex env set --prod STRIPE_WEBHOOK_SECRET "$(printf '%s' 'whsec_...')"
# Verify
npx convex env list --prod | grep STRIPE
```
Code fixes (delegate to Codex):
```bash
codex exec --full-auto "Fix [specific issue]. \
File: [path]. Problem: [what's wrong]. \
Solution: [what it should do]. \
Reference: [pattern file]. \
Verify: pnpm typecheck && pnpm test" \
--output-last-message /tmp/codex-fix.md 2>/dev/null
```
Then validate: git diff --stat && pnpm typecheck
Webhook URL fixes:
Update in Stripe Dashboard to canonical domain. If redirects exist, use the final URL.
Missing subscription management UX:
Per stripe-subscription-ux, every integration needs:
- Settings page showing plan, status, next billing date
- Payment method display (brand + last4)
- "Manage Subscription" button (Stripe Portal)
- Billing history with downloadable invoices
- State-specific messaging (trialing, canceled, past_due)
If missing, create it. This is non-negotiable.
4. Verify
Prove it works. Not "looks right"โactually works.
Configuration verification:
```bash
npx convex env list | grep STRIPE
npx convex env list --prod | grep STRIPE
curl -s -o /dev/null -w "%{http_code}" -I -X POST "$WEBHOOK_URL"
```
Checkout flow test:
- Create test checkout session
- Complete with card
4242 4242 4242 4242 - Verify webhook received (check logs)
- Verify subscription created in Stripe Dashboard
- Verify user state updated in database
- Verify access granted
Webhook delivery test:
```bash
stripe events list --limit 5 | jq '.data[] | {id, type, pending_webhooks}'
# All should have pending_webhooks: 0
```
Subscription management UX test:
- Navigate to settings page
- Verify plan and status displayed
- Click "Manage Subscription" โ Portal opens
- Verify billing history accessible
Business model compliance:
- Single pricing tier? โ
- Trial honored on upgrade? (Check Stripe subscription has trial_end) โ
- No freemium logic? (Expired trial = no access) โ
If any verification fails, go back and fix it. Don't declare done until everything passes.