Repository navigation
fix(billing): surface Stripe failures without leaking their detail - #12
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A Pro customer reported that the billing button does nothing.
POST /dashboard/billing/portalredirected back to/dashboard/billingwith 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_error, and the billing page shows a banner:no_customer: the account has nostripe_customer_idstripe: Stripe rejected the request, or the call threwcheckout_error=stripeand shows a banner, instead of a 500 page containing Stripe's message.console.errorand Sentry.Testing
test/billing-portal.test.tscovers 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 typecheckis 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