@mercurjs/magento2-connector-plugin 0.0.0-stage → 2.3.9-canary.2

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 (134) hide show
  1. package/.medusa/server/src/admin/index.js +810 -0
  2. package/.medusa/server/src/admin/index.mjs +787 -0
  3. package/.medusa/server/src/api/admin/magento/middlewares.d.ts +2 -0
  4. package/.medusa/server/src/api/admin/magento/middlewares.js +96 -0
  5. package/.medusa/server/src/api/admin/magento/order-groups/[id]/payments/cancel/route.d.ts +4 -0
  6. package/.medusa/server/src/api/admin/magento/order-groups/[id]/payments/cancel/route.js +24 -0
  7. package/.medusa/server/src/api/admin/magento/order-groups/[id]/payments/capture/route.d.ts +4 -0
  8. package/.medusa/server/src/api/admin/magento/order-groups/[id]/payments/capture/route.js +24 -0
  9. package/.medusa/server/src/api/admin/magento/order-groups/payment-fields.d.ts +1 -0
  10. package/.medusa/server/src/api/admin/magento/order-groups/payment-fields.js +16 -0
  11. package/.medusa/server/src/api/admin/magento/order-groups/validators.d.ts +9 -0
  12. package/.medusa/server/src/api/admin/magento/order-groups/validators.js +15 -0
  13. package/.medusa/server/src/api/admin/magento/orders/[id]/refunds/external/route.d.ts +4 -0
  14. package/.medusa/server/src/api/admin/magento/orders/[id]/refunds/external/route.js +24 -0
  15. package/.medusa/server/src/api/admin/magento/orders/validators.d.ts +7 -0
  16. package/.medusa/server/src/api/admin/magento/orders/validators.js +12 -0
  17. package/.medusa/server/src/api/admin/magento/status/route.d.ts +3 -0
  18. package/.medusa/server/src/api/admin/magento/status/route.js +46 -0
  19. package/.medusa/server/src/api/admin/magento/webhooks/[id]/deliveries/[delivery_id]/redeliver/route.d.ts +4 -0
  20. package/.medusa/server/src/api/admin/magento/webhooks/[id]/deliveries/[delivery_id]/redeliver/route.js +23 -0
  21. package/.medusa/server/src/api/admin/magento/webhooks/[id]/deliveries/route.d.ts +4 -0
  22. package/.medusa/server/src/api/admin/magento/webhooks/[id]/deliveries/route.js +21 -0
  23. package/.medusa/server/src/api/admin/magento/webhooks/[id]/route.d.ts +6 -0
  24. package/.medusa/server/src/api/admin/magento/webhooks/[id]/route.js +40 -0
  25. package/.medusa/server/src/api/admin/magento/webhooks/query-config.d.ts +22 -0
  26. package/.medusa/server/src/api/admin/magento/webhooks/query-config.js +36 -0
  27. package/.medusa/server/src/api/admin/magento/webhooks/route.d.ts +5 -0
  28. package/.medusa/server/src/api/admin/magento/webhooks/route.js +37 -0
  29. package/.medusa/server/src/api/admin/magento/webhooks/validators.d.ts +117 -0
  30. package/.medusa/server/src/api/admin/magento/webhooks/validators.js +46 -0
  31. package/.medusa/server/src/api/middlewares.d.ts +2 -0
  32. package/.medusa/server/src/api/middlewares.js +8 -0
  33. package/.medusa/server/src/index.d.ts +4 -0
  34. package/.medusa/server/src/index.js +24 -0
  35. package/.medusa/server/src/jobs/prune-magento-webhook-deliveries.d.ts +6 -0
  36. package/.medusa/server/src/jobs/prune-magento-webhook-deliveries.js +16 -0
  37. package/.medusa/server/src/jobs/retry-magento-webhook-deliveries.d.ts +6 -0
  38. package/.medusa/server/src/jobs/retry-magento-webhook-deliveries.js +20 -0
  39. package/.medusa/server/src/modules/magento-webhook/index.d.ts +36 -0
  40. package/.medusa/server/src/modules/magento-webhook/index.js +14 -0
  41. package/.medusa/server/src/modules/magento-webhook/migrations/Migration20261021155148.d.ts +5 -0
  42. package/.medusa/server/src/modules/magento-webhook/migrations/Migration20261021155148.js +22 -0
  43. package/.medusa/server/src/modules/magento-webhook/models/index.d.ts +2 -0
  44. package/.medusa/server/src/modules/magento-webhook/models/index.js +11 -0
  45. package/.medusa/server/src/modules/magento-webhook/models/magento-webhook-delivery.d.ts +22 -0
  46. package/.medusa/server/src/modules/magento-webhook/models/magento-webhook-delivery.js +38 -0
  47. package/.medusa/server/src/modules/magento-webhook/models/magento-webhook-endpoint.d.ts +22 -0
  48. package/.medusa/server/src/modules/magento-webhook/models/magento-webhook-endpoint.js +23 -0
  49. package/.medusa/server/src/modules/magento-webhook/services/magento-webhook-module-service.d.ts +48 -0
  50. package/.medusa/server/src/modules/magento-webhook/services/magento-webhook-module-service.js +10 -0
  51. package/.medusa/server/src/modules/magento-webhook/utils/index.d.ts +2 -0
  52. package/.medusa/server/src/modules/magento-webhook/utils/index.js +19 -0
  53. package/.medusa/server/src/modules/magento-webhook/utils/retry.d.ts +1 -0
  54. package/.medusa/server/src/modules/magento-webhook/utils/retry.js +16 -0
  55. package/.medusa/server/src/modules/magento-webhook/utils/signature.d.ts +2 -0
  56. package/.medusa/server/src/modules/magento-webhook/utils/signature.js +13 -0
  57. package/.medusa/server/src/providers/payment-external/index.d.ts +4 -0
  58. package/.medusa/server/src/providers/payment-external/index.js +13 -0
  59. package/.medusa/server/src/providers/payment-external/service.d.ts +26 -0
  60. package/.medusa/server/src/providers/payment-external/service.js +87 -0
  61. package/.medusa/server/src/subscribers/magento-refund-requested.d.ts +5 -0
  62. package/.medusa/server/src/subscribers/magento-refund-requested.js +16 -0
  63. package/.medusa/server/src/subscribers/magento-webhook-deliver-on-create.d.ts +5 -0
  64. package/.medusa/server/src/subscribers/magento-webhook-deliver-on-create.js +16 -0
  65. package/.medusa/server/src/subscribers/magento-webhook-fan-out.d.ts +3 -0
  66. package/.medusa/server/src/subscribers/magento-webhook-fan-out.js +27 -0
  67. package/.medusa/server/src/types/common.d.ts +107 -0
  68. package/.medusa/server/src/types/common.js +43 -0
  69. package/.medusa/server/src/types/http.d.ts +129 -0
  70. package/.medusa/server/src/types/http.js +3 -0
  71. package/.medusa/server/src/types/index.d.ts +3 -0
  72. package/.medusa/server/src/types/index.js +20 -0
  73. package/.medusa/server/src/types/service.d.ts +17 -0
  74. package/.medusa/server/src/types/service.js +3 -0
  75. package/.medusa/server/src/workflows/external-payment/index.d.ts +2 -0
  76. package/.medusa/server/src/workflows/external-payment/index.js +19 -0
  77. package/.medusa/server/src/workflows/external-payment/steps/build-refund-requested-event.d.ts +32 -0
  78. package/.medusa/server/src/workflows/external-payment/steps/build-refund-requested-event.js +37 -0
  79. package/.medusa/server/src/workflows/external-payment/steps/cancel-order-group-orders.d.ts +6 -0
  80. package/.medusa/server/src/workflows/external-payment/steps/cancel-order-group-orders.js +27 -0
  81. package/.medusa/server/src/workflows/external-payment/steps/index.d.ts +5 -0
  82. package/.medusa/server/src/workflows/external-payment/steps/index.js +22 -0
  83. package/.medusa/server/src/workflows/external-payment/steps/resolve-external-cart-payment.d.ts +16 -0
  84. package/.medusa/server/src/workflows/external-payment/steps/resolve-external-cart-payment.js +45 -0
  85. package/.medusa/server/src/workflows/external-payment/steps/validate-external-payment-cancelable.d.ts +7 -0
  86. package/.medusa/server/src/workflows/external-payment/steps/validate-external-payment-cancelable.js +13 -0
  87. package/.medusa/server/src/workflows/external-payment/steps/validate-external-payment.d.ts +13 -0
  88. package/.medusa/server/src/workflows/external-payment/steps/validate-external-payment.js +22 -0
  89. package/.medusa/server/src/workflows/external-payment/workflows/cancel-external-payment.d.ts +12 -0
  90. package/.medusa/server/src/workflows/external-payment/workflows/cancel-external-payment.js +39 -0
  91. package/.medusa/server/src/workflows/external-payment/workflows/capture-external-payment.d.ts +12 -0
  92. package/.medusa/server/src/workflows/external-payment/workflows/capture-external-payment.js +43 -0
  93. package/.medusa/server/src/workflows/external-payment/workflows/emit-refund-requested.d.ts +10 -0
  94. package/.medusa/server/src/workflows/external-payment/workflows/emit-refund-requested.js +45 -0
  95. package/.medusa/server/src/workflows/external-payment/workflows/index.d.ts +4 -0
  96. package/.medusa/server/src/workflows/external-payment/workflows/index.js +21 -0
  97. package/.medusa/server/src/workflows/external-payment/workflows/record-external-refund.d.ts +14 -0
  98. package/.medusa/server/src/workflows/external-payment/workflows/record-external-refund.js +58 -0
  99. package/.medusa/server/src/workflows/index.d.ts +2 -0
  100. package/.medusa/server/src/workflows/index.js +19 -0
  101. package/.medusa/server/src/workflows/magento-webhook/index.d.ts +2 -0
  102. package/.medusa/server/src/workflows/magento-webhook/index.js +19 -0
  103. package/.medusa/server/src/workflows/magento-webhook/steps/create-magento-webhook-deliveries.d.ts +6 -0
  104. package/.medusa/server/src/workflows/magento-webhook/steps/create-magento-webhook-deliveries.js +30 -0
  105. package/.medusa/server/src/workflows/magento-webhook/steps/create-magento-webhook-endpoints.d.ts +4 -0
  106. package/.medusa/server/src/workflows/magento-webhook/steps/create-magento-webhook-endpoints.js +18 -0
  107. package/.medusa/server/src/workflows/magento-webhook/steps/delete-magento-webhook-deliveries.d.ts +6 -0
  108. package/.medusa/server/src/workflows/magento-webhook/steps/delete-magento-webhook-deliveries.js +15 -0
  109. package/.medusa/server/src/workflows/magento-webhook/steps/delete-magento-webhook-endpoints.d.ts +3 -0
  110. package/.medusa/server/src/workflows/magento-webhook/steps/delete-magento-webhook-endpoints.js +18 -0
  111. package/.medusa/server/src/workflows/magento-webhook/steps/index.d.ts +7 -0
  112. package/.medusa/server/src/workflows/magento-webhook/steps/index.js +24 -0
  113. package/.medusa/server/src/workflows/magento-webhook/steps/send-magento-webhook-delivery.d.ts +7 -0
  114. package/.medusa/server/src/workflows/magento-webhook/steps/send-magento-webhook-delivery.js +74 -0
  115. package/.medusa/server/src/workflows/magento-webhook/steps/update-magento-webhook-endpoints.d.ts +4 -0
  116. package/.medusa/server/src/workflows/magento-webhook/steps/update-magento-webhook-endpoints.js +29 -0
  117. package/.medusa/server/src/workflows/magento-webhook/steps/validate-magento-webhook-delivery.d.ts +10 -0
  118. package/.medusa/server/src/workflows/magento-webhook/steps/validate-magento-webhook-delivery.js +19 -0
  119. package/.medusa/server/src/workflows/magento-webhook/workflows/create-magento-webhook-endpoints.d.ts +8 -0
  120. package/.medusa/server/src/workflows/magento-webhook/workflows/create-magento-webhook-endpoints.js +16 -0
  121. package/.medusa/server/src/workflows/magento-webhook/workflows/delete-magento-webhook-endpoints.d.ts +5 -0
  122. package/.medusa/server/src/workflows/magento-webhook/workflows/delete-magento-webhook-endpoints.js +11 -0
  123. package/.medusa/server/src/workflows/magento-webhook/workflows/deliver-magento-webhook.d.ts +7 -0
  124. package/.medusa/server/src/workflows/magento-webhook/workflows/deliver-magento-webhook.js +12 -0
  125. package/.medusa/server/src/workflows/magento-webhook/workflows/enqueue-magento-webhook-deliveries.d.ts +6 -0
  126. package/.medusa/server/src/workflows/magento-webhook/workflows/enqueue-magento-webhook-deliveries.js +17 -0
  127. package/.medusa/server/src/workflows/magento-webhook/workflows/index.d.ts +6 -0
  128. package/.medusa/server/src/workflows/magento-webhook/workflows/index.js +23 -0
  129. package/.medusa/server/src/workflows/magento-webhook/workflows/prune-magento-webhook-deliveries.d.ts +6 -0
  130. package/.medusa/server/src/workflows/magento-webhook/workflows/prune-magento-webhook-deliveries.js +11 -0
  131. package/.medusa/server/src/workflows/magento-webhook/workflows/update-magento-webhook-endpoints.d.ts +6 -0
  132. package/.medusa/server/src/workflows/magento-webhook/workflows/update-magento-webhook-endpoints.js +11 -0
  133. package/README.md +64 -2
  134. package/package.json +96 -4
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.verifyWebhookSignature = exports.signWebhookBody = void 0;
4
+ const node_crypto_1 = require("node:crypto");
5
+ const signWebhookBody = (body, secret) => `sha256=${(0, node_crypto_1.createHmac)("sha256", secret).update(body).digest("hex")}`;
6
+ exports.signWebhookBody = signWebhookBody;
7
+ const verifyWebhookSignature = (body, secret, signature) => {
8
+ const expected = Buffer.from((0, exports.signWebhookBody)(body, secret));
9
+ const received = Buffer.from(signature);
10
+ return expected.length === received.length && (0, node_crypto_1.timingSafeEqual)(expected, received);
11
+ };
12
+ exports.verifyWebhookSignature = verifyWebhookSignature;
13
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2lnbmF0dXJlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vc3JjL21vZHVsZXMvbWFnZW50by13ZWJob29rL3V0aWxzL3NpZ25hdHVyZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSw2Q0FBeUQ7QUFFbEQsTUFBTSxlQUFlLEdBQUcsQ0FBQyxJQUFZLEVBQUUsTUFBYyxFQUFVLEVBQUUsQ0FDdEUsVUFBVSxJQUFBLHdCQUFVLEVBQUMsUUFBUSxFQUFFLE1BQU0sQ0FBQyxDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsQ0FBQyxNQUFNLENBQUMsS0FBSyxDQUFDLEVBQUUsQ0FBQTtBQUR4RCxRQUFBLGVBQWUsbUJBQ3lDO0FBRTlELE1BQU0sc0JBQXNCLEdBQUcsQ0FDcEMsSUFBWSxFQUNaLE1BQWMsRUFDZCxTQUFpQixFQUNSLEVBQUU7SUFDWCxNQUFNLFFBQVEsR0FBRyxNQUFNLENBQUMsSUFBSSxDQUFDLElBQUEsdUJBQWUsRUFBQyxJQUFJLEVBQUUsTUFBTSxDQUFDLENBQUMsQ0FBQTtJQUMzRCxNQUFNLFFBQVEsR0FBRyxNQUFNLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFBO0lBRXZDLE9BQU8sUUFBUSxDQUFDLE1BQU0sS0FBSyxRQUFRLENBQUMsTUFBTSxJQUFJLElBQUEsNkJBQWUsRUFBQyxRQUFRLEVBQUUsUUFBUSxDQUFDLENBQUE7QUFDbkYsQ0FBQyxDQUFBO0FBVFksUUFBQSxzQkFBc0IsMEJBU2xDIn0=
@@ -0,0 +1,4 @@
1
+ import ExternalPaymentProviderService from "./service";
2
+ export { ExternalPaymentProviderService };
3
+ declare const _default: import("@medusajs/types").ModuleProviderExports;
4
+ export default _default;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ExternalPaymentProviderService = void 0;
7
+ const utils_1 = require("@medusajs/framework/utils");
8
+ const service_1 = __importDefault(require("./service"));
9
+ exports.ExternalPaymentProviderService = service_1.default;
10
+ exports.default = (0, utils_1.ModuleProvider)(utils_1.Modules.PAYMENT, {
11
+ services: [service_1.default],
12
+ });
13
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9zcmMvcHJvdmlkZXJzL3BheW1lbnQtZXh0ZXJuYWwvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7O0FBQUEscURBQW1FO0FBRW5FLHdEQUFzRDtBQUU3Qyx5Q0FGRixpQkFBOEIsQ0FFRTtBQUV2QyxrQkFBZSxJQUFBLHNCQUFjLEVBQUMsZUFBTyxDQUFDLE9BQU8sRUFBRTtJQUM3QyxRQUFRLEVBQUUsQ0FBQyxpQkFBOEIsQ0FBQztDQUMzQyxDQUFDLENBQUEifQ==
@@ -0,0 +1,26 @@
1
+ import { AuthorizePaymentInput, AuthorizePaymentOutput, CancelPaymentInput, CancelPaymentOutput, CapturePaymentInput, CapturePaymentOutput, DeletePaymentInput, DeletePaymentOutput, GetPaymentStatusInput, GetPaymentStatusOutput, InitiatePaymentInput, InitiatePaymentOutput, Logger, ProviderWebhookPayload, RefundPaymentInput, RefundPaymentOutput, RetrievePaymentInput, RetrievePaymentOutput, UpdatePaymentInput, UpdatePaymentOutput, WebhookActionResult } from "@medusajs/framework/types";
2
+ import { AbstractPaymentProvider } from "@medusajs/framework/utils";
3
+ type InjectedDependencies = {
4
+ logger: Logger;
5
+ };
6
+ type ExternalPaymentOptions = Record<string, never>;
7
+ /**
8
+ * Tracks a payment the external storefront holds; no provider is charged.
9
+ * The storefront authorizes at placement and reports the capture later, or
10
+ * passes `captured_at` up front when it already settled.
11
+ */
12
+ declare class ExternalPaymentProviderService extends AbstractPaymentProvider<ExternalPaymentOptions> {
13
+ static identifier: string;
14
+ constructor(container: InjectedDependencies, options?: ExternalPaymentOptions);
15
+ initiatePayment(input: InitiatePaymentInput): Promise<InitiatePaymentOutput>;
16
+ updatePayment(input: UpdatePaymentInput): Promise<UpdatePaymentOutput>;
17
+ authorizePayment(input: AuthorizePaymentInput): Promise<AuthorizePaymentOutput>;
18
+ capturePayment(input: CapturePaymentInput): Promise<CapturePaymentOutput>;
19
+ refundPayment(input: RefundPaymentInput): Promise<RefundPaymentOutput>;
20
+ cancelPayment(input: CancelPaymentInput): Promise<CancelPaymentOutput>;
21
+ deletePayment(input: DeletePaymentInput): Promise<DeletePaymentOutput>;
22
+ retrievePayment(input: RetrievePaymentInput): Promise<RetrievePaymentOutput>;
23
+ getPaymentStatus(input: GetPaymentStatusInput): Promise<GetPaymentStatusOutput>;
24
+ getWebhookActionAndData(_payload: ProviderWebhookPayload["payload"]): Promise<WebhookActionResult>;
25
+ }
26
+ export default ExternalPaymentProviderService;
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const utils_1 = require("@medusajs/framework/utils");
4
+ const toNumber = (value) => new utils_1.BigNumber(value).numeric;
5
+ const asSessionData = (data) => (data ?? {});
6
+ const statusOf = (data) => {
7
+ if (data.canceled_at) {
8
+ return utils_1.PaymentSessionStatus.CANCELED;
9
+ }
10
+ if (data.captured_at) {
11
+ return utils_1.PaymentSessionStatus.CAPTURED;
12
+ }
13
+ return utils_1.PaymentSessionStatus.AUTHORIZED;
14
+ };
15
+ /**
16
+ * Tracks a payment the external storefront holds; no provider is charged.
17
+ * The storefront authorizes at placement and reports the capture later, or
18
+ * passes `captured_at` up front when it already settled.
19
+ */
20
+ class ExternalPaymentProviderService extends utils_1.AbstractPaymentProvider {
21
+ constructor(container, options = {}) {
22
+ super(container, options);
23
+ }
24
+ async initiatePayment(input) {
25
+ const data = asSessionData(input.data);
26
+ const id = data.reference ?? `ext_${Date.now()}`;
27
+ const next = {
28
+ ...data,
29
+ reference: id,
30
+ amount: toNumber(input.amount),
31
+ currency_code: input.currency_code,
32
+ authorized_at: data.authorized_at ?? new Date().toISOString(),
33
+ };
34
+ return { id, status: statusOf(next), data: next };
35
+ }
36
+ async updatePayment(input) {
37
+ const next = {
38
+ ...asSessionData(input.data),
39
+ amount: toNumber(input.amount),
40
+ currency_code: input.currency_code,
41
+ };
42
+ return { status: statusOf(next), data: next };
43
+ }
44
+ async authorizePayment(input) {
45
+ const next = {
46
+ ...asSessionData(input.data),
47
+ authorized_at: asSessionData(input.data).authorized_at ?? new Date().toISOString(),
48
+ };
49
+ return { status: statusOf(next), data: next };
50
+ }
51
+ async capturePayment(input) {
52
+ const data = asSessionData(input.data);
53
+ return {
54
+ data: { ...data, captured_at: data.captured_at ?? new Date().toISOString() },
55
+ };
56
+ }
57
+ async refundPayment(input) {
58
+ const data = asSessionData(input.data);
59
+ return {
60
+ data: {
61
+ ...data,
62
+ refunds: [...(data.refunds ?? []), { amount: toNumber(input.amount) }],
63
+ },
64
+ };
65
+ }
66
+ async cancelPayment(input) {
67
+ const data = asSessionData(input.data);
68
+ return {
69
+ data: { ...data, canceled_at: data.canceled_at ?? new Date().toISOString() },
70
+ };
71
+ }
72
+ async deletePayment(input) {
73
+ return { data: input.data };
74
+ }
75
+ async retrievePayment(input) {
76
+ return { data: input.data };
77
+ }
78
+ async getPaymentStatus(input) {
79
+ return { status: statusOf(asSessionData(input.data)), data: input.data };
80
+ }
81
+ async getWebhookActionAndData(_payload) {
82
+ return { action: utils_1.PaymentActions.NOT_SUPPORTED };
83
+ }
84
+ }
85
+ ExternalPaymentProviderService.identifier = "external";
86
+ exports.default = ExternalPaymentProviderService;
87
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VydmljZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3NyYy9wcm92aWRlcnMvcGF5bWVudC1leHRlcm5hbC9zZXJ2a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MzQyxPQUFPLEVBQUUsSUFBSSxFQUFFLEtBQUssQ0FBQyxJQUFJLEVBQUUsQ0FBQTtJQUM3QixDQUFDO0lBRUQsS0FBSyxDQUFDLGVBQWUsQ0FDbkIsS0FBMkI7UUFFM0IsT0FBTyxFQUFFLElBQUksRUFBRSxLQUFLLENBQUMsSUFBSSxFQUFFLENBQUE7SUFDN0IsQ0FBQztJQUVELEtBQUssQ0FBQyxnQkFBZ0IsQ0FDcEIsS0FBNEI7UUFFNUIsT0FBTyxFQUFFLE1BQU0sRUFBRSxRQUFRLENBQUMsYUFBYSxDQUFDLEtBQUssQ0FBQyxJQUFJLENBQUMsQ0FBQyxFQUFFLElBQUksRUFBRSxLQUFLLENBQUMsSUFBSSxFQUFFLENBQUE7SUFDMUUsQ0FBQztJQUVELEtBQUssQ0FBQyx1QkFBdUIsQ0FDM0IsUUFBMkM7UUFFM0MsT0FBTyxFQUFFLE1BQU0sRUFBRSxzQkFBYyxDQUFDLGFBQWEsRUFBRSxDQUFBO0lBQ2pELENBQUM7O0FBM0ZNLHlDQUFVLEdBQUcsVUFBVSxDQUFBO0FBOEZoQyxrQkFBZSw4QkFBOEIsQ0FBQSJ9
@@ -0,0 +1,5 @@
1
+ import { SubscriberArgs, SubscriberConfig } from "@medusajs/framework";
2
+ export default function magentoRefundRequestedHandler({ event, container, }: SubscriberArgs<{
3
+ id: string;
4
+ }>): Promise<void>;
5
+ export declare const config: SubscriberConfig;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.config = void 0;
4
+ exports.default = magentoRefundRequestedHandler;
5
+ const utils_1 = require("@medusajs/framework/utils");
6
+ const workflows_1 = require("../workflows");
7
+ async function magentoRefundRequestedHandler({ event, container, }) {
8
+ await (0, workflows_1.emitRefundRequestedWorkflow)(container).run({
9
+ input: { payment_id: event.data.id },
10
+ });
11
+ }
12
+ exports.config = {
13
+ event: utils_1.PaymentEvents.REFUNDED,
14
+ context: { subscriberId: "magento-refund-requested" },
15
+ };
16
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWFnZW50by1yZWZ1bmQtcmVxdWVzdGVkLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3N1YnNjcmliZXJzL21hZ2VudG8tcmVmdW5kLXJlcXVlc3RlZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFLQSxnREFPQztBQVhELHFEQUF5RDtBQUV6RCw0Q0FBMEQ7QUFFM0MsS0FBSyxVQUFVLDZCQUE2QixDQUFDLEVBQzFELEtBQUssRUFDTCxTQUFTLEdBQ3NCO0lBQy9CLE1BQU0sSUFBQSx1Q0FBMkIsRUFBQyxTQUFTLENBQUMsQ0FBQyxHQUFHLENBQUM7UUFDL0MsS0FBSyxFQUFFLEVBQUUsVUFBVSxFQUFFLEtBQUssQ0FBQyxJQUFJLENBQUMsRUFBRSxFQUFFO0tBQ3JDLENBQUMsQ0FBQTtBQUNKLENBQUM7QUFFWSxRQUFBLE1BQU0sR0FBcUI7SUFDdEMsS0FBSyxFQUFFLHFCQUFhLENBQUMsUUFBUTtJQUM3QixPQUFPLEVBQUUsRUFBRSxZQUFZLEVBQUUsMEJBQTBCLEVBQUU7Q0FDdEQsQ0FBQSJ9
@@ -0,0 +1,5 @@
1
+ import { SubscriberArgs, SubscriberConfig } from "@medusajs/framework";
2
+ export default function magentoWebhookDeliverOnCreateHandler({ event, container, }: SubscriberArgs<{
3
+ id: string;
4
+ }>): Promise<void>;
5
+ export declare const config: SubscriberConfig;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.config = void 0;
4
+ exports.default = magentoWebhookDeliverOnCreateHandler;
5
+ const types_1 = require("../types");
6
+ const workflows_1 = require("../workflows");
7
+ async function magentoWebhookDeliverOnCreateHandler({ event, container, }) {
8
+ await (0, workflows_1.deliverMagentoWebhookWorkflow)(container).run({
9
+ input: { delivery_id: event.data.id },
10
+ });
11
+ }
12
+ exports.config = {
13
+ event: types_1.MagentoWebhookEvents.DELIVERY_CREATED,
14
+ context: { subscriberId: "magento-webhook-deliver-on-create" },
15
+ };
16
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWFnZW50by13ZWJob29rLWRlbGl2ZXItb24tY3JlYXRlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3N1YnNjcmliZXJzL21hZ2VudG8td2ViaG9vay1kZWxpdmVyLW9uLWNyZWF0ZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFLQSx1REFPQztBQVZELG9DQUErQztBQUMvQyw0Q0FBNEQ7QUFFN0MsS0FBSyxVQUFVLG9DQUFvQyxDQUFDLEVBQ2pFLEtBQUssRUFDTCxTQUFTLEdBQ3NCO0lBQy9CLE1BQU0sSUFBQSx5Q0FBNkIsRUFBQyxTQUFTLENBQUMsQ0FBQyxHQUFHLENBQUM7UUFDakQsS0FBSyxFQUFFLEVBQUUsV0FBVyxFQUFFLEtBQUssQ0FBQyxJQUFJLENBQUMsRUFBRSxFQUFFO0tBQ3RDLENBQUMsQ0FBQTtBQUNKLENBQUM7QUFFWSxRQUFBLE1BQU0sR0FBcUI7SUFDdEMsS0FBSyxFQUFFLDRCQUFvQixDQUFDLGdCQUFnQjtJQUM1QyxPQUFPLEVBQUUsRUFBRSxZQUFZLEVBQUUsbUNBQW1DLEVBQUU7Q0FDL0QsQ0FBQSJ9
@@ -0,0 +1,3 @@
1
+ import { SubscriberArgs, SubscriberConfig } from "@medusajs/framework";
2
+ export default function magentoWebhookFanOutHandler({ event, container, }: SubscriberArgs<Record<string, unknown>>): Promise<void>;
3
+ export declare const config: SubscriberConfig;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.config = void 0;
4
+ exports.default = magentoWebhookFanOutHandler;
5
+ const utils_1 = require("@medusajs/framework/utils");
6
+ const types_1 = require("../types");
7
+ const workflows_1 = require("../workflows");
8
+ async function magentoWebhookFanOutHandler({ event, container, }) {
9
+ let payload = event.data ?? {};
10
+ if (types_1.FULFILLMENT_SCOPED_EVENTS.includes(event.name) && typeof payload.id === "string") {
11
+ const query = container.resolve(utils_1.ContainerRegistrationKeys.QUERY);
12
+ const { data } = await query.graph({
13
+ entity: "order_fulfillment",
14
+ fields: ["order_id", "fulfillment_id"],
15
+ filters: { fulfillment_id: payload.id },
16
+ });
17
+ payload = { ...payload, fulfillment_id: payload.id, order_id: data[0]?.order_id ?? null };
18
+ }
19
+ await (0, workflows_1.enqueueMagentoWebhookDeliveriesWorkflow)(container).run({
20
+ input: { event: event.name, payload },
21
+ });
22
+ }
23
+ exports.config = {
24
+ event: [...types_1.MAGENTO_WEBHOOK_EVENTS],
25
+ context: { subscriberId: "magento-webhook-fan-out" },
26
+ };
27
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWFnZW50by13ZWJob29rLWZhbi1vdXQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvc3Vic2NyaWJlcnMvbWFnZW50by13ZWJob29rLWZhbi1vdXQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBTUEsOENBbUJDO0FBeEJELHFEQUFxRTtBQUVyRSxvQ0FBNEU7QUFDNUUsNENBQXNFO0FBRXZELEtBQUssVUFBVSwyQkFBMkIsQ0FBQyxFQUN4RCxLQUFLLEVBQ0wsU0FBUyxHQUMrQjtJQUN4QyxJQUFJLE9BQU8sR0FBNEIsS0FBSyxDQUFDLElBQUksSUFBSSxFQUFFLENBQUE7SUFFdkQsSUFBSSxpQ0FBeUIsQ0FBQyxRQUFRLENBQUMsS0FBSyxDQUFDLElBQUksQ0FBQyxJQUFJLE9BQU8sT0FBTyxDQUFDLEVBQUUsS0FBSyxRQUFRLEVBQUUsQ0FBQztRQUNyRixNQUFNLEtBQUssR0FBRyxTQUFTLENBQUMsT0FBTyxDQUFDLGlDQUF5QixDQUFDLEtBQUssQ0FBQyxDQUFBO1FBQ2hFLE1BQU0sRUFBRSxJQUFJLEVBQUUsR0FBRyxNQUFNLEtBQUssQ0FBQyxLQUFLLENBQUM7WUFDakMsTUFBTSxFQUFFLG1CQUFtQjtZQUMzQixNQUFNLEVBQUUsQ0FBQyxVQUFVLEVBQUUsZ0JBQWdCLENBQUM7WUFDdEMsT0FBTyxFQUFFLEVBQUUsY0FBYyxFQUFFLE9BQU8sQ0FBQyxFQUFFLEVBQUU7U0FDeEMsQ0FBQyxDQUFBO1FBQ0YsT0FBTyxHQUFHLEVBQUUsR0FBRyxPQUFPLEVBQUUsY0FBYyxFQUFFLE9BQU8sQ0FBQyxFQUFFLEVBQUUsUUFBUSxFQUFFLElBQUksQ0FBQyxDQUFDLENBQUMsRUFBRSxRQUFRLElBQUksSUFBSSxFQUFFLENBQUE7SUFDM0YsQ0FBQztJQUVELE1BQU0sSUFBQSxtREFBdUMsRUFBQyxTQUFTLENBQUMsQ0FBQyxHQUFHLENBQUM7UUFDM0QsS0FBSyxFQUFFLEVBQUUsS0FBSyxFQUFFLEtBQUssQ0FBQyxJQUFJLEVBQUUsT0FBTyxFQUFFO0tBQ3RDLENBQUMsQ0FBQTtBQUNKLENBQUM7QUFFWSxRQUFBLE1BQU0sR0FBcUI7SUFDdEMsS0FBSyxFQUFFLENBQUMsR0FBRyw4QkFBc0IsQ0FBQztJQUNsQyxPQUFPLEVBQUUsRUFBRSxZQUFZLEVBQUUseUJBQXlCLEVBQUU7Q0FDckQsQ0FBQSJ9
@@ -0,0 +1,107 @@
1
+ import { BaseFilterable, OperatorMap } from "@medusajs/framework/types";
2
+ export declare const MAGENTO_WEBHOOK_MODULE = "magento_webhook";
3
+ export declare const EXTERNAL_PAYMENT_PROVIDER_ID = "pp_external_external";
4
+ export declare const MAGENTO_WEBHOOK_EVENTS: readonly ["offer.created", "offer.updated", "offer.deleted", "seller.updated", "seller.approved", "seller.suspended", "seller.unsuspended", "seller.terminated", "seller.unterminated", "product.published", "product.rejected", "order_group.created", "order.updated", "order.canceled", "order.fulfillment_created", "order.fulfillment_canceled", "order.shipment_created", "shipment.created", "delivery.created", "order.return_requested", "order.return_received", "order.refund_recorded", "order.refund_requested", "order.payment_captured"];
5
+ /**
6
+ * Medusa emits these with the fulfillment id as `data.id` and no order id.
7
+ */
8
+ export declare const FULFILLMENT_SCOPED_EVENTS: readonly string[];
9
+ export type MagentoWebhookEvent = (typeof MAGENTO_WEBHOOK_EVENTS)[number];
10
+ export declare const MagentoWebhookEvents: {
11
+ readonly DELIVERY_CREATED: "magento_webhook_delivery.created";
12
+ readonly REFUND_RECORDED: "order.refund_recorded";
13
+ readonly REFUND_REQUESTED: "order.refund_requested";
14
+ readonly PAYMENT_CAPTURED: "order.payment_captured";
15
+ };
16
+ export declare const EXTERNAL_REFUND_SOURCE = "external";
17
+ export type MagentoWebhookDeliveryStatus = "pending" | "delivered" | "failed" | "dead";
18
+ export type MagentoWebhookEndpointDTO = {
19
+ id: string;
20
+ url: string;
21
+ secret: string;
22
+ events: string[];
23
+ is_active: boolean;
24
+ description: string | null;
25
+ metadata: Record<string, unknown> | null;
26
+ deliveries?: MagentoWebhookDeliveryDTO[];
27
+ created_at: Date;
28
+ updated_at: Date;
29
+ deleted_at: Date | null;
30
+ };
31
+ export type MagentoWebhookDeliveryDTO = {
32
+ id: string;
33
+ endpoint_id: string;
34
+ endpoint?: MagentoWebhookEndpointDTO;
35
+ event: string;
36
+ payload: Record<string, unknown>;
37
+ status: MagentoWebhookDeliveryStatus;
38
+ attempts: number;
39
+ next_attempt_at: Date | null;
40
+ response_status: number | null;
41
+ response_body: string | null;
42
+ delivered_at: Date | null;
43
+ created_at: Date;
44
+ updated_at: Date;
45
+ deleted_at: Date | null;
46
+ };
47
+ export type CreateMagentoWebhookEndpointDTO = {
48
+ url: string;
49
+ secret: string;
50
+ events: string[];
51
+ is_active?: boolean;
52
+ description?: string | null;
53
+ metadata?: Record<string, unknown> | null;
54
+ };
55
+ export type UpdateMagentoWebhookEndpointDTO = {
56
+ id: string;
57
+ url?: string;
58
+ secret?: string;
59
+ events?: string[];
60
+ is_active?: boolean;
61
+ description?: string | null;
62
+ metadata?: Record<string, unknown> | null;
63
+ };
64
+ export type CreateMagentoWebhookDeliveryDTO = {
65
+ endpoint_id: string;
66
+ event: string;
67
+ payload: Record<string, unknown>;
68
+ status?: MagentoWebhookDeliveryStatus;
69
+ attempts?: number;
70
+ next_attempt_at?: Date | null;
71
+ };
72
+ export type UpdateMagentoWebhookDeliveryDTO = {
73
+ id: string;
74
+ status?: MagentoWebhookDeliveryStatus;
75
+ attempts?: number;
76
+ next_attempt_at?: Date | null;
77
+ response_status?: number | null;
78
+ response_body?: string | null;
79
+ delivered_at?: Date | null;
80
+ };
81
+ export type FilterableMagentoWebhookEndpointProps = BaseFilterable<FilterableMagentoWebhookEndpointProps> & {
82
+ id?: string | string[];
83
+ is_active?: boolean;
84
+ };
85
+ export type FilterableMagentoWebhookDeliveryProps = BaseFilterable<FilterableMagentoWebhookDeliveryProps> & {
86
+ id?: string | string[];
87
+ endpoint_id?: string | string[];
88
+ event?: string | string[];
89
+ status?: MagentoWebhookDeliveryStatus | MagentoWebhookDeliveryStatus[];
90
+ next_attempt_at?: OperatorMap<Date>;
91
+ delivered_at?: OperatorMap<Date>;
92
+ created_at?: OperatorMap<Date>;
93
+ };
94
+ export type ExternalPaymentSessionData = {
95
+ reference?: string;
96
+ authorized_at?: string;
97
+ captured_at?: string;
98
+ canceled_at?: string;
99
+ payment_method?: string;
100
+ channel?: string;
101
+ amount?: number;
102
+ currency_code?: string;
103
+ refunds?: {
104
+ reference?: string;
105
+ amount: number;
106
+ }[];
107
+ };
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EXTERNAL_REFUND_SOURCE = exports.MagentoWebhookEvents = exports.FULFILLMENT_SCOPED_EVENTS = exports.MAGENTO_WEBHOOK_EVENTS = exports.EXTERNAL_PAYMENT_PROVIDER_ID = exports.MAGENTO_WEBHOOK_MODULE = void 0;
4
+ exports.MAGENTO_WEBHOOK_MODULE = "magento_webhook";
5
+ exports.EXTERNAL_PAYMENT_PROVIDER_ID = "pp_external_external";
6
+ exports.MAGENTO_WEBHOOK_EVENTS = [
7
+ "offer.created",
8
+ "offer.updated",
9
+ "offer.deleted",
10
+ "seller.updated",
11
+ "seller.approved",
12
+ "seller.suspended",
13
+ "seller.unsuspended",
14
+ "seller.terminated",
15
+ "seller.unterminated",
16
+ "product.published",
17
+ "product.rejected",
18
+ "order_group.created",
19
+ "order.updated",
20
+ "order.canceled",
21
+ "order.fulfillment_created",
22
+ "order.fulfillment_canceled",
23
+ "order.shipment_created",
24
+ "shipment.created",
25
+ "delivery.created",
26
+ "order.return_requested",
27
+ "order.return_received",
28
+ "order.refund_recorded",
29
+ "order.refund_requested",
30
+ "order.payment_captured",
31
+ ];
32
+ /**
33
+ * Medusa emits these with the fulfillment id as `data.id` and no order id.
34
+ */
35
+ exports.FULFILLMENT_SCOPED_EVENTS = ["shipment.created", "delivery.created"];
36
+ exports.MagentoWebhookEvents = {
37
+ DELIVERY_CREATED: "magento_webhook_delivery.created",
38
+ REFUND_RECORDED: "order.refund_recorded",
39
+ REFUND_REQUESTED: "order.refund_requested",
40
+ PAYMENT_CAPTURED: "order.payment_captured",
41
+ };
42
+ exports.EXTERNAL_REFUND_SOURCE = "external";
43
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tbW9uLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3R5cGVzL2NvbW1vbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFFYSxRQUFBLHNCQUFzQixHQUFHLGlCQUFpQixDQUFBO0FBRTFDLFFBQUEsNEJBQTRCLEdBQUcsc0JBQXNCLENBQUE7QUFFckQsUUFBQSxzQkFBc0IsR0FBRztJQUNwQyxlQUFlO0lBQ2YsZUFBZTtJQUNmLGVBQWU7SUFDZixnQkFBZ0I7SUFDaEIsaUJBQWlCO0lBQ2pCLGtCQUFrQjtJQUNsQixvQkFBb0I7SUFDcEIsbUJBQW1CO0lBQ25CLHFCQUFxQjtJQUNyQixtQkFBbUI7SUFDbkIsa0JBQWtCO0lBQ2xCLHFCQUFxQjtJQUNyQixlQUFlO0lBQ2YsZ0JBQWdCO0lBQ2hCLDJCQUEyQjtJQUMzQiw0QkFBNEI7SUFDNUIsd0JBQXdCO0lBQ3hCLGtCQUFrQjtJQUNsQixrQkFBa0I7SUFDbEIsd0JBQXdCO0lBQ3hCLHVCQUF1QjtJQUN2Qix1QkFBdUI7SUFDdkIsd0JBQXdCO0lBQ3hCLHdCQUF3QjtDQUNoQixDQUFBO0FBRVY7O0dBRUc7QUFDVSxRQUFBLHlCQUF5QixHQUFzQixDQUFDLGtCQUFrQixFQUFFLGtCQUFrQixDQUFDLENBQUE7QUFJdkYsUUFBQSxvQkFBb0IsR0FBRztJQUNsQyxnQkFBZ0IsRUFBRSxrQ0FBa0M7SUFDcEQsZUFBZSxFQUFFLHVCQUF1QjtJQUN4QyxnQkFBZ0IsRUFBRSx3QkFBd0I7SUFDMUMsZ0JBQWdCLEVBQUUsd0JBQXdCO0NBQ2xDLENBQUE7QUFFRyxRQUFBLHNCQUFzQixHQUFHLFVBQVUsQ0FBQSJ9
@@ -0,0 +1,129 @@
1
+ import { DeleteResponse, FindParams, OperatorMap, PaginatedResponse, SelectParams } from "@medusajs/framework/types";
2
+ import { MagentoWebhookDeliveryStatus, MagentoWebhookEvent } from "./common";
3
+ export interface AdminMagentoWebhook {
4
+ id: string;
5
+ url: string;
6
+ events: string[];
7
+ is_active: boolean;
8
+ description: string | null;
9
+ metadata: Record<string, unknown> | null;
10
+ created_at: string;
11
+ updated_at: string;
12
+ }
13
+ export interface AdminMagentoWebhookWithSecret extends AdminMagentoWebhook {
14
+ secret: string;
15
+ }
16
+ export interface AdminMagentoWebhookDelivery {
17
+ id: string;
18
+ endpoint_id: string;
19
+ event: string;
20
+ payload: Record<string, unknown>;
21
+ status: MagentoWebhookDeliveryStatus;
22
+ attempts: number;
23
+ next_attempt_at: string | null;
24
+ response_status: number | null;
25
+ response_body: string | null;
26
+ delivered_at: string | null;
27
+ created_at: string;
28
+ updated_at: string;
29
+ }
30
+ export interface AdminMagentoWebhookListParams extends FindParams {
31
+ id?: string | string[];
32
+ is_active?: boolean;
33
+ }
34
+ export interface AdminMagentoWebhookParams extends SelectParams {
35
+ }
36
+ export interface AdminMagentoWebhookDeliveryListParams extends FindParams {
37
+ status?: MagentoWebhookDeliveryStatus | MagentoWebhookDeliveryStatus[];
38
+ event?: string | string[];
39
+ created_at?: OperatorMap<string>;
40
+ }
41
+ export interface AdminCreateMagentoWebhook {
42
+ url: string;
43
+ secret?: string;
44
+ events: MagentoWebhookEvent[];
45
+ is_active?: boolean;
46
+ description?: string | null;
47
+ metadata?: Record<string, unknown> | null;
48
+ }
49
+ export interface AdminUpdateMagentoWebhook {
50
+ url?: string;
51
+ secret?: string;
52
+ events?: MagentoWebhookEvent[];
53
+ is_active?: boolean;
54
+ description?: string | null;
55
+ metadata?: Record<string, unknown> | null;
56
+ }
57
+ export interface AdminRecordExternalRefund {
58
+ amount: number;
59
+ reference?: string;
60
+ note?: string;
61
+ }
62
+ export interface AdminCaptureExternalPayment {
63
+ reference?: string;
64
+ }
65
+ export interface AdminCancelExternalPayment {
66
+ reference?: string;
67
+ }
68
+ export interface AdminMagentoWebhookResponse {
69
+ webhook: AdminMagentoWebhook;
70
+ }
71
+ export interface AdminMagentoWebhookCreateResponse {
72
+ webhook: AdminMagentoWebhookWithSecret;
73
+ }
74
+ export interface AdminMagentoWebhookListResponse extends PaginatedResponse<{
75
+ webhooks: AdminMagentoWebhook[];
76
+ }> {
77
+ }
78
+ export interface AdminMagentoWebhookDeleteResponse extends DeleteResponse<"magento_webhook"> {
79
+ }
80
+ export interface AdminMagentoWebhookDeliveryResponse {
81
+ delivery: AdminMagentoWebhookDelivery;
82
+ }
83
+ export interface AdminMagentoWebhookDeliveryListResponse extends PaginatedResponse<{
84
+ deliveries: AdminMagentoWebhookDelivery[];
85
+ }> {
86
+ }
87
+ export interface AdminMagentoStatusResponse {
88
+ payment_provider: {
89
+ id: string;
90
+ installed: boolean;
91
+ };
92
+ events: readonly string[];
93
+ webhooks: {
94
+ total: number;
95
+ active: number;
96
+ };
97
+ deliveries: {
98
+ window_hours: number;
99
+ delivered: number;
100
+ failed: number;
101
+ dead: number;
102
+ pending: number;
103
+ last_delivered_at: string | Date | null;
104
+ };
105
+ orders: {
106
+ channel: string;
107
+ last_24h: number;
108
+ };
109
+ }
110
+ export interface AdminExternalPayment {
111
+ id: string;
112
+ amount: number;
113
+ currency_code: string;
114
+ provider_id: string;
115
+ captured_at: string | null;
116
+ canceled_at: string | null;
117
+ refunds: {
118
+ id: string;
119
+ amount: number;
120
+ note: string | null;
121
+ created_at: string;
122
+ }[];
123
+ }
124
+ export interface AdminExternalRefundResponse {
125
+ payment: AdminExternalPayment;
126
+ }
127
+ export interface AdminExternalPaymentResponse {
128
+ payment: AdminExternalPayment;
129
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaHR0cC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy90eXBlcy9odHRwLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIifQ==
@@ -0,0 +1,3 @@
1
+ export * from "./common";
2
+ export * from "./service";
3
+ export * from "./http";
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./common"), exports);
18
+ __exportStar(require("./service"), exports);
19
+ __exportStar(require("./http"), exports);
20
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvdHlwZXMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7OztBQUFBLDJDQUF3QjtBQUN4Qiw0Q0FBeUI7QUFDekIseUNBQXNCIn0=
@@ -0,0 +1,17 @@
1
+ import { Context, FindConfig, IModuleService } from "@medusajs/framework/types";
2
+ import { CreateMagentoWebhookDeliveryDTO, CreateMagentoWebhookEndpointDTO, FilterableMagentoWebhookDeliveryProps, FilterableMagentoWebhookEndpointProps, MagentoWebhookDeliveryDTO, MagentoWebhookEndpointDTO, UpdateMagentoWebhookDeliveryDTO, UpdateMagentoWebhookEndpointDTO } from "./common";
3
+ export interface IMagentoWebhookModuleService extends IModuleService {
4
+ retrieveMagentoWebhookEndpoint(id: string, config?: FindConfig<MagentoWebhookEndpointDTO>, sharedContext?: Context): Promise<MagentoWebhookEndpointDTO>;
5
+ listMagentoWebhookEndpoints(filters?: FilterableMagentoWebhookEndpointProps, config?: FindConfig<MagentoWebhookEndpointDTO>, sharedContext?: Context): Promise<MagentoWebhookEndpointDTO[]>;
6
+ createMagentoWebhookEndpoints(data: CreateMagentoWebhookEndpointDTO, sharedContext?: Context): Promise<MagentoWebhookEndpointDTO>;
7
+ createMagentoWebhookEndpoints(data: CreateMagentoWebhookEndpointDTO[], sharedContext?: Context): Promise<MagentoWebhookEndpointDTO[]>;
8
+ updateMagentoWebhookEndpoints(data: UpdateMagentoWebhookEndpointDTO, sharedContext?: Context): Promise<MagentoWebhookEndpointDTO>;
9
+ updateMagentoWebhookEndpoints(data: UpdateMagentoWebhookEndpointDTO[], sharedContext?: Context): Promise<MagentoWebhookEndpointDTO[]>;
10
+ softDeleteMagentoWebhookEndpoints(ids: string | string[], config?: unknown, sharedContext?: Context): Promise<Record<string, string[]> | void>;
11
+ restoreMagentoWebhookEndpoints(ids: string | string[], config?: unknown, sharedContext?: Context): Promise<Record<string, string[]> | void>;
12
+ retrieveMagentoWebhookDelivery(id: string, config?: FindConfig<MagentoWebhookDeliveryDTO>, sharedContext?: Context): Promise<MagentoWebhookDeliveryDTO>;
13
+ listMagentoWebhookDeliveries(filters?: FilterableMagentoWebhookDeliveryProps, config?: FindConfig<MagentoWebhookDeliveryDTO>, sharedContext?: Context): Promise<MagentoWebhookDeliveryDTO[]>;
14
+ createMagentoWebhookDeliveries(data: CreateMagentoWebhookDeliveryDTO[], sharedContext?: Context): Promise<MagentoWebhookDeliveryDTO[]>;
15
+ updateMagentoWebhookDeliveries(data: UpdateMagentoWebhookDeliveryDTO[], sharedContext?: Context): Promise<MagentoWebhookDeliveryDTO[]>;
16
+ deleteMagentoWebhookDeliveries(ids: string | string[], sharedContext?: Context): Promise<void>;
17
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VydmljZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy90eXBlcy9zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIifQ==
@@ -0,0 +1,2 @@
1
+ export * from "./steps";
2
+ export * from "./workflows";
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./steps"), exports);
18
+ __exportStar(require("./workflows"), exports);
19
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9zcmMvd29ya2Zsb3dzL2V4dGVybmFsLXBheW1lbnQvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7OztBQUFBLDBDQUF1QjtBQUN2Qiw4Q0FBMkIifQ==
@@ -0,0 +1,32 @@
1
+ type RefundRow = {
2
+ id: string;
3
+ amount: unknown;
4
+ note?: string | null;
5
+ metadata?: Record<string, unknown> | null;
6
+ created_at?: string | Date | null;
7
+ };
8
+ export type BuildRefundRequestedEventStepInput = {
9
+ payment?: {
10
+ id: string;
11
+ provider_id: string;
12
+ currency_code: string;
13
+ payment_collection_id?: string | null;
14
+ refunds?: (RefundRow | null)[] | null;
15
+ } | null;
16
+ order_id?: string | null;
17
+ };
18
+ export type RefundRequestedEventData = {
19
+ order_id: string;
20
+ payment_id: string;
21
+ refund_id: string;
22
+ amount: number;
23
+ currency_code: string;
24
+ note: string | null;
25
+ };
26
+ export declare const buildRefundRequestedEventStepId = "build-refund-requested-event";
27
+ /**
28
+ * Picks the newest refund on an external-provider payment that did not come
29
+ * from Magento itself. Returns an empty list when there is nothing to forward.
30
+ */
31
+ export declare const buildRefundRequestedEventStep: import("@medusajs/framework/workflows-sdk").StepFunction<BuildRefundRequestedEventStepInput, RefundRequestedEventData[]>;
32
+ export {};