{"record":{"id":"5e90353e6e5f7acd","repo":"payloadcms/payload","slug":"unknown-error-initiating-payment","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/confirmOrder.ts","lineNumber":144,"sourceCode":"        id: transaction.id,\n        collection: transactionsSlug,\n        data: {\n          order: order.id,\n          status: 'succeeded',\n        },\n        req,\n      })\n\n      return {\n        message: 'Payment initiated successfully',\n        orderID: order.id,\n        transactionID: transaction.id,\n        ...(order.accessToken ? { accessToken: order.accessToken } : {}),\n      }\n    } catch (error) {\n      payload.logger.error({ err: error, msg: 'Error confirming order with Stripe' })\n\n      throw new Error(error instanceof Error ? error.message : 'Unknown error initiating payment')\n    }\n  }\n","sourceCodeStart":126,"sourceCodeEnd":147,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/plugin-ecommerce/src/payments/adapters/stripe/confirmOrder.ts#L126-L147","documentation":"Thrown by the catch block at the end of Stripe confirmOrder when the caught error is not an Error instance (e.g. a string, plain object, or null thrown deep in a dependency). It is the fallback branch of error instanceof Error ? error.message : 'Unknown error initiating payment'. The original error is logged via payload.logger.error before rethrowing, so the underlying cause is in the logs even though the thrown message is generic.","triggerScenarios":"Any non-Error value thrown inside confirmOrder's try block — for example a third-party SDK that throws a string, a JSON.parse on malformed metadata that throws in a wrapper, or a network layer that rejects with a plain object. Any Error-typed thrown value surfaces its own message instead; only non-Error throws reach this branch.","commonSituations":"Stripe SDK downgrade/upgrade introducing a non-Error rejection; a custom hook in the order-create pipeline throwing a string; JSON.parse on truncated Stripe metadata throwing a SyntaxError (that one is an Error and would surface its own message — but a wrapping library could convert it); unhandled promise rejections from misconfigured fetch polyfills.","solutions":["Check the Payload logs for the err field logged immediately before this throw to find the real cause.","Reproduce in isolation and inspect typeof error and error.constructor.name in a debugger.","Upgrade/downgrade the stripe package to a version whose errors are Error instances.","Wrap third-party calls so they always reject with Error objects (e.g. catch and re-throw new Error(String(e)))."],"exampleFix":"// before: a dependency throws a non-Error\nthrow 'bad value' // surfaces as 'Unknown error initiating payment'\n// after: normalize to Error\nthrow new Error('bad value')","handlingStrategy":"try-catch","validationCode":"// Wrap third-party calls so they always reject with Error instances\nasync function safeCall<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.confirmOrder({ data: { paymentIntentID } })\n} catch (err) {\n  if (err instanceof Error && err.message === 'Unknown error initiating payment') {\n    // inspect server logs for the original err object logged just before this throw\n    return { ok: false, reason: 'unknown-confirm-error', checkLogs: true }\n  }\n  throw err\n}","preventionTips":["Always read the Payload logger entry (msg 'Error confirming order with Stripe') for the real cause — the thrown message is generic by design.","Normalize third-party rejections to Error objects before they reach the adapter.","Pin the stripe package version known to throw Error instances.","Add structured logging that captures error.constructor.name alongside the message."],"tags":["stripe","error-handling","fallback","ecommerce","logging"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}