Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot add Custom Payment Provider #7988

Closed
jscardona12 opened this issue Jul 5, 2024 · 20 comments
Closed

Cannot add Custom Payment Provider #7988

jscardona12 opened this issue Jul 5, 2024 · 20 comments

Comments

@jscardona12
Copy link

Bug report

Hi, the documentation is not clear so i base my provider in https://github.com/medusajs/medusa/blob/develop/packages/modules/providers/payment-stripe/src/index.ts

Describe the bug

I have my module config like this
Screenshot 2024-07-05 at 1 18 26 PM

I'm getting this error:
Error: Loaders for module PaymentModuleService failed: Unable to find module ./modules/payment-wompi -- perhaps you need to install its package?

What do i need to do so the Payment Provider Module works?

Thank you in advance

@kenidotproton
Copy link

I also had this issue as well. I also have problems with the product images not showing up.

@jscardona12
Copy link
Author

I also had this issue as well. I also have problems with the product images not showing up.

@kenidotproton were you able to fix it?

@kenidotproton
Copy link

Nah not really while I got the plugin to kinda work by installing the @medusajs/payment and medusa-core-utils packages Stripe didn't work for me and Doesn't show up in the backend.

@adrien2p
Copy link
Member

adrien2p commented Jul 8, 2024

Thank you for the report, I ll fix that

@adrien2p
Copy link
Member

adrien2p commented Jul 8, 2024

I have fixed the loading mechanism, it should be available in the release that follows this pr

Screenshot 2024-07-08 at 12 15 07

@jscardona12
Copy link
Author

Hi @adrien2p i deleted de node_modules folder install them again, every medusa module is in preview, but i'm still facing the same issue, is there any step i'm missing?

@adrien2p
Copy link
Member

@jscardona12 I ve tried on my side and it worked, can I get your to remove your lock file as well please?

@jscardona12
Copy link
Author

Today is working, thx!

@ogcatt
Copy link

ogcatt commented Sep 29, 2024

Hi, I am still getting this issue even when deleting the lockfile, running migrations, removing node_modules etc.

The error: Error: Loaders for module Payment failed: Unable to find module ./modules/providers/crypto -- perhaps you need to install its package?

Relevant code in medusa config:

[Modules.PAYMENT]: {
      resolve: "@medusajs/payment",
      options: {
        providers: [
          {
            resolve: "./modules/providers/crypto",
            id: "crypto",
            options: {
              // provider options...
              ServerUrl: process.env.SERVER_URL,
              ServerPublicKey: process.env.SERVER_PUB_KEY,
              ServerPrivateKey: process.env.SERVER_PRIV_KEY,
              ServerStoreId: process.env.SERVER_STORE_ID,
            },
          },
        ],
      },
    },
    ```

@SalahAdDin
Copy link

Hi, I am still getting this issue even when deleting the lockfile, running migrations, removing node_modules etc.

The error: Error: Loaders for module Payment failed: Unable to find module ./modules/providers/crypto -- perhaps you need to install its package?

Relevant code in medusa config:

[Modules.PAYMENT]: {
      resolve: "@medusajs/payment",
      options: {
        providers: [
          {
            resolve: "./modules/providers/crypto",
            id: "crypto",
            options: {
              // provider options...
              ServerUrl: process.env.SERVER_URL,
              ServerPublicKey: process.env.SERVER_PUB_KEY,
              ServerPrivateKey: process.env.SERVER_PRIV_KEY,
              ServerStoreId: process.env.SERVER_STORE_ID,
            },
          },
        ],
      },
    },
    ```

Can you share the stack trace?

@ogcatt
Copy link

ogcatt commented Sep 30, 2024

Here ye go:

error:   Error starting server
Error: Loaders for module Payment failed: Unable to find module ./modules/providers/crypto -- perhaps you need to install its package?
    at runLoaders (/mnt/drive/Coding/medusa/node_modules/@medusajs/modules-sdk/dist/loaders/utils/load-internal.js:236:20)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async loadInternalModule (/mnt/drive/Coding/medusa/node_modules/@medusajs/modules-sdk/dist/loaders/utils/load-internal.js:82:19)
    at async loadModule (/mnt/drive/Coding/medusa/node_modules/@medusajs/modules-sdk/dist/loaders/module-loader.js:48:12)
    at async moduleLoader (/mnt/drive/Coding/medusa/node_modules/@medusajs/modules-sdk/dist/loaders/module-loader.js:10:36)
    at async MedusaModule.bootstrap (/mnt/drive/Coding/medusa/node_modules/@medusajs/modules-sdk/dist/medusa-module.js:188:13)
    at async /mnt/drive/Coding/medusa/node_modules/@medusajs/modules-sdk/dist/medusa-app.js:49:25
    at async Promise.all (index 16)
    at async loadModules (/mnt/drive/Coding/medusa/node_modules/@medusajs/modules-sdk/dist/medusa-app.js:21:5)
    at async MedusaApp_ (/mnt/drive/Coding/medusa/node_modules/@medusajs/modules-sdk/dist/medusa-app.js:169:24)

My modules are in src/ like docs recommended.

@SalahAdDin
Copy link

it says the module is not installed, either you didn't follow the documents or the installer does not install it by default!

@ogcatt
Copy link

ogcatt commented Sep 30, 2024

it says the module is not installed, either you didn't follow the documents or the installer does not install it by default!

It is a local module under a provider for the payment module. It should be able to find the local directory, but it thinks it is a package instead, when it shouldn't. This is the case unless the error log is innacurate.

@adrien2p
Copy link
Member

adrien2p commented Oct 1, 2024

We should probably improve the error and provide the location from which we are trying to import. Could you log the normalized path from here please

packages/core/modules-sdk/src/loaders/module-provider-loader.ts

@ogcatt
Copy link

ogcatt commented Oct 1, 2024

Sorry, I don't know what you mean by this

@adrien2p
Copy link
Member

adrien2p commented Oct 1, 2024

Sorry, I don't know what you mean by this

if you go in your node modules under /node_modules/@medusajs/modules-sdk/dist/loaders/module-provider-loader.js and you log what is stored in normalizedPath line 21, what is the value here

@ogcatt
Copy link

ogcatt commented Oct 1, 2024

Got this: /mnt/drive/Coding/medusa/dist/modules/providers/crypto

I think it is prefixing to dist not src and that is the issue.

I tried doing this: resolve: "./../src/modules/providers/crypto" and I checked the normalizedPath and it seems accurate with this updated resolve string, but it still can't find the provider. There is definitely an index.ts file so that is confusing.

@ogcatt
Copy link

ogcatt commented Oct 1, 2024

Added error logging (which should be handled by default btw) before the throw, here is an updated log:

Error: Cannot find module '/mnt/drive/Coding/medusa/src/modules/providers/crypto'
Require stack:
- /mnt/drive/Coding/medusa/node_modules/@medusajs/utils/dist/common/dynamic-import.js
- /mnt/drive/Coding/medusa/node_modules/@medusajs/utils/dist/common/index.js
- /mnt/drive/Coding/medusa/node_modules/@medusajs/utils/dist/graphql/graphql-to-ts-types.js
- /mnt/drive/Coding/medusa/node_modules/@medusajs/utils/dist/graphql/index.js
- /mnt/drive/Coding/medusa/node_modules/@medusajs/utils/dist/index.js
- /mnt/drive/Coding/medusa/node_modules/@medusajs/framework/dist/utils/index.js
- /mnt/drive/Coding/medusa/node_modules/@medusajs/medusa/dist/commands/start.js
- /usr/local/lib/node_modules/@medusajs/medusa-cli/dist/create-cli.js
- /usr/local/lib/node_modules/@medusajs/medusa-cli/dist/index.js
- /usr/local/lib/node_modules/@medusajs/medusa-cli/cli.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1149:15)
    at Module._load (node:internal/modules/cjs/loader:990:27)
    at Module.require (node:internal/modules/cjs/loader:1237:19)
    at require (node:internal/modules/helpers:176:18)
    at dynamicImport (/mnt/drive/Coding/medusa/node_modules/@medusajs/utils/dist/common/dynamic-import.js:17:20)
    at loadModuleProvider (/mnt/drive/Coding/medusa/node_modules/@medusajs/modules-sdk/dist/loaders/module-provider-loader.js:23:62)
    at /mnt/drive/Coding/medusa/node_modules/@medusajs/modules-sdk/dist/loaders/module-provider-loader.js:12:15
    at Array.map (<anonymous>)
    at moduleProviderLoader (/mnt/drive/Coding/medusa/node_modules/@medusajs/modules-sdk/dist/loaders/module-provider-loader.js:11:45)
    at exports.default (/mnt/drive/Coding/medusa/node_modules/@medusajs/payment/dist/loaders/providers.js:44:50) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/mnt/drive/Coding/medusa/node_modules/@medusajs/utils/dist/common/dynamic-import.js',
    '/mnt/drive/Coding/medusa/node_modules/@medusajs/utils/dist/common/index.js',
    '/mnt/drive/Coding/medusa/node_modules/@medusajs/utils/dist/graphql/graphql-to-ts-types.js',
    '/mnt/drive/Coding/medusa/node_modules/@medusajs/utils/dist/graphql/index.js',
    '/mnt/drive/Coding/medusa/node_modules/@medusajs/utils/dist/index.js',
    '/mnt/drive/Coding/medusa/node_modules/@medusajs/framework/dist/utils/index.js',
    '/mnt/drive/Coding/medusa/node_modules/@medusajs/medusa/dist/commands/start.js',
    '/usr/local/lib/node_modules/@medusajs/medusa-cli/dist/create-cli.js',
    '/usr/local/lib/node_modules/@medusajs/medusa-cli/dist/index.js',
    '/usr/local/lib/node_modules/@medusajs/medusa-cli/cli.js'
  ]
}
error:   Could not resolve module: Payment. Error: Loaders for module Payment failed: Unable to find module ./../src/modules/providers/crypto -- perhaps you need to install its package?

@thetutlage
Copy link
Contributor

Hello guys, can you please open a new issue with a repo that we can use for reproduction? Just want to make sure we are not mixing multiple things :)

@ogcatt
Copy link

ogcatt commented Oct 1, 2024

#9416

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants