{"record":{"id":"b85526a06d8e7de7","repo":"hcengineering/platform","slug":"failed-to-create-subscription-at-provider","errorCode":null,"errorMessage":"Failed to create subscription at provider","messagePattern":"Failed to create subscription at provider","errorType":"http","errorClass":null,"httpStatus":500,"severity":"critical","filePath":"services/payment/pod-payment/src/server.ts","lineNumber":243,"sourceCode":"\n          if (request.type === undefined || request.plan === undefined) {\n            res.status(400).json({ error: 'Missing required fields: type, plan' })\n            return\n          }\n\n          let createSubResponse: CheckoutResponse\n\n          try {\n            createSubResponse = await provider.createSubscription(\n              ctx,\n              request,\n              workspaceUuid,\n              loginInfo.workspaceUrl,\n              accountUuid\n            )\n          } catch (err) {\n            ctx.error('Failed to create subscription at provider', { err })\n            res.status(500).json({ error: 'Failed to create subscription at provider' })\n            return\n          }\n\n          res.status(200).json(createSubResponse)\n        },\n        req,\n        res,\n        () => {}\n      )\n    }\n  )\n\n  /**\n   * POST /api/v1/subscriptions/:subscriptionId/cancel\n   * Cancel a subscription\n   * Authorization: Only workspace owner/admin can cancel\n   */\n  app.post(","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/services/payment/pod-payment/src/server.ts#L225-L261","documentation":"This 500 is returned when provider.createSubscription(...) throws while creating the checkout/subscription with the external payment provider (e.g. Stripe/Paddle). The error is logged server-side with ctx.error and a sanitized generic message is returned to the client. It wraps any provider-side failure: network errors, invalid API keys, rejected plans, or provider API errors.","triggerScenarios":"POST /api/v1/subscriptions/:workspace/subscribe passing all local validation (token, loginInfo.workspaceUrl, type, plan) but the configured payment provider throws during createSubscription — e.g. unknown plan ID, provider API key invalid/expired, provider outage, or network failure to the provider.","commonSituations":"Rotated or missing provider API credentials in the environment; plan name in the request not existing in the provider's catalog; provider sandbox vs production mismatch; transient provider downtime; expired payment-provider access token.","solutions":["Check the server logs for the ctx.error entry labeled 'Failed to create subscription at provider' to see the underlying provider error.","Verify payment provider credentials/env vars (API keys, webhook secret) are present and valid in this deployment.","Confirm the requested plan exists in the provider dashboard and matches the provider's plan/price ID mapping.","Retry after confirming the provider status page shows no incident; add retry/backoff around provider calls for transient failures.","If the provider SDK throws on auth, rotate the API key and redeploy."],"exampleFix":"// before (stale key)\nPAYMENT_PROVIDER_API_KEY=sk_live_old\n// -> 500 Failed to create subscription at provider\n\n// after\nPAYMENT_PROVIDER_API_KEY=sk_live_current  // redeploy; request succeeds with 200 CheckoutResponse","handlingStrategy":"retry","validationCode":"// pre-flight: verify provider is reachable and credentials work\nconst ok = await provider.verifyConnection?.() // or a lightweight provider API call\nif (!ok) throw new Error('Payment provider unreachable or credentials invalid; aborting subscribe')","typeGuard":"function isProviderError(err: unknown): err is Error & { code?: string; providerStatus?: number } {\n  return err instanceof Error\n}","tryCatchPattern":"try {\n  const checkout = await subscribe(payload)\n} catch (e) {\n  if (e instanceof HttpError && e.status === 500 && e.message === 'Failed to create subscription at provider') {\n    // inspect server logs / provider status, then retry with exponential backoff (max 3)\n  } else throw e\n}","preventionTips":["Monitor provider status pages and add alerts for provider API error rates.","Rotate and validate provider API keys in CI before deploys.","Keep plan/price ID mappings in sync with the provider dashboard.","Implement idempotent retries with backoff around provider calls."],"tags":["http-500","payment-provider","external-api","network"],"backgroundTag":"payment-provider-request-failed","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}