|
1
|
import { MedusaContainer } from "@medusajs/framework/types" |
|
2
|
import { ContainerRegistrationKeys, Modules } from "@medusajs/framework/utils" |
|
3
|
|
|
4
|
/** |
|
5
|
* Enables payment providers in a region by creating the `region_payment_provider` |
|
6
|
* links directly. Useful for tests that create regions through the Region Module |
|
7
|
* rather than through `createRegionsWorkflow`. |
|
8
|
*/ |
|
9
|
export const linkRegionPaymentProviders = async ( |
|
10
|
container: MedusaContainer, |
|
11
|
regionId: string, |
|
12
|
paymentProviderIds: string[] = ["pp_system_default"] |
|
13
|
) => { |
|
14
|
const link = container.resolve(ContainerRegistrationKeys.LINK) |
|
15
|
|
|
16
|
await link.create( |
|
17
|
paymentProviderIds.map((paymentProviderId) => ({ |
|
18
|
[Modules.REGION]: { region_id: regionId }, |
|
19
|
[Modules.PAYMENT]: { payment_provider_id: paymentProviderId }, |
|
20
|
})) |
|
21
|
) |
|
22
|
} |