Skip to content

fix: setup stripe points to the dashboard instead of a dead OAuth flow - #35

Merged
sonpiaz merged 1 commit into
mainfrom
fix/setup-stripe-points-to-dashboard
Oct 13, 2026
Merged

sonpiaz merged 1 commit into
mainfrom
fix/setup-stripe-points-to-dashboard

Conversation

@sonpiaz

@sonpiaz sonpiaz commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

What & why

affitor setup stripe (CLI 0.4.2) cannot work for any brand and, when it gets far enough, leaves a dead webhook on the brand's Stripe account:

Step What it does Why it fails Evidence
OAuth token exchange stripe.oauth.token(...) with the key the user passes Exchanging a code for Affitor's Connect client_id needs Affitor's platform secret, which a brand does not have packages/cli/src/lib/stripe-oauth.ts:53-57 (before)
Create webhook webhookEndpoints.create on the connected account, URL <api-url>/webhooks/stripe/<program_id>, events incl. invoice.paid The CMS serves no /webhooks/stripe/* route (Stripe intake is POST /api/webhook-distributor/stripe), and the distributor handles invoice.payment_succeeded, not invoice.paid setup-stripe.ts:98, stripe-oauth.ts:196-200, types.ts:199-206 (before); affiliate-cms src/api/webhook-distributor/routes/custom-routes.ts:6, services/webhook-distributor.ts:773-790
Save connection POST /api/v1/cli/stripe-connect Retired, answers 410 Gone (W37-1690) affiliate-cms src/api/cli/routes/custom-routes.ts:68-80, controllers/cli.ts:368-382

Real Stripe tracking (dashboard Connect + Affitor's platform webhook, which handles invoice.payment_succeeded for renewals) is unaffected. No recurring sale is lost through this path, because the command never completes.

Fix (smallest): setup stripe now prints "Stripe is connected from the Affitor dashboard, not the CLI: open the program, go to Settings, and use Connect Stripe." and exits 1 ({"error": "stripe_setup_moved", "message": ...} with --json). It makes no network call, and old flags are still accepted.

  • Removed the dead code it used: lib/stripe-oauth.ts, WEBHOOK_EVENTS, the OAuth port constants, saveStripeConnection, StripeConnectResponse, and the now-unused stripe dependency.
  • status, the generated .env.example and agent instructions, and the README now point to the dashboard instead of npx affitor setup stripe.
  • Version 0.4.2 -> 0.4.3 + CHANGELOG. Not published.

Tests

  • New packages/cli/tests/setup-stripe.test.ts: --json prints stripe_setup_moved + exits 1 + no fetch; old --stripe-secret-key/--stripe-client-id flags still get the directions with no network call.
  • npm run build pass, npm run lint (tsc) pass, npm test: cli 115/115 (13 files), recipes 19/19, mcp 20/20.

Companion docs PR: Affitor/affitor-docs#105.

🤖 Generated with Claude Code

The CLI flow could not complete: the token exchange needs Affitor's platform
secret, POST /api/v1/cli/stripe-connect answers 410, and the webhook it created
pointed at /webhooks/stripe/<id>, which the CMS does not serve (and subscribed
to invoice.paid, which the CMS does not handle). Now it prints where to connect
Stripe and exits 1, with no network call. Bump to 0.4.3 (not published).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@sonpiaz
sonpiaz merged commit 8e23a09 into main Oct 13, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant