hcengineering/platform · critical

Failed to create subscription at provider

Error message

Failed to create subscription at provider

What it means

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.

Source

Thrown at services/payment/pod-payment/src/server.ts:243

          if (request.type === undefined || request.plan === undefined) {
            res.status(400).json({ error: 'Missing required fields: type, plan' })
            return
          }

          let createSubResponse: CheckoutResponse

          try {
            createSubResponse = await provider.createSubscription(
              ctx,
              request,
              workspaceUuid,
              loginInfo.workspaceUrl,
              accountUuid
            )
          } catch (err) {
            ctx.error('Failed to create subscription at provider', { err })
            res.status(500).json({ error: 'Failed to create subscription at provider' })
            return
          }

          res.status(200).json(createSubResponse)
        },
        req,
        res,
        () => {}
      )
    }
  )

  /**
   * POST /api/v1/subscriptions/:subscriptionId/cancel
   * Cancel a subscription
   * Authorization: Only workspace owner/admin can cancel
   */
  app.post(

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Check the server logs for the ctx.error entry labeled 'Failed to create subscription at provider' to see the underlying provider error.
  2. Verify payment provider credentials/env vars (API keys, webhook secret) are present and valid in this deployment.
  3. Confirm the requested plan exists in the provider dashboard and matches the provider's plan/price ID mapping.
  4. Retry after confirming the provider status page shows no incident; add retry/backoff around provider calls for transient failures.
  5. If the provider SDK throws on auth, rotate the API key and redeploy.

Example fix

// before (stale key)
PAYMENT_PROVIDER_API_KEY=sk_live_old
// -> 500 Failed to create subscription at provider

// after
PAYMENT_PROVIDER_API_KEY=sk_live_current  // redeploy; request succeeds with 200 CheckoutResponse
Defensive patterns

Strategy: retry

Validate before calling

// pre-flight: verify provider is reachable and credentials work
const ok = await provider.verifyConnection?.() // or a lightweight provider API call
if (!ok) throw new Error('Payment provider unreachable or credentials invalid; aborting subscribe')

Type guard

function isProviderError(err: unknown): err is Error & { code?: string; providerStatus?: number } {
  return err instanceof Error
}

Try / catch

try {
  const checkout = await subscribe(payload)
} catch (e) {
  if (e instanceof HttpError && e.status === 500 && e.message === 'Failed to create subscription at provider') {
    // inspect server logs / provider status, then retry with exponential backoff (max 3)
  } else throw e
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29). Data as JSON: /api/errors/b85526a06d8e7de7. Report an issue: GitHub.