fix(billing): surface checkout failures and stop silent start-trial 500s - #2776
Merged
Conversation
Stripe errors were mapped to a generic 500 and the billing gate never caught them, so Start trial looked dead. Map Stripe failures, pin card collection, bump checkout idempotency, and toast the user.
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.
Summary
POST /billing/checkout/sessionwith a 500 and the billing gate never caught it, so the UI looked dead (unhandledApiErrorin PostHog).compass-checkout-v2-…), maps Stripe errors to 400/502 with a safe client message, trims Stripe config values, and toasts failures instead of failing silently.Simplicity
getApiErrorDataexport and a deadBillingHttpErrorbranch in the Stripe wrap helper.useEffect/useRef/useStatethat already owned focus, analytics-once, export, and redirect busy state. No new hooks were added beyondSessionContextfor the live-session gate.Automated validation
trust proxy— 22 pass.stripe.service.db.test.ts— 7 pass (checkout params, Stripe error mapping).useAppAccess(including cached status after sign-out),api.util— 46 then 9 pass after the review fix.bun run type-check— pass.Independent review
/billing/statuscould keep BillingGateModal up afterauthenticatedbecame false. Fixed inaa50080a0.Test plan
bun packages/scripts/src/testing/test-parallel.ts backend-fast -- packages/backend/src/billing/controllers/billing.controller.test.ts packages/backend/src/common/constants/config.constants.test.ts packages/backend/src/servers/express/express.server.test.tsbun packages/scripts/src/testing/test-mongo-env.ts backend -- packages/backend/src/billing/services/stripe.service.db.test.tsbun packages/scripts/src/testing/test-parallel.ts web -- packages/web/src/billing/BillingGateModal.test.tsx packages/web/src/billing/useAppAccess.test.tsx packages/web/src/api/util/api.util.test.tsbun run type-check