{"record":{"id":"fb54c23569e84b24","repo":"medusajs/medusa","slug":"unable-to-retrieve-the-payment-provider-with-id","errorCode":null,"errorMessage":"Unable 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.","messagePattern":"Unable to retrieve the payment provider with id: (.+?)\nPlease make sure that the provider is registered in the container and it is configured correctly in your project configuration file\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/modules/payment/src/services/payment-provider.ts","lineNumber":71,"sourceCode":"    super(container)\n    this.#logger = container[\"logger\"]\n      ? container.logger\n      : (console as unknown as Logger)\n  }\n\n  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","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/modules/payment/src/services/payment-provider.ts#L53-L89","documentation":"Thrown when the payment module cannot resolve a payment provider from the container while retrieving it by id (providerId). This almost always wraps an AwilixResolutionError, meaning the provider service is not registered in the dependency container or is not declared in the project's payment provider configuration.","triggerScenarios":"Calling payment module methods that need a provider (createSession, authorizePayment, etc.) with a provider id that is not registered in medusa-config.js payment providers array, or when the provider plugin failed to load/resolve via Awilix resolution by name `pp_<providerId>`.","commonSituations":"Misspelled provider id, forgetting to add a custom/local plugin to payment_providers config, plugin not installed, env vars missing causing plugin resolution failure, or running with stale build after adding a new provider.","solutions":["Verify the provider id passed matches exactly what is configured (e.g. 'stripe') and what the provider declares","Add the provider to the payment provider configuration in medusa-config.js (plugins or providers array)","Ensure the provider package is installed and resolves correctly (rebuild plugins if local: yarn build)","Check the logged AwilixResolutionError above this message for the true resolution cause"],"exampleFix":"// before\nmodule.exports = defineConfig({ payment_providers: [] })\nawait paymentModuleService.createSession('stripe', input)\n\n// after\nmodule.exports = defineConfig({\n  payment_providers: [\n    resolveTo('@medusajs/medusa-payment-stripe'),\n  ],\n})\nawait paymentModuleService.createSession('stripe', input)","handlingStrategy":"validation","validationCode":"const registered = new Set(['stripe', 'manual', /* from config */])\nif (!registered.has(providerId)) {\n  throw new Error(`Provider ${providerId} is not configured`)\n}\nawait paymentService.createSession(providerId, input)","typeGuard":"const isConfiguredProvider = (id: string, configured: string[]): id is string =>\n  configured.includes(id)","tryCatchPattern":"try {\n  await paymentService.createSession(providerId, input)\n} catch (e) {\n  if (e instanceof Error && /Unable to retrieve the payment provider/.test(e.message)) {\n    // config problem: surface a setup error, do not retry\n  }\n  throw e\n}","preventionTips":["Keep a single source-of-truth list of configured provider ids shared by config and runtime checks","Validate provider ids at API boundary before reaching the payment module","Log the underlying AwilixResolutionError for fast diagnosis"],"tags":["payment","dependency-injection","configuration","awilix"],"backgroundTag":"service-resolution-failed","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}