From 798ac0068ed841d31f6aefc11c58738dc6bf8bd0 Mon Sep 17 00:00:00 2001 From: "Carlos R. L. Rodrigues" <37986729+carlos-r-l-rodrigues@users.noreply.github.com> Date: Mon, 21 Jul 2025 08:52:47 -0300 Subject: [PATCH] chore(payment): use generate schema (#13004) Fixes: https://github.com/medusajs/medusa/issues/12959 Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com> --- .changeset/warm-sloths-pay.md | 5 + .../services/payment-module/index.spec.ts | 52 +++++--- packages/modules/payment/src/joiner-config.ts | 13 +- packages/modules/payment/src/schema/index.ts | 111 ------------------ 4 files changed, 42 insertions(+), 139 deletions(-) create mode 100644 .changeset/warm-sloths-pay.md delete mode 100644 packages/modules/payment/src/schema/index.ts diff --git a/.changeset/warm-sloths-pay.md b/.changeset/warm-sloths-pay.md new file mode 100644 index 0000000000..b199b3fceb --- /dev/null +++ b/.changeset/warm-sloths-pay.md @@ -0,0 +1,5 @@ +--- +"@medusajs/payment": patch +--- + +chore(payment): remove fixed schema from joiner config diff --git a/packages/modules/payment/integration-tests/__tests__/services/payment-module/index.spec.ts b/packages/modules/payment/integration-tests/__tests__/services/payment-module/index.spec.ts index a776647477..3343e54d09 100644 --- a/packages/modules/payment/integration-tests/__tests__/services/payment-module/index.spec.ts +++ b/packages/modules/payment/integration-tests/__tests__/services/payment-module/index.spec.ts @@ -23,11 +23,13 @@ moduleIntegrationTestRunner({ service: PaymentModuleService, }).linkable - expect(Object.keys(linkable)).toHaveLength(6) + expect(Object.keys(linkable)).toHaveLength(8) expect(Object.keys(linkable)).toEqual([ "paymentCollection", "paymentSession", "payment", + "capture", + "refund", "refundReason", "accountHolder", "paymentProvider", @@ -38,58 +40,76 @@ moduleIntegrationTestRunner({ }) expect(linkable).toEqual({ - payment: { - id: { - linkable: "payment_id", - entity: "Payment", - primaryKey: "id", - serviceName: "payment", - field: "payment", - }, - }, paymentCollection: { id: { linkable: "payment_collection_id", - entity: "PaymentCollection", primaryKey: "id", serviceName: "payment", field: "paymentCollection", + entity: "PaymentCollection", }, }, paymentSession: { id: { - field: "paymentSession", - entity: "PaymentSession", linkable: "payment_session_id", primaryKey: "id", serviceName: "payment", + field: "paymentSession", + entity: "PaymentSession", + }, + }, + payment: { + id: { + linkable: "payment_id", + primaryKey: "id", + serviceName: "payment", + field: "payment", + entity: "Payment", + }, + }, + capture: { + id: { + linkable: "capture_id", + primaryKey: "id", + serviceName: "payment", + field: "capture", + entity: "Capture", + }, + }, + refund: { + id: { + linkable: "refund_id", + primaryKey: "id", + serviceName: "payment", + field: "refund", + entity: "Refund", }, }, refundReason: { id: { linkable: "refund_reason_id", - entity: "RefundReason", primaryKey: "id", serviceName: "payment", field: "refundReason", + entity: "RefundReason", }, }, accountHolder: { id: { linkable: "account_holder_id", - entity: "AccountHolder", primaryKey: "id", serviceName: "payment", field: "accountHolder", + entity: "AccountHolder", }, }, paymentProvider: { id: { linkable: "payment_provider_id", - entity: "PaymentProvider", primaryKey: "id", serviceName: "payment", field: "paymentProvider", + entity: "PaymentProvider", }, }, }) diff --git a/packages/modules/payment/src/joiner-config.ts b/packages/modules/payment/src/joiner-config.ts index 09a4b73f75..6a36eda8ed 100644 --- a/packages/modules/payment/src/joiner-config.ts +++ b/packages/modules/payment/src/joiner-config.ts @@ -1,24 +1,13 @@ import { defineJoinerConfig, Modules } from "@medusajs/framework/utils" import { + AccountHolder, Payment, PaymentCollection, PaymentProvider, - PaymentSession, RefundReason, - AccountHolder, } from "@models" -import { default as schema } from "./schema" export const joinerConfig = defineJoinerConfig(Modules.PAYMENT, { - schema, - models: [ - Payment, - PaymentCollection, - PaymentProvider, - PaymentSession, - RefundReason, - AccountHolder, - ], linkableKeys: { payment_id: Payment.name, payment_collection_id: PaymentCollection.name, diff --git a/packages/modules/payment/src/schema/index.ts b/packages/modules/payment/src/schema/index.ts deleted file mode 100644 index ba50266f90..0000000000 --- a/packages/modules/payment/src/schema/index.ts +++ /dev/null @@ -1,111 +0,0 @@ -export default ` -enum PaymentCollectionStatus { - not_paid - awaiting - authorized - partially_authorized - canceled -} - -enum PaymentSessionStatus { - authorized - captured - pending - requires_more - error - canceled -} - -type PaymentCollection { - id: ID! - currency_code: String! - region_id: String! - amount: Float! - authorized_amount: Float - refunded_amount: Float - captured_amount: Float - completed_at: DateTime - created_at: DateTime - updated_at: DateTime - metadata: JSON - status: PaymentCollectionStatus! - payment_providers: [PaymentProviderDTO!]! - payment_sessions: [PaymentSessionDTO] - payments: [PaymentDTO] -} - -type Payment { - id: ID! - amount: Float! - raw_amount: Float - authorized_amount: Float - raw_authorized_amount: Float - currency_code: String! - provider_id: String! - cart_id: String - order_id: String - order_edit_id: String - customer_id: String - data: JSON - created_at: DateTime - updated_at: DateTime - captured_at: DateTime - canceled_at: DateTime - captured_amount: Float - raw_captured_amount: Float - refunded_amount: Float - raw_refunded_amount: Float - captures: [CaptureDTO] - refunds: [RefundDTO] - payment_collection_id: String! - payment_collection: PaymentCollectionDTO - payment_session: PaymentSessionDTO -} - -type Capture { - id: ID! - amount: Float! - created_at: DateTime! - created_by: String - payment: Payment! -} - -type Refund { - id: ID! - amount: Float! - refund_reason_id: String - refund_reason: RefundReason - note: String - created_at: DateTime! - created_by: String - payment: Payment! -} - -type PaymentSession { - id: ID! - amount: Float! - currency_code: String! - provider_id: String! - data: JSON! - context: JSON - status: PaymentSessionStatus! - authorized_at: DateTime - payment_collection_id: String! - payment_collection: PaymentCollection - payment: Payment -} - -type PaymentProvider { - id: ID! - is_enabled: String! -} - -type RefundReason { - id: ID! - label: String! - description: String - metadata: JSON - created_at: DateTime! - updated_at: DateTime! -} -`