I have create a new payment processor as https://docs.medusajs.com/modules/carts-and-checkout/backend/add-payment-provider but my payment does not update the payment provider table. What should I do for the changes to take effect on the db ?
#My new Payment processor does not get registered in the database
8 messages · Page 1 of 1 (latest)
Is your new provider in a separate plugin package, or inside your medusa project folder? A common issue with first plugins has to do with duplicate package dependencies. If you are not doing so already, try moving the code to your medusa/src folder and making sure it works there before moving it to a plugin.
thanks it worked by moving it into the src directory
That helps narrow down the source of the issue. It is almost certainly due to the circlular dependency. Before typing it out, let me search and try to find a good existing explanation of why it happens and how to avoid it.
The message in that link got corrupted a little because @medusajs was automatically converted to @[Bot]-Medusajs. Here are the steps to fix:
-
In your plugin node_modules folder, delete any medusa project package that you installed as a dependency in your project. For example, @medusajs/medusa, @medusajs/utils, and medusa-interfaces. You can leave them as dev dependencies or peer dependencies in your package.json, but delete the actual folders.
-
In your medusa backend, go to node_modules/@medusajs/medusa and type yarn link
-
In your medusa backend, go to node_modules/medusa-interfaces and type yarn link
-
In your plugin folder, type yarn link @medusajs/medusa and yarn link medusa-interfaces
Steps 2-4 should be done for all project packages you deleted in step 1.
This will not be an issue for people who install from npm. It only happens when you install locally, because the local plugin folder includes copies of packages in its own node_modules folder that are duplicates of the same packages installed at the project-level node_modules folder. When everything gets compiled, these are imported as separate classes, types, etc. Specifically, the medusa-interfaces package is being duplicated in this case, making medusa not see your payment provider as a proper payment provider. But it can cause other issues, too. Always best to keep ANY medusa packages out of your plugin node_modules folder. Link them instead.
You can also simply use yalc instead of yarn link, so much more hassle free