{"record":{"id":"59648ddd9bb44641","repo":"medusajs/medusa","slug":"unable-to-retrieve-the-payment-provider-with-id-59648d","errorCode":null,"errorMessage":"Unable to retrieve the payment provider with id: ${providerId}, the following error occurred: ${err.message}","messagePattern":"Unable to retrieve the payment provider with id: (.+?), the following error occurred: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/modules/payment/src/services/payment-provider.ts","lineNumber":77,"sourceCode":"  retrieveProvider(providerId: string): IPaymentProvider {\n    try {\n      return this.__container__[providerId] as IPaymentProvider\n    } catch (err) {\n      if (err.name === \"AwilixResolutionError\") {\n        const errMessage = `\nUnable to retrieve the payment provider with id: ${providerId}\nPlease make sure that the provider is registered in the container and it is configured correctly in your project configuration file.`\n\n        // Log full error for debugging\n        this.#logger.error(`AwilixResolutionError: ${err.message}`, err)\n\n        throw new Error(errMessage)\n      }\n\n      const errMessage = `Unable to retrieve the payment provider with id: ${providerId}, the following error occurred: ${err.message}`\n      this.#logger.error(errMessage)\n\n      throw new Error(errMessage)\n    }\n  }\n\n  async createSession(\n    providerId: string,\n    sessionInput: InitiatePaymentInput\n  ): Promise<InitiatePaymentOutput> {\n    const provider = this.retrieveProvider(providerId)\n\n    return await provider.initiatePayment(sessionInput)\n  }\n\n  async updateSession(\n    providerId: string,\n    sessionInput: UpdatePaymentInput\n  ): Promise<UpdatePaymentOutput> {\n    const provider = this.retrieveProvider(providerId)\n","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/modules/payment/src/services/payment-provider.ts#L59-L95","documentation":"Generic wrapper thrown when retrieving a payment provider from the container fails with an unexpected (non-Awilix-resolution) error. The underlying error message is appended, so the real cause is whatever the container or provider module threw during resolution/instantiation.","triggerScenarios":"A payment provider whose constructor or module top-level code throws (e.g. missing env var like STRIPE_API_KEY, malformed config), causing container.resolve() of `pp_<providerId>` to fail with an arbitrary exception.","commonSituations":"Missing API key env vars for the provider, invalid provider options in medusa-config.js, a provider package version incompatible with the installed @medusajs/* framework, or broken plugin build output.","solutions":["Read the appended underlying error message — it names the actual failure","Check required env vars / API keys for the provider are set in .env","Validate the provider's options block in medusa-config.js","Reinstall or align the provider package version with your Medusa version"],"exampleFix":"// before\n// .env missing key, options empty\npayment_providers: [resolveTo('@medusajs/medusa-payment-stripe')]\n\n// after\n// .env: STRIPE_API_KEY=sk_test_...\npayment_providers: [\n  {\n    resolve: '@medusajs/medusa-payment-stripe',\n    options: { api_key: process.env.STRIPE_API_KEY },\n  },\n]","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const provider = service.retrieveProvider(id)\n} catch (e) {\n  const msg = e instanceof Error ? e.message : ''\n  if (msg.includes('the following error occurred')) {\n    // inspect appended cause; treat as environment/config failure, fail fast\n  }\n  throw e\n}","preventionTips":["Set and verify all provider env vars at startup","Fail fast in dev with a health check that resolves each configured provider once at boot"],"tags":["payment","configuration","environment-variables","provider"],"backgroundTag":"provider-initialization-failed","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}