@mj-biz-apps/orders-core-entities-server 5.24.0 → 5.26.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/dist/AccountingBridge.d.ts +17 -0
- package/dist/AccountingBridge.d.ts.map +1 -1
- package/dist/AccountingBridge.js +28 -9
- package/dist/AccountingBridge.js.map +1 -1
- package/dist/BaseInvoiceRail.d.ts +13 -0
- package/dist/BaseInvoiceRail.d.ts.map +1 -1
- package/dist/BaseInvoiceRail.js +16 -0
- package/dist/BaseInvoiceRail.js.map +1 -1
- package/dist/BillComInvoiceRail.d.ts +4 -0
- package/dist/BillComInvoiceRail.d.ts.map +1 -1
- package/dist/BillComInvoiceRail.js +10 -0
- package/dist/BillComInvoiceRail.js.map +1 -1
- package/dist/CancelSubscriptionOperation.d.ts +31 -8
- package/dist/CancelSubscriptionOperation.d.ts.map +1 -1
- package/dist/CancelSubscriptionOperation.js +125 -58
- package/dist/CancelSubscriptionOperation.js.map +1 -1
- package/dist/CheckEntitlementOperation.d.ts +2 -2
- package/dist/CheckEntitlementOperation.js +2 -2
- package/dist/CheckoutPrePurchaseCheck.d.ts +74 -0
- package/dist/CheckoutPrePurchaseCheck.d.ts.map +1 -0
- package/dist/CheckoutPrePurchaseCheck.js +125 -0
- package/dist/CheckoutPrePurchaseCheck.js.map +1 -0
- package/dist/CheckoutSessionService.d.ts +7 -0
- package/dist/CheckoutSessionService.d.ts.map +1 -1
- package/dist/CheckoutSessionService.js +44 -8
- package/dist/CheckoutSessionService.js.map +1 -1
- package/dist/DimensionDefaultResolver.d.ts +2 -1
- package/dist/DimensionDefaultResolver.d.ts.map +1 -1
- package/dist/DimensionDefaultResolver.js +2 -1
- package/dist/DimensionDefaultResolver.js.map +1 -1
- package/dist/EntitlementRead.d.ts.map +1 -1
- package/dist/EntitlementRead.js +12 -13
- package/dist/EntitlementRead.js.map +1 -1
- package/dist/GLAccountResolver.d.ts +74 -5
- package/dist/GLAccountResolver.d.ts.map +1 -1
- package/dist/GLAccountResolver.js +80 -0
- package/dist/GLAccountResolver.js.map +1 -1
- package/dist/InstalmentInvoiceEntry.d.ts.map +1 -1
- package/dist/InstalmentInvoiceEntry.js +10 -3
- package/dist/InstalmentInvoiceEntry.js.map +1 -1
- package/dist/IssueExternalInvoiceOperation.d.ts.map +1 -1
- package/dist/IssueExternalInvoiceOperation.js +15 -2
- package/dist/IssueExternalInvoiceOperation.js.map +1 -1
- package/dist/OrderEntityServer.d.ts +13 -1
- package/dist/OrderEntityServer.d.ts.map +1 -1
- package/dist/OrderEntityServer.js +51 -5
- package/dist/OrderEntityServer.js.map +1 -1
- package/dist/OrderJournalEntryFactory.d.ts.map +1 -1
- package/dist/OrderJournalEntryFactory.js +9 -2
- package/dist/OrderJournalEntryFactory.js.map +1 -1
- package/dist/PersonByEmail.d.ts +45 -0
- package/dist/PersonByEmail.d.ts.map +1 -0
- package/dist/PersonByEmail.js +78 -0
- package/dist/PersonByEmail.js.map +1 -0
- package/dist/ProgressSupersede.d.ts +15 -6
- package/dist/ProgressSupersede.d.ts.map +1 -1
- package/dist/ProgressSupersede.js +35 -9
- package/dist/ProgressSupersede.js.map +1 -1
- package/dist/RailCustomerNameLimit.d.ts +49 -0
- package/dist/RailCustomerNameLimit.d.ts.map +1 -0
- package/dist/RailCustomerNameLimit.js +86 -0
- package/dist/RailCustomerNameLimit.js.map +1 -0
- package/dist/RecordProgressOperation.d.ts +16 -32
- package/dist/RecordProgressOperation.d.ts.map +1 -1
- package/dist/RecordProgressOperation.js +25 -57
- package/dist/RecordProgressOperation.js.map +1 -1
- package/dist/SpawnRenewalsOperation.d.ts +13 -3
- package/dist/SpawnRenewalsOperation.d.ts.map +1 -1
- package/dist/SpawnRenewalsOperation.js +21 -25
- package/dist/SpawnRenewalsOperation.js.map +1 -1
- package/dist/SubscriptionBehavior.d.ts +26 -0
- package/dist/SubscriptionBehavior.d.ts.map +1 -1
- package/dist/SubscriptionBehavior.js +39 -2
- package/dist/SubscriptionBehavior.js.map +1 -1
- package/dist/displaced-start-event.d.ts +18 -0
- package/dist/displaced-start-event.d.ts.map +1 -0
- package/dist/displaced-start-event.js +20 -0
- package/dist/displaced-start-event.js.map +1 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -17,11 +17,14 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
17
17
|
* So the caller supplies a subscription, a date and a reason. `SubscriptionBehavior` decides what
|
|
18
18
|
* the rules permit; this operation performs it in ONE transaction:
|
|
19
19
|
*
|
|
20
|
-
* 1. resolve the affected term (the one whose window covers the request, else the
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
20
|
+
* 1. resolve the affected term (the one whose window covers the request, else the next to
|
|
21
|
+
* start, else the latest), and the LATER terms — open terms that start after its coverage ends
|
|
22
|
+
* 2. ask the behaviour what the rules say — effective date, refund, reversal fraction — for the
|
|
23
|
+
* affected term, and for each later term (never delivered, so reversed in full, #406)
|
|
24
|
+
* 3. when there is something to reverse, emit ONE reversal ORDER with a line per reversed term,
|
|
25
|
+
* each carrying the negative quantity and pointing at its original line, and confirm it —
|
|
26
|
+
* booking mirrors the JEs
|
|
27
|
+
* 4. stamp every term (Canceled/Completed, CanceledAt, CancellationEffectiveDate)
|
|
25
28
|
* 5. stamp the subscription (Canceled, EndDate = access-through, so grace is visible)
|
|
26
29
|
* 6. revoke standing grants when access-through has already passed; leave them when
|
|
27
30
|
* grace remains — the read evaluator honours `subscription.EndDate` either way
|
|
@@ -99,42 +102,65 @@ let CancelSubscriptionOperation = class CancelSubscriptionOperation extends Base
|
|
|
99
102
|
Message: `Subscription type '${subscription.SubscriptionTypeID}' was not found.`,
|
|
100
103
|
};
|
|
101
104
|
}
|
|
102
|
-
const
|
|
105
|
+
const openTerms = await this.loadOpenTerms(provider, user, subscription.ID);
|
|
106
|
+
const term = this.resolveTerm(openTerms, requestDate);
|
|
103
107
|
if (!term) {
|
|
104
108
|
return {
|
|
105
109
|
Success: false,
|
|
106
110
|
Message: `Subscription has no term to cancel — nothing was ever booked against it.`,
|
|
107
111
|
};
|
|
108
112
|
}
|
|
109
|
-
const
|
|
113
|
+
const behavior = this.behaviorFor(rules);
|
|
114
|
+
const decision = behavior.DecideCancellation({
|
|
110
115
|
Rules: rules,
|
|
111
116
|
RequestDate: requestDate,
|
|
112
|
-
Term:
|
|
113
|
-
StartDate: new Date(term.StartDate),
|
|
114
|
-
EndDate: new Date(term.EndDate),
|
|
115
|
-
Amount: Number(term.Amount),
|
|
116
|
-
TermNumber: term.TermNumber,
|
|
117
|
-
},
|
|
117
|
+
Term: this.cancellableTerm(term),
|
|
118
118
|
});
|
|
119
|
+
// A later term would otherwise stay booked and billed after the subscription it belongs to
|
|
120
|
+
// has ended (#406). One that starts on or before the effective date overlaps the cancelled
|
|
121
|
+
// term's coverage and is not decided here.
|
|
122
|
+
const later = openTerms
|
|
123
|
+
.filter((t) => t.ID !== term.ID && new Date(t.StartDate).getTime() > decision.EffectiveDate.getTime())
|
|
124
|
+
.sort((a, b) => a.TermNumber - b.TermNumber)
|
|
125
|
+
.map((t) => ({
|
|
126
|
+
Term: t,
|
|
127
|
+
Decision: behavior.DecideLaterTermCancellation({
|
|
128
|
+
Rules: rules,
|
|
129
|
+
Term: this.cancellableTerm(t),
|
|
130
|
+
CoverageEndsDate: decision.EffectiveDate,
|
|
131
|
+
}),
|
|
132
|
+
}));
|
|
133
|
+
const laterTerms = later.map((l) => ({
|
|
134
|
+
SubscriptionTermID: l.Term.ID,
|
|
135
|
+
TermNumber: l.Term.TermNumber,
|
|
136
|
+
Decision: l.Decision,
|
|
137
|
+
}));
|
|
138
|
+
const totalRefund = Math.round((decision.RefundAmount + later.reduce((sum, l) => sum + l.Decision.RefundAmount, 0)) * 100) / 100;
|
|
139
|
+
const message = [decision.Explanation, ...later.map((l) => l.Decision.Explanation)].join(' ');
|
|
140
|
+
const summary = { SubscriptionTermID: term.ID, LaterTerms: laterTerms, TotalRefundAmount: totalRefund };
|
|
119
141
|
if (input.Preview) {
|
|
120
|
-
return { Success: true, Decision: decision,
|
|
142
|
+
return { Success: true, Decision: decision, ...summary, Message: message };
|
|
121
143
|
}
|
|
144
|
+
const all = [{ Term: term, Decision: decision }, ...later];
|
|
122
145
|
const dbProvider = provider;
|
|
123
146
|
await dbProvider.BeginTransaction();
|
|
124
147
|
try {
|
|
125
|
-
const
|
|
126
|
-
|
|
148
|
+
const toReverse = all.filter((c) => c.Decision.ReversalFraction > 0);
|
|
149
|
+
const reversal = toReverse.length > 0
|
|
150
|
+
? await this.emitReversalOrder(provider, user, subscription, toReverse, decision.EffectiveDate, input.Reason)
|
|
127
151
|
: undefined;
|
|
128
|
-
|
|
152
|
+
for (const c of all) {
|
|
153
|
+
await this.stampTerm(provider, user, c.Term.ID, c.Decision);
|
|
154
|
+
}
|
|
129
155
|
await this.stampSubscription(provider, user, subscription.ID, decision);
|
|
130
156
|
await this.syncGrantsOnCancel(provider, user, subscription.ID, decision, input.Reason);
|
|
131
|
-
await this.logEvent(provider, user, subscription.ID, decision, input.Reason, reversal?.ID);
|
|
157
|
+
await this.logEvent(provider, user, subscription.ID, decision, later, totalRefund, input.Reason, reversal?.ID);
|
|
132
158
|
await dbProvider.CommitTransaction();
|
|
133
159
|
return {
|
|
134
160
|
Success: true,
|
|
135
|
-
Message:
|
|
161
|
+
Message: message,
|
|
136
162
|
Decision: decision,
|
|
137
|
-
|
|
163
|
+
...summary,
|
|
138
164
|
ReversalOrderID: reversal?.ID,
|
|
139
165
|
ReversalOrderNumber: reversal?.Number,
|
|
140
166
|
};
|
|
@@ -182,12 +208,8 @@ let CancelSubscriptionOperation = class CancelSubscriptionOperation extends Base
|
|
|
182
208
|
const result = await rv.RunView({ EntityName: SUBSCRIPTION_TYPE_ENTITY, ExtraFilter: `ID='${typeID}'`, ResultType: 'simple' }, user);
|
|
183
209
|
return result?.Results?.[0] ?? null;
|
|
184
210
|
}
|
|
185
|
-
/**
|
|
186
|
-
|
|
187
|
-
* cancellation of a future term, or a late one after everything lapsed) — the latest term.
|
|
188
|
-
* Cancelling always has to act on SOMETHING for the reversal to point at.
|
|
189
|
-
*/
|
|
190
|
-
async resolveTerm(provider, user, subscriptionID, requestDate) {
|
|
211
|
+
/** The subscription's terms that are still open — Scheduled or Active — latest first. */
|
|
212
|
+
async loadOpenTerms(provider, user, subscriptionID) {
|
|
191
213
|
const rv = new RunView(provider);
|
|
192
214
|
const result = await rv.RunView({
|
|
193
215
|
EntityName: SUBSCRIPTION_TERM_ENTITY,
|
|
@@ -196,59 +218,104 @@ let CancelSubscriptionOperation = class CancelSubscriptionOperation extends Base
|
|
|
196
218
|
ResultType: 'simple',
|
|
197
219
|
BypassCache: true,
|
|
198
220
|
}, user);
|
|
199
|
-
|
|
221
|
+
return result?.Results ?? [];
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* The term the request lands in. When the request falls outside every window: an early
|
|
225
|
+
* cancellation acts on the next term to start, so every term after it is a later term and
|
|
226
|
+
* none is left booked (#406); a late one, after everything lapsed, acts on the latest term.
|
|
227
|
+
* Cancelling always has to act on SOMETHING for the reversal to point at.
|
|
228
|
+
*/
|
|
229
|
+
resolveTerm(terms, requestDate) {
|
|
200
230
|
if (terms.length === 0)
|
|
201
231
|
return null;
|
|
202
232
|
const at = requestDate.getTime();
|
|
203
233
|
const covering = terms.find((t) => new Date(t.StartDate).getTime() <= at && new Date(t.EndDate).getTime() >= at);
|
|
204
|
-
|
|
234
|
+
if (covering)
|
|
235
|
+
return covering;
|
|
236
|
+
const upcoming = terms
|
|
237
|
+
.filter((t) => new Date(t.StartDate).getTime() > at)
|
|
238
|
+
.sort((a, b) => new Date(a.StartDate).getTime() - new Date(b.StartDate).getTime());
|
|
239
|
+
return upcoming[0] ?? terms[0];
|
|
240
|
+
}
|
|
241
|
+
cancellableTerm(term) {
|
|
242
|
+
return {
|
|
243
|
+
StartDate: new Date(term.StartDate),
|
|
244
|
+
EndDate: new Date(term.EndDate),
|
|
245
|
+
Amount: Number(term.Amount),
|
|
246
|
+
TermNumber: term.TermNumber,
|
|
247
|
+
};
|
|
205
248
|
}
|
|
206
249
|
// ─── Writes ────────────────────────────────────────────────────────────────
|
|
207
250
|
/**
|
|
208
|
-
* A reversal order carrying
|
|
251
|
+
* A reversal order carrying one line per reversed term: the negative slice of each original
|
|
252
|
+
* purchase. One order, not one per term, so the lifecycle event links to a single document.
|
|
209
253
|
*
|
|
210
254
|
* It goes through the ordinary confirm path rather than writing journal entries directly, so the
|
|
211
255
|
* mirrored ledger, the GL account resolution and the all-or-none guarantee are the SAME code
|
|
212
256
|
* that booked the original. `ReversesOrderLineID` is what makes a negative quantity legal
|
|
213
257
|
* (OrderLineEntityServer validates exactly that).
|
|
214
258
|
*/
|
|
215
|
-
async emitReversalOrder(provider, user, subscription,
|
|
259
|
+
async emitReversalOrder(provider, user, subscription, slices, orderDate, reason) {
|
|
260
|
+
const order = await provider.GetEntityObject(ORDER_HEADER_ENTITY, user);
|
|
261
|
+
order.NewRecord();
|
|
262
|
+
// 'Cancellation' — one of the CK_OrderHeader_OrderType values. There is no 'Reversal'
|
|
263
|
+
// order type; reversal is what the negative LINE does, not what the order is called.
|
|
264
|
+
order.OrderType = 'Cancellation';
|
|
265
|
+
order.OrderDate = orderDate;
|
|
266
|
+
order.CompanyID = subscription.CompanyID;
|
|
267
|
+
order.BillToOrganizationID = subscription.HolderOrganizationID;
|
|
268
|
+
order.BillToPersonID = subscription.BeneficiaryPersonID;
|
|
269
|
+
order.Notes = reason ? `Subscription cancellation: ${reason}` : 'Subscription cancellation';
|
|
270
|
+
for (const [index, slice] of slices.entries()) {
|
|
271
|
+
const { Line: line, OriginOrderHeaderID } = await this.reversalLine(provider, user, slice.Term, slice.Decision, index + 1);
|
|
272
|
+
// The order that sold the first reversed term. The booking save takes the reversal's
|
|
273
|
+
// addresses from it. Tax is mirrored per line from each term's own sale, so a reversal
|
|
274
|
+
// spanning two orders still refunds each line's tax where it was collected.
|
|
275
|
+
order.ReversesOrderHeaderID ??= OriginOrderHeaderID;
|
|
276
|
+
// Attached rather than assigned: `Lines` is a RelatedRecordCollection on the generated
|
|
277
|
+
// class, and `Add()` stamps OrderHeaderID and the LineNumber for us.
|
|
278
|
+
order.Lines.Add(line);
|
|
279
|
+
}
|
|
280
|
+
order.Status = 'Confirmed';
|
|
281
|
+
if (!(await order.Save())) {
|
|
282
|
+
throw new Error(`Failed to book the reversal order: ${order.LatestResult?.CompleteMessage ?? 'unknown error'}`);
|
|
283
|
+
}
|
|
284
|
+
return { ID: order.ID, Number: order.OrderNumber };
|
|
285
|
+
}
|
|
286
|
+
/** The negative slice of the line that bought `term`, as decided, and the order that sold it. */
|
|
287
|
+
async reversalLine(provider, user, term, decision, lineNumber) {
|
|
216
288
|
const original = await this.loadOriginalLine(provider, user, term.OrderLineID);
|
|
217
289
|
if (!original) {
|
|
218
290
|
throw new Error(`The order line that bought term ${term.TermNumber} (${term.OrderLineID}) no longer exists, ` +
|
|
219
291
|
`so the cancellation cannot be reversed against it.`);
|
|
220
292
|
}
|
|
221
|
-
//
|
|
222
|
-
// the term, from the effective date, while the credit memo and the releases
|
|
223
|
-
// worked out against the origin's own window. Booked here they would disagree
|
|
224
|
-
// already earned. Refused, so nothing half-right reaches the ledger; reverse the
|
|
225
|
-
// itself, which inherits the origin's window.
|
|
226
|
-
|
|
293
|
+
// A PARTIAL TERM ON AN ORDER BILLED BY INSTALMENT, NOT YET (D92 §6). A partial reversal covers
|
|
294
|
+
// only the rest of the term, from the effective date, while the credit memo and the releases
|
|
295
|
+
// it mirrors are worked out against the origin's own window. Booked here they would disagree
|
|
296
|
+
// by the months already earned. Refused, so nothing half-right reaches the ledger; reverse the
|
|
297
|
+
// order line itself, which inherits the origin's window.
|
|
298
|
+
//
|
|
299
|
+
// A WHOLE TERM IS NOT REFUSED. A term that never started — a renewal booked ahead, which
|
|
300
|
+
// since #305 always carries a one-row schedule — is reversed in full over its own window,
|
|
301
|
+
// which is the origin line's. That is exactly an order-line return: booking credits what
|
|
302
|
+
// was invoiced and, once the whole order is reversed, withdraws the instalments not yet
|
|
303
|
+
// invoiced.
|
|
304
|
+
const wholeTerm = decision.ReversalFraction >= 1 && decision.EffectiveDate.getTime() <= new Date(term.StartDate).getTime();
|
|
305
|
+
const context = wholeTerm ? null : await LoadReversalContext(original.ID, provider, user);
|
|
227
306
|
if (context?.OriginScheduled) {
|
|
228
307
|
throw new Error(`Term ${term.TermNumber} was sold on order ${context.Origin.OrderNumber ?? original.OrderHeaderID}, ` +
|
|
229
308
|
`which is billed by instalment. Cancelling part of a term on an instalment-billed order is ` +
|
|
230
309
|
`not supported yet. Reverse the order line instead: that credits back what was billed and ` +
|
|
231
310
|
`not yet earned, and once the whole order is reversed it withdraws the instalments nobody was invoiced for.`);
|
|
232
311
|
}
|
|
233
|
-
const order = await provider.GetEntityObject(ORDER_HEADER_ENTITY, user);
|
|
234
|
-
order.NewRecord();
|
|
235
|
-
// 'Cancellation' — one of the CK_OrderHeader_OrderType values. There is no 'Reversal'
|
|
236
|
-
// order type; reversal is what the negative LINE does, not what the order is called.
|
|
237
|
-
order.OrderType = 'Cancellation';
|
|
238
|
-
order.OrderDate = decision.EffectiveDate;
|
|
239
|
-
order.CompanyID = subscription.CompanyID;
|
|
240
|
-
// The order that sold the term. The booking save takes the reversal's addresses from it.
|
|
241
|
-
order.ReversesOrderHeaderID = original.OrderHeaderID;
|
|
242
|
-
order.BillToOrganizationID = subscription.HolderOrganizationID;
|
|
243
|
-
order.BillToPersonID = subscription.BeneficiaryPersonID;
|
|
244
|
-
order.Notes = reason ? `Subscription cancellation: ${reason}` : 'Subscription cancellation';
|
|
245
312
|
const line = await provider.GetEntityObject(ORDER_LINE_ENTITY, user);
|
|
246
313
|
// Orders writing its own line. An app that froze this line freezes what a PERSON
|
|
247
314
|
// may change, not Orders closing its own books (#206 item 1).
|
|
248
315
|
MarkAsOrdersOwnWrite(line);
|
|
249
316
|
line.NewRecord();
|
|
250
317
|
line.ProductID = original.ProductID;
|
|
251
|
-
line.LineNumber =
|
|
318
|
+
line.LineNumber = lineNumber;
|
|
252
319
|
// A FRACTION OF THE ORIGINAL LINE, not of one unit. The purchased line may already carry a
|
|
253
320
|
// prorated quantity (a short first period), so reversing `-fraction` flat would unwind more
|
|
254
321
|
// than was ever sold. Rounded to the column's 4dp scale for the same reason the purchase
|
|
@@ -265,14 +332,7 @@ let CancelSubscriptionOperation = class CancelSubscriptionOperation extends Base
|
|
|
265
332
|
line.ReversesOrderLineID = original.ID;
|
|
266
333
|
line.ServicePeriodStart = decision.EffectiveDate;
|
|
267
334
|
line.ServicePeriodEnd = new Date(term.EndDate);
|
|
268
|
-
|
|
269
|
-
// class, and `Add()` stamps OrderHeaderID and the LineNumber for us.
|
|
270
|
-
order.Lines.Add(line);
|
|
271
|
-
order.Status = 'Confirmed';
|
|
272
|
-
if (!(await order.Save())) {
|
|
273
|
-
throw new Error(`Failed to book the reversal order: ${order.LatestResult?.CompleteMessage ?? 'unknown error'}`);
|
|
274
|
-
}
|
|
275
|
-
return { ID: order.ID, Number: order.OrderNumber };
|
|
335
|
+
return { Line: line, OriginOrderHeaderID: original.OrderHeaderID };
|
|
276
336
|
}
|
|
277
337
|
async loadOriginalLine(provider, user, orderLineID) {
|
|
278
338
|
const rv = new RunView(provider);
|
|
@@ -306,7 +366,7 @@ let CancelSubscriptionOperation = class CancelSubscriptionOperation extends Base
|
|
|
306
366
|
throw new Error(`Failed to stamp the subscription: ${sub.LatestResult?.CompleteMessage ?? 'unknown error'}`);
|
|
307
367
|
}
|
|
308
368
|
}
|
|
309
|
-
async logEvent(provider, user, subscriptionID, decision, reason, reversalOrderID) {
|
|
369
|
+
async logEvent(provider, user, subscriptionID, decision, later, totalRefund, reason, reversalOrderID) {
|
|
310
370
|
const event = await provider.GetEntityObject(SUBSCRIPTION_EVENT_ENTITY, user);
|
|
311
371
|
event.NewRecord();
|
|
312
372
|
event.SubscriptionID = subscriptionID;
|
|
@@ -320,6 +380,13 @@ let CancelSubscriptionOperation = class CancelSubscriptionOperation extends Base
|
|
|
320
380
|
ReversalFraction: decision.ReversalFraction,
|
|
321
381
|
TermStatus: decision.TermStatus,
|
|
322
382
|
Explanation: decision.Explanation,
|
|
383
|
+
LaterTerms: later.map((l) => ({
|
|
384
|
+
SubscriptionTermID: l.Term.ID,
|
|
385
|
+
TermNumber: l.Term.TermNumber,
|
|
386
|
+
RefundAmount: l.Decision.RefundAmount,
|
|
387
|
+
ReversalFraction: l.Decision.ReversalFraction,
|
|
388
|
+
})),
|
|
389
|
+
TotalRefundAmount: totalRefund,
|
|
323
390
|
Reason: reason ?? null,
|
|
324
391
|
});
|
|
325
392
|
if (!(await event.Save())) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CancelSubscriptionOperation.js","sourceRoot":"","sources":["../src/CancelSubscriptionOperation.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,OAAO,EAEH,sBAAsB,EACtB,YAAY,EAIZ,QAAQ,EACR,OAAO,GAEV,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAQjE,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,mCAAmC,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EACH,oBAAoB,GAGvB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,MAAM,mBAAmB,GAAG,kCAAkC,CAAC;AAC/D,MAAM,wBAAwB,G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IACK,KAAK,CAAC,kBAAkB,CAC5B,QAA2B,EAC3B,IAAc,EACd,cAAsB,EACtB,QAA8B,EAC9B,MAAe;QAEf,MAAM,mCAAmC,CACrC,cAAc,EACd,QAAQ,CAAC,iBAAiB,EAC1B,MAAM,CAAC,CAAC,CAAC,0BAA0B,MAAM,EAAE,CAAC,CAAC,CAAC,uBAAuB,EACrE,QAAQ,EACR,IAAI,CACP,CAAC;IACN,CAAC;IAED,qFAAqF;IAC7E,WAAW,CAAC,KAA4B;QAC5C,IAAI,CAAC,KAAK,CAAC,WAAW;YAAE,OAAO,IAAI,oBAAoB,EAAE,CAAC;QAC1D,MAAM,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,cAAc,CACxD,oBAAoB,EACpB,KAAK,CAAC,WAAW,CACpB,CAAC;QACF,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CACX,sBAAsB,KAAK,CAAC,IAAI,mBAAmB,KAAK,CAAC,WAAW,6BAA6B,CACpG,CAAC;QACN,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ,CAAA;AAteY,2BAA2B;IADvC,aAAa,CAAC,sBAAsB,EAAE,2BAA2B,CAAC;GACtD,2BAA2B,CAsevC;;AAED,8FAA8F;AAC9F,MAAM,UAAU,+BAA+B;IAC3C,sBAAsB;AAC1B,CAAC"}
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* re-teach every consumer the evaluator, and the two would drift. The LXP asks; this answers.
|
|
7
7
|
*
|
|
8
8
|
* Asked by `ProductEntitlement.Code`, not SKU — a bundle, an upgrade and a grandfathered
|
|
9
|
-
* tier can all confer the same capability. PersonID is authoritative; email is convenience
|
|
10
|
-
*
|
|
9
|
+
* tier can all confer the same capability. PersonID is authoritative; email is convenience,
|
|
10
|
+
* resolved by `ResolvePersonByEmail` when several Persons share it. v1 evaluates person grants only.
|
|
11
11
|
*
|
|
12
12
|
* Fail closed. Unknown person and known-person-without-access share one response shape.
|
|
13
13
|
*
|
|
@@ -12,8 +12,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
12
12
|
* re-teach every consumer the evaluator, and the two would drift. The LXP asks; this answers.
|
|
13
13
|
*
|
|
14
14
|
* Asked by `ProductEntitlement.Code`, not SKU — a bundle, an upgrade and a grandfathered
|
|
15
|
-
* tier can all confer the same capability. PersonID is authoritative; email is convenience
|
|
16
|
-
*
|
|
15
|
+
* tier can all confer the same capability. PersonID is authoritative; email is convenience,
|
|
16
|
+
* resolved by `ResolvePersonByEmail` when several Persons share it. v1 evaluates person grants only.
|
|
17
17
|
*
|
|
18
18
|
* Fail closed. Unknown person and known-person-without-access share one response shape.
|
|
19
19
|
*
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The checks a self-serve checkout runs before it will price a purchase (#323).
|
|
3
|
+
*
|
|
4
|
+
* Two layers, run in order:
|
|
5
|
+
* 1. BUILT IN — the resolved Person already holds an Active or Trialing subscription to a product
|
|
6
|
+
* on the draft. Buying it again would charge them for coverage they have.
|
|
7
|
+
* 2. HOST — a `CheckoutPrePurchaseCheck` subclass registered through the ClassFactory. A host that
|
|
8
|
+
* also sells through another system is the only party that can see, for example, a
|
|
9
|
+
* subscription held there. The base class allows everything, so with nothing registered only
|
|
10
|
+
* the built-in rule applies.
|
|
11
|
+
*
|
|
12
|
+
* The draft is the gate: a refused draft persists nothing, so no payment intent can be opened for
|
|
13
|
+
* it. The payment-intent step runs the same checks again, because the host's own state can change
|
|
14
|
+
* between the two calls.
|
|
15
|
+
*/
|
|
16
|
+
import { UserInfo } from '@memberjunction/core';
|
|
17
|
+
/** The reason a host returns when its refusal means "this buyer already has it". */
|
|
18
|
+
export declare const ALREADY_SUBSCRIBED_REASON = "already-subscribed";
|
|
19
|
+
/** One line of the purchase being checked. */
|
|
20
|
+
export interface PrePurchaseLine {
|
|
21
|
+
ProductID: string;
|
|
22
|
+
Quantity: number;
|
|
23
|
+
}
|
|
24
|
+
/** Everything a check is told about the purchase. */
|
|
25
|
+
export interface PrePurchaseContext {
|
|
26
|
+
/** The buyer's e-mail as entered, normalized to lower case. May be empty. */
|
|
27
|
+
Email: string;
|
|
28
|
+
/** The Person the e-mail resolved to, or null for a buyer the system does not know yet. */
|
|
29
|
+
PersonID: string | null;
|
|
30
|
+
/** The selling company of the checkout widget. */
|
|
31
|
+
CompanyID: string;
|
|
32
|
+
Lines: PrePurchaseLine[];
|
|
33
|
+
ContextUser?: UserInfo;
|
|
34
|
+
}
|
|
35
|
+
/** A check's answer. */
|
|
36
|
+
export interface PrePurchaseVerdict {
|
|
37
|
+
Allowed: boolean;
|
|
38
|
+
/** Shown to the buyer when the purchase is refused. */
|
|
39
|
+
Message?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Why it was refused. Return {@link ALREADY_SUBSCRIBED_REASON} to have the widget emit its
|
|
42
|
+
* `checkout-already-subscribed` event; any other value only shows the message.
|
|
43
|
+
*/
|
|
44
|
+
Reason?: string;
|
|
45
|
+
/** The products the refusal is about, when it is about particular ones. */
|
|
46
|
+
ProductIDs?: string[];
|
|
47
|
+
}
|
|
48
|
+
/** Why a checkout step was refused, as the widget receives it. */
|
|
49
|
+
export interface CheckoutRefusal {
|
|
50
|
+
/** `Unverified` means a check could not answer, and the purchase was refused because of it. */
|
|
51
|
+
Code: 'AlreadySubscribed' | 'HostRefused' | 'Unverified';
|
|
52
|
+
Source: 'built-in' | 'host';
|
|
53
|
+
ProductIDs: string[];
|
|
54
|
+
}
|
|
55
|
+
/** A refusal plus the message the buyer sees. */
|
|
56
|
+
export interface PrePurchaseRefusal {
|
|
57
|
+
Message: string;
|
|
58
|
+
Refusal: CheckoutRefusal;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The host seam. Register a subclass with `@RegisterClass(CheckoutPrePurchaseCheck)` and reference
|
|
62
|
+
* its class from the server bootstrap so the decorator is not tree-shaken away. The highest-priority
|
|
63
|
+
* registration wins; a host with several rules chains them inside its one subclass.
|
|
64
|
+
*/
|
|
65
|
+
export declare class CheckoutPrePurchaseCheck {
|
|
66
|
+
Check(_context: PrePurchaseContext): Promise<PrePurchaseVerdict>;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Runs the built-in rule, then the registered host check.
|
|
70
|
+
*
|
|
71
|
+
* @returns null when the purchase may proceed, otherwise the refusal to report.
|
|
72
|
+
*/
|
|
73
|
+
export declare function RunPrePurchaseChecks(context: PrePurchaseContext): Promise<PrePurchaseRefusal | null>;
|
|
74
|
+
//# sourceMappingURL=CheckoutPrePurchaseCheck.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CheckoutPrePurchaseCheck.d.ts","sourceRoot":"","sources":["../src/CheckoutPrePurchaseCheck.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAqB,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AASnE,oFAAoF;AACpF,eAAO,MAAM,yBAAyB,uBAAuB,CAAC;AAE9D,8CAA8C;AAC9C,MAAM,WAAW,eAAe;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,qDAAqD;AACrD,MAAM,WAAW,kBAAkB;IAC/B,6EAA6E;IAC7E,KAAK,EAAE,MAAM,CAAC;IACd,2FAA2F;IAC3F,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,kDAAkD;IAClD,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,eAAe,EAAE,CAAC;IACzB,WAAW,CAAC,EAAE,QAAQ,CAAC;CAC1B;AAED,wBAAwB;AACxB,MAAM,WAAW,kBAAkB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2EAA2E;IAC3E,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,kEAAkE;AAClE,MAAM,WAAW,eAAe;IAC5B,+FAA+F;IAC/F,IAAI,EAAE,mBAAmB,GAAG,aAAa,GAAG,YAAY,CAAC;IACzD,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC;IAC5B,UAAU,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,iDAAiD;AACjD,MAAM,WAAW,kBAAkB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,eAAe,CAAC;CAC5B;AAED;;;;GAIG;AACH,qBAAa,wBAAwB;IACpB,KAAK,CAAC,QAAQ,EAAE,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAGhF;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAS1G"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The checks a self-serve checkout runs before it will price a purchase (#323).
|
|
3
|
+
*
|
|
4
|
+
* Two layers, run in order:
|
|
5
|
+
* 1. BUILT IN — the resolved Person already holds an Active or Trialing subscription to a product
|
|
6
|
+
* on the draft. Buying it again would charge them for coverage they have.
|
|
7
|
+
* 2. HOST — a `CheckoutPrePurchaseCheck` subclass registered through the ClassFactory. A host that
|
|
8
|
+
* also sells through another system is the only party that can see, for example, a
|
|
9
|
+
* subscription held there. The base class allows everything, so with nothing registered only
|
|
10
|
+
* the built-in rule applies.
|
|
11
|
+
*
|
|
12
|
+
* The draft is the gate: a refused draft persists nothing, so no payment intent can be opened for
|
|
13
|
+
* it. The payment-intent step runs the same checks again, because the host's own state can change
|
|
14
|
+
* between the two calls.
|
|
15
|
+
*/
|
|
16
|
+
import { LogError, RunView } from '@memberjunction/core';
|
|
17
|
+
import { MJGlobal } from '@memberjunction/global';
|
|
18
|
+
import { EscapeSQLString } from './sql-guards.js';
|
|
19
|
+
const SUBSCRIPTION_ENTITY = 'MJ_BizApps_Orders: Subscriptions';
|
|
20
|
+
/** Subscription statuses that mean the Person already has the coverage a purchase would sell. */
|
|
21
|
+
const HELD_SUBSCRIPTION_STATUSES = ['Active', 'Trialing'];
|
|
22
|
+
/** The reason a host returns when its refusal means "this buyer already has it". */
|
|
23
|
+
export const ALREADY_SUBSCRIBED_REASON = 'already-subscribed';
|
|
24
|
+
/**
|
|
25
|
+
* The host seam. Register a subclass with `@RegisterClass(CheckoutPrePurchaseCheck)` and reference
|
|
26
|
+
* its class from the server bootstrap so the decorator is not tree-shaken away. The highest-priority
|
|
27
|
+
* registration wins; a host with several rules chains them inside its one subclass.
|
|
28
|
+
*/
|
|
29
|
+
export class CheckoutPrePurchaseCheck {
|
|
30
|
+
async Check(_context) {
|
|
31
|
+
return { Allowed: true };
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Runs the built-in rule, then the registered host check.
|
|
36
|
+
*
|
|
37
|
+
* @returns null when the purchase may proceed, otherwise the refusal to report.
|
|
38
|
+
*/
|
|
39
|
+
export async function RunPrePurchaseChecks(context) {
|
|
40
|
+
let builtIn;
|
|
41
|
+
try {
|
|
42
|
+
builtIn = await checkHeldSubscriptions(context);
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
LogError(`[CheckoutPrePurchaseCheck] subscription check failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
46
|
+
return unverified('built-in');
|
|
47
|
+
}
|
|
48
|
+
return builtIn ?? (await runHostCheck(context));
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Fail closed: the checks exist to stop a charge the buyer should not incur, and a check that
|
|
52
|
+
* cannot answer has not said the charge is safe.
|
|
53
|
+
*/
|
|
54
|
+
function unverified(source) {
|
|
55
|
+
return {
|
|
56
|
+
Message: 'This purchase could not be verified right now. Please try again later.',
|
|
57
|
+
Refusal: { Code: 'Unverified', Source: source, ProductIDs: [] },
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
async function checkHeldSubscriptions(context) {
|
|
61
|
+
const productIDs = [...new Set(context.Lines.map((l) => l.ProductID).filter(Boolean))];
|
|
62
|
+
if (!context.PersonID || productIDs.length === 0) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
const held = await findHeldSubscriptions(context.PersonID, productIDs, context.ContextUser);
|
|
66
|
+
if (held.length === 0) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
const names = [...new Set(held.map((h) => h.Product).filter(Boolean))];
|
|
70
|
+
const what = names.length > 0 ? names.join(', ') : 'this product';
|
|
71
|
+
return {
|
|
72
|
+
Message: `You already have an active subscription to ${what}, so it cannot be bought again.`,
|
|
73
|
+
Refusal: {
|
|
74
|
+
Code: 'AlreadySubscribed',
|
|
75
|
+
Source: 'built-in',
|
|
76
|
+
ProductIDs: [...new Set(held.map((h) => h.ProductID))],
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The Person's held subscriptions to any of these products. Matches on the beneficiary, which a
|
|
82
|
+
* checkout order fills from its ship-to Person — the buyer.
|
|
83
|
+
*/
|
|
84
|
+
async function findHeldSubscriptions(personID, productIDs, contextUser) {
|
|
85
|
+
const productList = productIDs.map((id) => `'${EscapeSQLString(id)}'`).join(', ');
|
|
86
|
+
const statusList = HELD_SUBSCRIPTION_STATUSES.map((s) => `'${s}'`).join(', ');
|
|
87
|
+
const result = await new RunView().RunView({
|
|
88
|
+
EntityName: SUBSCRIPTION_ENTITY,
|
|
89
|
+
ExtraFilter: `BeneficiaryPersonID = '${EscapeSQLString(personID)}' ` +
|
|
90
|
+
`AND ProductID IN (${productList}) AND Status IN (${statusList})`,
|
|
91
|
+
Fields: ['ProductID', 'Product'],
|
|
92
|
+
ResultType: 'simple',
|
|
93
|
+
BypassCache: true,
|
|
94
|
+
}, contextUser);
|
|
95
|
+
if (!result.Success) {
|
|
96
|
+
throw new Error(`Could not read existing subscriptions: ${result.ErrorMessage ?? 'unknown error'}`);
|
|
97
|
+
}
|
|
98
|
+
return result.Results ?? [];
|
|
99
|
+
}
|
|
100
|
+
async function runHostCheck(context) {
|
|
101
|
+
const check = MJGlobal.Instance.ClassFactory.CreateInstance(CheckoutPrePurchaseCheck);
|
|
102
|
+
if (!check) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
let verdict;
|
|
106
|
+
try {
|
|
107
|
+
verdict = await check.Check(context);
|
|
108
|
+
}
|
|
109
|
+
catch (err) {
|
|
110
|
+
LogError(`[CheckoutPrePurchaseCheck] ${check.constructor.name} threw: ${err instanceof Error ? err.message : String(err)}`);
|
|
111
|
+
return unverified('host');
|
|
112
|
+
}
|
|
113
|
+
if (verdict.Allowed) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
Message: verdict.Message?.trim() || 'This purchase cannot be completed.',
|
|
118
|
+
Refusal: {
|
|
119
|
+
Code: verdict.Reason === ALREADY_SUBSCRIBED_REASON ? 'AlreadySubscribed' : 'HostRefused',
|
|
120
|
+
Source: 'host',
|
|
121
|
+
ProductIDs: verdict.ProductIDs ?? [],
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=CheckoutPrePurchaseCheck.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CheckoutPrePurchaseCheck.js","sourceRoot":"","sources":["../src/CheckoutPrePurchaseCheck.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAY,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,mBAAmB,GAAG,kCAAkC,CAAC;AAE/D,iGAAiG;AACjG,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ACH,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,oCAAoC;QACxE,OAAO,EAAE;YACL,IAAI,EAAE,OAAO,CAAC,MAAM,KAAK,yBAAyB,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,aAAa;YACxF,MAAM,EAAE,MAAM;YACd,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,EAAE;SACvC;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { UserInfo } from '@memberjunction/core';
|
|
11
11
|
import { type CheckoutWidgetConfiguration, type CheckoutAnswersInput, type CheckoutChoicesInput } from '@mj-biz-apps/orders-entities';
|
|
12
|
+
import { type CheckoutRefusal } from './CheckoutPrePurchaseCheck.js';
|
|
12
13
|
export interface InitSessionResult {
|
|
13
14
|
Success: boolean;
|
|
14
15
|
ErrorMessage?: string;
|
|
@@ -82,6 +83,8 @@ export interface UpdateDraftResult {
|
|
|
82
83
|
TotalGross: number;
|
|
83
84
|
RequiresPayment: boolean;
|
|
84
85
|
Lines: CheckoutLineSummary[];
|
|
86
|
+
/** Set when a pre-purchase check refused the draft; `ErrorMessage` carries the buyer's message. */
|
|
87
|
+
Refusal?: CheckoutRefusal;
|
|
85
88
|
/** The promotion code the draft was priced with, when it was usable. */
|
|
86
89
|
AppliedPromotionCodes?: string[];
|
|
87
90
|
/** Codes the buyer entered that did nothing, and why — shown to the buyer, never silently dropped. */
|
|
@@ -152,6 +155,8 @@ export interface OpenSessionPaymentIntentResult {
|
|
|
152
155
|
ClientSecret?: string;
|
|
153
156
|
Status?: string;
|
|
154
157
|
Amount?: number;
|
|
158
|
+
/** Set when a pre-purchase check refused the purchase; `ErrorMessage` carries the buyer's message. */
|
|
159
|
+
Refusal?: CheckoutRefusal;
|
|
155
160
|
}
|
|
156
161
|
export declare class CheckoutSessionService {
|
|
157
162
|
/**
|
|
@@ -279,6 +284,8 @@ export declare class CheckoutSessionService {
|
|
|
279
284
|
static OpenPaymentIntentForSession(sessionID: string, clientSessionKey: string, contextUser?: UserInfo, options?: {
|
|
280
285
|
AutoRenewConsent?: boolean;
|
|
281
286
|
}): Promise<OpenSessionPaymentIntentResult>;
|
|
287
|
+
/** Re-runs the pre-purchase checks against the lines the session's draft stored. */
|
|
288
|
+
private static recheckDraftedPurchase;
|
|
282
289
|
/**
|
|
283
290
|
* The gateway customer a renewal card will belong to, when this checkout sells a subscription:
|
|
284
291
|
* the one the buyer already has with this provider, or a new one. A buyer with no person record
|