@endora-commerce/mod-payments 0.100.0

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 (107) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +59 -0
  3. package/dist/admin/index.d.ts +32 -0
  4. package/dist/admin/index.d.ts.map +1 -0
  5. package/dist/admin/index.js +61 -0
  6. package/dist/admin/index.js.map +1 -0
  7. package/dist/admin/zones/OrderPaymentsTab.d.ts +42 -0
  8. package/dist/admin/zones/OrderPaymentsTab.d.ts.map +1 -0
  9. package/dist/admin/zones/OrderPaymentsTab.js +104 -0
  10. package/dist/admin/zones/OrderPaymentsTab.js.map +1 -0
  11. package/dist/backend/adapters/built-in-adapters.d.ts +58 -0
  12. package/dist/backend/adapters/built-in-adapters.d.ts.map +1 -0
  13. package/dist/backend/adapters/built-in-adapters.js +83 -0
  14. package/dist/backend/adapters/built-in-adapters.js.map +1 -0
  15. package/dist/backend/drivers/bank-transfer-driver.d.ts +28 -0
  16. package/dist/backend/drivers/bank-transfer-driver.d.ts.map +1 -0
  17. package/dist/backend/drivers/bank-transfer-driver.js +26 -0
  18. package/dist/backend/drivers/bank-transfer-driver.js.map +1 -0
  19. package/dist/backend/drivers/gateway-adapter-port.d.ts +71 -0
  20. package/dist/backend/drivers/gateway-adapter-port.d.ts.map +1 -0
  21. package/dist/backend/drivers/gateway-adapter-port.js +18 -0
  22. package/dist/backend/drivers/gateway-adapter-port.js.map +1 -0
  23. package/dist/backend/drivers/pickup-driver.d.ts +23 -0
  24. package/dist/backend/drivers/pickup-driver.d.ts.map +1 -0
  25. package/dist/backend/drivers/pickup-driver.js +19 -0
  26. package/dist/backend/drivers/pickup-driver.js.map +1 -0
  27. package/dist/backend/email-templates/transactional-defaults.d.ts +6 -0
  28. package/dist/backend/email-templates/transactional-defaults.d.ts.map +1 -0
  29. package/dist/backend/email-templates/transactional-defaults.js +27 -0
  30. package/dist/backend/email-templates/transactional-defaults.js.map +1 -0
  31. package/dist/backend/entities/payment.entity.d.ts +26 -0
  32. package/dist/backend/entities/payment.entity.d.ts.map +1 -0
  33. package/dist/backend/entities/payment.entity.js +100 -0
  34. package/dist/backend/entities/payment.entity.js.map +1 -0
  35. package/dist/backend/index.d.ts +88 -0
  36. package/dist/backend/index.d.ts.map +1 -0
  37. package/dist/backend/index.js +318 -0
  38. package/dist/backend/index.js.map +1 -0
  39. package/dist/backend/routes.customer.d.ts +20 -0
  40. package/dist/backend/routes.customer.d.ts.map +1 -0
  41. package/dist/backend/routes.customer.js +24 -0
  42. package/dist/backend/routes.customer.js.map +1 -0
  43. package/dist/backend/routes.d.ts +36 -0
  44. package/dist/backend/routes.d.ts.map +1 -0
  45. package/dist/backend/routes.js +44 -0
  46. package/dist/backend/routes.js.map +1 -0
  47. package/dist/backend/services/gateway-refund-registry.d.ts +122 -0
  48. package/dist/backend/services/gateway-refund-registry.d.ts.map +1 -0
  49. package/dist/backend/services/gateway-refund-registry.js +106 -0
  50. package/dist/backend/services/gateway-refund-registry.js.map +1 -0
  51. package/dist/backend/services/payment-email-notifier.d.ts +71 -0
  52. package/dist/backend/services/payment-email-notifier.d.ts.map +1 -0
  53. package/dist/backend/services/payment-email-notifier.js +73 -0
  54. package/dist/backend/services/payment-email-notifier.js.map +1 -0
  55. package/dist/backend/services/payment-email-renderer.d.ts +22 -0
  56. package/dist/backend/services/payment-email-renderer.d.ts.map +1 -0
  57. package/dist/backend/services/payment-email-renderer.js +17 -0
  58. package/dist/backend/services/payment-email-renderer.js.map +1 -0
  59. package/dist/backend/services/payment-placement-apply-port.d.ts +33 -0
  60. package/dist/backend/services/payment-placement-apply-port.d.ts.map +1 -0
  61. package/dist/backend/services/payment-placement-apply-port.js +68 -0
  62. package/dist/backend/services/payment-placement-apply-port.js.map +1 -0
  63. package/dist/backend/services/payment-read-port.d.ts +33 -0
  64. package/dist/backend/services/payment-read-port.d.ts.map +1 -0
  65. package/dist/backend/services/payment-read-port.js +64 -0
  66. package/dist/backend/services/payment-read-port.js.map +1 -0
  67. package/dist/backend/services/payment-reference-port.d.ts +29 -0
  68. package/dist/backend/services/payment-reference-port.d.ts.map +1 -0
  69. package/dist/backend/services/payment-reference-port.js +70 -0
  70. package/dist/backend/services/payment-reference-port.js.map +1 -0
  71. package/dist/backend/services/payment-refund.d.ts +55 -0
  72. package/dist/backend/services/payment-refund.d.ts.map +1 -0
  73. package/dist/backend/services/payment-refund.js +101 -0
  74. package/dist/backend/services/payment-refund.js.map +1 -0
  75. package/dist/backend/services/payment-retry-service.d.ts +45 -0
  76. package/dist/backend/services/payment-retry-service.d.ts.map +1 -0
  77. package/dist/backend/services/payment-retry-service.js +187 -0
  78. package/dist/backend/services/payment-retry-service.js.map +1 -0
  79. package/dist/backend/services/payment-service.d.ts +62 -0
  80. package/dist/backend/services/payment-service.d.ts.map +1 -0
  81. package/dist/backend/services/payment-service.js +134 -0
  82. package/dist/backend/services/payment-service.js.map +1 -0
  83. package/dist/backend/services/receive-payment-handler.d.ts +260 -0
  84. package/dist/backend/services/receive-payment-handler.d.ts.map +1 -0
  85. package/dist/backend/services/receive-payment-handler.js +356 -0
  86. package/dist/backend/services/receive-payment-handler.js.map +1 -0
  87. package/dist/backend/services/registry-singleton.d.ts +16 -0
  88. package/dist/backend/services/registry-singleton.d.ts.map +1 -0
  89. package/dist/backend/services/registry-singleton.js +17 -0
  90. package/dist/backend/services/registry-singleton.js.map +1 -0
  91. package/dist/manifest.d.ts +210 -0
  92. package/dist/manifest.d.ts.map +1 -0
  93. package/dist/manifest.js +182 -0
  94. package/dist/manifest.js.map +1 -0
  95. package/dist/migrations/20260925T115728_payments_refunded_amount.d.ts +28 -0
  96. package/dist/migrations/20260925T115728_payments_refunded_amount.d.ts.map +1 -0
  97. package/dist/migrations/20260925T115728_payments_refunded_amount.js +32 -0
  98. package/dist/migrations/20260925T115728_payments_refunded_amount.js.map +1 -0
  99. package/dist/migrations/index.d.ts +27 -0
  100. package/dist/migrations/index.d.ts.map +1 -0
  101. package/dist/migrations/index.js +29 -0
  102. package/dist/migrations/index.js.map +1 -0
  103. package/docs/payments.md +69 -0
  104. package/i18n/en.json +5 -0
  105. package/i18n/pl.json +5 -0
  106. package/package.json +96 -0
  107. package/tailwind.css +14 -0
@@ -0,0 +1,18 @@
1
+ import { ERROR_CODES } from '@endora-commerce/contracts';
2
+ import { HttpError } from '@endora-commerce/platform/http';
3
+ /**
4
+ * Default placeholder until a per-vendor adapter is wired by the
5
+ * integrations module's composition root. Implements the contract
6
+ * surface so type-checking passes everywhere; throws at runtime when
7
+ * the order-placement transaction tries to use it.
8
+ */
9
+ export class GatewayAdapterPortNotWired {
10
+ vendor = 'unwired';
11
+ async reserve(_input) {
12
+ throw new HttpError(501, ERROR_CODES.INTERNAL, 'No payment-gateway adapter is configured. Configure a vendor under /admin/integrations or use a non-gateway PaymentMethod.');
13
+ }
14
+ async settle(_input) {
15
+ throw new HttpError(501, ERROR_CODES.INTERNAL, 'No payment-gateway adapter is configured.');
16
+ }
17
+ }
18
+ //# sourceMappingURL=gateway-adapter-port.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gateway-adapter-port.js","sourceRoot":"","sources":["../../../src/backend/drivers/gateway-adapter-port.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AA+C3D;;;;;GAKG;AACH,MAAM,OAAO,0BAA0B;IAC5B,MAAM,GAAG,SAAS,CAAC;IAE5B,KAAK,CAAC,OAAO,CAAC,MAA2B;QACvC,MAAM,IAAI,SAAS,CACjB,GAAG,EACH,WAAW,CAAC,QAAQ,EACpB,4HAA4H,CAC7H,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,MAA0B;QACrC,MAAM,IAAI,SAAS,CACjB,GAAG,EACH,WAAW,CAAC,QAAQ,EACpB,2CAA2C,CAC5C,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Pickup driver (T140).
3
+ *
4
+ * Used when the buyer pays in cash on pickup. No external integration,
5
+ * no `nextAction` for the storefront to navigate to — the order stays
6
+ * `paymentStatus='awaiting_payment'` until staff settles it on receipt
7
+ * via `POST /api/v1/admin/orders/:id/payment-status`.
8
+ *
9
+ * Captured here so the spec's `payments/drivers/*-driver.ts` layout
10
+ * exists; the order-service dispatch refactor that consumes the driver
11
+ * registry is a separate slice.
12
+ */
13
+ export interface PickupReserveResult {
14
+ paymentRef: null;
15
+ nextAction: {
16
+ kind: 'none';
17
+ };
18
+ }
19
+ export declare class PickupDriver {
20
+ readonly kind: "pickup";
21
+ reserve(): PickupReserveResult;
22
+ }
23
+ //# sourceMappingURL=pickup-driver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pickup-driver.d.ts","sourceRoot":"","sources":["../../../src/backend/drivers/pickup-driver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,IAAI,CAAC;IACjB,UAAU,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAC9B;AAED,qBAAa,YAAY;IACvB,QAAQ,CAAC,IAAI,EAAG,QAAQ,CAAU;IAElC,OAAO,IAAI,mBAAmB;CAG/B"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Pickup driver (T140).
3
+ *
4
+ * Used when the buyer pays in cash on pickup. No external integration,
5
+ * no `nextAction` for the storefront to navigate to — the order stays
6
+ * `paymentStatus='awaiting_payment'` until staff settles it on receipt
7
+ * via `POST /api/v1/admin/orders/:id/payment-status`.
8
+ *
9
+ * Captured here so the spec's `payments/drivers/*-driver.ts` layout
10
+ * exists; the order-service dispatch refactor that consumes the driver
11
+ * registry is a separate slice.
12
+ */
13
+ export class PickupDriver {
14
+ kind = 'pickup';
15
+ reserve() {
16
+ return { paymentRef: null, nextAction: { kind: 'none' } };
17
+ }
18
+ }
19
+ //# sourceMappingURL=pickup-driver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pickup-driver.js","sourceRoot":"","sources":["../../../src/backend/drivers/pickup-driver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAOH,MAAM,OAAO,YAAY;IACd,IAAI,GAAG,QAAiB,CAAC;IAElC,OAAO;QACL,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC;IAC5D,CAAC;CACF"}
@@ -0,0 +1,6 @@
1
+ export declare const PAYMENT_STATUS_CHANGED_DEFAULT: {
2
+ defaultSubject: Record<string, string>;
3
+ defaultContent: Record<string, unknown>;
4
+ languages: string[];
5
+ };
6
+ //# sourceMappingURL=transactional-defaults.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transactional-defaults.d.ts","sourceRoot":"","sources":["../../../src/backend/email-templates/transactional-defaults.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,8BAA8B;oBAIpC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;oBAetB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;CAE7B,CAAC"}
@@ -0,0 +1,27 @@
1
+ // Default subject + content for the payment_status_changed transactional email
2
+ // (feature 047). Simple layout via shared header/footer embeds.
3
+ import { simpleEmailBodyTree } from '@endora-commerce/email-components/defaults/simple-email-body';
4
+ const LANGS = ['en-US', 'pl-PL'];
5
+ export const PAYMENT_STATUS_CHANGED_DEFAULT = {
6
+ defaultSubject: {
7
+ 'en-US': 'Payment update for order {{var order.businessId}}',
8
+ 'pl-PL': 'Aktualizacja płatności dla zamówienia {{var order.businessId}}',
9
+ },
10
+ defaultContent: {
11
+ schema_version: 1,
12
+ languages: {
13
+ 'en-US': simpleEmailBodyTree({
14
+ idPrefix: 'payment',
15
+ heading: 'Payment update',
16
+ text: 'The payment status for your order {{var order.businessId}} is now: {{var payment.statusLabel}}.\n{{if payment.failureReason}}Reason: {{var payment.failureReason}}{{/if}}',
17
+ }),
18
+ 'pl-PL': simpleEmailBodyTree({
19
+ idPrefix: 'payment',
20
+ heading: 'Aktualizacja płatności',
21
+ text: 'Status płatności dla Twojego zamówienia {{var order.businessId}} to teraz: {{var payment.statusLabel}}.\n{{if payment.failureReason}}Powód: {{var payment.failureReason}}{{/if}}',
22
+ }),
23
+ },
24
+ },
25
+ languages: LANGS,
26
+ };
27
+ //# sourceMappingURL=transactional-defaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transactional-defaults.js","sourceRoot":"","sources":["../../../src/backend/email-templates/transactional-defaults.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,gEAAgE;AAEhE,OAAO,EAAE,mBAAmB,EAAE,MAAM,8DAA8D,CAAC;AAEnG,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAEjC,MAAM,CAAC,MAAM,8BAA8B,GAAG;IAC5C,cAAc,EAAE;QACd,OAAO,EAAE,mDAAmD;QAC5D,OAAO,EAAE,gEAAgE;KAChD;IAC3B,cAAc,EAAE;QACd,cAAc,EAAE,CAAC;QACjB,SAAS,EAAE;YACT,OAAO,EAAE,mBAAmB,CAAC;gBAC3B,QAAQ,EAAE,SAAS;gBACnB,OAAO,EAAE,gBAAgB;gBACzB,IAAI,EAAE,2KAA2K;aAClL,CAAC;YACF,OAAO,EAAE,mBAAmB,CAAC;gBAC3B,QAAQ,EAAE,SAAS;gBACnB,OAAO,EAAE,wBAAwB;gBACjC,IAAI,EAAE,kLAAkL;aACzL,CAAC;SACH;KACyB;IAC5B,SAAS,EAAE,KAAK;CACjB,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { OptionalProps } from '@mikro-orm/core';
2
+ export declare class Payment {
3
+ [OptionalProps]?: 'id' | 'createdAt' | 'updatedAt' | 'status' | 'paidAt' | 'externalReference' | 'providerDetails' | 'failureReason' | 'attemptNo' | 'refundedAmount';
4
+ id: string;
5
+ orderId: string;
6
+ paymentMethodId: string;
7
+ status: 'awaiting_payment' | 'paid' | 'failed' | 'deferred' | 'refunded' | 'partially_refunded';
8
+ amount: string;
9
+ /**
10
+ * Cumulative amount refunded against this payment (feature 049). Kept in sync
11
+ * with the gateway's authoritative total via the `charge.refunded` webhook.
12
+ */
13
+ refundedAmount: string;
14
+ currency: string;
15
+ paidAt?: Date | null;
16
+ externalReference?: string | null;
17
+ /** Adapter/PSP payload captured on receive_payment (feature 034). */
18
+ providerDetails?: Record<string, unknown> | null;
19
+ /** Populated on a failure outcome. */
20
+ failureReason?: string | null;
21
+ /** Retry sequence per order: 1 = first attempt. */
22
+ attemptNo: number;
23
+ createdAt: Date;
24
+ updatedAt: Date;
25
+ }
26
+ //# sourceMappingURL=payment.entity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payment.entity.d.ts","sourceRoot":"","sources":["../../../src/backend/entities/payment.entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,aAAa,EAAwB,MAAM,iBAAiB,CAAC;AAIrF,qBAEa,OAAO;IAClB,CAAC,aAAa,CAAC,CAAC,EACZ,IAAI,GACJ,WAAW,GACX,WAAW,GACX,QAAQ,GACR,QAAQ,GACR,mBAAmB,GACnB,iBAAiB,GACjB,eAAe,GACf,WAAW,GACX,gBAAgB,CAAC;IAGrB,EAAE,EAAE,MAAM,CAAgB;IAI1B,OAAO,EAAG,MAAM,CAAC;IAGjB,eAAe,EAAG,MAAM,CAAC;IAIzB,MAAM,EACF,kBAAkB,GAClB,MAAM,GACN,QAAQ,GACR,UAAU,GACV,UAAU,GACV,oBAAoB,CAAsB;IAG9C,MAAM,EAAG,MAAM,CAAC;IAEhB;;;OAGG;IAEH,cAAc,EAAE,MAAM,CAAO;IAG7B,QAAQ,EAAG,MAAM,CAAC;IAGlB,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IAGrB,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAElC,qEAAqE;IAErE,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAEjD,sCAAsC;IAEtC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAE9B,mDAAmD;IAEnD,SAAS,EAAE,MAAM,CAAK;IAGtB,SAAS,EAAE,IAAI,CAAc;IAG7B,SAAS,EAAE,IAAI,CAAc;CAC9B"}
@@ -0,0 +1,100 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { Entity, Index, OptionalProps, PrimaryKey, Property } from '@mikro-orm/core';
11
+ import { GlobalEntity } from '@endora-commerce/platform/tenancy';
12
+ import { randomUUID } from 'crypto';
13
+ let Payment = class Payment {
14
+ [OptionalProps];
15
+ id = randomUUID();
16
+ orderId;
17
+ paymentMethodId;
18
+ status = 'awaiting_payment';
19
+ amount;
20
+ /**
21
+ * Cumulative amount refunded against this payment (feature 049). Kept in sync
22
+ * with the gateway's authoritative total via the `charge.refunded` webhook.
23
+ */
24
+ refundedAmount = '0';
25
+ currency;
26
+ paidAt;
27
+ externalReference;
28
+ /** Adapter/PSP payload captured on receive_payment (feature 034). */
29
+ providerDetails;
30
+ /** Populated on a failure outcome. */
31
+ failureReason;
32
+ /** Retry sequence per order: 1 = first attempt. */
33
+ attemptNo = 1;
34
+ createdAt = new Date();
35
+ updatedAt = new Date();
36
+ };
37
+ __decorate([
38
+ PrimaryKey({ type: 'uuid' }),
39
+ __metadata("design:type", String)
40
+ ], Payment.prototype, "id", void 0);
41
+ __decorate([
42
+ Property({ type: 'uuid' }),
43
+ Index(),
44
+ __metadata("design:type", String)
45
+ ], Payment.prototype, "orderId", void 0);
46
+ __decorate([
47
+ Property({ type: 'uuid' }),
48
+ __metadata("design:type", String)
49
+ ], Payment.prototype, "paymentMethodId", void 0);
50
+ __decorate([
51
+ Property({ type: 'string', length: 32 }),
52
+ Index(),
53
+ __metadata("design:type", String)
54
+ ], Payment.prototype, "status", void 0);
55
+ __decorate([
56
+ Property({ type: 'decimal', precision: 14, scale: 2 }),
57
+ __metadata("design:type", String)
58
+ ], Payment.prototype, "amount", void 0);
59
+ __decorate([
60
+ Property({ type: 'decimal', precision: 14, scale: 2 }),
61
+ __metadata("design:type", String)
62
+ ], Payment.prototype, "refundedAmount", void 0);
63
+ __decorate([
64
+ Property({ type: 'string', length: 3 }),
65
+ __metadata("design:type", String)
66
+ ], Payment.prototype, "currency", void 0);
67
+ __decorate([
68
+ Property({ type: 'datetime', nullable: true }),
69
+ __metadata("design:type", Object)
70
+ ], Payment.prototype, "paidAt", void 0);
71
+ __decorate([
72
+ Property({ type: 'string', length: 255, nullable: true }),
73
+ __metadata("design:type", Object)
74
+ ], Payment.prototype, "externalReference", void 0);
75
+ __decorate([
76
+ Property({ type: 'json', nullable: true }),
77
+ __metadata("design:type", Object)
78
+ ], Payment.prototype, "providerDetails", void 0);
79
+ __decorate([
80
+ Property({ type: 'text', nullable: true }),
81
+ __metadata("design:type", Object)
82
+ ], Payment.prototype, "failureReason", void 0);
83
+ __decorate([
84
+ Property({ type: 'integer' }),
85
+ __metadata("design:type", Number)
86
+ ], Payment.prototype, "attemptNo", void 0);
87
+ __decorate([
88
+ Property({ type: 'datetime', onCreate: () => new Date() }),
89
+ __metadata("design:type", Date)
90
+ ], Payment.prototype, "createdAt", void 0);
91
+ __decorate([
92
+ Property({ type: 'datetime', onUpdate: () => new Date() }),
93
+ __metadata("design:type", Date)
94
+ ], Payment.prototype, "updatedAt", void 0);
95
+ Payment = __decorate([
96
+ GlobalEntity(),
97
+ Entity({ tableName: 'payments' })
98
+ ], Payment);
99
+ export { Payment };
100
+ //# sourceMappingURL=payment.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payment.entity.js","sourceRoot":"","sources":["../../../src/backend/entities/payment.entity.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAI7B,IAAM,OAAO,GAAb,MAAM,OAAO;IAClB,CAAC,aAAa,CAAC,CAUM;IAGrB,EAAE,GAAW,UAAU,EAAE,CAAC;IAI1B,OAAO,CAAU;IAGjB,eAAe,CAAU;IAIzB,MAAM,GAMqB,kBAAkB,CAAC;IAG9C,MAAM,CAAU;IAEhB;;;OAGG;IAEH,cAAc,GAAW,GAAG,CAAC;IAG7B,QAAQ,CAAU;IAGlB,MAAM,CAAe;IAGrB,iBAAiB,CAAiB;IAElC,qEAAqE;IAErE,eAAe,CAAkC;IAEjD,sCAAsC;IAEtC,aAAa,CAAiB;IAE9B,mDAAmD;IAEnD,SAAS,GAAW,CAAC,CAAC;IAGtB,SAAS,GAAS,IAAI,IAAI,EAAE,CAAC;IAG7B,SAAS,GAAS,IAAI,IAAI,EAAE,CAAC;CAC9B,CAAA;AAvDC;IADC,UAAU,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;mCACH;AAI1B;IAFC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC1B,KAAK,EAAE;;wCACS;AAGjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CA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AAE;IACd,MAAM,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;GACrB,OAAO,CAqEnB"}
@@ -0,0 +1,88 @@
1
+ import type { EntityManager } from '@mikro-orm/postgresql';
2
+ import type { GatewayRefundRegistryPort, PaymentAdapterRegistryPort } from '@endora-commerce/contracts';
3
+ import type { FastifyReply, FastifyRequest } from 'fastify';
4
+ import type { EventBus } from '@endora-commerce/platform/events';
5
+ import type { ModuleContext } from '@endora-commerce/platform/kernel';
6
+ import type { OrganizationReadPort } from '@endora-commerce/platform/kernel';
7
+ import type { RequireAdminFactory } from '@endora-commerce/platform/kernel';
8
+ import { Payment } from './entities/payment.entity.js';
9
+ import { ReceivePaymentHandler } from './services/receive-payment-handler.js';
10
+ import { PaymentService } from './services/payment-service.js';
11
+ import { PaymentRetryService } from './services/payment-retry-service.js';
12
+ import { PaymentEmailNotifier } from './services/payment-email-notifier.js';
13
+ import type { PaymentEmailNotifierDeps } from './services/payment-email-notifier.js';
14
+ /**
15
+ * `payments` — the delivery-side twin of `shipments`, with the same history
16
+ * (feature 072, wave 3, T126).
17
+ *
18
+ * Like `shipments` before T124, this module owned a manifest, entities, two
19
+ * services, a route file and a transactional email, and registered none of it:
20
+ * `orders/plugin.ts` imported both services, constructed them inside its own
21
+ * plugin and mounted the routes there. So the payment lifecycle answered
22
+ * whenever `orders` was on, and switching `payments` off did nothing — there
23
+ * was no seam for a gate to sit on.
24
+ *
25
+ * The payment-status notifier moves in with it, and it is the same
26
+ * finding twice: both roots built it and called `attach(eventBus)`, subscribing
27
+ * to the raw bus rather than through `subscribeForModule`, so a payment-status
28
+ * e-mail went out whether or not the module was on. `ctx.subscribe` gates it and
29
+ * `attach()` is deleted, leaving no ungated path to fall back into.
30
+ *
31
+ * The order-status registry is already a port `delivery_methods` provides, and
32
+ * the manifest already declares that dependency. The transactional-email sender
33
+ * stays contributed: `transactional_emails` announces it through a callback a
34
+ * root holds, later than this module composes, so a port would point the
35
+ * dependency at a module that does not yet have the value.
36
+ *
37
+ * **The four built-in adapters came home in T143a cluster 6.** They live in
38
+ * this module (`adapters/built-in-adapters.ts`); `payment_methods` merely holds
39
+ * the registry, and its `backend.ts` says outright that seeding them from there
40
+ * would be a reach into another module's internals. Both roots did it instead,
41
+ * which made "which payment kinds this platform can settle" a property of the
42
+ * composition rather than of the module that implements them — and left the
43
+ * four registered with `payments` switched off.
44
+ */
45
+ /** What `payments` resolves from the container, and the names it owns. */
46
+ export interface PaymentsCradle {
47
+ readonly emFactory: () => EntityManager;
48
+ readonly eventBus: EventBus;
49
+ readonly requireAdmin: RequireAdminFactory;
50
+ /** How this composition authenticates and names the buyer on the retry route. */
51
+ readonly requireCustomer: (req: FastifyRequest, reply: FastifyReply) => Promise<void>;
52
+ readonly customerAccountIdResolver: (req: FastifyRequest) => string;
53
+ /** The tenancy read: a suspended Organization may not pay, as it may not place. */
54
+ readonly organizationReadPort: OrganizationReadPort;
55
+ /** Owned by `payment_methods`: the table this module's adapters are listed in. */
56
+ readonly paymentAdapterRegistry: PaymentAdapterRegistryPort;
57
+ /** Contribution point: absent means a payment-status e-mail is not sent. */
58
+ readonly paymentEmailSender: PaymentEmailNotifierDeps['getTransactionalEmailSender'];
59
+ readonly paymentEmailNotifier: PaymentEmailNotifier;
60
+ /**
61
+ * This module's own refund-handler table, as the container's value — the
62
+ * push seam the four gateways contribute to, ungated on purpose (see the
63
+ * registration).
64
+ */
65
+ readonly gatewayRefundRegistry: GatewayRefundRegistryPort;
66
+ readonly paymentService: PaymentService;
67
+ readonly paymentRetryService: PaymentRetryService;
68
+ readonly receivePaymentHandler: ReceivePaymentHandler;
69
+ }
70
+ export declare function registerModule(ctx: ModuleContext): void;
71
+ /**
72
+ * The module's persisted entity classes, on the `./backend` subpath, as one
73
+ * array and **no named class export** (D-168).
74
+ *
75
+ * This is the shape the platform reads when the package is *installed*: the
76
+ * boot-time loader (`src/packages/package-runtime.ts`, `exported['entities']`)
77
+ * and the static declaration reader (`scripts/lib/package-declarations.ts`),
78
+ * which is the third source of `check:module-boundary`'s `table->owner` map and
79
+ * the package pass of `check-entity-tenant-classification`. A missing array is
80
+ * answered with `[]` — zero entities registered, no error anywhere.
81
+ *
82
+ * One class, and the one that used to cross a boundary: `orders` constructed
83
+ * `Payment` directly until T048, which was the last cross-module entity-class
84
+ * reach in the tree. What crosses now is `PaymentPlacementApplyPort`, and D-168
85
+ * leaves a stranger no supported spelling for the class itself.
86
+ */
87
+ export declare const entities: (typeof Payment)[];
88
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/backend/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAGV,yBAAyB,EAGzB,0BAA0B,EAO3B,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAE5E,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AACvD,OAAO,EACL,qBAAqB,EAGtB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAO1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAE5E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAKrF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,0EA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