@owlmeans/server-payment 0.1.18-rc.20 → 0.1.18-rc.21
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/README.md +1 -1
- package/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/server-payment/SKILL.md +402 -260
- package/build/config.d.ts +15 -1
- package/build/config.d.ts.map +1 -1
- package/build/config.js +99 -3
- package/build/config.js.map +1 -1
- package/build/consts.d.ts +27 -0
- package/build/consts.d.ts.map +1 -1
- package/build/consts.js +27 -0
- package/build/consts.js.map +1 -1
- package/build/consumer/capture.d.ts +74 -0
- package/build/consumer/capture.d.ts.map +1 -0
- package/build/consumer/capture.js +291 -0
- package/build/consumer/capture.js.map +1 -0
- package/build/consumer/format.d.ts +27 -0
- package/build/consumer/format.d.ts.map +1 -0
- package/build/consumer/format.js +81 -0
- package/build/consumer/format.js.map +1 -0
- package/build/consumer/handlers.d.ts +28 -0
- package/build/consumer/handlers.d.ts.map +1 -0
- package/build/consumer/handlers.js +173 -0
- package/build/consumer/handlers.js.map +1 -0
- package/build/consumer/index.d.ts +7 -0
- package/build/consumer/index.d.ts.map +1 -0
- package/build/consumer/index.js +6 -0
- package/build/consumer/index.js.map +1 -0
- package/build/consumer/mail.d.ts +27 -0
- package/build/consumer/mail.d.ts.map +1 -0
- package/build/consumer/mail.js +314 -0
- package/build/consumer/mail.js.map +1 -0
- package/build/consumer/origin.d.ts +14 -0
- package/build/consumer/origin.d.ts.map +1 -0
- package/build/consumer/origin.js +47 -0
- package/build/consumer/origin.js.map +1 -0
- package/build/consumer/reconcile.d.ts +12 -0
- package/build/consumer/reconcile.d.ts.map +1 -0
- package/build/consumer/reconcile.js +317 -0
- package/build/consumer/reconcile.js.map +1 -0
- package/build/consumer/records.d.ts +78 -0
- package/build/consumer/records.d.ts.map +1 -0
- package/build/consumer/records.js +296 -0
- package/build/consumer/records.js.map +1 -0
- package/build/consumer/service.d.ts +51 -0
- package/build/consumer/service.d.ts.map +1 -0
- package/build/consumer/service.js +760 -0
- package/build/consumer/service.js.map +1 -0
- package/build/consumer/withdrawal.d.ts +57 -0
- package/build/consumer/withdrawal.d.ts.map +1 -0
- package/build/consumer/withdrawal.js +247 -0
- package/build/consumer/withdrawal.js.map +1 -0
- package/build/index.d.ts +4 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +4 -2
- package/build/index.js.map +1 -1
- package/build/model.d.ts +6 -1
- package/build/model.d.ts.map +1 -1
- package/build/model.js +134 -4
- package/build/model.js.map +1 -1
- package/build/observer.d.ts +4 -0
- package/build/observer.d.ts.map +1 -1
- package/build/observer.js +13 -0
- package/build/observer.js.map +1 -1
- package/build/plugins/checkout-plugins.d.ts +49 -0
- package/build/plugins/checkout-plugins.d.ts.map +1 -0
- package/build/plugins/checkout-plugins.js +124 -0
- package/build/plugins/checkout-plugins.js.map +1 -0
- package/build/plugins/estimate.d.ts.map +1 -1
- package/build/plugins/estimate.js +41 -8
- package/build/plugins/estimate.js.map +1 -1
- package/build/plugins/events.d.ts +2 -0
- package/build/plugins/events.d.ts.map +1 -1
- package/build/plugins/events.js +126 -9
- package/build/plugins/events.js.map +1 -1
- package/build/plugins/fx.d.ts +5 -0
- package/build/plugins/fx.d.ts.map +1 -1
- package/build/plugins/fx.js +25 -0
- package/build/plugins/fx.js.map +1 -1
- package/build/plugins/portal.d.ts.map +1 -1
- package/build/plugins/portal.js +11 -1
- package/build/plugins/portal.js.map +1 -1
- package/build/plugins/stripe.d.ts +21 -2
- package/build/plugins/stripe.d.ts.map +1 -1
- package/build/plugins/stripe.js +397 -61
- package/build/plugins/stripe.js.map +1 -1
- package/build/resource.d.ts +8 -1
- package/build/resource.d.ts.map +1 -1
- package/build/resource.js +59 -2
- package/build/resource.js.map +1 -1
- package/build/service.d.ts +2 -1
- package/build/service.d.ts.map +1 -1
- package/build/service.js +28 -5
- package/build/service.js.map +1 -1
- package/build/subscription.d.ts +6 -0
- package/build/subscription.d.ts.map +1 -1
- package/build/subscription.js +1 -0
- package/build/subscription.js.map +1 -1
- package/build/sync.d.ts +7 -0
- package/build/sync.d.ts.map +1 -1
- package/build/sync.js +108 -15
- package/build/sync.js.map +1 -1
- package/build/types.d.ts +707 -4
- package/build/types.d.ts.map +1 -1
- package/build/utils.d.ts +22 -1
- package/build/utils.d.ts.map +1 -1
- package/build/utils.js +27 -1
- package/build/utils.js.map +1 -1
- package/package.json +14 -13
- package/src/config.ts +111 -7
- package/src/consts.ts +34 -0
- package/src/consumer/capture.ts +362 -0
- package/src/consumer/format.ts +90 -0
- package/src/consumer/handlers.ts +211 -0
- package/src/consumer/index.ts +6 -0
- package/src/consumer/mail.ts +368 -0
- package/src/consumer/origin.ts +63 -0
- package/src/consumer/reconcile.ts +329 -0
- package/src/consumer/records.ts +374 -0
- package/src/consumer/service.ts +868 -0
- package/src/consumer/withdrawal.ts +302 -0
- package/src/index.ts +6 -4
- package/src/model.ts +148 -6
- package/src/observer.ts +15 -2
- package/src/plugins/checkout-plugins.ts +155 -0
- package/src/plugins/estimate.ts +49 -9
- package/src/plugins/events.ts +135 -11
- package/src/plugins/fx.ts +29 -0
- package/src/plugins/portal.ts +11 -1
- package/src/plugins/stripe.ts +476 -60
- package/src/resource.ts +87 -4
- package/src/service.ts +28 -6
- package/src/subscription.ts +7 -0
- package/src/sync.ts +124 -17
- package/src/types.ts +756 -6
- package/src/utils.ts +56 -7
- package/tests/checkout-consumer.spec.ts +348 -0
- package/tests/checkout-plugins.spec.ts +164 -0
- package/tests/consumer-events.spec.ts +218 -0
- package/tests/consumer-fixtures.ts +132 -0
- package/tests/consumer-ops.spec.ts +351 -0
- package/tests/consumer-rights.integration.spec.ts +150 -0
- package/tests/consumer-rights.spec.ts +501 -0
- package/tests/context.ts +20 -2
- package/tests/fake-stripe.ts +188 -18
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
import { MAILER_SERVICE } from '@owlmeans/mailer';
|
|
2
|
+
import { CancellationStatus, DeclarationKind, ENTITLING_STATUSES, PurchaseKind, WithdrawalStatus, } from '@owlmeans/payment';
|
|
3
|
+
import { PURCHASE_BACKFILL_DAYS, STRIPE_PAYGATE_ALIAS } from '../consts.js';
|
|
4
|
+
import { billingProfiles, consumerConsents, consumerDeclarations, consumerEvents, consumerMailConfig, errorText, idOf, paygateCustomers, payment, purchases, subscriptions, } from '../utils.js';
|
|
5
|
+
import { capturePaymentPurchase, captureSubscriptionPurchase, completeSubscriptionPurchase, } from './capture.js';
|
|
6
|
+
import { sendConsumerMail } from './mail.js';
|
|
7
|
+
import { hasEvent, hasPaid, lockProfile, purchaseIdOf, wasUnlocked } from './records.js';
|
|
8
|
+
import { notifyCancellation, notifyConsent, notifyWithdrawal, scheduleCancellation, } from './service.js';
|
|
9
|
+
import { executeWithdrawal, retryCreditNote } from './withdrawal.js';
|
|
10
|
+
const DAY_MS = 86_400_000;
|
|
11
|
+
/** A paygate step failed this often is left to an operator. */
|
|
12
|
+
const MAX_ATTEMPTS = 5;
|
|
13
|
+
/** What `withdraw` computed for a declaration, read back from its `computed` event. */
|
|
14
|
+
const computedOf = async (ctx, withdrawalId) => {
|
|
15
|
+
const event = await consumerEvents(ctx).load({ recordId: withdrawalId, action: 'computed', ok: true });
|
|
16
|
+
if (event == null) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
const detail = JSON.parse(event.detail ?? '{}');
|
|
20
|
+
return {
|
|
21
|
+
reading: detail.reading ?? { granted: 0, used: 0, usedAfter: 0 },
|
|
22
|
+
deducted: detail.deducted ?? 0,
|
|
23
|
+
unitsReturned: detail.unitsReturned ?? 0,
|
|
24
|
+
netMinor: detail.netMinor ?? 0,
|
|
25
|
+
refundMinor: event.amountMinor ?? 0,
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
const failures = async (ctx, recordId, action) => await consumerEvents(ctx).count({ recordId, action, ok: false });
|
|
29
|
+
/** Every distinct (record, step) with a failed event since `since` and no success after all. */
|
|
30
|
+
const pendingSteps = async (ctx, action, since, limit) => {
|
|
31
|
+
const { items } = await consumerEvents(ctx).list({ action, ok: false, at: { $gte: since } }, {
|
|
32
|
+
size: limit * 4, sort: [{ field: 'at', order: 'desc' }],
|
|
33
|
+
});
|
|
34
|
+
const seen = new Set();
|
|
35
|
+
const pending = [];
|
|
36
|
+
for (const event of items) {
|
|
37
|
+
const key = `${event.recordId}:${event.step ?? ''}`;
|
|
38
|
+
if (seen.has(key))
|
|
39
|
+
continue;
|
|
40
|
+
seen.add(key);
|
|
41
|
+
if (!await hasEvent(ctx, event.recordId, action, event.step ?? undefined, true)) {
|
|
42
|
+
pending.push(event);
|
|
43
|
+
}
|
|
44
|
+
if (pending.length >= limit)
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
return pending;
|
|
48
|
+
};
|
|
49
|
+
const retryWithdrawals = async (ctx, stripe, since, limit, result) => {
|
|
50
|
+
const { items } = await consumerDeclarations(ctx).list({
|
|
51
|
+
kind: DeclarationKind.Withdrawal, status: WithdrawalStatus.Processing, matched: true, receivedAt: { $gte: since },
|
|
52
|
+
}, { size: limit * 2, sort: [{ field: 'receivedAt', order: 'asc' }] });
|
|
53
|
+
let handled = 0;
|
|
54
|
+
for (const declaration of items) {
|
|
55
|
+
if (handled >= limit)
|
|
56
|
+
break;
|
|
57
|
+
const id = declaration.id;
|
|
58
|
+
const purchase = declaration.purchaseId != null ? await purchases(ctx).byPurchaseId(declaration.purchaseId) : null;
|
|
59
|
+
// A declaration that lost the race for its purchase is a duplicate — never executed.
|
|
60
|
+
if (purchase == null || purchase.withdrawalId !== id)
|
|
61
|
+
continue;
|
|
62
|
+
const computed = await computedOf(ctx, id);
|
|
63
|
+
const refundDone = (declaration.refundMinor ?? 0) <= 0 || await hasEvent(ctx, id, 'refund', undefined, true);
|
|
64
|
+
const cancelDone = purchase.kind !== PurchaseKind.Subscription || await hasEvent(ctx, id, 'subscription-cancel', undefined, true);
|
|
65
|
+
if (refundDone && cancelDone) {
|
|
66
|
+
const refundEvent = await consumerEvents(ctx).load({ recordId: id, action: 'refund', ok: true });
|
|
67
|
+
const noteFailed = await consumerEvents(ctx).load({ recordId: id, action: 'credit-note', ok: false, step: null });
|
|
68
|
+
if (refundEvent?.externalId != null && noteFailed != null && computed != null
|
|
69
|
+
&& !await hasEvent(ctx, id, 'credit-note', undefined, true)) {
|
|
70
|
+
const attempt = await failures(ctx, id, 'credit-note');
|
|
71
|
+
if (attempt < MAX_ATTEMPTS) {
|
|
72
|
+
handled++;
|
|
73
|
+
result.retried++;
|
|
74
|
+
if (!await retryCreditNote(ctx, stripe, declaration, purchase, computed.netMinor, refundEvent.externalId, attempt)) {
|
|
75
|
+
result.failed++;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
const attempt = Math.max(await failures(ctx, id, 'refund'), await failures(ctx, id, 'subscription-cancel'));
|
|
82
|
+
if (attempt >= MAX_ATTEMPTS)
|
|
83
|
+
continue;
|
|
84
|
+
handled++;
|
|
85
|
+
result.retried++;
|
|
86
|
+
try {
|
|
87
|
+
const execution = await executeWithdrawal(ctx, stripe, declaration, purchase, {
|
|
88
|
+
refundMinor: declaration.refundMinor ?? computed?.refundMinor ?? 0, netMinor: computed?.netMinor ?? 0,
|
|
89
|
+
}, { attempt });
|
|
90
|
+
if (!execution.ok) {
|
|
91
|
+
result.failed++;
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (!await hasEvent(ctx, id, 'observers', 'withdrawal')) {
|
|
95
|
+
await notifyWithdrawal(ctx, declaration, purchase, WithdrawalStatus.Refunded, computed, execution);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
result.failed++;
|
|
100
|
+
console.error(`[payment] reconcile: withdrawal "${id}" failed`, error);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
const retryCancellations = async (ctx, stripe, since, limit, result) => {
|
|
105
|
+
const { items } = await consumerDeclarations(ctx).list({
|
|
106
|
+
kind: DeclarationKind.Cancellation, status: CancellationStatus.Scheduled, matched: true, receivedAt: { $gte: since },
|
|
107
|
+
}, { size: limit * 2, sort: [{ field: 'receivedAt', order: 'asc' }] });
|
|
108
|
+
let handled = 0;
|
|
109
|
+
for (const declaration of items) {
|
|
110
|
+
if (handled >= limit)
|
|
111
|
+
break;
|
|
112
|
+
const id = declaration.id;
|
|
113
|
+
if (declaration.subscriptionId == null || await hasEvent(ctx, id, 'cancel-scheduled', undefined, true))
|
|
114
|
+
continue;
|
|
115
|
+
const attempt = await failures(ctx, id, 'cancel-scheduled');
|
|
116
|
+
const row = await subscriptions(ctx).byExternalId(declaration.subscriptionId, STRIPE_PAYGATE_ALIAS);
|
|
117
|
+
if (row == null || attempt >= MAX_ATTEMPTS)
|
|
118
|
+
continue;
|
|
119
|
+
handled++;
|
|
120
|
+
result.retried++;
|
|
121
|
+
if (!await scheduleCancellation(ctx, stripe, declaration, row, attempt)) {
|
|
122
|
+
result.failed++;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
const retryMails = async (ctx, since, limit, result) => {
|
|
127
|
+
const policy = await payment(ctx).consumerRightsPolicy();
|
|
128
|
+
const alias = (await consumerMailConfig(ctx))?.alias ?? MAILER_SERVICE;
|
|
129
|
+
if (policy == null || ctx.hasService?.(alias) !== true) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
for (const event of await pendingSteps(ctx, 'mail', since, limit)) {
|
|
133
|
+
if (event.step == null)
|
|
134
|
+
continue;
|
|
135
|
+
if (await sendConsumerMail(ctx, policy, event.step, event.recordId)) {
|
|
136
|
+
result.mailed++;
|
|
137
|
+
}
|
|
138
|
+
else if (!await hasEvent(ctx, event.recordId, 'mail', event.step, true)) {
|
|
139
|
+
result.failed++;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
const retryObservers = async (ctx, since, limit, result) => {
|
|
144
|
+
for (const event of await pendingSteps(ctx, 'observers', since, limit)) {
|
|
145
|
+
let told = false;
|
|
146
|
+
try {
|
|
147
|
+
if (event.step === 'consent') {
|
|
148
|
+
const consent = await consumerConsents(ctx).load(event.recordId);
|
|
149
|
+
told = consent != null && await notifyConsent(ctx, consent);
|
|
150
|
+
}
|
|
151
|
+
else if (event.step === 'withdrawal') {
|
|
152
|
+
const declaration = await consumerDeclarations(ctx).load(event.recordId);
|
|
153
|
+
const purchase = declaration?.purchaseId != null ? await purchases(ctx).byPurchaseId(declaration.purchaseId) : null;
|
|
154
|
+
if (declaration != null && purchase != null) {
|
|
155
|
+
const refunded = await hasEvent(ctx, event.recordId, 'refund', undefined, true) || (declaration.refundMinor ?? 0) <= 0;
|
|
156
|
+
const refund = await consumerEvents(ctx).load({ recordId: event.recordId, action: 'refund', ok: true });
|
|
157
|
+
const note = await consumerEvents(ctx).load({ recordId: event.recordId, action: 'credit-note', ok: true });
|
|
158
|
+
told = await notifyWithdrawal(ctx, declaration, purchase, declaration.status === WithdrawalStatus.Processing && refunded ? WithdrawalStatus.Refunded : WithdrawalStatus.Review, await computedOf(ctx, event.recordId), refund != null ? {
|
|
159
|
+
ok: true, refundId: refund.externalId ?? undefined, creditNoteId: note?.externalId ?? undefined,
|
|
160
|
+
refundedMinor: refund.amountMinor ?? 0, needsReview: false,
|
|
161
|
+
subscriptionCanceled: await hasEvent(ctx, event.recordId, 'subscription-cancel', undefined, true),
|
|
162
|
+
} : null);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
else if (event.step === 'cancellation') {
|
|
166
|
+
const declaration = await consumerDeclarations(ctx).load(event.recordId);
|
|
167
|
+
if (declaration != null) {
|
|
168
|
+
const scheduled = await hasEvent(ctx, event.recordId, 'cancel-scheduled', undefined, true);
|
|
169
|
+
told = await notifyCancellation(ctx, declaration, declaration.status === CancellationStatus.Scheduled && !scheduled
|
|
170
|
+
? CancellationStatus.Received : declaration.status);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
console.error(`[payment] reconcile: observers of "${event.recordId}" failed`, error);
|
|
176
|
+
}
|
|
177
|
+
if (told) {
|
|
178
|
+
result.observed++;
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
result.failed++;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
/** Completed checkouts of the last days that have no purchase row (records only — no mail). */
|
|
186
|
+
const backfillPurchases = async (ctx, stripe, limit, result) => {
|
|
187
|
+
const from = Math.floor((Date.now() - PURCHASE_BACKFILL_DAYS * DAY_MS) / 1000);
|
|
188
|
+
let startingAfter;
|
|
189
|
+
let scanned = 0;
|
|
190
|
+
for (;;) {
|
|
191
|
+
const page = await stripe.checkout.sessions.list({
|
|
192
|
+
created: { gte: from }, status: 'complete', limit: 100,
|
|
193
|
+
...(startingAfter != null ? { starting_after: startingAfter } : {}),
|
|
194
|
+
});
|
|
195
|
+
for (const session of page.data) {
|
|
196
|
+
scanned++;
|
|
197
|
+
if (result.backfilled >= limit)
|
|
198
|
+
return;
|
|
199
|
+
const metadata = session.metadata ?? {};
|
|
200
|
+
if (metadata.entityId == null || metadata.productSku == null)
|
|
201
|
+
continue;
|
|
202
|
+
try {
|
|
203
|
+
if (session.mode === 'payment' && session.payment_status === 'paid') {
|
|
204
|
+
if (await purchases(ctx).load({ sessionId: session.id }) != null)
|
|
205
|
+
continue;
|
|
206
|
+
const amount = Number(metadata.amountMinor);
|
|
207
|
+
const captured = await capturePaymentPurchase(ctx, stripe, session, {
|
|
208
|
+
...(Number.isSafeInteger(amount) && amount > 0 ? { netAmountMinor: amount } : {}),
|
|
209
|
+
...(metadata.amountCurrency != null ? { amountCurrency: metadata.amountCurrency } : {}),
|
|
210
|
+
at: new Date(session.created * 1000),
|
|
211
|
+
}, { mail: false });
|
|
212
|
+
if (captured?.created === true)
|
|
213
|
+
result.backfilled++;
|
|
214
|
+
}
|
|
215
|
+
else if (session.mode === 'subscription') {
|
|
216
|
+
const subscriptionId = idOf(session.subscription);
|
|
217
|
+
if (subscriptionId == null || await purchases(ctx).byPurchaseId(purchaseIdOf(subscriptionId)) != null)
|
|
218
|
+
continue;
|
|
219
|
+
const row = await subscriptions(ctx).byExternalId(subscriptionId, STRIPE_PAYGATE_ALIAS);
|
|
220
|
+
if (row == null || !ENTITLING_STATUSES.includes(row.status))
|
|
221
|
+
continue;
|
|
222
|
+
const subscription = await stripe.subscriptions.retrieve(subscriptionId);
|
|
223
|
+
const captured = await captureSubscriptionPurchase(ctx, stripe, subscription, row);
|
|
224
|
+
if (captured != null) {
|
|
225
|
+
await completeSubscriptionPurchase(ctx, stripe, session, captured.purchase, { mail: false });
|
|
226
|
+
if (captured.created)
|
|
227
|
+
result.backfilled++;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
catch (error) {
|
|
232
|
+
result.failed++;
|
|
233
|
+
console.error(`[payment] reconcile: backfill of "${session.id}" failed`, error);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
if (!page.has_more || page.data.length === 0 || scanned >= limit * 20)
|
|
237
|
+
return;
|
|
238
|
+
startingAfter = page.data[page.data.length - 1].id;
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
/**
|
|
242
|
+
* Organizations that paid before countries were locked: locked from their paygate customer's
|
|
243
|
+
* address — never one an operator unlocked (its next completed purchase locks it).
|
|
244
|
+
*/
|
|
245
|
+
const lockLegacy = async (ctx, stripe, limit, result) => {
|
|
246
|
+
const policy = await payment(ctx).consumerRightsPolicy();
|
|
247
|
+
if (policy?.mechanisms.countryLock !== true) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
const { items } = await paygateCustomers(ctx).list({ paygate: STRIPE_PAYGATE_ALIAS, deletedAt: null }, { size: limit * 4 });
|
|
251
|
+
for (const customer of items) {
|
|
252
|
+
if (result.locked >= limit)
|
|
253
|
+
return;
|
|
254
|
+
if (customer.entityId == null || await billingProfiles(ctx).byEntity(customer.entityId) != null)
|
|
255
|
+
continue;
|
|
256
|
+
if (!await hasPaid(ctx, customer.entityId) || await wasUnlocked(ctx, customer.entityId))
|
|
257
|
+
continue;
|
|
258
|
+
try {
|
|
259
|
+
let country = customer.country;
|
|
260
|
+
if (country == null) {
|
|
261
|
+
const retrieved = await stripe.customers.retrieve(customer.externalId);
|
|
262
|
+
country = retrieved.deleted ? undefined : retrieved.address?.country ?? undefined;
|
|
263
|
+
}
|
|
264
|
+
if (country == null)
|
|
265
|
+
continue;
|
|
266
|
+
const { created } = await lockProfile(ctx, policy, {
|
|
267
|
+
entityId: customer.entityId, country, source: 'customer', customerId: customer.externalId,
|
|
268
|
+
email: customer.email ?? undefined,
|
|
269
|
+
});
|
|
270
|
+
if (created)
|
|
271
|
+
result.locked++;
|
|
272
|
+
}
|
|
273
|
+
catch (error) {
|
|
274
|
+
result.failed++;
|
|
275
|
+
console.error(`[payment] reconcile: legacy lock of "${customer.entityId}" failed: ${errorText(error)}`);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
/**
|
|
280
|
+
* The consumer-rights repair an application runs nightly: retry the paygate steps of withdrawals
|
|
281
|
+
* (refunds, credit notes, subscription cancels) and scheduled cancellations, failed mails and
|
|
282
|
+
* failed observers; backfill purchases of completed checkouts of the last 16 days that have no
|
|
283
|
+
* row; lock organizations that paid before countries were locked. The paygate steps, the
|
|
284
|
+
* backfill and the legacy locks need a managed service. Each step handles at most `limit` items.
|
|
285
|
+
*/
|
|
286
|
+
export const reconcileConsumerRights = async (ctx, internals, opts = {}) => {
|
|
287
|
+
const result = { retried: 0, mailed: 0, observed: 0, backfilled: 0, locked: 0, failed: 0 };
|
|
288
|
+
if (await payment(ctx).consumerRightsPolicy() == null) {
|
|
289
|
+
return result;
|
|
290
|
+
}
|
|
291
|
+
const limit = Math.max(1, opts.limit ?? 50);
|
|
292
|
+
const since = opts.since ?? new Date(Date.now() - 30 * DAY_MS);
|
|
293
|
+
const stripe = internals.managed ? await internals.stripe(ctx) : null;
|
|
294
|
+
const steps = [
|
|
295
|
+
...(stripe != null ? [
|
|
296
|
+
['withdrawals', async () => { await retryWithdrawals(ctx, stripe, since, limit, result); }],
|
|
297
|
+
['cancellations', async () => { await retryCancellations(ctx, stripe, since, limit, result); }],
|
|
298
|
+
] : []),
|
|
299
|
+
['mails', async () => { await retryMails(ctx, since, limit, result); }],
|
|
300
|
+
['observers', async () => { await retryObservers(ctx, since, limit, result); }],
|
|
301
|
+
...(stripe != null ? [
|
|
302
|
+
['backfill', async () => { await backfillPurchases(ctx, stripe, limit, result); }],
|
|
303
|
+
['legacy locks', async () => { await lockLegacy(ctx, stripe, limit, result); }],
|
|
304
|
+
] : []),
|
|
305
|
+
];
|
|
306
|
+
for (const [name, step] of steps) {
|
|
307
|
+
try {
|
|
308
|
+
await step();
|
|
309
|
+
}
|
|
310
|
+
catch (error) {
|
|
311
|
+
result.failed++;
|
|
312
|
+
console.error(`[payment] consumer-rights reconcile step "${name}" failed`, error);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
return result;
|
|
316
|
+
};
|
|
317
|
+
//# sourceMappingURL=reconcile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reconcile.js","sourceRoot":"","sources":["../../src/consumer/reconcile.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EACL,kBAAkB,EAAE,eAAe,EAAE,kBAAkB,EAAE,YAAY,EAAE,gBAAgB,GACxF,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAC3E,OAAO,EACL,eAAe,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,cAAc,EAAE,kBAAkB,EAAE,SAAS,EAAE,IAAI,EAC5G,gBAAgB,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,GACpD,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CAAA;YACf,OAAO,CAAC,KAAK,CAAC,6CAA6C,IAAI,UAAU,EAAE,KAAK,CAAC,CAAA;QACnF,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { BillingProfileView, ConsumerRightsPolicy, PurchaseView } from '@owlmeans/payment';
|
|
2
|
+
import type { Context as ApiContext } from '@owlmeans/server-api';
|
|
3
|
+
import type { BillingProfileRecord, BillingProfileSource, ConsumerEventRecord, LockOptions, PaymentSubscriptionRecord, PurchaseRecord, PurchaseRef, UnlockOptions } from '../types.js';
|
|
4
|
+
export declare const purchaseIdOf: (externalId: string) => string;
|
|
5
|
+
/** A locked profile as the wire sees it. */
|
|
6
|
+
export declare const profileViewOf: (record: BillingProfileRecord, policy: ConsumerRightsPolicy | null) => BillingProfileView;
|
|
7
|
+
/** No profile yet: nothing locked, the default legal language, an unknown buyer (protected by default). */
|
|
8
|
+
export declare const unlockedProfileView: (policy: ConsumerRightsPolicy | null) => BillingProfileView;
|
|
9
|
+
/**
|
|
10
|
+
* Append one audit step. A failure to write it is logged and never fails the act it describes —
|
|
11
|
+
* the act's own record (consent, declaration, purchase) is already written.
|
|
12
|
+
*/
|
|
13
|
+
export declare const recordEvent: (ctx: ApiContext, event: Omit<ConsumerEventRecord, 'at' | 'id'> & {
|
|
14
|
+
at?: Date;
|
|
15
|
+
}) => Promise<void>;
|
|
16
|
+
/** Whether a step already succeeded (or a mail was deliberately skipped) for a record. */
|
|
17
|
+
export declare const hasEvent: (ctx: ApiContext, recordId: string, action: ConsumerEventRecord['action'], step?: string, ok?: boolean) => Promise<boolean>;
|
|
18
|
+
/** The currency of the entity's entitling Stripe subscription — two of one customer cannot differ. */
|
|
19
|
+
export declare const activeSubscriptionCurrency: (ctx: ApiContext, entityId: string) => Promise<string | undefined>;
|
|
20
|
+
/** The entity's highest-ranked entitling Stripe subscription, or `null`. */
|
|
21
|
+
export declare const entitlingStripeSubscription: (ctx: ApiContext, entityId: string) => Promise<PaymentSubscriptionRecord | null>;
|
|
22
|
+
/** Whether the entity ever paid through the paygate (a fulfilled checkout or a propagated subscription). */
|
|
23
|
+
export declare const hasPaid: (ctx: ApiContext, entityId: string) => Promise<boolean>;
|
|
24
|
+
export interface LockInput extends LockOptions {
|
|
25
|
+
entityId: string;
|
|
26
|
+
country: string;
|
|
27
|
+
source: BillingProfileSource;
|
|
28
|
+
}
|
|
29
|
+
export interface LockResult {
|
|
30
|
+
record: BillingProfileRecord;
|
|
31
|
+
created: boolean;
|
|
32
|
+
/** The lock exists with another country: recorded as `lock-mismatch`, never relocked. */
|
|
33
|
+
mismatch: boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Fix an entity's billing country — the FIRST write wins (a unique index on `entityId` settles a
|
|
37
|
+
* race). A later, different country is only a `lock-mismatch` event; only a `manual` lock with
|
|
38
|
+
* `force` replaces the country, audited as `relock`. The charge currency is fixed with it: the
|
|
39
|
+
* currency of an entitling paygate subscription when one exists (a customer's subscriptions share
|
|
40
|
+
* one currency), else the region's (`policy.currencies`), else the given one.
|
|
41
|
+
*/
|
|
42
|
+
export declare const lockProfile: (ctx: ApiContext, policy: ConsumerRightsPolicy | null, input: LockInput) => Promise<LockResult>;
|
|
43
|
+
/**
|
|
44
|
+
* An operator removes an entity's lock: the profile row is deleted (only while it still holds the
|
|
45
|
+
* country read — a concurrent relock survives) and an `unlock` event keeps the whole row, `by` and
|
|
46
|
+
* `reason`. `null` when nothing was locked.
|
|
47
|
+
*/
|
|
48
|
+
export declare const unlockProfile: (ctx: ApiContext, entityId: string, opts?: UnlockOptions) => Promise<BillingProfileRecord | null>;
|
|
49
|
+
/**
|
|
50
|
+
* Whether an operator unlocked the entity — then no lock is taken from its paygate customer's saved
|
|
51
|
+
* address (at checkout or in reconcile): its next completed purchase locks it.
|
|
52
|
+
*/
|
|
53
|
+
export declare const wasUnlocked: (ctx: ApiContext, entityId: string) => Promise<boolean>;
|
|
54
|
+
/** Inside its window at `at`: in scope, before the deadline, neither withdrawn from nor refunded. */
|
|
55
|
+
export declare const windowOpen: (purchase: PurchaseRecord, at?: Date) => boolean;
|
|
56
|
+
export declare const purchaseViewOf: (purchase: PurchaseRecord, withdrawable: boolean) => PurchaseView;
|
|
57
|
+
export declare const purchaseRefOf: (purchase: PurchaseRecord) => PurchaseRef;
|
|
58
|
+
/** The open, unconsented top-up windows of an entity — what a performance consent covers. */
|
|
59
|
+
export declare const unconsentedWindows: (ctx: ApiContext, entityId: string, at?: Date) => Promise<PurchaseRecord[]>;
|
|
60
|
+
export type PurchaseDraft = Omit<PurchaseRecord, 'id' | 'contractRef' | 'createdAt'>;
|
|
61
|
+
/**
|
|
62
|
+
* Write a purchase once: an existing row for the same purchase (or the same checkout session) is
|
|
63
|
+
* returned as it is. A contract-reference collision retries with a fresh reference.
|
|
64
|
+
*/
|
|
65
|
+
export declare const createPurchase: (ctx: ApiContext, draft: PurchaseDraft) => Promise<{
|
|
66
|
+
record: PurchaseRecord;
|
|
67
|
+
created: boolean;
|
|
68
|
+
}>;
|
|
69
|
+
/** Set fields on a purchase without replacing it (a concurrent conditional write survives). */
|
|
70
|
+
export declare const patchPurchase: (ctx: ApiContext, purchaseId: string, fields: Partial<PurchaseRecord>) => Promise<void>;
|
|
71
|
+
/** The e-mail a consumer-rights mail reaches the organization at when no person named one. */
|
|
72
|
+
export declare const contactEmailOf: (ctx: ApiContext, entityId: string) => Promise<string | undefined>;
|
|
73
|
+
/**
|
|
74
|
+
* Whether an e-mail address belongs to a purchase: its checkout e-mail, the organization's
|
|
75
|
+
* profile e-mail or its paygate customer's — compared case-insensitively.
|
|
76
|
+
*/
|
|
77
|
+
export declare const emailMatches: (ctx: ApiContext, purchase: PurchaseRecord, email: string) => Promise<boolean>;
|
|
78
|
+
//# sourceMappingURL=records.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"records.d.ts","sourceRoot":"","sources":["../../src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