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:
Stevche Radevski
2025-10-29 15:07:33 +01:00
committed by GitHub
co-authored by adrien2p Oli Juhl
parent 1defb3c29b
commit ef7b9b9375
19 changed files with 1182 additions and 23 deletions
@@ -7,9 +7,50 @@ jest.setTimeout(30000)
moduleIntegrationTestRunner<IPaymentModuleService>({
moduleName: Modules.PAYMENT,
moduleOptions: {
cloud: {
api_key: "test",
environment_handle: "test",
webhook_secret: "test",
endpoint: "test",
},
},
testSuite: ({ service }) => {
describe("Payment Module Service", () => {
describe("providers", () => {
it("should load the system and medusa payments providers by default", async () => {
const paymentProviders = await service.listPaymentProviders()
expect(paymentProviders).toHaveLength(2)
expect(paymentProviders).toEqual(
expect.arrayContaining([
expect.objectContaining({
id: "pp_system_default",
}),
expect.objectContaining({
id: "pp_medusa-payments_default",
}),
])
)
})
it("should create a payment session successfully", async () => {
const paymentCollection = await service.createPaymentCollections({
currency_code: "USD",
amount: 200,
})
const paymentSession = await service.createPaymentSession(
paymentCollection.id,
{
provider_id: "pp_system_default",
amount: 200,
currency_code: "USD",
data: {},
}
)
})
it("should load payment plugins", async () => {
let error = await service
.createPaymentCollections([
@@ -46,3 +87,16 @@ moduleIntegrationTestRunner<IPaymentModuleService>({
})
},
})
moduleIntegrationTestRunner<IPaymentModuleService>({
moduleName: Modules.PAYMENT,
moduleOptions: {},
testSuite: ({ service }) =>
describe("providers", () => {
it("should not load the medusa payments provider if the cloud options are not provided", async () => {
const paymentProviders = await service.listPaymentProviders()
expect(paymentProviders).toHaveLength(1)
expect(paymentProviders[0].id).toBe("pp_system_default")
})
}),
})