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

feat(modules-sdk): Module provider plugin loader #6286

Merged
merged 11 commits into from
Feb 1, 2024

Conversation

olivermrbl
Copy link
Contributor

@olivermrbl olivermrbl commented Jan 31, 2024

What

Allow plugins to be installed in a module:

modules: {
    ...
    payment: {
      resolve: "@medusajs/payment",
      options: {
        providers: [
          {
            name: "@medusajs/payment-stripe",
            options: { ... },
          },
          {
            name: "@medusajs/payment-klarna",
            options: { ... },
          },
        ]
      }
    },
  },

Copy link

changeset-bot bot commented Jan 31, 2024

⚠️ No Changeset found

Latest commit: a2b7969

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Jan 31, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
medusa-dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 1, 2024 11:09am
3 Ignored Deployments
Name Status Preview Comments Updated (UTC)
api-reference ⬜️ Ignored (Inspect) Feb 1, 2024 11:09am
docs-ui ⬜️ Ignored (Inspect) Visit Preview Feb 1, 2024 11:09am
medusa-docs ⬜️ Ignored (Inspect) Visit Preview Feb 1, 2024 11:09am

Copy link
Contributor

@riqwan riqwan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clean!

Copy link
Contributor

@carlos-r-l-rodrigues carlos-r-l-rodrigues left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

just a small comment

packages/modules-sdk/src/loaders/module-provider-loader.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@fPolic fPolic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 💪

Copy link
Member

@adrien2p adrien2p left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 💪 small suggestions and todo

@srindom
Copy link
Collaborator

srindom commented Feb 1, 2024

@olivermrbl - is this ready to merge?

@olivermrbl
Copy link
Contributor Author

olivermrbl commented Feb 1, 2024

@olivermrbl - is this ready to merge?

Yes, I will work on the changes for provider plugins in a follow-up PR.

I.e. the changes needed in the Payment Module to load multiple provider installations like so:

/**
 * Example: Payment provider installation
 * {
 *  resolve: "@medusajs/payment-stripe",
 *  options: {
 *    providers: {
 *     dkk: { ...credentials }
 *     usd: { ...credentials }
 *   }
 *  }
 * }
 *
 * The installation above will install the Stripe payment provider plugin.
 * The plugin is installed with two sets of credentials, one for a DKK Stripe account and one for a USD Stripe account.
 */

This will not touch the general module provider loading mechanism but instead be specific to modules. This is where the registrationFn will come in handy.

@olivermrbl olivermrbl merged commit 3a103f0 into develop Feb 1, 2024
17 checks passed
@olivermrbl olivermrbl deleted the feat/payment-provider-support branch February 1, 2024 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants