@mj-biz-apps/orders-core-entities-server 5.23.0 → 5.24.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 (84) hide show
  1. package/dist/BasePaymentProvider.d.ts +61 -0
  2. package/dist/BasePaymentProvider.d.ts.map +1 -1
  3. package/dist/BasePaymentProvider.js +9 -0
  4. package/dist/BasePaymentProvider.js.map +1 -1
  5. package/dist/CancelSubscriptionOperation.d.ts.map +1 -1
  6. package/dist/CancelSubscriptionOperation.js +2 -0
  7. package/dist/CancelSubscriptionOperation.js.map +1 -1
  8. package/dist/CheckoutAccessStatus.d.ts +27 -0
  9. package/dist/CheckoutAccessStatus.d.ts.map +1 -0
  10. package/dist/CheckoutAccessStatus.js +75 -0
  11. package/dist/CheckoutAccessStatus.js.map +1 -0
  12. package/dist/CheckoutAccountStep.d.ts +3 -3
  13. package/dist/CheckoutAccountStep.d.ts.map +1 -1
  14. package/dist/CheckoutAccountStep.js +2 -2
  15. package/dist/CheckoutAccountStep.js.map +1 -1
  16. package/dist/CheckoutMemberDiscountResolver.d.ts +85 -0
  17. package/dist/CheckoutMemberDiscountResolver.d.ts.map +1 -0
  18. package/dist/CheckoutMemberDiscountResolver.js +62 -0
  19. package/dist/CheckoutMemberDiscountResolver.js.map +1 -0
  20. package/dist/CheckoutSavedInstrument.d.ts +71 -0
  21. package/dist/CheckoutSavedInstrument.d.ts.map +1 -0
  22. package/dist/CheckoutSavedInstrument.js +238 -0
  23. package/dist/CheckoutSavedInstrument.js.map +1 -0
  24. package/dist/CheckoutSessionService.d.ts +100 -4
  25. package/dist/CheckoutSessionService.d.ts.map +1 -1
  26. package/dist/CheckoutSessionService.js +477 -52
  27. package/dist/CheckoutSessionService.js.map +1 -1
  28. package/dist/EntitlementBehavior.d.ts +24 -1
  29. package/dist/EntitlementBehavior.d.ts.map +1 -1
  30. package/dist/EntitlementBehavior.js +29 -0
  31. package/dist/EntitlementBehavior.js.map +1 -1
  32. package/dist/EntitlementRead.d.ts +1 -1
  33. package/dist/EntitlementRead.js +13 -13
  34. package/dist/EntitlementRead.js.map +1 -1
  35. package/dist/GetProgressWorklistOperation.d.ts.map +1 -1
  36. package/dist/GetProgressWorklistOperation.js +24 -8
  37. package/dist/GetProgressWorklistOperation.js.map +1 -1
  38. package/dist/OrderEntityServer.d.ts +15 -0
  39. package/dist/OrderEntityServer.d.ts.map +1 -1
  40. package/dist/OrderEntityServer.js +91 -5
  41. package/dist/OrderEntityServer.js.map +1 -1
  42. package/dist/OrderLineProgressMeasurementEntityServer.d.ts.map +1 -1
  43. package/dist/OrderLineProgressMeasurementEntityServer.js +3 -2
  44. package/dist/OrderLineProgressMeasurementEntityServer.js.map +1 -1
  45. package/dist/PaymentGatedAccess.d.ts +13 -7
  46. package/dist/PaymentGatedAccess.d.ts.map +1 -1
  47. package/dist/PaymentGatedAccess.js +34 -21
  48. package/dist/PaymentGatedAccess.js.map +1 -1
  49. package/dist/PaymentIntentService.d.ts +13 -0
  50. package/dist/PaymentIntentService.d.ts.map +1 -1
  51. package/dist/PaymentIntentService.js +14 -0
  52. package/dist/PaymentIntentService.js.map +1 -1
  53. package/dist/PriceOrderOperation.d.ts.map +1 -1
  54. package/dist/PriceOrderOperation.js +16 -31
  55. package/dist/PriceOrderOperation.js.map +1 -1
  56. package/dist/ProgressSupersede.d.ts +107 -0
  57. package/dist/ProgressSupersede.d.ts.map +1 -0
  58. package/dist/ProgressSupersede.js +117 -0
  59. package/dist/ProgressSupersede.js.map +1 -0
  60. package/dist/RecordProgressOperation.d.ts +63 -2
  61. package/dist/RecordProgressOperation.d.ts.map +1 -1
  62. package/dist/RecordProgressOperation.js +215 -41
  63. package/dist/RecordProgressOperation.js.map +1 -1
  64. package/dist/ReversalBehavior.d.ts +45 -0
  65. package/dist/ReversalBehavior.d.ts.map +1 -1
  66. package/dist/ReversalBehavior.js +47 -0
  67. package/dist/ReversalBehavior.js.map +1 -1
  68. package/dist/ReversalResolver.d.ts +8 -1
  69. package/dist/ReversalResolver.d.ts.map +1 -1
  70. package/dist/ReversalResolver.js +49 -1
  71. package/dist/ReversalResolver.js.map +1 -1
  72. package/dist/StripePaymentProvider.d.ts +8 -1
  73. package/dist/StripePaymentProvider.d.ts.map +1 -1
  74. package/dist/StripePaymentProvider.js +73 -1
  75. package/dist/StripePaymentProvider.js.map +1 -1
  76. package/dist/checkoutCaptureAlert.d.ts +6 -0
  77. package/dist/checkoutCaptureAlert.d.ts.map +1 -1
  78. package/dist/checkoutCaptureAlert.js +15 -3
  79. package/dist/checkoutCaptureAlert.js.map +1 -1
  80. package/dist/index.d.ts +8 -4
  81. package/dist/index.d.ts.map +1 -1
  82. package/dist/index.js +6 -3
  83. package/dist/index.js.map +1 -1
  84. package/package.json +3 -3
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Keeping a checkout's card so an auto-renewing subscription can be charged at renewal.
3
+ *
4
+ * A subscription sold through the anonymous checkout renews through `Orders.SpawnRenewals`, which can
5
+ * only charge a card the gateway kept. The gateway keeps one only if it was ASKED to at the first
6
+ * payment — asking later is impossible, because the buyer and their card entry are gone. So this runs
7
+ * in two places, and both are about the first purchase:
8
+ *
9
+ * BEFORE PAYMENT `SnapshotSellsSubscription` decides whether to ask at all, from the products in
10
+ * the session's priced draft: the order is created only after payment, so there is
11
+ * no order to read yet. `FindReusableProviderCustomerRef` finds the gateway
12
+ * customer the card will belong to. One customer per person per provider: a
13
+ * person's second subscription reuses the customer their first created, found
14
+ * through their own wallet — never by searching the gateway by e-mail, which would
15
+ * attach to records this application did not create. A first-time buyer has no
16
+ * person yet (completion creates it), so their customer is opened for the checkout
17
+ * session instead, and becomes that person's once the card is filed.
18
+ * AFTER PAYMENT `SaveCheckoutInstrumentForRenewals` reads back the card the buyer paid with, puts
19
+ * it in their wallet (`CustomerPaymentMethod` over its own `PaymentDetail`, D38/D39)
20
+ * and makes it each new subscription's renewal card.
21
+ *
22
+ * FAIL-SOFT AFTER PAYMENT. By the time the card is saved the money has moved and the order is
23
+ * confirmed. A failure here must not undo either; it leaves the subscription without a renewal card,
24
+ * which is logged and visible (`DefaultCustomerPaymentMethodID` is null) and is fixed by the buyer
25
+ * adding a card, not by refusing a sale that succeeded.
26
+ *
27
+ * IDEMPOTENT. Checkout completion is replayed (client retry, the settled-payment webhook), so a second
28
+ * call finds the wallet entry the first one wrote — matched on the gateway's instrument id — and only
29
+ * fills subscriptions that still have no renewal card.
30
+ *
31
+ * CONNECTS TO:
32
+ * CALLER: ./CheckoutSessionService.ts (OpenPaymentIntentForSession, applySettledPaymentToOrder)
33
+ * DRIVER: ./BasePaymentProvider.ts (EnsureCustomer, RetrieveIntent.Instrument)
34
+ * TABLES: __mj_BizAppsOrders.{CustomerPaymentMethod,PaymentDetail,PaymentType,Subscription,OrderLine,Product}
35
+ */
36
+ import { IMetadataProvider, UserInfo } from '@memberjunction/core';
37
+ /**
38
+ * True when the session's priced draft sells a product that renews as a subscription. Read from the
39
+ * snapshot because the order does not exist until payment has settled.
40
+ */
41
+ export declare function SnapshotSellsSubscription(metadataJSON: string | null | undefined, user: UserInfo): Promise<boolean>;
42
+ /**
43
+ * The gateway customer this person already has with this provider — the one their first saved card
44
+ * belongs to — or null when they have none yet.
45
+ */
46
+ export declare function FindReusableProviderCustomerRef(personID: string, paymentProviderID: string, user: UserInfo): Promise<string | null>;
47
+ export interface SaveCheckoutInstrumentInput {
48
+ OrderHeaderID: string;
49
+ CompanyID: string;
50
+ OwnerPersonID: string | null;
51
+ PaymentProviderID: string;
52
+ /** The gateway's intent id, read back to learn which card paid. */
53
+ ProviderIntentID: string;
54
+ /** `PaymentType.Code` of the tender the card is filed under. */
55
+ TenderCode: string;
56
+ }
57
+ export interface SaveCheckoutInstrumentResult {
58
+ Saved: boolean;
59
+ /** The wallet entry, when one was written or found. */
60
+ CustomerPaymentMethodID?: string;
61
+ /** Subscriptions that were given this card as their renewal card by this call. */
62
+ SubscriptionIDs?: string[];
63
+ /** Why nothing was saved. Not an error: most checkouts sell nothing that renews. */
64
+ Reason?: string;
65
+ }
66
+ /**
67
+ * Put the card that paid for this order in the buyer's wallet, and make it the renewal card of every
68
+ * subscription the order created that has none. Fail-soft — see the header.
69
+ */
70
+ export declare function SaveCheckoutInstrumentForRenewals(input: SaveCheckoutInstrumentInput, provider: IMetadataProvider, user: UserInfo): Promise<SaveCheckoutInstrumentResult>;
71
+ //# sourceMappingURL=CheckoutSavedInstrument.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CheckoutSavedInstrument.d.ts","sourceRoot":"","sources":["../src/CheckoutSavedInstrument.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,OAAO,EAAE,iBAAiB,EAAgC,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAiBjG;;;GAGG;AACH,wBAAsB,yBAAyB,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CAwBzH;AAED;;;GAGG;AACH,wBAAsB,+BAA+B,CACjD,QAAQ,EAAE,MAAM,EAChB,iBAAiB,EAAE,MAAM,EACzB,IAAI,EAAE,QAAQ,GACf,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA4BxB;AAED,MAAM,WAAW,2BAA2B;IACxC,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,mEAAmE;IACnE,gBAAgB,EAAE,MAAM,CAAC;IACzB,gEAAgE;IAChE,UAAU,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,4BAA4B;IACzC,KAAK,EAAE,OAAO,CAAC;IACf,uDAAuD;IACvD,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,kFAAkF;IAClF,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,oFAAoF;IACpF,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAsB,iCAAiC,CACnD,KAAK,EAAE,2BAA2B,EAClC,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,EAAE,QAAQ,GACf,OAAO,CAAC,4BAA4B,CAAC,CAgDvC"}
@@ -0,0 +1,238 @@
1
+ /**
2
+ * Keeping a checkout's card so an auto-renewing subscription can be charged at renewal.
3
+ *
4
+ * A subscription sold through the anonymous checkout renews through `Orders.SpawnRenewals`, which can
5
+ * only charge a card the gateway kept. The gateway keeps one only if it was ASKED to at the first
6
+ * payment — asking later is impossible, because the buyer and their card entry are gone. So this runs
7
+ * in two places, and both are about the first purchase:
8
+ *
9
+ * BEFORE PAYMENT `SnapshotSellsSubscription` decides whether to ask at all, from the products in
10
+ * the session's priced draft: the order is created only after payment, so there is
11
+ * no order to read yet. `FindReusableProviderCustomerRef` finds the gateway
12
+ * customer the card will belong to. One customer per person per provider: a
13
+ * person's second subscription reuses the customer their first created, found
14
+ * through their own wallet — never by searching the gateway by e-mail, which would
15
+ * attach to records this application did not create. A first-time buyer has no
16
+ * person yet (completion creates it), so their customer is opened for the checkout
17
+ * session instead, and becomes that person's once the card is filed.
18
+ * AFTER PAYMENT `SaveCheckoutInstrumentForRenewals` reads back the card the buyer paid with, puts
19
+ * it in their wallet (`CustomerPaymentMethod` over its own `PaymentDetail`, D38/D39)
20
+ * and makes it each new subscription's renewal card.
21
+ *
22
+ * FAIL-SOFT AFTER PAYMENT. By the time the card is saved the money has moved and the order is
23
+ * confirmed. A failure here must not undo either; it leaves the subscription without a renewal card,
24
+ * which is logged and visible (`DefaultCustomerPaymentMethodID` is null) and is fixed by the buyer
25
+ * adding a card, not by refusing a sale that succeeded.
26
+ *
27
+ * IDEMPOTENT. Checkout completion is replayed (client retry, the settled-payment webhook), so a second
28
+ * call finds the wallet entry the first one wrote — matched on the gateway's instrument id — and only
29
+ * fills subscriptions that still have no renewal card.
30
+ *
31
+ * CONNECTS TO:
32
+ * CALLER: ./CheckoutSessionService.ts (OpenPaymentIntentForSession, applySettledPaymentToOrder)
33
+ * DRIVER: ./BasePaymentProvider.ts (EnsureCustomer, RetrieveIntent.Instrument)
34
+ * TABLES: __mj_BizAppsOrders.{CustomerPaymentMethod,PaymentDetail,PaymentType,Subscription,OrderLine,Product}
35
+ */
36
+ import { LogError, LogStatus, RunView } from '@memberjunction/core';
37
+ import { ResolvePaymentProvider } from './PaymentProviderResolver.js';
38
+ import { EscapeText, RequireUUID, RequireUUIDs } from './sql-guards.js';
39
+ const ORDER_LINE_ENTITY = 'MJ_BizApps_Orders: Order Lines';
40
+ const PRODUCT_ENTITY = 'MJ_BizApps_Orders: Products';
41
+ const SUBSCRIPTION_ENTITY = 'MJ_BizApps_Orders: Subscriptions';
42
+ const CUSTOMER_PAYMENT_METHOD_ENTITY = 'MJ_BizApps_Orders: Customer Payment Methods';
43
+ const PAYMENT_DETAIL_ENTITY = 'MJ_BizApps_Orders: Payment Details';
44
+ const PAYMENT_TYPE_ENTITY = 'MJ_BizApps_Orders: Payment Types';
45
+ /**
46
+ * True when the session's priced draft sells a product that renews as a subscription. Read from the
47
+ * snapshot because the order does not exist until payment has settled.
48
+ */
49
+ export async function SnapshotSellsSubscription(metadataJSON, user) {
50
+ let priced = [];
51
+ if (metadataJSON) {
52
+ try {
53
+ priced = JSON.parse(metadataJSON).PricedLines ?? [];
54
+ }
55
+ catch {
56
+ priced = [];
57
+ }
58
+ }
59
+ const productIDs = [...new Set(priced.map((l) => l.ProductID).filter((id) => !!id))];
60
+ if (productIDs.length === 0)
61
+ return false;
62
+ const rv = new RunView();
63
+ const products = await rv.RunView({
64
+ EntityName: PRODUCT_ENTITY,
65
+ ExtraFilter: `ID IN (${RequireUUIDs(productIDs, 'ProductID').map((id) => `'${id}'`).join(',')}) AND SubscriptionTypeID IS NOT NULL`,
66
+ Fields: ['ID'],
67
+ MaxRows: 1,
68
+ ResultType: 'simple',
69
+ }, user);
70
+ return (products.Results ?? []).length > 0;
71
+ }
72
+ /**
73
+ * The gateway customer this person already has with this provider — the one their first saved card
74
+ * belongs to — or null when they have none yet.
75
+ */
76
+ export async function FindReusableProviderCustomerRef(personID, paymentProviderID, user) {
77
+ const rv = new RunView();
78
+ const wallet = await rv.RunView({
79
+ EntityName: CUSTOMER_PAYMENT_METHOD_ENTITY,
80
+ ExtraFilter: `OwnerPersonID = '${RequireUUID(personID, 'OwnerPersonID')}' AND IsActive = 1`,
81
+ Fields: ['PaymentDetailID'],
82
+ ResultType: 'simple',
83
+ }, user);
84
+ const detailIDs = (wallet.Results ?? []).map((w) => w.PaymentDetailID).filter((id) => !!id);
85
+ if (detailIDs.length === 0)
86
+ return null;
87
+ const details = await rv.RunView({
88
+ EntityName: PAYMENT_DETAIL_ENTITY,
89
+ ExtraFilter: `ID IN (${RequireUUIDs(detailIDs, 'PaymentDetailID').map((id) => `'${id}'`).join(',')}) ` +
90
+ `AND PaymentProviderID = '${RequireUUID(paymentProviderID, 'PaymentProviderID')}' ` +
91
+ `AND ProviderCustomerRef IS NOT NULL`,
92
+ Fields: ['ProviderCustomerRef'],
93
+ MaxRows: 1,
94
+ ResultType: 'simple',
95
+ }, user);
96
+ return details.Results?.[0]?.ProviderCustomerRef ?? null;
97
+ }
98
+ /**
99
+ * Put the card that paid for this order in the buyer's wallet, and make it the renewal card of every
100
+ * subscription the order created that has none. Fail-soft — see the header.
101
+ */
102
+ export async function SaveCheckoutInstrumentForRenewals(input, provider, user) {
103
+ try {
104
+ if (!input.OwnerPersonID) {
105
+ return { Saved: false, Reason: 'the order has no bill-to person to own a saved card' };
106
+ }
107
+ const subscriptions = await subscriptionsNeedingRenewalCard(input.OrderHeaderID, user);
108
+ if (subscriptions.length === 0) {
109
+ return { Saved: false, Reason: 'the order created no subscription that needs a renewal card' };
110
+ }
111
+ const driver = await ResolvePaymentProvider(input.PaymentProviderID, provider, user);
112
+ const retrieved = await driver.RetrieveIntent({ ProviderIntentID: input.ProviderIntentID });
113
+ const instrument = retrieved.Success ? retrieved.Instrument : undefined;
114
+ if (!instrument?.ProviderInstrumentRef || !instrument.ProviderCustomerRef) {
115
+ // The gateway kept no card for this payment — the intent was opened without a customer,
116
+ // or the gateway does not keep instruments. Nothing to file; the subscription will need a
117
+ // card before it renews.
118
+ LogError(`[CheckoutSavedInstrument] Order ${input.OrderHeaderID}: the gateway reported no saved card for intent ` +
119
+ `${input.ProviderIntentID}; ${subscriptions.length} subscription(s) have no renewal card.`);
120
+ return { Saved: false, Reason: 'the gateway kept no card for this payment' };
121
+ }
122
+ const walletID = (await findWalletEntryForInstrument(input.OwnerPersonID, input.PaymentProviderID, instrument.ProviderInstrumentRef, user)) ??
123
+ (await createWalletEntry(input, instrument, provider, user));
124
+ const updated = [];
125
+ for (const subscription of subscriptions) {
126
+ subscription.DefaultCustomerPaymentMethodID = walletID;
127
+ if (await subscription.Save()) {
128
+ updated.push(subscription.ID);
129
+ }
130
+ else {
131
+ LogError(`[CheckoutSavedInstrument] Could not set the renewal card on subscription ${subscription.ID}: ` +
132
+ `${subscription.LatestResult?.CompleteMessage ?? 'unknown error'}`);
133
+ }
134
+ }
135
+ LogStatus(`[CheckoutSavedInstrument] Order ${input.OrderHeaderID}: renewal card ${walletID} set on ${updated.length} subscription(s).`);
136
+ return { Saved: true, CustomerPaymentMethodID: walletID, SubscriptionIDs: updated };
137
+ }
138
+ catch (err) {
139
+ const message = err instanceof Error ? err.message : String(err);
140
+ LogError(`[CheckoutSavedInstrument] Could not save the card for order ${input.OrderHeaderID}: ${message}`);
141
+ return { Saved: false, Reason: message };
142
+ }
143
+ }
144
+ /** The order's auto-renewing subscriptions that do not yet have a renewal card. */
145
+ async function subscriptionsNeedingRenewalCard(orderID, user) {
146
+ const rv = new RunView();
147
+ const lines = await rv.RunView({
148
+ EntityName: ORDER_LINE_ENTITY,
149
+ ExtraFilter: `OrderHeaderID = '${RequireUUID(orderID, 'OrderHeaderID')}'`,
150
+ Fields: ['ID'],
151
+ ResultType: 'simple',
152
+ }, user);
153
+ const lineIDs = (lines.Results ?? []).map((l) => l.ID);
154
+ if (lineIDs.length === 0)
155
+ return [];
156
+ const found = await rv.RunView({
157
+ EntityName: SUBSCRIPTION_ENTITY,
158
+ ExtraFilter: `OrderLineID IN (${RequireUUIDs(lineIDs, 'OrderLineID').map((id) => `'${id}'`).join(',')}) ` +
159
+ `AND AutoRenew = 1 AND DefaultCustomerPaymentMethodID IS NULL`,
160
+ ResultType: 'entity_object',
161
+ }, user);
162
+ return found.Results ?? [];
163
+ }
164
+ /** The wallet entry already holding this gateway instrument for this person, if a prior call wrote it. */
165
+ async function findWalletEntryForInstrument(personID, paymentProviderID, instrumentRef, user) {
166
+ const rv = new RunView();
167
+ const details = await rv.RunView({
168
+ EntityName: PAYMENT_DETAIL_ENTITY,
169
+ ExtraFilter: `PaymentProviderID = '${RequireUUID(paymentProviderID, 'PaymentProviderID')}' ` +
170
+ `AND ProviderInstrumentRef = '${EscapeText(instrumentRef)}'`,
171
+ Fields: ['ID'],
172
+ ResultType: 'simple',
173
+ }, user);
174
+ const detailIDs = (details.Results ?? []).map((d) => d.ID);
175
+ if (detailIDs.length === 0)
176
+ return null;
177
+ const wallet = await rv.RunView({
178
+ EntityName: CUSTOMER_PAYMENT_METHOD_ENTITY,
179
+ ExtraFilter: `OwnerPersonID = '${RequireUUID(personID, 'OwnerPersonID')}' AND IsActive = 1 ` +
180
+ `AND PaymentDetailID IN (${RequireUUIDs(detailIDs, 'PaymentDetailID').map((id) => `'${id}'`).join(',')})`,
181
+ Fields: ['ID'],
182
+ MaxRows: 1,
183
+ ResultType: 'simple',
184
+ }, user);
185
+ return wallet.Results?.[0]?.ID ?? null;
186
+ }
187
+ /** Write the instrument snapshot and the wallet entry over it; the new entry becomes the default. */
188
+ async function createWalletEntry(input, instrument, provider, user) {
189
+ const paymentTypeID = await paymentTypeIDFor(input.TenderCode, user);
190
+ const detail = await provider.GetEntityObject(PAYMENT_DETAIL_ENTITY, user);
191
+ detail.NewRecord();
192
+ detail.CompanyID = input.CompanyID;
193
+ detail.PaymentTypeID = paymentTypeID;
194
+ detail.PaymentProviderID = input.PaymentProviderID;
195
+ detail.ProviderCustomerRef = instrument.ProviderCustomerRef;
196
+ detail.ProviderInstrumentRef = instrument.ProviderInstrumentRef;
197
+ if (instrument.Brand)
198
+ detail.Brand = instrument.Brand;
199
+ if (instrument.Last4)
200
+ detail.Last4 = instrument.Last4;
201
+ if (instrument.ExpiryMonth)
202
+ detail.ExpiryMonth = instrument.ExpiryMonth;
203
+ if (instrument.ExpiryYear)
204
+ detail.ExpiryYear = instrument.ExpiryYear;
205
+ if (instrument.HolderName)
206
+ detail.HolderName = instrument.HolderName;
207
+ if (!(await detail.Save())) {
208
+ throw new Error(`could not record the card: ${detail.LatestResult?.CompleteMessage ?? 'unknown error'}`);
209
+ }
210
+ const wallet = await provider.GetEntityObject(CUSTOMER_PAYMENT_METHOD_ENTITY, user);
211
+ wallet.NewRecord();
212
+ wallet.OwnerPersonID = input.OwnerPersonID;
213
+ wallet.PaymentDetailID = detail.ID;
214
+ wallet.IsDefault = true;
215
+ wallet.IsActive = true;
216
+ const nickname = [instrument.Brand, instrument.Last4 ? `ending ${instrument.Last4}` : null].filter(Boolean).join(' ');
217
+ if (nickname)
218
+ wallet.Nickname = nickname;
219
+ if (!(await wallet.Save())) {
220
+ throw new Error(`could not add the card to the wallet: ${wallet.LatestResult?.CompleteMessage ?? 'unknown error'}`);
221
+ }
222
+ return wallet.ID;
223
+ }
224
+ async function paymentTypeIDFor(tenderCode, user) {
225
+ const rv = new RunView();
226
+ const found = await rv.RunView({
227
+ EntityName: PAYMENT_TYPE_ENTITY,
228
+ ExtraFilter: `Code = '${EscapeText(tenderCode)}'`,
229
+ Fields: ['ID'],
230
+ MaxRows: 1,
231
+ ResultType: 'simple',
232
+ }, user);
233
+ const id = found.Results?.[0]?.ID;
234
+ if (!id)
235
+ throw new Error(`no payment type with code '${tenderCode}'`);
236
+ return id;
237
+ }
238
+ //# sourceMappingURL=CheckoutSavedInstrument.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CheckoutSavedInstrument.js","sourceRoot":"","sources":["../src/CheckoutSavedInstrument.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,OAAO,EAAqB,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAY,MAAM,sBAAsB,CAAC;AAOjG,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAExE,MAAM,iBAAiB,GAAG,gCAAgC,CAAC;AAC3D,MAAM,cAAc,GAAG,6BAA6B,CAAC;AACrD,MAAM,mBAAmB,GAAG,kCAAkC,CAAC;AAC/D,MAAM,8BAA8B,GAAG,6CAA6C,CAAC;AACrF,MAAM,qBAAqB,GAAG,oCAAoC,CAAC;AACnE,MAAM,mBAAmB,GAAG,kCAAkC,CAAC;AAE/D;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,YAAuC,EAAE,IAAc;IACnG,IAAI,MAAM,GAAyC,EAAE,CAAC;IACtD,IAAI,YAAY,EAAE,CAAC;QACf,IAAI,CAAC;YACD,MAAM,GAAI,IAAI,CAAC,KAAK,CAAC,YAAY,CAA4D,CAAC,WAAW,IAAI,EAAE,CAAC;QACpH,CAAC;QAAC,MAAM,CAAC;YACL,MAAM,GAAG,EAAE,CAAC;QAChB,CAAC;IACL,CAAC;IACD,MAAM,UAAU,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,EAAgB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACnG,IAAI,UAAU,CAAC,MAA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C,CAAC,CAAC,EAAE,EAAE,CAAC;IAClC,IAAI,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,8BAA8B,UAAU,GAAG,CAAC,CAAC;IACtE,OAAO,EAAE,CAAC;AACd,CAAC"}
@@ -53,6 +53,15 @@ export interface CheckoutLineInput {
53
53
  /** Legacy attendee input compatibility */
54
54
  Attendees?: CheckoutAttendeeInput[];
55
55
  }
56
+ /**
57
+ * The buyer's billing location as the widget sends it. Codes only: Country is ISO 3166-1 alpha-2
58
+ * and StateProvince an ISO 3166-2 subdivision code — see `CheckBillingLocation`.
59
+ */
60
+ export interface CheckoutBillingAddressInput {
61
+ Country?: string;
62
+ StateProvince?: string;
63
+ PostalCode?: string;
64
+ }
56
65
  export interface CheckoutLineSummary {
57
66
  ID: string;
58
67
  ProductID: string;
@@ -73,7 +82,37 @@ export interface UpdateDraftResult {
73
82
  TotalGross: number;
74
83
  RequiresPayment: boolean;
75
84
  Lines: CheckoutLineSummary[];
85
+ /** The promotion code the draft was priced with, when it was usable. */
86
+ AppliedPromotionCodes?: string[];
87
+ /** Codes the buyer entered that did nothing, and why — shown to the buyer, never silently dropped. */
88
+ UnusablePromotionCodes?: Array<{
89
+ Code: string;
90
+ Reason: string;
91
+ }>;
92
+ /** What the applied promotion took off, in major units (0 when none). */
93
+ Discount?: number;
94
+ /** True when a member token earned a discount that this draft is priced with. */
95
+ MemberDiscountApplied?: boolean;
96
+ /** Why a member token earned no discount, for the buyer. Absent when no token was sent. */
97
+ MemberDiscountMessage?: string;
76
98
  }
99
+ /** Most codes a buyer can present on one checkout. One, as a hosted card checkout allows. */
100
+ export declare const MAX_PROMOTION_CODES_PER_CHECKOUT = 1;
101
+ /**
102
+ * Normalise the codes an anonymous caller sent: strings only, trimmed, empties dropped, de-duplicated
103
+ * case-insensitively. Refuses more than {@link MAX_PROMOTION_CODES_PER_CHECKOUT} or an over-long code
104
+ * rather than truncating — a code that was cut short is a different code.
105
+ */
106
+ export declare function NormalizeCheckoutPromotionCodes(input: unknown): {
107
+ Codes: string[];
108
+ } | {
109
+ Error: string;
110
+ };
111
+ /**
112
+ * The codes a checkout prices with: the buyer's own codes plus the code a verified member token
113
+ * earned, de-duplicated case-insensitively. Whether they stack is the promotion engine's call.
114
+ */
115
+ export declare function CombineCheckoutPromotionCodes(buyerCodes: string[], memberCode: string | null | undefined): string[];
77
116
  /** Outcome of booking CapturePayment after a checkout order is already confirmed. */
78
117
  export interface BookCheckoutPaymentResult {
79
118
  /** True when CapturePayment was invoked (or would have been, but a pre-check failed). */
@@ -190,6 +229,19 @@ export declare class CheckoutSessionService {
190
229
  /**
191
230
  * Creates an order line entity instance attached to the order's Lines collection.
192
231
  */
232
+ /**
233
+ * Turns a draft's member token into the promotion code it earns (#324). No token prices at
234
+ * full rate with no message; a rejected token, or a verifier that throws, prices at full rate
235
+ * with a message. A token sent to a widget that cannot verify one is refused — a host that
236
+ * expects member pricing must not silently charge full price.
237
+ */
238
+ private static resolveMemberDiscount;
239
+ /**
240
+ * Computes each line's totals the way its save would, so a discount the pricing walk wrote to
241
+ * `DiscountAmount` reaches the checkout total. Same hoisted call `OrderEntityServer` makes
242
+ * before companion validation; idempotent.
243
+ */
244
+ private static settleLineTotals;
193
245
  private static createOrderLine;
194
246
  /**
195
247
  * Dynamically populates and coerces extension companion properties from a field map.
@@ -202,11 +254,17 @@ export declare class CheckoutSessionService {
202
254
  /**
203
255
  * Builds and prices draft order lines in memory, persisting the checkout state to the
204
256
  * CheckoutSession without creating premature draft rows in the OrderHeader database table.
257
+ *
258
+ * The billing location is required: tax is priced from it here, and completion records it as
259
+ * the order's address. Nothing is saved for it until completion, so an abandoned draft leaves
260
+ * no Address row behind.
205
261
  */
206
- static UpdateDraft(sessionID: string, clientSessionKey: string, email: string, lines: CheckoutLineInput[], contextUser?: UserInfo, options?: {
262
+ static UpdateDraft(sessionID: string, clientSessionKey: string, email: string, lines: CheckoutLineInput[], billingAddress: CheckoutBillingAddressInput | null | undefined, contextUser?: UserInfo, options?: {
207
263
  Attribution?: unknown;
208
264
  Answers?: CheckoutAnswersInput;
209
265
  Choices?: CheckoutChoicesInput;
266
+ MemberToken?: string;
267
+ PromotionCodes?: unknown;
210
268
  }): Promise<UpdateDraftResult>;
211
269
  /**
212
270
  * Opens (or idempotently re-opens) a payment intent for a session's CURRENT server-priced
@@ -218,17 +276,55 @@ export declare class CheckoutSessionService {
218
276
  * (`paymentProviderId`) — the client supplies only its session id + key. The gateway
219
277
  * client secret is returned for Stripe.js confirmation and never persisted.
220
278
  */
221
- static OpenPaymentIntentForSession(sessionID: string, clientSessionKey: string, contextUser?: UserInfo): Promise<OpenSessionPaymentIntentResult>;
279
+ static OpenPaymentIntentForSession(sessionID: string, clientSessionKey: string, contextUser?: UserInfo, options?: {
280
+ AutoRenewConsent?: boolean;
281
+ }): Promise<OpenSessionPaymentIntentResult>;
282
+ /**
283
+ * The gateway customer a renewal card will belong to, when this checkout sells a subscription:
284
+ * the one the buyer already has with this provider, or a new one. A buyer with no person record
285
+ * yet — completion creates it — gets a customer opened for this checkout, keyed on the session and
286
+ * the e-mail; the card is filed under the person once the order is booked. Null when nothing
287
+ * renews or the customer cannot be had — logged, and the sale goes ahead without keeping the card.
288
+ */
289
+ private static resolveCustomerForRenewal;
290
+ /**
291
+ * Twelve hex characters of a SHA-256, for idempotency keys that must change with a value — an
292
+ * e-mail, a gateway customer — without carrying it.
293
+ */
294
+ private static keyDigest;
222
295
  /**
223
296
  * Completes an existing CheckoutSession, constructing the final Order,
224
297
  * executing lifecycle confirmation (with accounting GL bookings and deferred revenue),
225
298
  * and generating a claim token if unauthenticated.
226
299
  */
227
300
  static CompleteCheckout(sessionID: string, clientSessionKey: string, contextUser?: UserInfo): Promise<CompleteCheckoutResult>;
301
+ /** The session's MetadataJSON, or an empty snapshot when it is absent or unreadable. */
302
+ private static readSnapshot;
303
+ /** The billing location the draft stored, re-checked — null when it is missing or no longer valid. */
304
+ private static snapshotBillingLocation;
305
+ private static toTaxAddress;
306
+ /**
307
+ * What the buyer pays: each line's gross including the tax pricing resolved onto it. A line
308
+ * that has not been saved has no stored `LineTotalGross`, so its tax is added explicitly —
309
+ * otherwise the intent would be opened for less than the confirmed order's total.
310
+ */
311
+ private static sumLineTotals;
312
+ private static sumLineTax;
313
+ /**
314
+ * Records the billing location as a Common Address and links it to the buyer as their
315
+ * Billing address. Street and city are not collected by checkout and stay empty.
316
+ *
317
+ * A failed Address save throws: the order must not confirm without its location. A failed
318
+ * link is logged and tolerated — the order still references the Address; only the buyer's
319
+ * address book misses it.
320
+ */
321
+ private static recordBillingAddress;
322
+ private static linkBillingAddress;
228
323
  /**
229
324
  * Verifies the paid-order gate for a session against a server-computed total. Returns a
230
- * refusal message, or null when payment checks out. The intent must exist, belong to this
231
- * session, be in a settled state, and cover the freshly re-priced total.
325
+ * refusal, or null when payment checks out. The intent must exist, belong to this session,
326
+ * be in a settled state, and cover the freshly re-priced total. `SettledButShort` marks the
327
+ * one refusal where money has already moved.
232
328
  */
233
329
  private static verifySessionPayment;
234
330
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"CheckoutSessionService.d.ts","sourceRoot":"","sources":["../src/CheckoutSessionService.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAA+E,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAM7H,OAAO,EAcH,KAAK,2BAA2B,EAMhC,KAAK,oBAAoB,EAQzB,KAAK,oBAAoB,EAC5B,MAAM,8BAA8B,CAAC;AAkCtC,MAAM,WAAW,iBAAiB;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM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