feat: Implement medusa payments provider (#13772)
* feat: Implement medusa payments provider * chore: Improvements after testing * chore: Add typings to medusa payments * fix: Final changes to complete medusa payment provider * update package * fix: Final changes to complete medusa payment provider --------- Co-authored-by: adrien2p <adrien.deperetti@gmail.com> Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
co-authored by
adrien2p
Oli Juhl
parent
1defb3c29b
commit
ef7b9b9375
@@ -41,11 +41,46 @@ export default async ({
|
||||
(
|
||||
| ModulesSdkTypes.ModuleServiceInitializeOptions
|
||||
| ModulesSdkTypes.ModuleServiceInitializeCustomDataLayerOptions
|
||||
) & { providers: ModuleProvider[] }
|
||||
) & {
|
||||
providers: ModuleProvider[]
|
||||
cloud: {
|
||||
api_key?: string
|
||||
endpoint?: string
|
||||
environment_handle?: string
|
||||
sandbox_handle?: string
|
||||
webhook_secret?: string
|
||||
}
|
||||
}
|
||||
>): Promise<void> => {
|
||||
// Local providers
|
||||
for (const provider of Object.values(providers)) {
|
||||
await registrationFn(provider, container, { id: "default" })
|
||||
await registrationFn(providers.SystemPaymentProvider, container, {
|
||||
id: "default",
|
||||
})
|
||||
|
||||
// We only want to register medusa payments if the options for it have been provided.
|
||||
const {
|
||||
api_key,
|
||||
endpoint,
|
||||
environment_handle,
|
||||
sandbox_handle,
|
||||
webhook_secret,
|
||||
} = options?.cloud ?? {}
|
||||
|
||||
if (
|
||||
api_key &&
|
||||
endpoint &&
|
||||
webhook_secret &&
|
||||
(environment_handle || sandbox_handle)
|
||||
) {
|
||||
await registrationFn(providers.MedusaPaymentsProvider, container, {
|
||||
options: {
|
||||
api_key,
|
||||
endpoint,
|
||||
environment_handle,
|
||||
sandbox_handle,
|
||||
webhook_secret,
|
||||
},
|
||||
id: "default",
|
||||
})
|
||||
}
|
||||
|
||||
await moduleProviderLoader({
|
||||
|
||||
Reference in New Issue
Block a user