@mj-biz-apps/orders-core-entities-server 0.0.1 → 5.2.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.
- package/LICENSE +183 -0
- package/README.md +141 -2
- package/dist/AccountingBridge.d.ts +65 -0
- package/dist/AccountingBridge.d.ts.map +1 -0
- package/dist/AccountingBridge.js +102 -0
- package/dist/AccountingBridge.js.map +1 -0
- package/dist/AdvanceOrderStateOperation.d.ts +80 -0
- package/dist/AdvanceOrderStateOperation.d.ts.map +1 -0
- package/dist/AdvanceOrderStateOperation.js +267 -0
- package/dist/AdvanceOrderStateOperation.js.map +1 -0
- package/dist/ApplyAccountCreditOperation.d.ts +97 -0
- package/dist/ApplyAccountCreditOperation.d.ts.map +1 -0
- package/dist/ApplyAccountCreditOperation.js +275 -0
- package/dist/ApplyAccountCreditOperation.js.map +1 -0
- package/dist/BaseDeliveryChannel.d.ts +106 -0
- package/dist/BaseDeliveryChannel.d.ts.map +1 -0
- package/dist/BaseDeliveryChannel.js +36 -0
- package/dist/BaseDeliveryChannel.js.map +1 -0
- package/dist/BasePaymentProvider.d.ts +239 -0
- package/dist/BasePaymentProvider.d.ts.map +1 -0
- package/dist/BasePaymentProvider.js +91 -0
- package/dist/BasePaymentProvider.js.map +1 -0
- package/dist/BundleBehavior.d.ts +139 -0
- package/dist/BundleBehavior.d.ts.map +1 -0
- package/dist/BundleBehavior.js +173 -0
- package/dist/BundleBehavior.js.map +1 -0
- package/dist/BundleEngine.d.ts +60 -0
- package/dist/BundleEngine.d.ts.map +1 -0
- package/dist/BundleEngine.js +197 -0
- package/dist/BundleEngine.js.map +1 -0
- package/dist/CancelSubscriptionOperation.d.ts +98 -0
- package/dist/CancelSubscriptionOperation.d.ts.map +1 -0
- package/dist/CancelSubscriptionOperation.js +317 -0
- package/dist/CancelSubscriptionOperation.js.map +1 -0
- package/dist/CapturePaymentOperation.d.ts +62 -0
- package/dist/CapturePaymentOperation.d.ts.map +1 -0
- package/dist/CapturePaymentOperation.js +463 -0
- package/dist/CapturePaymentOperation.js.map +1 -0
- package/dist/CheckEntitlementOperation.d.ts +27 -0
- package/dist/CheckEntitlementOperation.d.ts.map +1 -0
- package/dist/CheckEntitlementOperation.js +45 -0
- package/dist/CheckEntitlementOperation.js.map +1 -0
- package/dist/CheckoutSessionService.d.ts +258 -0
- package/dist/CheckoutSessionService.d.ts.map +1 -0
- package/dist/CheckoutSessionService.js +1557 -0
- package/dist/CheckoutSessionService.js.map +1 -0
- package/dist/DeliveryBehavior.d.ts +121 -0
- package/dist/DeliveryBehavior.d.ts.map +1 -0
- package/dist/DeliveryBehavior.js +145 -0
- package/dist/DeliveryBehavior.js.map +1 -0
- package/dist/DeliveryRecipientResolver.d.ts +38 -0
- package/dist/DeliveryRecipientResolver.d.ts.map +1 -0
- package/dist/DeliveryRecipientResolver.js +93 -0
- package/dist/DeliveryRecipientResolver.js.map +1 -0
- package/dist/DeliveryResolver.d.ts +14 -0
- package/dist/DeliveryResolver.d.ts.map +1 -0
- package/dist/DeliveryResolver.js +45 -0
- package/dist/DeliveryResolver.js.map +1 -0
- package/dist/EmailDeliveryChannel.d.ts +31 -0
- package/dist/EmailDeliveryChannel.d.ts.map +1 -0
- package/dist/EmailDeliveryChannel.js +158 -0
- package/dist/EmailDeliveryChannel.js.map +1 -0
- package/dist/EntitlementBehavior.d.ts +235 -0
- package/dist/EntitlementBehavior.d.ts.map +1 -0
- package/dist/EntitlementBehavior.js +330 -0
- package/dist/EntitlementBehavior.js.map +1 -0
- package/dist/EntitlementEngine.d.ts +97 -0
- package/dist/EntitlementEngine.d.ts.map +1 -0
- package/dist/EntitlementEngine.js +338 -0
- package/dist/EntitlementEngine.js.map +1 -0
- package/dist/EntitlementGrantClaimDriver.d.ts +42 -0
- package/dist/EntitlementGrantClaimDriver.d.ts.map +1 -0
- package/dist/EntitlementGrantClaimDriver.js +158 -0
- package/dist/EntitlementGrantClaimDriver.js.map +1 -0
- package/dist/EntitlementRead.d.ts +82 -0
- package/dist/EntitlementRead.d.ts.map +1 -0
- package/dist/EntitlementRead.js +368 -0
- package/dist/EntitlementRead.js.map +1 -0
- package/dist/FulfillOrderLinesOperation.d.ts +34 -0
- package/dist/FulfillOrderLinesOperation.d.ts.map +1 -0
- package/dist/FulfillOrderLinesOperation.js +208 -0
- package/dist/FulfillOrderLinesOperation.js.map +1 -0
- package/dist/FulfillmentBehavior.d.ts +101 -0
- package/dist/FulfillmentBehavior.d.ts.map +1 -0
- package/dist/FulfillmentBehavior.js +145 -0
- package/dist/FulfillmentBehavior.js.map +1 -0
- package/dist/GLAccountResolver.d.ts +123 -0
- package/dist/GLAccountResolver.d.ts.map +1 -0
- package/dist/GLAccountResolver.js +175 -0
- package/dist/GLAccountResolver.js.map +1 -0
- package/dist/GetFulfillmentQueueOperation.d.ts +35 -0
- package/dist/GetFulfillmentQueueOperation.d.ts.map +1 -0
- package/dist/GetFulfillmentQueueOperation.js +221 -0
- package/dist/GetFulfillmentQueueOperation.js.map +1 -0
- package/dist/GetOverdueWorklistOperation.d.ts +41 -0
- package/dist/GetOverdueWorklistOperation.d.ts.map +1 -0
- package/dist/GetOverdueWorklistOperation.js +210 -0
- package/dist/GetOverdueWorklistOperation.js.map +1 -0
- package/dist/GiftCardBehavior.d.ts +97 -0
- package/dist/GiftCardBehavior.d.ts.map +1 -0
- package/dist/GiftCardBehavior.js +121 -0
- package/dist/GiftCardBehavior.js.map +1 -0
- package/dist/GiftCardEngine.d.ts +59 -0
- package/dist/GiftCardEngine.d.ts.map +1 -0
- package/dist/GiftCardEngine.js +197 -0
- package/dist/GiftCardEngine.js.map +1 -0
- package/dist/GuestOrderClaimDriver.d.ts +36 -0
- package/dist/GuestOrderClaimDriver.d.ts.map +1 -0
- package/dist/GuestOrderClaimDriver.js +161 -0
- package/dist/GuestOrderClaimDriver.js.map +1 -0
- package/dist/InvoiceBehavior.d.ts +394 -0
- package/dist/InvoiceBehavior.d.ts.map +1 -0
- package/dist/InvoiceBehavior.js +496 -0
- package/dist/InvoiceBehavior.js.map +1 -0
- package/dist/InvoiceBuilder.d.ts +48 -0
- package/dist/InvoiceBuilder.d.ts.map +1 -0
- package/dist/InvoiceBuilder.js +352 -0
- package/dist/InvoiceBuilder.js.map +1 -0
- package/dist/InvoiceDisplay.d.ts +96 -0
- package/dist/InvoiceDisplay.d.ts.map +1 -0
- package/dist/InvoiceDisplay.js +121 -0
- package/dist/InvoiceDisplay.js.map +1 -0
- package/dist/ListEntitlementsOperation.d.ts +21 -0
- package/dist/ListEntitlementsOperation.d.ts.map +1 -0
- package/dist/ListEntitlementsOperation.js +39 -0
- package/dist/ListEntitlementsOperation.js.map +1 -0
- package/dist/ManualPaymentProvider.d.ts +19 -0
- package/dist/ManualPaymentProvider.d.ts.map +1 -0
- package/dist/ManualPaymentProvider.js +92 -0
- package/dist/ManualPaymentProvider.js.map +1 -0
- package/dist/OrderEntityServer.d.ts +542 -0
- package/dist/OrderEntityServer.d.ts.map +1 -0
- package/dist/OrderEntityServer.js +2100 -0
- package/dist/OrderEntityServer.js.map +1 -0
- package/dist/OrderJournalEntryFactory.d.ts +140 -0
- package/dist/OrderJournalEntryFactory.d.ts.map +1 -0
- package/dist/OrderJournalEntryFactory.js +466 -0
- package/dist/OrderJournalEntryFactory.js.map +1 -0
- package/dist/OrderLineEntityServer.d.ts +90 -0
- package/dist/OrderLineEntityServer.d.ts.map +1 -0
- package/dist/OrderLineEntityServer.js +260 -0
- package/dist/OrderLineEntityServer.js.map +1 -0
- package/dist/OrdersSettings.d.ts +36 -0
- package/dist/OrdersSettings.d.ts.map +1 -0
- package/dist/OrdersSettings.js +147 -0
- package/dist/OrdersSettings.js.map +1 -0
- package/dist/PaymentAllocationFactory.d.ts +128 -0
- package/dist/PaymentAllocationFactory.d.ts.map +1 -0
- package/dist/PaymentAllocationFactory.js +235 -0
- package/dist/PaymentAllocationFactory.js.map +1 -0
- package/dist/PaymentHeaderEntityServer.d.ts +180 -0
- package/dist/PaymentHeaderEntityServer.d.ts.map +1 -0
- package/dist/PaymentHeaderEntityServer.js +656 -0
- package/dist/PaymentHeaderEntityServer.js.map +1 -0
- package/dist/PaymentIntentService.d.ts +101 -0
- package/dist/PaymentIntentService.d.ts.map +1 -0
- package/dist/PaymentIntentService.js +150 -0
- package/dist/PaymentIntentService.js.map +1 -0
- package/dist/PaymentJournalEntryFactory.d.ts +99 -0
- package/dist/PaymentJournalEntryFactory.d.ts.map +1 -0
- package/dist/PaymentJournalEntryFactory.js +127 -0
- package/dist/PaymentJournalEntryFactory.js.map +1 -0
- package/dist/PaymentLineEntityServer.d.ts +73 -0
- package/dist/PaymentLineEntityServer.d.ts.map +1 -0
- package/dist/PaymentLineEntityServer.js +303 -0
- package/dist/PaymentLineEntityServer.js.map +1 -0
- package/dist/PaymentProviderBehavior.d.ts +222 -0
- package/dist/PaymentProviderBehavior.d.ts.map +1 -0
- package/dist/PaymentProviderBehavior.js +368 -0
- package/dist/PaymentProviderBehavior.js.map +1 -0
- package/dist/PaymentProviderResolver.d.ts +84 -0
- package/dist/PaymentProviderResolver.d.ts.map +1 -0
- package/dist/PaymentProviderResolver.js +220 -0
- package/dist/PaymentProviderResolver.js.map +1 -0
- package/dist/PaymentReversalFactory.d.ts +107 -0
- package/dist/PaymentReversalFactory.d.ts.map +1 -0
- package/dist/PaymentReversalFactory.js +174 -0
- package/dist/PaymentReversalFactory.js.map +1 -0
- package/dist/PaymentSettlement.d.ts +56 -0
- package/dist/PaymentSettlement.d.ts.map +1 -0
- package/dist/PaymentSettlement.js +243 -0
- package/dist/PaymentSettlement.js.map +1 -0
- package/dist/PaymentTermsBehavior.d.ts +109 -0
- package/dist/PaymentTermsBehavior.d.ts.map +1 -0
- package/dist/PaymentTermsBehavior.js +172 -0
- package/dist/PaymentTermsBehavior.js.map +1 -0
- package/dist/PaymentWebhookHandler.d.ts +103 -0
- package/dist/PaymentWebhookHandler.d.ts.map +1 -0
- package/dist/PaymentWebhookHandler.js +246 -0
- package/dist/PaymentWebhookHandler.js.map +1 -0
- package/dist/PreviewPriceOperation.d.ts +62 -0
- package/dist/PreviewPriceOperation.d.ts.map +1 -0
- package/dist/PreviewPriceOperation.js +161 -0
- package/dist/PreviewPriceOperation.js.map +1 -0
- package/dist/PriceOrderOperation.d.ts +93 -0
- package/dist/PriceOrderOperation.d.ts.map +1 -0
- package/dist/PriceOrderOperation.js +146 -0
- package/dist/PriceOrderOperation.js.map +1 -0
- package/dist/ProductPriceEntityServer.d.ts +34 -0
- package/dist/ProductPriceEntityServer.d.ts.map +1 -0
- package/dist/ProductPriceEntityServer.js +97 -0
- package/dist/ProductPriceEntityServer.js.map +1 -0
- package/dist/RefundPaymentOperation.d.ts +61 -0
- package/dist/RefundPaymentOperation.d.ts.map +1 -0
- package/dist/RefundPaymentOperation.js +177 -0
- package/dist/RefundPaymentOperation.js.map +1 -0
- package/dist/RevenueRecognition.d.ts +76 -0
- package/dist/RevenueRecognition.d.ts.map +1 -0
- package/dist/RevenueRecognition.js +133 -0
- package/dist/RevenueRecognition.js.map +1 -0
- package/dist/ReversalBehavior.d.ts +82 -0
- package/dist/ReversalBehavior.d.ts.map +1 -0
- package/dist/ReversalBehavior.js +100 -0
- package/dist/ReversalBehavior.js.map +1 -0
- package/dist/ReversalResolver.d.ts +37 -0
- package/dist/ReversalResolver.d.ts.map +1 -0
- package/dist/ReversalResolver.js +96 -0
- package/dist/ReversalResolver.js.map +1 -0
- package/dist/SpawnRenewalsOperation.d.ts +109 -0
- package/dist/SpawnRenewalsOperation.d.ts.map +1 -0
- package/dist/SpawnRenewalsOperation.js +295 -0
- package/dist/SpawnRenewalsOperation.js.map +1 -0
- package/dist/StoredValuePaymentProvider.d.ts +52 -0
- package/dist/StoredValuePaymentProvider.d.ts.map +1 -0
- package/dist/StoredValuePaymentProvider.js +205 -0
- package/dist/StoredValuePaymentProvider.js.map +1 -0
- package/dist/StripeACHPaymentProvider.d.ts +50 -0
- package/dist/StripeACHPaymentProvider.d.ts.map +1 -0
- package/dist/StripeACHPaymentProvider.js +211 -0
- package/dist/StripeACHPaymentProvider.js.map +1 -0
- package/dist/StripePaymentProvider.d.ts +83 -0
- package/dist/StripePaymentProvider.d.ts.map +1 -0
- package/dist/StripePaymentProvider.js +442 -0
- package/dist/StripePaymentProvider.js.map +1 -0
- package/dist/SubscriptionBehavior.d.ts +197 -0
- package/dist/SubscriptionBehavior.d.ts.map +1 -0
- package/dist/SubscriptionBehavior.js +415 -0
- package/dist/SubscriptionBehavior.js.map +1 -0
- package/dist/checkoutCaptureAlert.d.ts +16 -0
- package/dist/checkoutCaptureAlert.d.ts.map +1 -0
- package/dist/checkoutCaptureAlert.js +55 -0
- package/dist/checkoutCaptureAlert.js.map +1 -0
- package/dist/checkoutCaptureRetry.d.ts +27 -0
- package/dist/checkoutCaptureRetry.d.ts.map +1 -0
- package/dist/checkoutCaptureRetry.js +50 -0
- package/dist/checkoutCaptureRetry.js.map +1 -0
- package/dist/claimDriverHelpers.d.ts +15 -0
- package/dist/claimDriverHelpers.d.ts.map +1 -0
- package/dist/claimDriverHelpers.js +34 -0
- package/dist/claimDriverHelpers.js.map +1 -0
- package/dist/entity-names.d.ts +15 -0
- package/dist/entity-names.d.ts.map +1 -0
- package/dist/entity-names.js +15 -0
- package/dist/entity-names.js.map +1 -0
- package/dist/identityClaimContracts.d.ts +118 -0
- package/dist/identityClaimContracts.d.ts.map +1 -0
- package/dist/identityClaimContracts.js +58 -0
- package/dist/identityClaimContracts.js.map +1 -0
- package/dist/index.d.ts +126 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +115 -0
- package/dist/index.js.map +1 -0
- package/dist/sql-guards.d.ts +78 -0
- package/dist/sql-guards.d.ts.map +1 -0
- package/dist/sql-guards.js +115 -0
- package/dist/sql-guards.js.map +1 -0
- package/package.json +50 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApplyAccountCreditOperation.js","sourceRoot":"","sources":["../src/ApplyAccountCreditOperation.ts"],"names":[],"mappings":";;;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M,UAAU,+BAA+B;IAC3C,sBAAsB;AAC1B,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BaseDeliveryChannel — the seam a document leaves the building through.
|
|
3
|
+
*
|
|
4
|
+
* WHY A SEAM AT ALL, WHEN EMAIL IS THE ONLY CHANNEL TODAY. Because the callers are already plural and
|
|
5
|
+
* the second channel is already named. §4.4 of the plan settles delivery as "thin send-via-email of
|
|
6
|
+
* the rendered order first, with an Action-plugin seam", and lists a bill-presentment service as the
|
|
7
|
+
* adapter that arrives when a channel needs it. A hard-coded `sendEmail()` would have to be unpicked
|
|
8
|
+
* from every caller on the day that happens; a class keyed by channel code is a metadata row and a
|
|
9
|
+
* subclass, which is the same shape `BasePaymentProvider` uses for gateways and for the same reason.
|
|
10
|
+
*
|
|
11
|
+
* IT IS DOCUMENT-AGNOSTIC ON PURPOSE. Nothing below knows what an invoice is. A channel takes a
|
|
12
|
+
* rendered document — a subject, a body, a recipient — and gets it to that recipient. That is what
|
|
13
|
+
* makes this reusable for statements, dunning notices, order confirmations and receipts without any
|
|
14
|
+
* of them teaching the channel a new noun. The KIND of document is carried as free text purely so a
|
|
15
|
+
* channel can log it or route on it, never so it can branch on it.
|
|
16
|
+
*
|
|
17
|
+
* IT DOES NOT RENDER, AND IT DOES NOT DECIDE. Rendering belongs to whoever owns the document's shape;
|
|
18
|
+
* deciding whether to send belongs to `DeliveryBehavior`. A channel that rendered would need one
|
|
19
|
+
* template per document type and would become the place every future document type is edited. A
|
|
20
|
+
* channel that decided would put "is this order confirmed?" in the mail layer.
|
|
21
|
+
*
|
|
22
|
+
* REFUSAL IS NOT AN EXCEPTION — the same contract the payment drivers follow. A rejected address is a
|
|
23
|
+
* normal outcome of asking; a mail server being unreachable is not. Only the second throws, because a
|
|
24
|
+
* caller that has to read exception messages to tell "bad address" from "provider down" will
|
|
25
|
+
* eventually treat one as the other, and the two want completely different responses.
|
|
26
|
+
*
|
|
27
|
+
* CONNECTS TO:
|
|
28
|
+
* PURE: ./DeliveryBehavior.ts — who it goes to, and whether it should
|
|
29
|
+
* SHIPPED: ./EmailDeliveryChannel.ts
|
|
30
|
+
* LOOKUP: ./DeliveryResolver.ts
|
|
31
|
+
* DOC: plans/archive/bizapps-orders-master.md §4.4
|
|
32
|
+
*/
|
|
33
|
+
import type { IMetadataProvider, UserInfo } from '@memberjunction/core';
|
|
34
|
+
import type { DeliveryChannelCode, DeliveryContact } from './DeliveryBehavior.js';
|
|
35
|
+
/** A document that has already been rendered and is ready to leave. */
|
|
36
|
+
export interface DeliverableDocument {
|
|
37
|
+
/** `Invoice`, `Statement`, `OrderConfirmation`, … — for logging and routing, never for branching. */
|
|
38
|
+
Kind: string;
|
|
39
|
+
/** The document's own number. Appears in the subject and in every log line about this send. */
|
|
40
|
+
DocumentNumber: string;
|
|
41
|
+
/** Already built by `BuildSubject` or supplied by the caller. */
|
|
42
|
+
Subject: string;
|
|
43
|
+
/** The rendered document. HTML today; a channel that cannot render HTML uses `BodyPlain`. */
|
|
44
|
+
BodyHtml: string;
|
|
45
|
+
/**
|
|
46
|
+
* A plain-text alternative. OPTIONAL, and its absence is not fatal — but a channel sending only
|
|
47
|
+
* HTML gives spam filters one of their strongest signals, so callers are encouraged to supply one.
|
|
48
|
+
*/
|
|
49
|
+
BodyPlain?: string;
|
|
50
|
+
}
|
|
51
|
+
/** Where a document is going, and who it is from. */
|
|
52
|
+
export interface DeliveryAddressing {
|
|
53
|
+
To: DeliveryContact[];
|
|
54
|
+
CC?: string[];
|
|
55
|
+
BCC?: string[];
|
|
56
|
+
/** The sending address. Null lets the channel fall back to its provider's configured default. */
|
|
57
|
+
From?: string | null;
|
|
58
|
+
FromName?: string | null;
|
|
59
|
+
}
|
|
60
|
+
export interface DeliveryResult {
|
|
61
|
+
Success: boolean;
|
|
62
|
+
/** Why not, when not — in the provider's words where it has any. */
|
|
63
|
+
Reason?: string;
|
|
64
|
+
/** The provider's own message id, for correlating with its logs. */
|
|
65
|
+
ProviderMessageID?: string;
|
|
66
|
+
/** Addresses the channel actually accepted, which may be fewer than were offered. */
|
|
67
|
+
Delivered: string[];
|
|
68
|
+
}
|
|
69
|
+
/** Everything a channel needs that is not the document itself. */
|
|
70
|
+
export interface DeliveryContext {
|
|
71
|
+
Provider: IMetadataProvider;
|
|
72
|
+
User: UserInfo;
|
|
73
|
+
/**
|
|
74
|
+
* Render without sending, for a preview screen. A channel MUST honour this — a preview that sends
|
|
75
|
+
* is the worst possible bug in a mail path, because it is invisible on the sending side.
|
|
76
|
+
*/
|
|
77
|
+
PreviewOnly?: boolean;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The channel contract.
|
|
81
|
+
*
|
|
82
|
+
* Registered against this base by channel code:
|
|
83
|
+
*
|
|
84
|
+
* ```ts
|
|
85
|
+
* @RegisterClass(BaseDeliveryChannel, 'Email')
|
|
86
|
+
* export class EmailDeliveryChannel extends BaseDeliveryChannel { … }
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* NOT DECORATED ITSELF, matching `BasePaymentProvider`. MJ's ClassFactory instantiates the base when
|
|
90
|
+
* no key matches, so a self-registration would make "nobody registered a channel" indistinguishable
|
|
91
|
+
* from "the channel refused" — `DeliveryResolver` checks for exactly that.
|
|
92
|
+
*/
|
|
93
|
+
export declare class BaseDeliveryChannel {
|
|
94
|
+
/** Which channel this is. Set by the resolver; the ClassFactory constructs with no arguments. */
|
|
95
|
+
Code: DeliveryChannelCode;
|
|
96
|
+
/**
|
|
97
|
+
* Send it. The default REFUSES rather than reporting a success nobody can verify.
|
|
98
|
+
*
|
|
99
|
+
* A channel author who forgets to override should find out from a clear message, not from a
|
|
100
|
+
* customer who never received their invoice and a log full of successes.
|
|
101
|
+
*/
|
|
102
|
+
Deliver(_document: DeliverableDocument, _addressing: DeliveryAddressing, _context: DeliveryContext): Promise<DeliveryResult>;
|
|
103
|
+
}
|
|
104
|
+
/** Tree-shaking anchor — call from the server bootstrap so @RegisterClass is retained. */
|
|
105
|
+
export declare function LoadBaseDeliveryChannel(): void;
|
|
106
|
+
//# sourceMappingURL=BaseDeliveryChannel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseDeliveryChannel.d.ts","sourceRoot":"","sources":["../src/BaseDeliveryChannel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,KAAK,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAElF,uEAAuE;AACvE,MAAM,WAAW,mBAAmB;IAChC,qGAAqG;IACrG,IAAI,EAAE,MAAM,CAAC;IACb,+FAA+F;IAC/F,cAAc,EAAE,MAAM,CAAC;IACvB,iEAAiE;IACjE,OAAO,EAAE,MAAM,CAAC;IAChB,6FAA6F;IAC7F,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,qDAAqD;AACrD,MAAM,WAAW,kBAAkB;IAC/B,EAAE,EAAE,eAAe,EAAE,CAAC;IACtB,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,iGAAiG;IACjG,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,cAAc;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,oEAAoE;IACpE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oEAAoE;IACpE,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,qFAAqF;IACrF,SAAS,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,kEAAkE;AAClE,MAAM,WAAW,eAAe;IAC5B,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,IAAI,EAAE,QAAQ,CAAC;IACf;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,mBAAmB;IAC5B,iGAAiG;IAC1F,IAAI,EAAG,mBAAmB,CAAC;IAElC;;;;;OAKG;IACU,OAAO,CAChB,SAAS,EAAE,mBAAmB,EAC9B,WAAW,EAAE,kBAAkB,EAC/B,QAAQ,EAAE,eAAe,GAC1B,OAAO,CAAC,cAAc,CAAC;CAU7B;AAED,0FAA0F;AAC1F,wBAAgB,uBAAuB,IAAI,IAAI,CAE9C"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The channel contract.
|
|
3
|
+
*
|
|
4
|
+
* Registered against this base by channel code:
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* @RegisterClass(BaseDeliveryChannel, 'Email')
|
|
8
|
+
* export class EmailDeliveryChannel extends BaseDeliveryChannel { … }
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* NOT DECORATED ITSELF, matching `BasePaymentProvider`. MJ's ClassFactory instantiates the base when
|
|
12
|
+
* no key matches, so a self-registration would make "nobody registered a channel" indistinguishable
|
|
13
|
+
* from "the channel refused" — `DeliveryResolver` checks for exactly that.
|
|
14
|
+
*/
|
|
15
|
+
export class BaseDeliveryChannel {
|
|
16
|
+
/**
|
|
17
|
+
* Send it. The default REFUSES rather than reporting a success nobody can verify.
|
|
18
|
+
*
|
|
19
|
+
* A channel author who forgets to override should find out from a clear message, not from a
|
|
20
|
+
* customer who never received their invoice and a log full of successes.
|
|
21
|
+
*/
|
|
22
|
+
async Deliver(_document, _addressing, _context) {
|
|
23
|
+
return {
|
|
24
|
+
Success: false,
|
|
25
|
+
Delivered: [],
|
|
26
|
+
Reason: `The '${this.Code ?? 'unknown'}' delivery channel has no implementation. This is a channel ` +
|
|
27
|
+
`that was never registered, not a message that was rejected — check the @RegisterClass key ` +
|
|
28
|
+
`against the channel code.`,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/** Tree-shaking anchor — call from the server bootstrap so @RegisterClass is retained. */
|
|
33
|
+
export function LoadBaseDeliveryChannel() {
|
|
34
|
+
// intentionally empty
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=BaseDeliveryChannel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseDeliveryChannel.js","sourceRoot":"","sources":["../src/BaseDeliveryChannel.ts"],"names":[],"mappings":"AAmFA;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,mBAAmB;IAI5B;;;;;OAKG;IACI,KAAK,CAAC,OAAO,CAChB,SAA8B,EAC9B,WAA+B,EAC/B,QAAyB;QAEzB,OAAO;YACH,OAAO,EAAE,KAAK;YACd,SAAS,EAAE,EAAE;YACb,MAAM,EACF,QAAQ,IAAI,CAAC,IAAI,IAAI,SAAS,8DAA8D;gBAC5F,4FAA4F;gBAC5F,2BAA2B;SAClC,CAAC;IACN,CAAC;CACJ;AAED,0FAA0F;AAC1F,MAAM,UAAU,uBAAuB;IACnC,sBAAsB;AAC1B,CAAC"}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BasePaymentProvider — the seam every gateway plugs into (D19/D37).
|
|
3
|
+
*
|
|
4
|
+
* A `PaymentProviderType` row's `Code` IS the `@RegisterClass` key, so adding a gateway is a metadata
|
|
5
|
+
* row plus a subclass, never a schema change. `DriverClass` on the same row names the class for a
|
|
6
|
+
* human reading the configuration; the ClassFactory resolves by `Code`.
|
|
7
|
+
*
|
|
8
|
+
* WHAT A DRIVER IS RESPONSIBLE FOR, and what it is emphatically not:
|
|
9
|
+
*
|
|
10
|
+
* IT DOES talk to the gateway, and translate between that gateway's vocabulary and ours.
|
|
11
|
+
* IT DOES NOT write journal entries, move `PaymentHeader.Status`, or touch allocations.
|
|
12
|
+
*
|
|
13
|
+
* That division is why `PaymentHeaderEntityServer` can stay the single place cash is booked. A driver
|
|
14
|
+
* that posted its own entries would give every gateway its own accounting, and the first one to get it
|
|
15
|
+
* wrong would balance anyway.
|
|
16
|
+
*
|
|
17
|
+
* LOGICAL REFUSAL IS NOT AN EXCEPTION. Every operation returns a result carrying `Success` and, when
|
|
18
|
+
* false, a `Reason` a person can act on. A declined card is a normal outcome of asking; a gateway
|
|
19
|
+
* being unreachable is not. Only the second throws. This is the same rule the remotable operations
|
|
20
|
+
* follow, and it exists because a caller that has to read exception messages to tell "declined" from
|
|
21
|
+
* "broken" will eventually treat one as the other.
|
|
22
|
+
*
|
|
23
|
+
* MONEY CROSSES THIS BOUNDARY IN MAJOR UNITS — decimals, as we store them. Each driver converts at
|
|
24
|
+
* its own edge using `ToMinorUnits`/`FromMinorUnits`, because the conversion is the GATEWAY'S
|
|
25
|
+
* convention rather than ours, and hoisting it here would impose Stripe's on everyone.
|
|
26
|
+
*
|
|
27
|
+
* CONNECTS TO:
|
|
28
|
+
* PURE: ./PaymentProviderBehavior.ts
|
|
29
|
+
* DRIVERS: ./StripePaymentProvider.ts · ./ManualPaymentProvider.ts · ./StoredValuePaymentProvider.ts
|
|
30
|
+
* LOOKUP: ./PaymentProviderResolver.ts
|
|
31
|
+
* DOC: plans/archive/bizapps-orders-master.md D19, D37
|
|
32
|
+
*/
|
|
33
|
+
import { IMetadataProvider, UserInfo } from '@memberjunction/core';
|
|
34
|
+
import type { IntentStatus } from './PaymentProviderBehavior.js';
|
|
35
|
+
/** The configured account a driver is acting for — one `PaymentProvider` row. */
|
|
36
|
+
export interface PaymentProviderConfig {
|
|
37
|
+
ID: string;
|
|
38
|
+
/** The `PaymentProviderType.Code`, which is also the ClassFactory key. */
|
|
39
|
+
TypeCode: string;
|
|
40
|
+
CompanyID: string;
|
|
41
|
+
Name: string;
|
|
42
|
+
/**
|
|
43
|
+
* How to FIND the credentials, never the credentials themselves. Resolved through
|
|
44
|
+
* `PaymentProviderResolver`'s secret seam so a deployment can point it at a vault.
|
|
45
|
+
*/
|
|
46
|
+
CredentialsRef: string | null;
|
|
47
|
+
IsLiveMode: boolean;
|
|
48
|
+
Capabilities: {
|
|
49
|
+
SupportsTokenization: boolean;
|
|
50
|
+
SupportsRefund: boolean;
|
|
51
|
+
SupportsWebhooks: boolean;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/** Resolved secrets. Held only for the duration of a call and never persisted. */
|
|
55
|
+
export interface PaymentCredentials {
|
|
56
|
+
/** The gateway API key. */
|
|
57
|
+
ApiKey?: string;
|
|
58
|
+
/** The webhook endpoint signing secret — a DIFFERENT secret from the API key, deliberately. */
|
|
59
|
+
WebhookSecret?: string;
|
|
60
|
+
/** Anything a specific gateway needs beyond those two. */
|
|
61
|
+
Extra?: Record<string, string>;
|
|
62
|
+
}
|
|
63
|
+
export interface CreateIntentRequest {
|
|
64
|
+
/** Major units, as we store money. */
|
|
65
|
+
Amount: number;
|
|
66
|
+
CurrencyCode: string;
|
|
67
|
+
OrderHeaderID?: string | null;
|
|
68
|
+
/** Who we are collecting from (D65) — carried so the gateway's record matches ours. */
|
|
69
|
+
BillToPersonID?: string | null;
|
|
70
|
+
BillToOrganizationID?: string | null;
|
|
71
|
+
/** A saved instrument to charge, when the customer has one on file. */
|
|
72
|
+
ProviderCustomerRef?: string | null;
|
|
73
|
+
ProviderInstrumentRef?: string | null;
|
|
74
|
+
/** Free-form, echoed back on webhooks. Useful for reconciliation, never load-bearing. */
|
|
75
|
+
Metadata?: Record<string, string>;
|
|
76
|
+
/**
|
|
77
|
+
* OUR idempotency key. Sent to gateways that support one so a retried create does not open a
|
|
78
|
+
* second intent — and therefore does not charge the customer twice.
|
|
79
|
+
*/
|
|
80
|
+
IdempotencyKey?: string;
|
|
81
|
+
}
|
|
82
|
+
export interface CreateIntentResult {
|
|
83
|
+
Success: boolean;
|
|
84
|
+
Reason?: string;
|
|
85
|
+
ProviderIntentID?: string;
|
|
86
|
+
Status?: IntentStatus;
|
|
87
|
+
/** For a client-side confirmation flow. Never logged. */
|
|
88
|
+
ClientSecret?: string;
|
|
89
|
+
/** For a hosted-checkout flow — where to send the customer. */
|
|
90
|
+
HostedUrl?: string;
|
|
91
|
+
}
|
|
92
|
+
export interface CaptureRequest {
|
|
93
|
+
ProviderIntentID: string;
|
|
94
|
+
/** Omit for the full authorised amount. Major units. */
|
|
95
|
+
Amount?: number;
|
|
96
|
+
CurrencyCode: string;
|
|
97
|
+
}
|
|
98
|
+
export interface RetrieveIntentRequest {
|
|
99
|
+
ProviderIntentID: string;
|
|
100
|
+
}
|
|
101
|
+
export interface RetrieveIntentResult {
|
|
102
|
+
Success: boolean;
|
|
103
|
+
Reason?: string;
|
|
104
|
+
Status?: IntentStatus;
|
|
105
|
+
/** Major units as the gateway currently reports them. */
|
|
106
|
+
Amount?: number;
|
|
107
|
+
}
|
|
108
|
+
export interface CaptureResult {
|
|
109
|
+
Success: boolean;
|
|
110
|
+
Reason?: string;
|
|
111
|
+
/** Major units, as reported by the gateway rather than as we asked. */
|
|
112
|
+
Amount?: number;
|
|
113
|
+
/**
|
|
114
|
+
* The gateway's cut, major units. Feeds `PaymentHeader.ProcessingFeeAmount` and the fee leg of the
|
|
115
|
+
* capture entry (D18). Zero is a legitimate answer; UNKNOWN is not the same thing, so a driver
|
|
116
|
+
* that cannot determine a fee leaves this undefined rather than reporting 0.
|
|
117
|
+
*/
|
|
118
|
+
FeeAmount?: number;
|
|
119
|
+
ProviderChargeID?: string;
|
|
120
|
+
Status?: IntentStatus;
|
|
121
|
+
}
|
|
122
|
+
export interface RefundRequest {
|
|
123
|
+
/** One of these. A gateway may key refunds off either. */
|
|
124
|
+
ProviderIntentID?: string;
|
|
125
|
+
ProviderChargeID?: string;
|
|
126
|
+
/** Major units. Omit for a full refund. */
|
|
127
|
+
Amount?: number;
|
|
128
|
+
CurrencyCode: string;
|
|
129
|
+
Reason?: string;
|
|
130
|
+
IdempotencyKey?: string;
|
|
131
|
+
}
|
|
132
|
+
export interface RefundResult {
|
|
133
|
+
Success: boolean;
|
|
134
|
+
Reason?: string;
|
|
135
|
+
Amount?: number;
|
|
136
|
+
ProviderRefundID?: string;
|
|
137
|
+
}
|
|
138
|
+
/** A gateway event, reduced to the facts this application acts on. */
|
|
139
|
+
export interface WebhookEvent {
|
|
140
|
+
/** The gateway's own event id. Our idempotency key — `PaymentIntent.ProviderEventID` is UNIQUE. */
|
|
141
|
+
EventID: string;
|
|
142
|
+
/** The gateway's event name, unmapped. Matched against a driver's `HandledEventKinds`. */
|
|
143
|
+
Kind: string;
|
|
144
|
+
ProviderIntentID?: string;
|
|
145
|
+
ProviderChargeID?: string;
|
|
146
|
+
/** Major units. */
|
|
147
|
+
Amount?: number;
|
|
148
|
+
FeeAmount?: number;
|
|
149
|
+
CurrencyCode?: string;
|
|
150
|
+
Status?: IntentStatus;
|
|
151
|
+
/** Present on a failure event, in the gateway's words. */
|
|
152
|
+
FailureReason?: string;
|
|
153
|
+
/**
|
|
154
|
+
* When the gateway says the event happened. Stripe `created` (unix seconds).
|
|
155
|
+
* Used to bound checkout-capture webhook 500s; absent means the bound cannot
|
|
156
|
+
* be applied and retries follow Retryable only.
|
|
157
|
+
*/
|
|
158
|
+
OccurredAt?: Date;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* The driver contract.
|
|
162
|
+
*
|
|
163
|
+
* Registered against this base by `PaymentProviderType.Code`:
|
|
164
|
+
*
|
|
165
|
+
* ```ts
|
|
166
|
+
* @RegisterClass(BasePaymentProvider, 'Stripe')
|
|
167
|
+
* export class StripePaymentProvider extends BasePaymentProvider { … }
|
|
168
|
+
* ```
|
|
169
|
+
*
|
|
170
|
+
* Default implementations REFUSE rather than pretend. A gateway that cannot refund should not silently
|
|
171
|
+
* report a successful refund, and a driver author who forgets to override should find out from a clear
|
|
172
|
+
* message rather than from a reconciliation weeks later.
|
|
173
|
+
*
|
|
174
|
+
* NOT DECORATED ITSELF, matching `BasePriceResolver`. MJ's ClassFactory instantiates the base when no
|
|
175
|
+
* key matches, so a self-registration would make "nobody registered a driver" indistinguishable from
|
|
176
|
+
* "the driver declined" — `PaymentProviderResolver` checks for exactly that and refuses.
|
|
177
|
+
*/
|
|
178
|
+
export declare class BasePaymentProvider {
|
|
179
|
+
/**
|
|
180
|
+
* Set by the resolver immediately after construction — the ClassFactory constructs with no
|
|
181
|
+
* arguments, so configuration cannot arrive through a constructor.
|
|
182
|
+
*/
|
|
183
|
+
Config: PaymentProviderConfig;
|
|
184
|
+
Credentials: PaymentCredentials;
|
|
185
|
+
/** For drivers that need to read or write our own tables (the internal ones do). */
|
|
186
|
+
Provider?: IMetadataProvider;
|
|
187
|
+
User?: UserInfo;
|
|
188
|
+
/** Gateway event names this driver acts on. Everything else is ignored rather than rejected. */
|
|
189
|
+
get HandledEventKinds(): readonly string[];
|
|
190
|
+
/**
|
|
191
|
+
* Whether money moves on a DELAY this driver cannot observe synchronously.
|
|
192
|
+
*
|
|
193
|
+
* FALSE for a card: `Capture` returns and the money has moved, so the caller books cash in the
|
|
194
|
+
* same breath and a later event only confirms what we already recorded. TRUE for a bank debit:
|
|
195
|
+
* `Capture` returns "submitted", the bank answers days later, and the only honest thing to record
|
|
196
|
+
* in the meantime is that we are waiting.
|
|
197
|
+
*
|
|
198
|
+
* The flag exists because it changes WHO BOOKS THE CASH. When false, `PaymentHeaderEntityServer`
|
|
199
|
+
* books at the moment the caller asks — the existing path, untouched. When true, the caller leaves
|
|
200
|
+
* the payment `Pending` and the WEBHOOK promotes it, which means `PaymentWebhookHandler` has to do
|
|
201
|
+
* something it deliberately never did before (see its `applyEvent` note). Gating that on a driver's
|
|
202
|
+
* own declaration is what keeps the card path exactly as it was: a driver that does not opt in
|
|
203
|
+
* cannot have its payments promoted behind its back.
|
|
204
|
+
*
|
|
205
|
+
* It is a capability of the DRIVER rather than a column on `PaymentProviderType` because it is not
|
|
206
|
+
* configuration — an operator cannot make ACH settle instantly by editing a row, and offering the
|
|
207
|
+
* switch would invite exactly that.
|
|
208
|
+
*/
|
|
209
|
+
get SettlesAsynchronously(): boolean;
|
|
210
|
+
CreateIntent(_request: CreateIntentRequest): Promise<CreateIntentResult>;
|
|
211
|
+
Capture(_request: CaptureRequest): Promise<CaptureResult>;
|
|
212
|
+
/**
|
|
213
|
+
* Ask the gateway what it currently believes about an intent we already opened.
|
|
214
|
+
*
|
|
215
|
+
* Used by checkout completion when the browser has confirmed the card (Stripe.js)
|
|
216
|
+
* but the signature-verified webhook has not yet landed — localhost never receives
|
|
217
|
+
* Stripe's POST. This is a SERVER retrieve with our key, not a client claim.
|
|
218
|
+
*/
|
|
219
|
+
RetrieveIntent(_request: RetrieveIntentRequest): Promise<RetrieveIntentResult>;
|
|
220
|
+
Refund(_request: RefundRequest): Promise<RefundResult>;
|
|
221
|
+
/**
|
|
222
|
+
* Verify that a webhook really came from the gateway.
|
|
223
|
+
*
|
|
224
|
+
* DEFAULTS TO FALSE, and that default is load-bearing. The route is unauthenticated (D19), so a
|
|
225
|
+
* driver that inherits this and forgets to override gets a closed door rather than an open one.
|
|
226
|
+
* A provider genuinely without webhooks never reaches here — `SupportsWebhooks` is false and the
|
|
227
|
+
* route refuses earlier.
|
|
228
|
+
*/
|
|
229
|
+
VerifyWebhook(_rawBody: string, _headers: Record<string, string | undefined>): Promise<{
|
|
230
|
+
Valid: boolean;
|
|
231
|
+
Reason?: string;
|
|
232
|
+
}>;
|
|
233
|
+
/** Reduce a verified payload to the facts we act on. Null when it is not an event we can read. */
|
|
234
|
+
ParseWebhookEvent(_rawBody: string): WebhookEvent | null;
|
|
235
|
+
protected notImplemented(what: string): string;
|
|
236
|
+
}
|
|
237
|
+
/** Tree-shaking anchor — call from the server bootstrap so @RegisterClass is retained. */
|
|
238
|
+
export declare function LoadBasePaymentProvider(): void;
|
|
239
|
+
//# sourceMappingURL=BasePaymentProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BasePaymentProvider.d.ts","sourceRoot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,GAAG,OAAO,CAAC,aAAa,CAAC;IAItE;;;;;;OAMG;IACU,cAAc,CAAC,QAAQ,EAAE,qBAAqB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAI9E,MAAM,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;IAInE;;;;;;;OAOG;IACU,aAAa,CACtB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAC7C,OAAO,CAAC;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAI/C,kGAAkG;IAC3F,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI;IAI/D,SAAS,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAQjD;AAED,0FAA0F;AAC1F,wBAAgB,uBAAuB,IAAI,IAAI,CAE9C"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The driver contract.
|
|
3
|
+
*
|
|
4
|
+
* Registered against this base by `PaymentProviderType.Code`:
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* @RegisterClass(BasePaymentProvider, 'Stripe')
|
|
8
|
+
* export class StripePaymentProvider extends BasePaymentProvider { … }
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* Default implementations REFUSE rather than pretend. A gateway that cannot refund should not silently
|
|
12
|
+
* report a successful refund, and a driver author who forgets to override should find out from a clear
|
|
13
|
+
* message rather than from a reconciliation weeks later.
|
|
14
|
+
*
|
|
15
|
+
* NOT DECORATED ITSELF, matching `BasePriceResolver`. MJ's ClassFactory instantiates the base when no
|
|
16
|
+
* key matches, so a self-registration would make "nobody registered a driver" indistinguishable from
|
|
17
|
+
* "the driver declined" — `PaymentProviderResolver` checks for exactly that and refuses.
|
|
18
|
+
*/
|
|
19
|
+
export class BasePaymentProvider {
|
|
20
|
+
/** Gateway event names this driver acts on. Everything else is ignored rather than rejected. */
|
|
21
|
+
get HandledEventKinds() {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Whether money moves on a DELAY this driver cannot observe synchronously.
|
|
26
|
+
*
|
|
27
|
+
* FALSE for a card: `Capture` returns and the money has moved, so the caller books cash in the
|
|
28
|
+
* same breath and a later event only confirms what we already recorded. TRUE for a bank debit:
|
|
29
|
+
* `Capture` returns "submitted", the bank answers days later, and the only honest thing to record
|
|
30
|
+
* in the meantime is that we are waiting.
|
|
31
|
+
*
|
|
32
|
+
* The flag exists because it changes WHO BOOKS THE CASH. When false, `PaymentHeaderEntityServer`
|
|
33
|
+
* books at the moment the caller asks — the existing path, untouched. When true, the caller leaves
|
|
34
|
+
* the payment `Pending` and the WEBHOOK promotes it, which means `PaymentWebhookHandler` has to do
|
|
35
|
+
* something it deliberately never did before (see its `applyEvent` note). Gating that on a driver's
|
|
36
|
+
* own declaration is what keeps the card path exactly as it was: a driver that does not opt in
|
|
37
|
+
* cannot have its payments promoted behind its back.
|
|
38
|
+
*
|
|
39
|
+
* It is a capability of the DRIVER rather than a column on `PaymentProviderType` because it is not
|
|
40
|
+
* configuration — an operator cannot make ACH settle instantly by editing a row, and offering the
|
|
41
|
+
* switch would invite exactly that.
|
|
42
|
+
*/
|
|
43
|
+
get SettlesAsynchronously() {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
async CreateIntent(_request) {
|
|
47
|
+
return { Success: false, Reason: this.notImplemented('creating a payment intent') };
|
|
48
|
+
}
|
|
49
|
+
async Capture(_request) {
|
|
50
|
+
return { Success: false, Reason: this.notImplemented('capturing a payment') };
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Ask the gateway what it currently believes about an intent we already opened.
|
|
54
|
+
*
|
|
55
|
+
* Used by checkout completion when the browser has confirmed the card (Stripe.js)
|
|
56
|
+
* but the signature-verified webhook has not yet landed — localhost never receives
|
|
57
|
+
* Stripe's POST. This is a SERVER retrieve with our key, not a client claim.
|
|
58
|
+
*/
|
|
59
|
+
async RetrieveIntent(_request) {
|
|
60
|
+
return { Success: false, Reason: this.notImplemented('retrieving a payment intent') };
|
|
61
|
+
}
|
|
62
|
+
async Refund(_request) {
|
|
63
|
+
return { Success: false, Reason: this.notImplemented('refunding a payment') };
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Verify that a webhook really came from the gateway.
|
|
67
|
+
*
|
|
68
|
+
* DEFAULTS TO FALSE, and that default is load-bearing. The route is unauthenticated (D19), so a
|
|
69
|
+
* driver that inherits this and forgets to override gets a closed door rather than an open one.
|
|
70
|
+
* A provider genuinely without webhooks never reaches here — `SupportsWebhooks` is false and the
|
|
71
|
+
* route refuses earlier.
|
|
72
|
+
*/
|
|
73
|
+
async VerifyWebhook(_rawBody, _headers) {
|
|
74
|
+
return { Valid: false, Reason: `${this.Config?.TypeCode ?? 'this provider'} does not verify webhooks` };
|
|
75
|
+
}
|
|
76
|
+
/** Reduce a verified payload to the facts we act on. Null when it is not an event we can read. */
|
|
77
|
+
ParseWebhookEvent(_rawBody) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
notImplemented(what) {
|
|
81
|
+
const code = this.Config?.TypeCode ?? 'unknown';
|
|
82
|
+
return (`The '${code}' payment provider does not support ${what}. This is a driver that has not ` +
|
|
83
|
+
`implemented the operation, not a gateway that declined it — check ` +
|
|
84
|
+
`PaymentProviderType.Code against the registered driver classes.`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/** Tree-shaking anchor — call from the server bootstrap so @RegisterClass is retained. */
|
|
88
|
+
export function LoadBasePaymentProvider() {
|
|
89
|
+
// intentionally empty
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=BasePaymentProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BasePaymentProvider.js","sourceRoot":"","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,MAAM,EAAE,QAAQ,IAAI,SAAS,CAAC;QAChD,OAAO,CACH,QAAQ,IAAI,uCAAuC,IAAI,kCAAkC;YACzF,oEAAoE;YACpE,iEAAiE,CACpE,CAAC;IACN,CAAC;CACJ;AAED,0FAA0F;AAC1F,MAAM,UAAU,uBAAuB;IACnC,sBAAsB;AAC1B,CAAC"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bundle expansion arithmetic, with no database in sight.
|
|
3
|
+
*
|
|
4
|
+
* WHY EXPAND AT ALL. A bundle sold as one line forces ONE of everything: one tax treatment, one
|
|
5
|
+
* revenue schedule, one GL account, one entitlement, one returnable unit. A bundle of a publication
|
|
6
|
+
* (often exempt) and a conference registration (not) taxed at the header is simply wrong, and a
|
|
7
|
+
* bundle spanning a subscription and an event cannot be scheduled from a single line at all. So the
|
|
8
|
+
* components become real order lines and everything downstream keeps working per line.
|
|
9
|
+
*
|
|
10
|
+
* WHAT THE PARENT IS FOR. The customer bought "the Gold Package", not four things, and reporting
|
|
11
|
+
* needs to know a component came from a bundle — and from WHICH bundle line, since two Gold Packages
|
|
12
|
+
* on one order produce two indistinguishable sets otherwise. So the parent line survives as the
|
|
13
|
+
* customer-facing row, carrying `IsRollupParent`, and contributes ZERO to every total. The children
|
|
14
|
+
* carry the money.
|
|
15
|
+
*
|
|
16
|
+
* THE ARITHMETIC THAT BITES. Allocating one bundle price across components by relative standalone
|
|
17
|
+
* selling price does not divide evenly. Allocate $100 across three equal components and naive
|
|
18
|
+
* rounding gives 33.33 × 3 = 99.99 — a penny that vanishes, on an order that still balances because
|
|
19
|
+
* every line agrees with itself. `AllocateBundlePrice` uses largest-remainder so the parts sum to
|
|
20
|
+
* the whole EXACTLY, and its tests assert that on deliberately awkward numbers.
|
|
21
|
+
*
|
|
22
|
+
* CONNECTS TO:
|
|
23
|
+
* CODE: BundleEngine (the rows) · OrderEntityServer (the lifecycle point)
|
|
24
|
+
* DOC: plans/archive/bizapps-orders-master.md D32/D41 (bundles), D45 (ParentOrderLineID)
|
|
25
|
+
*/
|
|
26
|
+
/** How a bundle prices its components. */
|
|
27
|
+
export type BundlePricingMode = 'Bundled' | 'SumOfParts';
|
|
28
|
+
/** One component of a bundle, as the catalog defines it. */
|
|
29
|
+
export interface BundleComponent {
|
|
30
|
+
ComponentProductID: string;
|
|
31
|
+
/** Units of this component per ONE bundle. */
|
|
32
|
+
Quantity: number;
|
|
33
|
+
PricingMode: BundlePricingMode;
|
|
34
|
+
SortOrder: number;
|
|
35
|
+
/**
|
|
36
|
+
* The component's own list price — its standalone selling price. Null when the catalog has no
|
|
37
|
+
* price rule for it, which is survivable: see `AllocateBundlePrice`.
|
|
38
|
+
*/
|
|
39
|
+
StandaloneSellingPrice: number | null;
|
|
40
|
+
}
|
|
41
|
+
/** One child line to be created. */
|
|
42
|
+
export interface PlannedBundleChild {
|
|
43
|
+
ComponentProductID: string;
|
|
44
|
+
/** parent quantity × component quantity. */
|
|
45
|
+
Quantity: number;
|
|
46
|
+
/** The child's share of the bundle price, per unit. */
|
|
47
|
+
UnitPrice: number;
|
|
48
|
+
SortOrder: number;
|
|
49
|
+
}
|
|
50
|
+
export type BundleRefusal = 'NotABundle' | 'ReversalLine' | 'NonPositiveQuantity' | 'NestedBundle' | 'NoComponents';
|
|
51
|
+
export interface BundlePlan {
|
|
52
|
+
Children: PlannedBundleChild[];
|
|
53
|
+
Refusal: BundleRefusal | null;
|
|
54
|
+
/** True when allocation fell back to splitting evenly because no component had a price. */
|
|
55
|
+
AllocatedEvenly: boolean;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Split `total` across `weights` so the parts sum to `total` EXACTLY.
|
|
59
|
+
*
|
|
60
|
+
* Largest-remainder: floor every share to cents, then hand the leftover pennies one at a time to
|
|
61
|
+
* whichever shares were cut by the most. The naive alternative — round each share independently —
|
|
62
|
+
* loses or invents money on most inputs, and does it invisibly: each line is individually plausible
|
|
63
|
+
* and the order still balances against itself.
|
|
64
|
+
*
|
|
65
|
+
* Ties break toward the earlier index, so the result is deterministic for a given input rather than
|
|
66
|
+
* dependent on sort stability.
|
|
67
|
+
*/
|
|
68
|
+
export declare function SplitExactly(total: number, weights: number[]): number[];
|
|
69
|
+
/**
|
|
70
|
+
* Allocate a bundle's price across its components by relative standalone selling price.
|
|
71
|
+
*
|
|
72
|
+
* `Bundled` components share the bundle price. `SumOfParts` components are priced on their own and
|
|
73
|
+
* take no share of it — a bundle may mix the two, which is how "everything in the package plus a
|
|
74
|
+
* discounted add-on priced separately" is expressed.
|
|
75
|
+
*
|
|
76
|
+
* WHEN NO COMPONENT HAS A PRICE the weights are all zero and there is nothing to allocate BY. Rather
|
|
77
|
+
* than refuse the sale or silently dump the whole amount on the first component, it splits evenly
|
|
78
|
+
* and says so through `AllocatedEvenly`, so a caller can record that the allocation was arbitrary.
|
|
79
|
+
* An even split is defensible; a silent lopsided one is not.
|
|
80
|
+
*/
|
|
81
|
+
export declare function AllocateBundlePrice(bundleTotal: number, components: BundleComponent[]): {
|
|
82
|
+
PerComponent: number[];
|
|
83
|
+
AllocatedEvenly: boolean;
|
|
84
|
+
};
|
|
85
|
+
/** What a bundle line needs to say for itself. */
|
|
86
|
+
export interface BundleLineFacts {
|
|
87
|
+
ID: string;
|
|
88
|
+
ProductID: string;
|
|
89
|
+
Quantity: number;
|
|
90
|
+
/** The price of ONE bundle. Multiplied by quantity to get what is allocated. */
|
|
91
|
+
UnitPrice: number;
|
|
92
|
+
ReversesOrderLineID: string | null;
|
|
93
|
+
/** True when this line is ITSELF a component of another bundle — one level only (D45). */
|
|
94
|
+
HasParent: boolean;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Plan the child lines a bundle line expands into.
|
|
98
|
+
*
|
|
99
|
+
* ONE LEVEL ONLY. A component that is itself a bundle is refused rather than expanded recursively:
|
|
100
|
+
* the quantity ripple and the allocation both get considerably harder, and nothing in the catalog
|
|
101
|
+
* needs it yet. Easy to relax; very hard to un-ship once orders exist that depend on it.
|
|
102
|
+
*/
|
|
103
|
+
export declare function PlanBundleExpansion(line: BundleLineFacts, components: BundleComponent[]): BundlePlan;
|
|
104
|
+
/** A child's quantity: how many bundles times how many of the component each contains. */
|
|
105
|
+
export declare function ChildQuantity(parentQuantity: number, componentQuantity: number): number;
|
|
106
|
+
/** One child's current state, for deciding whether the ripple may touch it. */
|
|
107
|
+
export interface RippleChild {
|
|
108
|
+
ID: string;
|
|
109
|
+
ComponentQuantity: number;
|
|
110
|
+
IsQuantityOverridden: boolean;
|
|
111
|
+
CurrentQuantity: number;
|
|
112
|
+
}
|
|
113
|
+
export interface RippleChange {
|
|
114
|
+
OrderLineID: string;
|
|
115
|
+
FromQuantity: number;
|
|
116
|
+
ToQuantity: number;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* What a change to the parent's quantity should do to its children.
|
|
120
|
+
*
|
|
121
|
+
* A child whose quantity was hand-edited DETACHES from the ripple. Without that, bumping the bundle
|
|
122
|
+
* quantity silently overwrites a deliberate correction — data loss that looks exactly like
|
|
123
|
+
* arithmetic, because the number it lands on is the number the formula says it should be.
|
|
124
|
+
*
|
|
125
|
+
* Returns only the children that actually change, so a no-op ripple writes nothing.
|
|
126
|
+
*/
|
|
127
|
+
export declare function PlanQuantityRipple(parentQuantity: number, children: RippleChild[]): RippleChange[];
|
|
128
|
+
/**
|
|
129
|
+
* Does this set of lines total correctly once parents are excluded?
|
|
130
|
+
*
|
|
131
|
+
* The invariant every rollup depends on: a rollup parent contributes nothing, so the sum over
|
|
132
|
+
* non-parent lines is the order's real value. Exported because it is worth asserting from the
|
|
133
|
+
* outside rather than trusting each rollup to remember.
|
|
134
|
+
*/
|
|
135
|
+
export declare function RollupTotal(lines: Array<{
|
|
136
|
+
IsRollupParent: boolean;
|
|
137
|
+
Amount: number;
|
|
138
|
+
}>): number;
|
|
139
|
+
//# sourceMappingURL=BundleBehavior.d.ts.map
|