chore: Update modules providers configuration with 'identifier' and 'PROVIDER' (#9636)
* chore: Update modules providers configuration with 'identifier' and 'PROVIDER' * update check * fix tests * type * normalize auth provider * emailpass * providers --------- Co-authored-by: Carlos R. L. Rodrigues <rodrigolr@gmail.com> Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
902ac12f73
commit
876d8072e7
@@ -5,7 +5,7 @@ import {
|
||||
ModuleProvider,
|
||||
ModulesSdkTypes,
|
||||
} from "@medusajs/framework/types"
|
||||
import { Lifetime, asFunction, asValue } from "awilix"
|
||||
import { asFunction, asValue, Lifetime } from "awilix"
|
||||
import { MedusaError } from "@medusajs/framework/utils"
|
||||
|
||||
import { PaymentProviderService } from "@services"
|
||||
@@ -14,14 +14,16 @@ import * as providers from "../providers"
|
||||
const PROVIDER_REGISTRATION_KEY = "payment_providers"
|
||||
|
||||
const registrationFn = async (klass, container, pluginOptions) => {
|
||||
if (!klass?.PROVIDER) {
|
||||
if (!klass?.identifier) {
|
||||
throw new MedusaError(
|
||||
MedusaError.Types.INVALID_ARGUMENT,
|
||||
`Trying to register a payment provider without a provider identifier.`
|
||||
)
|
||||
}
|
||||
|
||||
const key = `pp_${klass.PROVIDER}_${pluginOptions.id}`
|
||||
const key = `pp_${klass.identifier}${
|
||||
pluginOptions.id ? `_${pluginOptions.id}` : ""
|
||||
}`
|
||||
|
||||
container.register({
|
||||
[key]: asFunction((cradle) => new klass(cradle, pluginOptions.options), {
|
||||
|
||||
@@ -13,7 +13,6 @@ import {
|
||||
|
||||
export class SystemProviderService extends AbstractPaymentProvider {
|
||||
static identifier = "system"
|
||||
static PROVIDER = "system"
|
||||
|
||||
async getStatus(_): Promise<string> {
|
||||
return "authorized"
|
||||
|
||||
Reference in New Issue
Block a user