{"record":{"id":"fe145606ac591f87","repo":"payloadcms/payload","slug":"unknown-error-initiating-payment-fe1456","errorCode":null,"errorMessage":"Unknown error initiating payment","messagePattern":"Unknown error initiating payment","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/plugin-ecommerce/src/payments/adapters/stripe/initiatePayment.ts","lineNumber":135,"sourceCode":"          stripe: {\n            customerID: customer.id,\n            paymentIntentID: paymentIntent.id,\n          },\n        },\n        req,\n      })\n\n      const returnData: InitiatePaymentReturnType = {\n        clientSecret: paymentIntent.client_secret || '',\n        message: 'Payment initiated successfully',\n        paymentIntentID: paymentIntent.id,\n      }\n\n      return returnData\n    } catch (error) {\n      payload.logger.error({ err: error, msg: 'Error initiating payment with Stripe' })\n\n      throw new Error(error instanceof Error ? error.message : 'Unknown error initiating payment')\n    }\n  }\n","sourceCodeStart":117,"sourceCodeEnd":138,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/plugin-ecommerce/src/payments/adapters/stripe/initiatePayment.ts#L117-L138","documentation":"Thrown by the catch block at the end of Stripe initiatePayment when the caught error is not an Error instance. It is the fallback branch of error instanceof Error ? error.message : 'Unknown error initiating payment'. The original value is logged via payload.logger.error with msg 'Error initiating payment with Stripe' before the generic message is thrown, so the true cause is in the logs.","triggerScenarios":"Any non-Error value thrown inside initiatePayment's try block — e.g. a dependency rejecting with a string, a malformed Stripe response parsed into a plain object, or a polyfill that throws non-Error values. Error-typed throws surface their own message; only non-Error throws reach this branch.","commonSituations":"Stripe SDK version mismatch producing non-Error rejections; a custom middleware throwing a string; JSON.stringify failing on circular cart data and a wrapper converting it; fetch polyfills in older Node versions; misconfigured proxy throwing plain objects.","solutions":["Inspect the Payload log entry (msg 'Error initiating payment with Stripe', field err) for the real cause.","Reproduce locally and log typeof error, error, and (error as any)?.constructor?.name.","Align the stripe package version with the adapter's expectations.","Normalize third-party rejections to Error objects before they reach the adapter."],"exampleFix":"// before: dependency throws a non-Error\nthrow { status: 400 } // surfaces as 'Unknown error initiating payment'\n// after\nthrow new Error('Request failed with status 400')","handlingStrategy":"try-catch","validationCode":"// Normalize third-party rejections to Error instances before they reach the adapter\nasync function safeStripeCall<T>(fn: () => Promise<T>): Promise<T> {\n  try {\n    return await fn()\n  } catch (e) {\n    if (e instanceof Error) throw e\n    throw new Error(typeof e === 'string' ? e : JSON.stringify(e))\n  }\n}","typeGuard":"export function isErrorLike(e: unknown): e is Error {\n  return e instanceof Error || (typeof e === 'object' && e !== null && typeof (e as { message?: unknown }).message === 'string')\n}","tryCatchPattern":"try {\n  await payments.initiatePayment({ data })\n} catch (err) {\n  if (err instanceof Error && err.message === 'Unknown error initiating payment') {\n    // consult server logs: msg 'Error initiating payment with Stripe' carries the original err\n    return { ok: false, reason: 'unknown-initiate-error', checkLogs: true }\n  }\n  throw err\n}","preventionTips":["Read the Payload log entry for the original err object — the thrown message is generic by design.","Pin the stripe package version known to reject with Error instances.","Wrap third-party calls so they reject with Error objects before reaching the adapter.","Add structured logging that records error.constructor.name and the full error."],"tags":["stripe","error-handling","fallback","ecommerce","logging"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}