@mercurjs/core 2.3.9-canary.4 → 2.3.9-canary.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (197) hide show
  1. package/.medusa/server/src/api/admin/middlewares.js +41 -39
  2. package/.medusa/server/src/api/admin/payout-accounts/[id]/refresh-link/route.d.ts +3 -0
  3. package/.medusa/server/src/api/admin/payout-accounts/[id]/refresh-link/route.js +14 -0
  4. package/.medusa/server/src/api/admin/payout-accounts/[id]/route.d.ts +3 -0
  5. package/.medusa/server/src/api/admin/payout-accounts/[id]/route.js +18 -0
  6. package/.medusa/server/src/api/admin/payout-accounts/[id]/sync/route.d.ts +3 -0
  7. package/.medusa/server/src/api/admin/payout-accounts/[id]/sync/route.js +14 -0
  8. package/.medusa/server/src/api/admin/payout-accounts/helpers.d.ts +2 -0
  9. package/.medusa/server/src/api/admin/payout-accounts/helpers.js +7 -0
  10. package/.medusa/server/src/api/admin/payout-accounts/middlewares.d.ts +2 -0
  11. package/.medusa/server/src/api/admin/payout-accounts/middlewares.js +45 -0
  12. package/.medusa/server/src/api/admin/payout-accounts/query-config.d.ts +11 -0
  13. package/.medusa/server/src/api/admin/payout-accounts/query-config.js +26 -0
  14. package/.medusa/server/src/api/admin/payout-accounts/route.d.ts +5 -0
  15. package/.medusa/server/src/api/admin/payout-accounts/route.js +31 -0
  16. package/.medusa/server/src/api/admin/payout-accounts/validators.d.ts +51 -0
  17. package/.medusa/server/src/api/admin/payout-accounts/validators.js +22 -0
  18. package/.medusa/server/src/api/admin/payouts/[id]/retry/route.d.ts +3 -0
  19. package/.medusa/server/src/api/admin/payouts/[id]/retry/route.js +14 -0
  20. package/.medusa/server/src/api/admin/payouts/helpers.d.ts +2 -0
  21. package/.medusa/server/src/api/admin/payouts/helpers.js +7 -0
  22. package/.medusa/server/src/api/admin/payouts/middlewares.js +16 -1
  23. package/.medusa/server/src/api/admin/payouts/query-config.js +10 -1
  24. package/.medusa/server/src/api/admin/payouts/validators.d.ts +2 -0
  25. package/.medusa/server/src/api/admin/payouts/validators.js +3 -1
  26. package/.medusa/server/src/api/hooks/payout/route.js +4 -6
  27. package/.medusa/server/src/api/middlewares.js +5 -1
  28. package/.medusa/server/src/api/payout/onboarding/refresh/route.d.ts +6 -0
  29. package/.medusa/server/src/api/payout/onboarding/refresh/route.js +21 -0
  30. package/.medusa/server/src/api/store/carts/middlewares.js +11 -1
  31. package/.medusa/server/src/api/utils/ensure-seller-middleware.js +2 -2
  32. package/.medusa/server/src/api/vendor/payout-accounts/[id]/onboarding/route.js +2 -8
  33. package/.medusa/server/src/api/vendor/payout-accounts/helpers.d.ts +2 -0
  34. package/.medusa/server/src/api/vendor/payout-accounts/helpers.js +7 -2
  35. package/.medusa/server/src/api/vendor/payout-accounts/me/route.d.ts +3 -0
  36. package/.medusa/server/src/api/vendor/payout-accounts/me/route.js +15 -0
  37. package/.medusa/server/src/api/vendor/payout-accounts/middlewares.js +9 -1
  38. package/.medusa/server/src/api/vendor/payout-accounts/query-config.d.ts +11 -0
  39. package/.medusa/server/src/api/vendor/payout-accounts/query-config.js +30 -2
  40. package/.medusa/server/src/api/vendor/payout-accounts/route.js +4 -9
  41. package/.medusa/server/src/api/vendor/payout-accounts/validators.d.ts +3 -1
  42. package/.medusa/server/src/api/vendor/payout-accounts/validators.js +5 -2
  43. package/.medusa/server/src/api/vendor/payouts/query-config.d.ts +2 -0
  44. package/.medusa/server/src/api/vendor/payouts/query-config.js +12 -2
  45. package/.medusa/server/src/api/vendor/payouts/validators.d.ts +1 -0
  46. package/.medusa/server/src/api/vendor/payouts/validators.js +2 -1
  47. package/.medusa/server/src/api/vendor/sellers/select/route.js +2 -2
  48. package/.medusa/server/src/modules/payout/index.d.ts +1 -45
  49. package/.medusa/server/src/modules/payout/loaders/provider.js +7 -3
  50. package/.medusa/server/src/modules/payout/migrations/Migration20261028120000.d.ts +5 -0
  51. package/.medusa/server/src/modules/payout/migrations/Migration20261028120000.js +97 -0
  52. package/.medusa/server/src/modules/payout/models/index.d.ts +1 -0
  53. package/.medusa/server/src/modules/payout/models/index.js +4 -2
  54. package/.medusa/server/src/modules/payout/models/onboarding.d.ts +22 -1
  55. package/.medusa/server/src/modules/payout/models/payout-account.d.ts +23 -2
  56. package/.medusa/server/src/modules/payout/models/payout-account.js +33 -7
  57. package/.medusa/server/src/modules/payout/models/payout-reversal.d.ts +48 -0
  58. package/.medusa/server/src/modules/payout/models/payout-reversal.js +37 -0
  59. package/.medusa/server/src/modules/payout/models/payout.d.ts +22 -1
  60. package/.medusa/server/src/modules/payout/models/payout.js +18 -2
  61. package/.medusa/server/src/modules/payout/providers/system.d.ts +11 -5
  62. package/.medusa/server/src/modules/payout/providers/system.js +33 -14
  63. package/.medusa/server/src/modules/payout/services/payout-module-service.d.ts +94 -100
  64. package/.medusa/server/src/modules/payout/services/payout-module-service.js +316 -109
  65. package/.medusa/server/src/modules/payout/services/provider-service.d.ts +11 -7
  66. package/.medusa/server/src/modules/payout/services/provider-service.js +33 -13
  67. package/.medusa/server/src/modules/payout/utils/abstract-payout-provider.d.ts +20 -0
  68. package/.medusa/server/src/modules/payout/utils/abstract-payout-provider.js +19 -0
  69. package/.medusa/server/src/modules/payout/utils/index.d.ts +1 -0
  70. package/.medusa/server/src/modules/payout/utils/index.js +18 -0
  71. package/.medusa/server/src/modules/telemetry/index.d.ts +21 -0
  72. package/.medusa/server/src/modules/telemetry/index.js +12 -0
  73. package/.medusa/server/src/modules/telemetry/migrations/Migration20261029000000.d.ts +5 -0
  74. package/.medusa/server/src/modules/telemetry/migrations/Migration20261029000000.js +27 -0
  75. package/.medusa/server/src/modules/telemetry/models/index.d.ts +1 -0
  76. package/.medusa/server/src/modules/telemetry/models/index.js +10 -0
  77. package/.medusa/server/src/modules/telemetry/models/installation.d.ts +9 -0
  78. package/.medusa/server/src/modules/telemetry/models/installation.js +14 -0
  79. package/.medusa/server/src/modules/telemetry/repositories/index.d.ts +1 -0
  80. package/.medusa/server/src/modules/telemetry/repositories/index.js +18 -0
  81. package/.medusa/server/src/modules/telemetry/repositories/telemetry-heartbeat.d.ts +10 -0
  82. package/.medusa/server/src/modules/telemetry/repositories/telemetry-heartbeat.js +28 -0
  83. package/.medusa/server/src/modules/telemetry/service.d.ts +25 -0
  84. package/.medusa/server/src/modules/telemetry/service.js +54 -0
  85. package/.medusa/server/src/subscribers/payout-webhook.d.ts +2 -2
  86. package/.medusa/server/src/subscribers/payout-webhook.js +9 -5
  87. package/.medusa/server/src/subscribers/telemetry-first-member-invited.d.ts +3 -0
  88. package/.medusa/server/src/subscribers/telemetry-first-member-invited.js +14 -0
  89. package/.medusa/server/src/subscribers/telemetry-first-offer.d.ts +3 -0
  90. package/.medusa/server/src/subscribers/telemetry-first-offer.js +14 -0
  91. package/.medusa/server/src/subscribers/telemetry-first-order.d.ts +3 -0
  92. package/.medusa/server/src/subscribers/telemetry-first-order.js +14 -0
  93. package/.medusa/server/src/subscribers/telemetry-first-payout-account.d.ts +5 -0
  94. package/.medusa/server/src/subscribers/telemetry-first-payout-account.js +24 -0
  95. package/.medusa/server/src/subscribers/telemetry-first-product-published.d.ts +3 -0
  96. package/.medusa/server/src/subscribers/telemetry-first-product-published.js +14 -0
  97. package/.medusa/server/src/subscribers/telemetry-first-seller-approved.d.ts +3 -0
  98. package/.medusa/server/src/subscribers/telemetry-first-seller-approved.js +14 -0
  99. package/.medusa/server/src/subscribers/telemetry-first-seller.d.ts +3 -0
  100. package/.medusa/server/src/subscribers/telemetry-first-seller.js +14 -0
  101. package/.medusa/server/src/utils/telemetry/boot.d.ts +7 -0
  102. package/.medusa/server/src/utils/telemetry/boot.js +117 -0
  103. package/.medusa/server/src/utils/telemetry/buckets.d.ts +2 -0
  104. package/.medusa/server/src/utils/telemetry/buckets.js +22 -0
  105. package/.medusa/server/src/utils/telemetry/config.d.ts +19 -0
  106. package/.medusa/server/src/utils/telemetry/config.js +60 -0
  107. package/.medusa/server/src/utils/telemetry/first-party.d.ts +11 -0
  108. package/.medusa/server/src/utils/telemetry/first-party.js +33 -0
  109. package/.medusa/server/src/utils/telemetry/identity.d.ts +6 -0
  110. package/.medusa/server/src/utils/telemetry/identity.js +32 -0
  111. package/.medusa/server/src/utils/telemetry/index.d.ts +8 -0
  112. package/.medusa/server/src/utils/telemetry/index.js +27 -0
  113. package/.medusa/server/src/utils/telemetry/milestones.d.ts +20 -0
  114. package/.medusa/server/src/utils/telemetry/milestones.js +60 -0
  115. package/.medusa/server/src/utils/telemetry/sender.d.ts +17 -0
  116. package/.medusa/server/src/utils/telemetry/sender.js +48 -0
  117. package/.medusa/server/src/utils/telemetry/snapshot.d.ts +13 -0
  118. package/.medusa/server/src/utils/telemetry/snapshot.js +193 -0
  119. package/.medusa/server/src/with-mercur.d.ts +6 -0
  120. package/.medusa/server/src/with-mercur.js +1 -1
  121. package/.medusa/server/src/workflows/payment/utils/split-order-payment-group.js +11 -3
  122. package/.medusa/server/src/workflows/payment/workflows/process-payment.js +10 -5
  123. package/.medusa/server/src/workflows/payout/steps/create-onboarding.d.ts +8 -2
  124. package/.medusa/server/src/workflows/payout/steps/create-onboarding.js +10 -4
  125. package/.medusa/server/src/workflows/payout/steps/create-payout-account.d.ts +3 -2
  126. package/.medusa/server/src/workflows/payout/steps/create-payout-account.js +9 -3
  127. package/.medusa/server/src/workflows/payout/steps/create-payout-accounts.d.ts +11 -0
  128. package/.medusa/server/src/workflows/payout/steps/create-payout-accounts.js +22 -0
  129. package/.medusa/server/src/workflows/payout/steps/create-payout-reversals.d.ts +4 -0
  130. package/.medusa/server/src/workflows/payout/steps/create-payout-reversals.js +23 -0
  131. package/.medusa/server/src/workflows/payout/steps/create-payouts.d.ts +4 -0
  132. package/.medusa/server/src/workflows/payout/steps/create-payouts.js +23 -0
  133. package/.medusa/server/src/workflows/payout/steps/index.d.ts +12 -5
  134. package/.medusa/server/src/workflows/payout/steps/index.js +13 -6
  135. package/.medusa/server/src/workflows/payout/steps/process-payout-reversals.d.ts +6 -0
  136. package/.medusa/server/src/workflows/payout/steps/process-payout-reversals.js +17 -0
  137. package/.medusa/server/src/workflows/payout/steps/process-payouts.d.ts +6 -0
  138. package/.medusa/server/src/workflows/payout/steps/process-payouts.js +17 -0
  139. package/.medusa/server/src/workflows/payout/steps/sync-payout-account.d.ts +8 -0
  140. package/.medusa/server/src/workflows/payout/steps/sync-payout-account.js +33 -0
  141. package/.medusa/server/src/workflows/payout/steps/update-payout-reversals.d.ts +4 -0
  142. package/.medusa/server/src/workflows/payout/steps/update-payout-reversals.js +29 -0
  143. package/.medusa/server/src/workflows/payout/steps/update-payouts.d.ts +4 -0
  144. package/.medusa/server/src/workflows/payout/steps/update-payouts.js +34 -0
  145. package/.medusa/server/src/workflows/payout/steps/validate-onboarding-token.d.ts +12 -0
  146. package/.medusa/server/src/workflows/payout/steps/validate-onboarding-token.js +23 -0
  147. package/.medusa/server/src/workflows/payout/steps/validate-payout-retry.d.ts +10 -0
  148. package/.medusa/server/src/workflows/payout/steps/validate-payout-retry.js +15 -0
  149. package/.medusa/server/src/workflows/payout/steps/validate-seller-without-payout-account.d.ts +10 -0
  150. package/.medusa/server/src/workflows/payout/steps/validate-seller-without-payout-account.js +13 -0
  151. package/.medusa/server/src/workflows/payout/utils/fulfillment-status.d.ts +26 -0
  152. package/.medusa/server/src/workflows/payout/utils/fulfillment-status.js +64 -0
  153. package/.medusa/server/src/workflows/payout/utils/index.d.ts +3 -0
  154. package/.medusa/server/src/workflows/payout/utils/index.js +20 -0
  155. package/.medusa/server/src/workflows/payout/utils/payout-amounts.d.ts +173 -0
  156. package/.medusa/server/src/workflows/payout/utils/payout-amounts.js +304 -0
  157. package/.medusa/server/src/workflows/payout/utils/sent-to-provider.d.ts +11 -0
  158. package/.medusa/server/src/workflows/payout/utils/sent-to-provider.js +15 -0
  159. package/.medusa/server/src/workflows/payout/workflows/create-onboarding.d.ts +5 -0
  160. package/.medusa/server/src/workflows/payout/workflows/create-onboarding.js +8 -3
  161. package/.medusa/server/src/workflows/payout/workflows/create-or-refresh-seller-payout-account.d.ts +16 -0
  162. package/.medusa/server/src/workflows/payout/workflows/create-or-refresh-seller-payout-account.js +38 -0
  163. package/.medusa/server/src/workflows/payout/workflows/create-order-payouts.d.ts +28 -0
  164. package/.medusa/server/src/workflows/payout/workflows/create-order-payouts.js +82 -0
  165. package/.medusa/server/src/workflows/payout/workflows/create-payout-account.d.ts +11 -5
  166. package/.medusa/server/src/workflows/payout/workflows/create-payout-account.js +42 -17
  167. package/.medusa/server/src/workflows/payout/workflows/create-payout-reversals.d.ts +14 -0
  168. package/.medusa/server/src/workflows/payout/workflows/create-payout-reversals.js +61 -0
  169. package/.medusa/server/src/workflows/payout/workflows/index.d.ts +11 -2
  170. package/.medusa/server/src/workflows/payout/workflows/index.js +12 -3
  171. package/.medusa/server/src/workflows/payout/workflows/link-payout-account.d.ts +11 -0
  172. package/.medusa/server/src/workflows/payout/workflows/link-payout-account.js +35 -0
  173. package/.medusa/server/src/workflows/payout/workflows/process-payout-for-webhook.d.ts +7 -3
  174. package/.medusa/server/src/workflows/payout/workflows/process-payout-for-webhook.js +50 -57
  175. package/.medusa/server/src/workflows/payout/workflows/process-payout-reversal.d.ts +9 -0
  176. package/.medusa/server/src/workflows/payout/workflows/process-payout-reversal.js +19 -0
  177. package/.medusa/server/src/workflows/payout/workflows/process-payout.d.ts +13 -0
  178. package/.medusa/server/src/workflows/payout/workflows/process-payout.js +23 -0
  179. package/.medusa/server/src/workflows/payout/workflows/refresh-onboarding.d.ts +13 -0
  180. package/.medusa/server/src/workflows/payout/workflows/refresh-onboarding.js +26 -0
  181. package/.medusa/server/src/workflows/payout/workflows/refresh-payout-account-link.d.ts +9 -0
  182. package/.medusa/server/src/workflows/payout/workflows/refresh-payout-account-link.js +15 -0
  183. package/.medusa/server/src/workflows/payout/workflows/retry-payout.d.ts +10 -0
  184. package/.medusa/server/src/workflows/payout/workflows/retry-payout.js +36 -0
  185. package/.medusa/server/src/workflows/payout/workflows/sync-payout-account.d.ts +9 -0
  186. package/.medusa/server/src/workflows/payout/workflows/sync-payout-account.js +24 -0
  187. package/package.json +3 -3
  188. package/.medusa/server/src/workflows/payout/steps/create-payout.d.ts +0 -3
  189. package/.medusa/server/src/workflows/payout/steps/create-payout.js +0 -12
  190. package/.medusa/server/src/workflows/payout/steps/update-payout-account.d.ts +0 -35
  191. package/.medusa/server/src/workflows/payout/steps/update-payout-account.js +0 -27
  192. package/.medusa/server/src/workflows/payout/steps/update-payout.d.ts +0 -35
  193. package/.medusa/server/src/workflows/payout/steps/update-payout.js +0 -27
  194. package/.medusa/server/src/workflows/payout/steps/validate-seller-payout-account.d.ts +0 -5
  195. package/.medusa/server/src/workflows/payout/steps/validate-seller-payout-account.js +0 -21
  196. package/.medusa/server/src/workflows/payout/workflows/create-payout.d.ts +0 -9
  197. package/.medusa/server/src/workflows/payout/workflows/create-payout.js +0 -87
@@ -1,111 +1,105 @@
1
- import { CreatePayoutAccountDTO, CreatePayoutDTO, CreateOnboardingDTO, OnboardingDTO, PayoutAccountDTO, PayoutAccountStatus, PayoutDTO, PayoutWebhookActionInput, PayoutWebhookResult, PayoutModuleOptions, PayoutStatus } from "@mercurjs/types";
1
+ import { AccountOutput, CreateAccountInput, CreatePayoutAccountDTO, CreateOnboardingDTO, IPayoutModuleService, OnboardingDTO, PayoutAccountDTO, PayoutAccountRequirements, PayoutAccountStatus, PayoutDTO, PayoutKycStatus, PayoutModuleOptions, PayoutOutput, PayoutProviderErrorCode, PayoutReversalDTO, PayoutStatus, PayoutWebhookActionInput, PayoutWebhookResult, ResolvedPayoutModuleOptions } from "@mercurjs/types";
2
2
  import PayoutProviderService from "./provider-service";
3
- import { Payout, PayoutAccount } from "../models";
4
- import { Context, DAL, InferEntityType } from "@medusajs/framework/types";
5
- import { EntityManager } from "@medusajs/framework/mikro-orm/knex";
3
+ import { Context, DAL } from "@medusajs/framework/types";
4
+ import { SqlEntityManager } from "@medusajs/framework/mikro-orm/postgresql";
6
5
  type InjectedDependencies = {
7
6
  payoutProviderService: PayoutProviderService;
8
7
  baseRepository: DAL.RepositoryService;
9
8
  };
10
- declare const PayoutModuleService_base: import("@medusajs/framework/utils").MedusaServiceReturnType<import("@medusajs/framework/utils").ModelConfigurationsToConfigTemplate<{
11
- readonly Onboarding: import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
12
- id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
13
- data: import("@medusajs/framework/utils").NullableModifier<NoInfer<Record<string, unknown>>, import("@medusajs/framework/utils").JSONProperty<NoInfer<Record<string, unknown>>>>;
14
- context: import("@medusajs/framework/utils").NullableModifier<NoInfer<Record<string, unknown>>, import("@medusajs/framework/utils").JSONProperty<NoInfer<Record<string, unknown>>>>;
15
- account: import("@medusajs/framework/utils").BelongsTo<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
16
- id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
17
- status: import("@medusajs/framework/utils").EnumProperty<typeof PayoutAccountStatus>;
18
- data: import("@medusajs/framework/utils").JSONProperty<NoInfer<Record<string, unknown>>>;
19
- context: import("@medusajs/framework/utils").NullableModifier<NoInfer<Record<string, unknown>>, import("@medusajs/framework/utils").JSONProperty<NoInfer<Record<string, unknown>>>>;
20
- onboarding: import("@medusajs/framework/utils").RelationNullableModifier<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder</*elided*/ any>, "onboarding">, import("@medusajs/framework/utils").HasOne<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder</*elided*/ any>, "onboarding">>, false>;
21
- payouts: import("@medusajs/framework/utils").HasMany<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
22
- id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
23
- display_id: import("@medusajs/framework/utils").AutoIncrementProperty;
24
- currency_code: import("@medusajs/framework/utils").TextProperty;
25
- amount: import("@medusajs/framework/utils").BigNumberProperty;
26
- data: import("@medusajs/framework/utils").NullableModifier<NoInfer<Record<string, unknown>>, import("@medusajs/framework/utils").JSONProperty<NoInfer<Record<string, unknown>>>>;
27
- account: import("@medusajs/framework/utils").BelongsTo<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder</*elided*/ any>, "payout_account">, undefined>;
28
- status: import("@medusajs/framework/utils").EnumProperty<typeof PayoutStatus>;
29
- }>, "payout">>;
30
- }>, "payout_account">, undefined>;
31
- }>, "onboarding">;
32
- readonly Payout: import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
33
- id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
34
- display_id: import("@medusajs/framework/utils").AutoIncrementProperty;
35
- currency_code: import("@medusajs/framework/utils").TextProperty;
36
- amount: import("@medusajs/framework/utils").BigNumberProperty;
37
- data: import("@medusajs/framework/utils").NullableModifier<NoInfer<Record<string, unknown>>, import("@medusajs/framework/utils").JSONProperty<NoInfer<Record<string, unknown>>>>;
38
- account: import("@medusajs/framework/utils").BelongsTo<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
39
- id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
40
- status: import("@medusajs/framework/utils").EnumProperty<typeof PayoutAccountStatus>;
41
- data: import("@medusajs/framework/utils").JSONProperty<NoInfer<Record<string, unknown>>>;
42
- context: import("@medusajs/framework/utils").NullableModifier<NoInfer<Record<string, unknown>>, import("@medusajs/framework/utils").JSONProperty<NoInfer<Record<string, unknown>>>>;
43
- onboarding: import("@medusajs/framework/utils").RelationNullableModifier<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
44
- id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
45
- data: import("@medusajs/framework/utils").NullableModifier<NoInfer<Record<string, unknown>>, import("@medusajs/framework/utils").JSONProperty<NoInfer<Record<string, unknown>>>>;
46
- context: import("@medusajs/framework/utils").NullableModifier<NoInfer<Record<string, unknown>>, import("@medusajs/framework/utils").JSONProperty<NoInfer<Record<string, unknown>>>>;
47
- account: import("@medusajs/framework/utils").BelongsTo<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder</*elided*/ any>, "payout_account">, undefined>;
48
- }>, "onboarding">, import("@medusajs/framework/utils").HasOne<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
49
- id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
50
- data: import("@medusajs/framework/utils").NullableModifier<NoInfer<Record<string, unknown>>, import("@medusajs/framework/utils").JSONProperty<NoInfer<Record<string, unknown>>>>;
51
- context: import("@medusajs/framework/utils").NullableModifier<NoInfer<Record<string, unknown>>, import("@medusajs/framework/utils").JSONProperty<NoInfer<Record<string, unknown>>>>;
52
- account: import("@medusajs/framework/utils").BelongsTo<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder</*elided*/ any>, "payout_account">, undefined>;
53
- }>, "onboarding">>, false>;
54
- payouts: import("@medusajs/framework/utils").HasMany<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder</*elided*/ any>, "payout">>;
55
- }>, "payout_account">, undefined>;
56
- status: import("@medusajs/framework/utils").EnumProperty<typeof PayoutStatus>;
57
- }>, "payout">;
58
- readonly PayoutAccount: import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
59
- id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
60
- status: import("@medusajs/framework/utils").EnumProperty<typeof PayoutAccountStatus>;
61
- data: import("@medusajs/framework/utils").JSONProperty<NoInfer<Record<string, unknown>>>;
62
- context: import("@medusajs/framework/utils").NullableModifier<NoInfer<Record<string, unknown>>, import("@medusajs/framework/utils").JSONProperty<NoInfer<Record<string, unknown>>>>;
63
- onboarding: import("@medusajs/framework/utils").RelationNullableModifier<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
64
- id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
65
- data: import("@medusajs/framework/utils").NullableModifier<NoInfer<Record<string, unknown>>, import("@medusajs/framework/utils").JSONProperty<NoInfer<Record<string, unknown>>>>;
66
- context: import("@medusajs/framework/utils").NullableModifier<NoInfer<Record<string, unknown>>, import("@medusajs/framework/utils").JSONProperty<NoInfer<Record<string, unknown>>>>;
67
- account: import("@medusajs/framework/utils").BelongsTo<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder</*elided*/ any>, "payout_account">, undefined>;
68
- }>, "onboarding">, import("@medusajs/framework/utils").HasOne<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
69
- id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
70
- data: import("@medusajs/framework/utils").NullableModifier<NoInfer<Record<string, unknown>>, import("@medusajs/framework/utils").JSONProperty<NoInfer<Record<string, unknown>>>>;
71
- context: import("@medusajs/framework/utils").NullableModifier<NoInfer<Record<string, unknown>>, import("@medusajs/framework/utils").JSONProperty<NoInfer<Record<string, unknown>>>>;
72
- account: import("@medusajs/framework/utils").BelongsTo<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder</*elided*/ any>, "payout_account">, undefined>;
73
- }>, "onboarding">>, false>;
74
- payouts: import("@medusajs/framework/utils").HasMany<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
75
- id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
76
- display_id: import("@medusajs/framework/utils").AutoIncrementProperty;
77
- currency_code: import("@medusajs/framework/utils").TextProperty;
78
- amount: import("@medusajs/framework/utils").BigNumberProperty;
79
- data: import("@medusajs/framework/utils").NullableModifier<NoInfer<Record<string, unknown>>, import("@medusajs/framework/utils").JSONProperty<NoInfer<Record<string, unknown>>>>;
80
- account: import("@medusajs/framework/utils").BelongsTo<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder</*elided*/ any>, "payout_account">, undefined>;
81
- status: import("@medusajs/framework/utils").EnumProperty<typeof PayoutStatus>;
82
- }>, "payout">>;
83
- }>, "payout_account">;
84
- }>>;
85
- export default class PayoutModuleService extends PayoutModuleService_base {
9
+ type ProviderAccount = {
10
+ external_id?: string | null;
11
+ data?: Record<string, unknown> | null;
12
+ };
13
+ type ProviderResult = {
14
+ status: PayoutStatus;
15
+ status_reason: string | null;
16
+ data: Record<string, unknown>;
17
+ };
18
+ declare const PayoutModuleService_base: import("@medusajs/framework/utils").MedusaServiceReturnType<{
19
+ Onboarding: {
20
+ dto: OnboardingDTO;
21
+ };
22
+ Payout: {
23
+ dto: PayoutDTO;
24
+ };
25
+ PayoutAccount: {
26
+ dto: PayoutAccountDTO;
27
+ };
28
+ PayoutReversal: {
29
+ dto: PayoutReversalDTO;
30
+ };
31
+ }>;
32
+ export default class PayoutModuleService extends PayoutModuleService_base implements IPayoutModuleService {
33
+ protected static readonly PROCESSABLE_STATUSES: PayoutStatus[];
34
+ protected static readonly STATUS_DETAIL_MAX_LENGTH = 1024;
86
35
  protected readonly payoutProviderService_: PayoutProviderService;
87
36
  protected readonly baseRepository_: DAL.RepositoryService;
88
- protected readonly options_: PayoutModuleOptions;
37
+ protected readonly options_: ResolvedPayoutModuleOptions;
89
38
  constructor({ payoutProviderService, baseRepository }: InjectedDependencies, options: PayoutModuleOptions);
90
- getOptions(): {
91
- providers?: {
92
- resolve: string | import("@mercurjs/types").ModuleProviderExports;
93
- id: string;
94
- options?: Record<string, unknown>;
95
- }[];
96
- disabled: boolean;
97
- authorizationWindowMs: number;
98
- sellerActionWindowMs: number;
99
- captureSafetyBufferMs: number;
100
- requiredFulfillmentStatus: import("@mercurjs/types").FulfillmentStatus;
101
- };
102
- createPayoutAccount(input: CreatePayoutAccountDTO, sharedContext?: Context<EntityManager>): Promise<PayoutAccountDTO>;
103
- createOnboarding(input: CreateOnboardingDTO, sharedContext?: Context<EntityManager>): Promise<OnboardingDTO>;
104
- createPayouts(input: CreatePayoutDTO, sharedContext?: Context<EntityManager>): Promise<PayoutDTO>;
105
- protected createPayouts_(input: CreatePayoutDTO, sharedContext?: Context<EntityManager>): Promise<{
106
- payout: InferEntityType<typeof Payout>;
107
- payoutAccount: InferEntityType<typeof PayoutAccount>;
108
- }>;
39
+ getOptions(): ResolvedPayoutModuleOptions;
40
+ createPayoutAccount(input: CreatePayoutAccountDTO, sharedContext?: Context<SqlEntityManager>): Promise<PayoutAccountDTO>;
41
+ syncPayoutAccount(accountId: string, sharedContext?: Context<SqlEntityManager>): Promise<PayoutAccountDTO>;
42
+ deletePayoutAccount(accountId: string, sharedContext?: Context<SqlEntityManager>): Promise<void>;
43
+ createOnboarding(input: CreateOnboardingDTO, sharedContext?: Context<SqlEntityManager>): Promise<OnboardingDTO>;
44
+ processPayout(payoutId: string, sharedContext?: Context<SqlEntityManager>): Promise<PayoutDTO>;
45
+ processPayoutReversal(reversalId: string, sharedContext?: Context<SqlEntityManager>): Promise<PayoutReversalDTO>;
109
46
  getWebhookActionAndData(input: PayoutWebhookActionInput): Promise<PayoutWebhookResult>;
47
+ protected processPayout_(payoutId: string, sharedContext?: Context<SqlEntityManager>): Promise<{
48
+ payout: PayoutDTO;
49
+ attempt: {
50
+ attempts: number;
51
+ idempotency_key: string;
52
+ } | null;
53
+ }>;
54
+ protected processPayoutReversal_(reversalId: string, sharedContext?: Context<SqlEntityManager>): Promise<{
55
+ reversal: PayoutReversalDTO;
56
+ attempt: {
57
+ attempts: number;
58
+ idempotency_key: string;
59
+ } | null;
60
+ }>;
61
+ protected processPayoutFromProvider_(payout: PayoutDTO, attempt: {
62
+ idempotency_key: string;
63
+ }): Promise<ProviderResult>;
64
+ protected processPayoutReversalFromProvider_(reversal: PayoutReversalDTO, attempt: {
65
+ idempotency_key: string;
66
+ }): Promise<ProviderResult>;
67
+ protected lockRow_(table: string, id: string, sharedContext: Context<SqlEntityManager>): Promise<void>;
68
+ /**
69
+ * The key of a request whose outcome is unknown is kept, so a retry after a
70
+ * timeout returns the payout the provider may already have made. Only a
71
+ * provider refusal clears it, and the next attempt gets a fresh key.
72
+ */
73
+ protected nextAttempt_(id: string, data: Record<string, unknown> | null): {
74
+ attempts: number;
75
+ idempotency_key: string;
76
+ };
77
+ protected statusFromProvider_(response: PayoutOutput): ProviderResult;
78
+ protected statusFromError_(error: unknown): ProviderResult;
79
+ protected providerErrorCode_(error: unknown): PayoutProviderErrorCode;
80
+ protected isOnboardingTokenValid_(account: PayoutAccountDTO): boolean;
81
+ protected generateOnboardingToken_(): string;
82
+ protected providerAccountRef_(account: ProviderAccount): {
83
+ id: string;
84
+ data: Record<string, unknown>;
85
+ };
86
+ protected providerAccountInput_(accountId: string, input: CreatePayoutAccountDTO): CreateAccountInput;
87
+ protected accountFieldsFromProvider_(account: AccountOutput): {
88
+ external_id: string;
89
+ status: PayoutAccountStatus;
90
+ kyc_status: PayoutKycStatus;
91
+ payouts_enabled: boolean;
92
+ charges_enabled: boolean;
93
+ details_submitted: boolean;
94
+ disabled_reason: string | null;
95
+ data: Record<string, unknown>;
96
+ last_synced_at: Date;
97
+ };
98
+ /**
99
+ * Outstanding requirements beat pending verification, a `rejected.*`
100
+ * disabled reason is final, any other disabled reason is still under review.
101
+ */
102
+ protected deriveKycStatus_(requirements: PayoutAccountRequirements | null | undefined, disabledReason: string | null | undefined): PayoutKycStatus;
103
+ protected deriveAccountStatus_(account: AccountOutput): PayoutAccountStatus;
110
104
  }
111
105
  export {};