Skip to content

fix(billing): surface Stripe failures without leaking their detail - #12

Merged
scobb merged 2 commits into
mainfrom
fix/billing-portal-silent-failure
Nov 15, 2026
Merged

scobb merged 2 commits into
mainfrom
fix/billing-portal-silent-failure

Conversation

@scobb

@scobb scobb commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Problem

A Pro customer reported that the billing button does nothing. POST /dashboard/billing/portal redirected back to /dashboard/billing with no message and no logging whenever it could not create a Stripe portal session, so the button looked dead.

The underlying cause in production was the restricted Stripe key missing permissions (fixed separately in the Stripe dashboard). Nothing in the app surfaced that, because the route discarded Stripe's error.

The checkout route had the opposite problem: on failure it printed Stripe's raw error message to the customer. Those messages can include the Stripe account ID, the key suffix and a dashboard link to edit the key.

Change

Both routes now handle a Stripe failure the same way: a fixed message for the customer, the detail for us.

  • Portal: redirects with portal_error, and the billing page shows a banner:
    • no_customer: the account has no stripe_customer_id
    • stripe: Stripe rejected the request, or the call threw
  • Checkout: redirects with checkout_error=stripe and shows a banner, instead of a 500 page containing Stripe's message.
  • The Stripe failure (HTTP status and Stripe's message) goes to console.error and Sentry.

Testing

  • test/billing-portal.test.ts covers the success redirect and failure paths for both routes, including that Stripe's error text never reaches the response or the billing page.
  • npm test: 163 pass, 4 skipped (the existing WordPress plugin skips). npm run typecheck is clean.

Not in this PR

The billing page's Stripe plan sync (GET /v1/subscriptions) also swallows failures. It falls back to the plan in the database, so it is left as is here.

🤖 Generated with Claude Code

Steve Cobb and others added 2 commits November 15, 2026 07:29
The portal route redirected back to the billing page with no message and no
logging whenever it could not create a Stripe portal session, so the button
looked dead. A customer reported exactly that; the cause was a restricted
Stripe key missing permissions, which nothing surfaced.

Both failure paths (no Stripe customer on the account, Stripe rejecting the
request) now show a banner on the billing page, and Stripe's error is logged
and sent to Sentry.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A failed checkout session printed Stripe's error message to the customer.
Those messages can name the Stripe account and the API key (a permission
error includes the account ID and a dashboard link to edit the key).

Checkout failures now redirect to the billing page with a fixed message, and
the detail goes to the logs and Sentry, the same as the portal route.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@scobb scobb changed the title fix(billing): stop "Manage Subscription" failing silently fix(billing): surface Stripe failures without leaking their detail Nov 15, 2026
@scobb
scobb merged commit 060dca6 into main Nov 15, 2026
2 checks passed
@scobb
scobb deleted the fix/billing-portal-silent-failure branch November 15, 2026 15:42
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