{"record":{"id":"a44cbfc1898b938a","repo":"different-ai/openwork","slug":"checkout-failed-response-status","errorCode":null,"errorMessage":"Checkout failed (${response.status}).","messagePattern":"Checkout failed \\((.+?)\\)\\.","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"ee/apps/den-web/app/(den)/dashboard/_components/inference-screen.tsx","lineNumber":359,"sourceCode":"  // instead of bouncing the user to the billing page. Billing stays the\n  // status/portal view.\n  async function startSubscribeCheckout() {\n    if (!canManageModels) {\n      setError(\"Only workspace admins can start OpenWork Models checkout.\");\n      return;\n    }\n\n    setError(null);\n    try {\n      await runReauthableAction(\"inference-checkout\", async () => {\n        setSubscribeBusy(true);\n        const { response, payload } = await requestJson(\n          \"/v1/billing/stripe/checkout\",\n          { method: \"POST\", body: JSON.stringify({ type: \"inference\" }) },\n          12000,\n        );\n        if (!response.ok) {\n          throw getRequestError(payload, response, `Checkout failed (${response.status}).`);\n        }\n        const url = payload && typeof payload === \"object\" && \"url\" in payload && typeof payload.url === \"string\" ? payload.url : null;\n        if (!url) {\n          throw new Error(\"Checkout response did not include a URL.\");\n        }\n        window.location.href = url;\n      });\n    } catch (checkoutError) {\n      setError(checkoutError instanceof Error ? checkoutError.message : \"Could not start checkout.\");\n      setSubscribeBusy(false);\n    }\n  }\n\n  async function toggleEnabled() {\n    if (!canManageModels) {\n      setError(\"Only workspace admins can manage OpenWork Models.\");\n      return;\n    }","sourceCodeStart":341,"sourceCodeEnd":377,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/ee/apps/den-web/app/(den)/dashboard/_components/inference-screen.tsx#L341-L377","documentation":"Thrown by startSubscribeCheckout when POST /v1/billing/stripe/checkout with type \"inference\" returns non-OK. getRequestError turns a 403 reauth payload into ReauthRequiredError and otherwise throws the server message or this fallback. It means the Stripe checkout session for inference usage subscription could not be created.","triggerScenarios":"POST /v1/billing/stripe/checkout (type \"inference\") fails: Stripe unconfigured on the server, org already subscribed or in an incompatible billing state (409/400), payment method/plan mismatch, expired session (401), or Stripe API 5xx. 12s timeout.","commonSituations":"Self-hosted Den without Stripe keys; clicking 'Subscribe' twice and hitting a state conflict; org switching between seat and inference subscriptions; Stripe outage.","solutions":["Read the surfaced server message for the specific billing conflict.","Re-authenticate if the error is reauth-required; runReauthableAction retries transparently.","Verify Stripe configuration on the Den server (keys, webhooks, price IDs for inference).","Refresh the inference status (GET) to see if a subscription already exists before retrying.","On 5xx, check server logs for Stripe API errors."],"exampleFix":"// before\nif (!response.ok) {\n  throw getRequestError(payload, response, `Checkout failed (${response.status}).`);\n}\n// after\nif (!response.ok) {\n  if (response.status === 409) throw new Error(\"You already have an inference subscription - open the billing portal instead.\");\n  throw getRequestError(payload, response, `Checkout failed (${response.status}).`);\n}","handlingStrategy":"try-catch","validationCode":"const { response, payload: status } = await requestJson(\"/v1/inference/status\", {}, 10000);\nif (status && typeof status === \"object\" && \"subscribed\" in status && status.subscribed === true) {\n  showToast(\"Already subscribed - use the billing portal to manage it.\"); return;\n}","typeGuard":"function isReauth(error: unknown): error is ReauthRequiredError { return error instanceof ReauthRequiredError; }","tryCatchPattern":"try {\n  await runReauthableAction(\"inference-checkout\", startSubscribeCheckout);\n} catch (error) {\n  if (isReauthRequiredError(error)) { promptReauth(); return; }\n  setStripeError(error instanceof Error ? error.message : \"Could not start checkout.\");\n}","preventionTips":["Check existing subscription state before starting checkout to avoid conflicts","Verify Stripe env config server-side before showing the subscribe CTA","Wrap in runReauthableAction to auto-handle reauth","Disable the button while busy to prevent duplicate checkout sessions"],"tags":["http","billing","stripe","network"],"backgroundTag":"stripe-checkout-failed","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}