@open-mercato/checkout 0.10.1-develop.8289.1.9a25111d49 → 0.10.1-develop.8291.1.6ec3aee41c
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/.turbo/turbo-build.log +1 -1
- package/dist/modules/checkout/__integration__/TC-CHK-CRUDFORM-001.spec.js +3 -3
- package/dist/modules/checkout/__integration__/TC-CHK-CRUDFORM-001.spec.js.map +2 -2
- package/dist/modules/checkout/__integration__/TC-CHKT-037-template-sync.spec.js +3 -1
- package/dist/modules/checkout/__integration__/TC-CHKT-037-template-sync.spec.js.map +2 -2
- package/dist/modules/checkout/__integration__/TC-CHKT-PRECISION-001.spec.js +259 -0
- package/dist/modules/checkout/__integration__/TC-CHKT-PRECISION-001.spec.js.map +7 -0
- package/dist/modules/checkout/__integration__/TC-CHKT-PRECISION-002-admin-round-trip.spec.js +85 -0
- package/dist/modules/checkout/__integration__/TC-CHKT-PRECISION-002-admin-round-trip.spec.js.map +7 -0
- package/dist/modules/checkout/api/pay/[slug]/submit/route.js +17 -2
- package/dist/modules/checkout/api/pay/[slug]/submit/route.js.map +2 -2
- package/dist/modules/checkout/backend/checkout/pay-links/page.js +9 -3
- package/dist/modules/checkout/backend/checkout/pay-links/page.js.map +2 -2
- package/dist/modules/checkout/commands/links.js +7 -10
- package/dist/modules/checkout/commands/links.js.map +2 -2
- package/dist/modules/checkout/commands/shared.js +43 -7
- package/dist/modules/checkout/commands/shared.js.map +2 -2
- package/dist/modules/checkout/commands/templates.js +12 -10
- package/dist/modules/checkout/commands/templates.js.map +2 -2
- package/dist/modules/checkout/commands/transactions.js +13 -1
- package/dist/modules/checkout/commands/transactions.js.map +2 -2
- package/dist/modules/checkout/components/LinkTemplateForm.js +47 -20
- package/dist/modules/checkout/components/LinkTemplateForm.js.map +2 -2
- package/dist/modules/checkout/components/PayPage.js +59 -55
- package/dist/modules/checkout/components/PayPage.js.map +2 -2
- package/dist/modules/checkout/data/entities.js +6 -5
- package/dist/modules/checkout/data/entities.js.map +2 -2
- package/dist/modules/checkout/data/validators.js +19 -2
- package/dist/modules/checkout/data/validators.js.map +2 -2
- package/dist/modules/checkout/i18n/de.json +1 -0
- package/dist/modules/checkout/i18n/en.json +1 -0
- package/dist/modules/checkout/i18n/es.json +1 -0
- package/dist/modules/checkout/i18n/ko.json +1 -0
- package/dist/modules/checkout/i18n/pl.json +1 -0
- package/dist/modules/checkout/lib/amountPrecision.js +98 -0
- package/dist/modules/checkout/lib/amountPrecision.js.map +7 -0
- package/dist/modules/checkout/lib/payPageAmount.js +56 -0
- package/dist/modules/checkout/lib/payPageAmount.js.map +7 -0
- package/dist/modules/checkout/lib/utils.js +63 -20
- package/dist/modules/checkout/lib/utils.js.map +2 -2
- package/dist/modules/checkout/migrations/Migration20261014082519_checkout.js +33 -0
- package/dist/modules/checkout/migrations/Migration20261014082519_checkout.js.map +7 -0
- package/dist/modules/checkout/workers/send-email.worker.js +8 -1
- package/dist/modules/checkout/workers/send-email.worker.js.map +2 -2
- package/package.json +10 -7
- package/src/modules/checkout/__integration__/TC-CHK-CRUDFORM-001.spec.ts +3 -3
- package/src/modules/checkout/__integration__/TC-CHKT-037-template-sync.spec.ts +2 -0
- package/src/modules/checkout/__integration__/TC-CHKT-PRECISION-001.spec.ts +320 -0
- package/src/modules/checkout/__integration__/TC-CHKT-PRECISION-002-admin-round-trip.spec.ts +112 -0
- package/src/modules/checkout/api/pay/[slug]/__tests__/route.test.ts +4 -0
- package/src/modules/checkout/api/pay/[slug]/submit/__tests__/route.test.ts +145 -0
- package/src/modules/checkout/api/pay/[slug]/submit/route.ts +19 -2
- package/src/modules/checkout/backend/checkout/pay-links/page.tsx +13 -3
- package/src/modules/checkout/commands/__tests__/configured-amount-precision.test.ts +180 -0
- package/src/modules/checkout/commands/__tests__/create-transaction-amount.test.ts +77 -0
- package/src/modules/checkout/commands/__tests__/template-sync.test.ts +145 -0
- package/src/modules/checkout/commands/links.ts +7 -10
- package/src/modules/checkout/commands/shared.ts +56 -7
- package/src/modules/checkout/commands/templates.ts +12 -10
- package/src/modules/checkout/commands/transactions.ts +15 -1
- package/src/modules/checkout/components/LinkTemplateForm.tsx +52 -21
- package/src/modules/checkout/components/PayPage.tsx +76 -58
- package/src/modules/checkout/components/__tests__/LinkTemplateForm.localeDecimalSeparator.test.tsx +35 -1
- package/src/modules/checkout/components/__tests__/LinkTemplateForm.priceListExactAmount.test.tsx +196 -0
- package/src/modules/checkout/components/__tests__/PayPage.amountPrecision.test.tsx +115 -0
- package/src/modules/checkout/components/__tests__/PayPagePricing.amountDisplay.test.tsx +98 -0
- package/src/modules/checkout/components/__tests__/__fixtures__/legacyPayPageContracts.ts +13 -0
- package/src/modules/checkout/components/__tests__/payPageContracts.backwardCompat.test.ts +32 -0
- package/src/modules/checkout/data/__tests__/validators.test.ts +91 -0
- package/src/modules/checkout/data/entities.ts +7 -6
- package/src/modules/checkout/data/validators.ts +26 -2
- package/src/modules/checkout/i18n/de.json +1 -0
- package/src/modules/checkout/i18n/en.json +1 -0
- package/src/modules/checkout/i18n/es.json +1 -0
- package/src/modules/checkout/i18n/ko.json +1 -0
- package/src/modules/checkout/i18n/pl.json +1 -0
- package/src/modules/checkout/lib/__tests__/amountPrecision.test.ts +169 -0
- package/src/modules/checkout/lib/__tests__/payPageAmount.test.ts +127 -0
- package/src/modules/checkout/lib/__tests__/utils.test.ts +72 -0
- package/src/modules/checkout/lib/amountPrecision.ts +152 -0
- package/src/modules/checkout/lib/payPageAmount.ts +99 -0
- package/src/modules/checkout/lib/utils.ts +85 -28
- package/src/modules/checkout/migrations/.snapshot-open-mercato.json +158 -27
- package/src/modules/checkout/migrations/Migration20261014082519_checkout.ts +35 -0
- package/src/modules/checkout/migrations/__tests__/Migration20261014082519_checkout.integration.test.ts +6 -0
- package/src/modules/checkout/workers/__tests__/send-email.worker.test.ts +43 -0
- package/src/modules/checkout/workers/send-email.worker.ts +8 -1
|
@@ -2,11 +2,21 @@ import { createHmac, timingSafeEqual } from "crypto";
|
|
|
2
2
|
import bcrypt from "bcryptjs";
|
|
3
3
|
import { slugify } from "@open-mercato/shared/lib/slugify";
|
|
4
4
|
import { CrudHttpError } from "@open-mercato/shared/lib/crud/errors";
|
|
5
|
+
import {
|
|
6
|
+
decimalToNumber,
|
|
7
|
+
decimalToString,
|
|
8
|
+
parseDecimal,
|
|
9
|
+
resolveExactDecimal,
|
|
10
|
+
withExactAmounts
|
|
11
|
+
} from "@open-mercato/shared/lib/decimal";
|
|
5
12
|
import { normalizeCustomFieldResponse } from "@open-mercato/shared/lib/custom-fields/normalize";
|
|
6
13
|
import { parseDecryptedFieldValue } from "@open-mercato/shared/lib/encryption/tenantDataEncryptionService";
|
|
7
14
|
import { getPaymentGatewayDescriptor } from "@open-mercato/shared/modules/payment_gateways/types";
|
|
8
15
|
import { CheckoutLink } from "../data/entities.js";
|
|
9
16
|
import { buildCheckoutAttachmentPreviewUrl, normalizeOptionalString } from "./client-utils.js";
|
|
17
|
+
import {
|
|
18
|
+
assertExactCustomAmountRange
|
|
19
|
+
} from "../data/validators.js";
|
|
10
20
|
import { CHECKOUT_TERMINAL_STATUSES } from "./constants.js";
|
|
11
21
|
import {
|
|
12
22
|
getCheckoutCustomerFieldSemanticType,
|
|
@@ -14,6 +24,13 @@ import {
|
|
|
14
24
|
isValidCheckoutPhone,
|
|
15
25
|
validateCheckoutCustomerData
|
|
16
26
|
} from "./customerDataValidation.js";
|
|
27
|
+
const CHECKOUT_MONEY_FIELDS = [
|
|
28
|
+
"fixedPriceAmount",
|
|
29
|
+
"fixedPriceOriginalAmount",
|
|
30
|
+
"customAmountMin",
|
|
31
|
+
"customAmountMax",
|
|
32
|
+
"amount"
|
|
33
|
+
];
|
|
17
34
|
function isRecord(value) {
|
|
18
35
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
19
36
|
}
|
|
@@ -30,7 +47,8 @@ function pickExplicitParsedOverrides(rawInput, parsed) {
|
|
|
30
47
|
if (!isRecord(rawInput)) return {};
|
|
31
48
|
const overrides = {};
|
|
32
49
|
for (const key of Object.keys(parsed)) {
|
|
33
|
-
|
|
50
|
+
const sourceKey = key.endsWith("Exact") ? key.slice(0, -"Exact".length) : key;
|
|
51
|
+
if (!Object.prototype.hasOwnProperty.call(rawInput, key) && !Object.prototype.hasOwnProperty.call(rawInput, sourceKey)) continue;
|
|
34
52
|
overrides[key] = parsed[key];
|
|
35
53
|
}
|
|
36
54
|
return overrides;
|
|
@@ -47,10 +65,16 @@ function parseCheckoutInput(raw, parser) {
|
|
|
47
65
|
const source = isRecord(raw) ? { ...raw } : {};
|
|
48
66
|
const customFields = isRecord(source.customFields) ? source.customFields : {};
|
|
49
67
|
delete source.customFields;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
68
|
+
const parsed = withExactAmounts(parser(source), source, CHECKOUT_MONEY_FIELDS);
|
|
69
|
+
const items = parsed.priceListItems;
|
|
70
|
+
if (Array.isArray(items)) {
|
|
71
|
+
const rawItems = Array.isArray(source.priceListItems) ? source.priceListItems : [];
|
|
72
|
+
parsed.priceListItems = items.map(
|
|
73
|
+
(item, index) => isRecord(item) ? withExactAmounts(item, rawItems[index], ["amount"]) : item
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
assertExactCustomAmountRange(parsed);
|
|
77
|
+
return { parsed, customFields };
|
|
54
78
|
}
|
|
55
79
|
function resolveLoadedCheckoutCustomFields(values) {
|
|
56
80
|
return normalizeCustomFieldResponse(values) ?? {};
|
|
@@ -67,8 +91,8 @@ function toMoneyNumber(value) {
|
|
|
67
91
|
return Number.isFinite(numeric) ? numeric : null;
|
|
68
92
|
}
|
|
69
93
|
function toMoneyString(value) {
|
|
70
|
-
const
|
|
71
|
-
return
|
|
94
|
+
const parsed = parseDecimal(value);
|
|
95
|
+
return parsed ? decimalToString(parsed) : null;
|
|
72
96
|
}
|
|
73
97
|
import { normalizeOptionalString as normalizeOptionalString2, buildCheckoutAttachmentPreviewUrl as buildCheckoutAttachmentPreviewUrl2 } from "./client-utils.js";
|
|
74
98
|
function normalizeJsonRecord(value) {
|
|
@@ -105,11 +129,15 @@ function toTemplateOrLinkMutationInput(record, overrides = {}) {
|
|
|
105
129
|
themeMode: record.themeMode,
|
|
106
130
|
pricingMode: record.pricingMode,
|
|
107
131
|
fixedPriceAmount: toMoneyNumber(record.fixedPriceAmount),
|
|
132
|
+
fixedPriceAmountExact: toMoneyString(record.fixedPriceAmount),
|
|
108
133
|
fixedPriceCurrencyCode: record.fixedPriceCurrencyCode ?? null,
|
|
109
134
|
fixedPriceIncludesTax: record.fixedPriceIncludesTax,
|
|
110
135
|
fixedPriceOriginalAmount: toMoneyNumber(record.fixedPriceOriginalAmount),
|
|
136
|
+
fixedPriceOriginalAmountExact: toMoneyString(record.fixedPriceOriginalAmount),
|
|
111
137
|
customAmountMin: toMoneyNumber(record.customAmountMin),
|
|
138
|
+
customAmountMinExact: toMoneyString(record.customAmountMin),
|
|
112
139
|
customAmountMax: toMoneyNumber(record.customAmountMax),
|
|
140
|
+
customAmountMaxExact: toMoneyString(record.customAmountMax),
|
|
113
141
|
customAmountCurrencyCode: record.customAmountCurrencyCode ?? null,
|
|
114
142
|
priceListItems: record.priceListItems ?? null,
|
|
115
143
|
gatewayProviderKey: record.gatewayProviderKey ?? "",
|
|
@@ -270,33 +298,33 @@ function buildConsentProof(link, acceptedLegalConsents) {
|
|
|
270
298
|
return proof;
|
|
271
299
|
}
|
|
272
300
|
function resolveSubmittedAmount(link, input) {
|
|
301
|
+
const submitted = input.amount == null ? null : parseDecimal(resolveExactDecimal(input.amountExact, input.amount));
|
|
273
302
|
if (link.pricingMode === "fixed") {
|
|
274
|
-
const expected =
|
|
303
|
+
const expected = parseDecimal(link.fixedPriceAmount);
|
|
275
304
|
if (expected == null || !link.fixedPriceCurrencyCode) {
|
|
276
305
|
throw new CrudHttpError(422, { error: "checkout.payPage.errors.submit" });
|
|
277
306
|
}
|
|
278
|
-
if (input.amount != null &&
|
|
307
|
+
if (input.amount != null && (!submitted || !submitted.eq(expected))) {
|
|
279
308
|
throw new CrudHttpError(422, { error: "checkout.payPage.errors.submit" });
|
|
280
309
|
}
|
|
281
|
-
return
|
|
310
|
+
return withAmount(expected, link.fixedPriceCurrencyCode, null);
|
|
282
311
|
}
|
|
283
312
|
if (link.pricingMode === "custom_amount") {
|
|
284
|
-
if (input.amount == null || !link.customAmountCurrencyCode) {
|
|
313
|
+
if (input.amount == null || !submitted || !link.customAmountCurrencyCode) {
|
|
285
314
|
throw new CrudHttpError(422, {
|
|
286
315
|
error: "checkout.payPage.validation.fixErrors",
|
|
287
316
|
fieldErrors: { amount: "checkout.payPage.validation.amountRequired" }
|
|
288
317
|
});
|
|
289
318
|
}
|
|
290
|
-
const min =
|
|
291
|
-
const max =
|
|
292
|
-
|
|
293
|
-
if (amount < min || max != null && amount > max) {
|
|
319
|
+
const min = parseDecimal(link.customAmountMin);
|
|
320
|
+
const max = parseDecimal(link.customAmountMax);
|
|
321
|
+
if (min && submitted.lt(min) || !min && submitted.lt(0) || max && submitted.gt(max)) {
|
|
294
322
|
throw new CrudHttpError(422, {
|
|
295
323
|
error: "checkout.payPage.validation.fixErrors",
|
|
296
324
|
fieldErrors: { amount: "checkout.payPage.errors.submit" }
|
|
297
325
|
});
|
|
298
326
|
}
|
|
299
|
-
return
|
|
327
|
+
return withAmount(submitted, link.customAmountCurrencyCode, null);
|
|
300
328
|
}
|
|
301
329
|
const selectedPriceItem = (link.priceListItems ?? []).find((item) => item.id === input.selectedPriceItemId);
|
|
302
330
|
if (!selectedPriceItem) {
|
|
@@ -305,13 +333,18 @@ function resolveSubmittedAmount(link, input) {
|
|
|
305
333
|
fieldErrors: { selectedPriceItemId: "checkout.payPage.validation.priceSelectionRequired" }
|
|
306
334
|
});
|
|
307
335
|
}
|
|
308
|
-
|
|
336
|
+
const itemAmount = parseDecimal(resolveExactDecimal(selectedPriceItem.amountExact, selectedPriceItem.amount));
|
|
337
|
+
if (!itemAmount || input.amount != null && (!submitted || !submitted.eq(itemAmount))) {
|
|
309
338
|
throw new CrudHttpError(422, { error: "checkout.payPage.errors.submit" });
|
|
310
339
|
}
|
|
340
|
+
return withAmount(itemAmount, selectedPriceItem.currencyCode, selectedPriceItem.id);
|
|
341
|
+
}
|
|
342
|
+
function withAmount(amount, currencyCode, selectedPriceItemId) {
|
|
311
343
|
return {
|
|
312
|
-
amount:
|
|
313
|
-
|
|
314
|
-
|
|
344
|
+
amount: decimalToNumber(amount),
|
|
345
|
+
amountExact: decimalToString(amount),
|
|
346
|
+
currencyCode,
|
|
347
|
+
selectedPriceItemId
|
|
315
348
|
};
|
|
316
349
|
}
|
|
317
350
|
function serializeTemplateOrLink(record) {
|
|
@@ -331,11 +364,15 @@ function serializeTemplateOrLink(record) {
|
|
|
331
364
|
themeMode: record.themeMode,
|
|
332
365
|
pricingMode: record.pricingMode,
|
|
333
366
|
fixedPriceAmount: toMoneyNumber(record.fixedPriceAmount),
|
|
367
|
+
fixedPriceAmountExact: toMoneyString(record.fixedPriceAmount),
|
|
334
368
|
fixedPriceCurrencyCode: record.fixedPriceCurrencyCode ?? null,
|
|
335
369
|
fixedPriceIncludesTax: record.fixedPriceIncludesTax,
|
|
336
370
|
fixedPriceOriginalAmount: toMoneyNumber(record.fixedPriceOriginalAmount),
|
|
371
|
+
fixedPriceOriginalAmountExact: toMoneyString(record.fixedPriceOriginalAmount),
|
|
337
372
|
customAmountMin: toMoneyNumber(record.customAmountMin),
|
|
373
|
+
customAmountMinExact: toMoneyString(record.customAmountMin),
|
|
338
374
|
customAmountMax: toMoneyNumber(record.customAmountMax),
|
|
375
|
+
customAmountMaxExact: toMoneyString(record.customAmountMax),
|
|
339
376
|
customAmountCurrencyCode: record.customAmountCurrencyCode ?? null,
|
|
340
377
|
priceListItems: record.priceListItems ?? [],
|
|
341
378
|
gatewayProviderKey: record.gatewayProviderKey ?? null,
|
|
@@ -390,11 +427,15 @@ function serializePublicPayLink(record) {
|
|
|
390
427
|
themeMode: record.themeMode,
|
|
391
428
|
pricingMode: record.pricingMode,
|
|
392
429
|
fixedPriceAmount: toMoneyNumber(record.fixedPriceAmount),
|
|
430
|
+
fixedPriceAmountExact: toMoneyString(record.fixedPriceAmount),
|
|
393
431
|
fixedPriceCurrencyCode: record.fixedPriceCurrencyCode ?? null,
|
|
394
432
|
fixedPriceIncludesTax: record.fixedPriceIncludesTax,
|
|
395
433
|
fixedPriceOriginalAmount: toMoneyNumber(record.fixedPriceOriginalAmount),
|
|
434
|
+
fixedPriceOriginalAmountExact: toMoneyString(record.fixedPriceOriginalAmount),
|
|
396
435
|
customAmountMin: toMoneyNumber(record.customAmountMin),
|
|
436
|
+
customAmountMinExact: toMoneyString(record.customAmountMin),
|
|
397
437
|
customAmountMax: toMoneyNumber(record.customAmountMax),
|
|
438
|
+
customAmountMaxExact: toMoneyString(record.customAmountMax),
|
|
398
439
|
customAmountCurrencyCode: record.customAmountCurrencyCode ?? null,
|
|
399
440
|
priceListItems: record.priceListItems ?? [],
|
|
400
441
|
gatewayProviderKey: record.gatewayProviderKey ?? null,
|
|
@@ -419,6 +460,7 @@ function serializeTransaction(record, link, includePii = false) {
|
|
|
419
460
|
linkName: link?.name ?? null,
|
|
420
461
|
linkSlug: link?.slug ?? null,
|
|
421
462
|
amount: toMoneyNumber(record.amount),
|
|
463
|
+
amountExact: toMoneyString(record.amount),
|
|
422
464
|
currencyCode: record.currencyCode,
|
|
423
465
|
status: record.status,
|
|
424
466
|
paymentStatus: record.paymentStatus ?? null,
|
|
@@ -437,6 +479,7 @@ function serializeTransaction(record, link, includePii = false) {
|
|
|
437
479
|
};
|
|
438
480
|
}
|
|
439
481
|
export {
|
|
482
|
+
CHECKOUT_MONEY_FIELDS,
|
|
440
483
|
applyTerminalTransactionState,
|
|
441
484
|
buildCheckoutAttachmentPreviewUrl2 as buildCheckoutAttachmentPreviewUrl,
|
|
442
485
|
buildConsentProof,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/checkout/lib/utils.ts"],
|
|
4
|
-
"sourcesContent": ["import { createHmac, timingSafeEqual } from 'crypto'\nimport bcrypt from 'bcryptjs'\nimport { slugify } from '@open-mercato/shared/lib/slugify'\nimport { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'\nimport { normalizeCustomFieldResponse } from '@open-mercato/shared/lib/custom-fields/normalize'\nimport { parseDecryptedFieldValue } from '@open-mercato/shared/lib/encryption/tenantDataEncryptionService'\nimport type { EntityManager } from '@mikro-orm/postgresql'\nimport { getPaymentGatewayDescriptor } from '@open-mercato/shared/modules/payment_gateways/types'\nimport { CheckoutLink, CheckoutLinkTemplate, CheckoutTransaction } from '../data/entities'\nimport { buildCheckoutAttachmentPreviewUrl, normalizeOptionalString } from './client-utils'\nimport type {\n CreateLinkInput,\n CreateTemplateInput,\n PublicSubmitInput,\n UpdateLinkInput,\n UpdateTemplateInput,\n} from '../data/validators'\nimport { CHECKOUT_TERMINAL_STATUSES } from './constants'\nexport {\n getCheckoutCustomerFieldSemanticType,\n isValidCheckoutEmail,\n isValidCheckoutPhone,\n validateCheckoutCustomerData,\n} from './customerDataValidation'\n\nexport type CheckoutScope = {\n organizationId: string\n tenantId: string\n}\n\nexport type CheckoutLinkStatus = 'draft' | 'active' | 'inactive'\n\nexport type CheckoutPayloadWithCustomFields<TInput> = {\n parsed: TInput\n customFields: Record<string, unknown>\n}\n\ntype TemplateOrLinkInput =\n | CreateTemplateInput\n | UpdateTemplateInput\n | CreateLinkInput\n | UpdateLinkInput\n\ntype TemplateOrLinkMutationInput = Omit<CreateLinkInput, 'password'> & {\n password?: string | null\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return !!value && typeof value === 'object' && !Array.isArray(value)\n}\n\nfunction isCheckoutLinkRecord(record: CheckoutLinkTemplate | CheckoutLink): record is CheckoutLink {\n return typeof (record as { slug?: unknown }).slug === 'string'\n}\n\nfunction normalizeMaybeStringifiedJsonObject(value: unknown): Record<string, unknown> {\n if (isRecord(value)) return value\n if (typeof value !== 'string') return {}\n\n const parsed = parseDecryptedFieldValue(value)\n return isRecord(parsed) ? parsed : {}\n}\n\nexport function pickExplicitParsedOverrides<TInput extends Record<string, unknown>>(\n rawInput: unknown,\n parsed: TInput,\n): Partial<TInput> {\n if (!isRecord(rawInput)) return {}\n\n const overrides: Partial<TInput> = {}\n for (const key of Object.keys(parsed) as Array<keyof TInput>) {\n if (!Object.prototype.hasOwnProperty.call(rawInput, key)) continue\n overrides[key] = parsed[key]\n }\n\n return overrides\n}\n\nexport function requireCheckoutScope(input: { auth?: { orgId?: string | null; tenantId?: string | null } | null }): CheckoutScope {\n const organizationId = input.auth?.orgId ?? null\n const tenantId = input.auth?.tenantId ?? null\n if (!organizationId || !tenantId) {\n throw new CrudHttpError(401, { error: 'Unauthorized' })\n }\n return { organizationId, tenantId }\n}\n\nexport function parseCheckoutInput<TInput>(raw: unknown, parser: (value: unknown) => TInput): CheckoutPayloadWithCustomFields<TInput> {\n const source = isRecord(raw) ? { ...raw } : {}\n const customFields = isRecord(source.customFields) ? source.customFields : {}\n delete source.customFields\n return {\n parsed: parser(source),\n customFields,\n }\n}\n\nexport function resolveLoadedCheckoutCustomFields(\n values: Record<string, unknown> | null | undefined,\n): Record<string, unknown> {\n return normalizeCustomFieldResponse(values) ?? {}\n}\n\nexport function toIsoString(value: unknown): string | null {\n if (!value) return null\n if (value instanceof Date) return value.toISOString()\n const parsed = new Date(value as string | number)\n return Number.isNaN(parsed.getTime()) ? null : parsed.toISOString()\n}\n\nexport function toMoneyNumber(value: string | number | null | undefined): number | null {\n if (value == null) return null\n const numeric = Number(value)\n return Number.isFinite(numeric) ? numeric : null\n}\n\nexport function toMoneyString(value: string | number | null | undefined): string | null {\n const numeric = toMoneyNumber(value)\n return numeric == null ? null : numeric.toFixed(2)\n}\n\nexport { normalizeOptionalString, buildCheckoutAttachmentPreviewUrl } from './client-utils'\n\nfunction normalizeJsonRecord(value: unknown): Record<string, unknown> {\n if (!value) return {}\n if (typeof value === 'object' && !Array.isArray(value)) return value as Record<string, unknown>\n if (typeof value !== 'string') return {}\n try {\n const parsed = JSON.parse(value)\n return parsed && typeof parsed === 'object' && !Array.isArray(parsed)\n ? parsed as Record<string, unknown>\n : {}\n } catch {\n return {}\n }\n}\n\nexport function deriveConfiguredCurrencies(input: TemplateOrLinkInput): string[] {\n const currencies = new Set<string>()\n if (input.pricingMode === 'fixed' && input.fixedPriceCurrencyCode) currencies.add(input.fixedPriceCurrencyCode)\n if (input.pricingMode === 'custom_amount' && input.customAmountCurrencyCode) currencies.add(input.customAmountCurrencyCode)\n if (input.pricingMode === 'price_list') {\n for (const item of input.priceListItems ?? []) currencies.add(item.currencyCode)\n }\n return Array.from(currencies)\n}\n\nexport function toTemplateOrLinkMutationInput(\n record: CheckoutLinkTemplate | CheckoutLink,\n overrides: Partial<TemplateOrLinkMutationInput> = {},\n): TemplateOrLinkMutationInput {\n return {\n name: record.name,\n title: record.title ?? null,\n subtitle: record.subtitle ?? null,\n description: record.description ?? null,\n logoAttachmentId: record.logoAttachmentId ?? null,\n logoUrl: record.logoUrl ?? null,\n primaryColor: record.primaryColor ?? null,\n secondaryColor: record.secondaryColor ?? null,\n backgroundColor: record.backgroundColor ?? null,\n themeMode: record.themeMode,\n pricingMode: record.pricingMode,\n fixedPriceAmount: toMoneyNumber(record.fixedPriceAmount),\n fixedPriceCurrencyCode: record.fixedPriceCurrencyCode ?? null,\n fixedPriceIncludesTax: record.fixedPriceIncludesTax,\n fixedPriceOriginalAmount: toMoneyNumber(record.fixedPriceOriginalAmount),\n customAmountMin: toMoneyNumber(record.customAmountMin),\n customAmountMax: toMoneyNumber(record.customAmountMax),\n customAmountCurrencyCode: record.customAmountCurrencyCode ?? null,\n priceListItems: record.priceListItems ?? null,\n gatewayProviderKey: record.gatewayProviderKey ?? '',\n gatewaySettings: normalizeJsonRecord(record.gatewaySettings),\n customFieldsetCode: record.customFieldsetCode ?? null,\n collectCustomerDetails: record.collectCustomerDetails,\n customerFieldsSchema: (record.customerFieldsSchema ?? []) as CreateTemplateInput['customerFieldsSchema'],\n legalDocuments: (record.legalDocuments ?? undefined) as CreateTemplateInput['legalDocuments'],\n displayCustomFieldsOnPage: record.displayCustomFieldsOnPage,\n successTitle: record.successTitle ?? null,\n successMessage: record.successMessage ?? null,\n cancelTitle: record.cancelTitle ?? null,\n cancelMessage: record.cancelMessage ?? null,\n errorTitle: record.errorTitle ?? null,\n errorMessage: record.errorMessage ?? null,\n successEmailSubject: record.successEmailSubject ?? null,\n successEmailBody: record.successEmailBody ?? null,\n sendSuccessEmail: record.sendSuccessEmail,\n errorEmailSubject: record.errorEmailSubject ?? null,\n errorEmailBody: record.errorEmailBody ?? null,\n sendErrorEmail: record.sendErrorEmail,\n startEmailSubject: record.startEmailSubject ?? null,\n startEmailBody: record.startEmailBody ?? null,\n sendStartEmail: record.sendStartEmail,\n password: undefined,\n maxCompletions: record.maxCompletions ?? null,\n status: record.status,\n checkoutType: record.checkoutType,\n ...(isCheckoutLinkRecord(record) ? { slug: record.slug, templateId: record.templateId ?? null } : {}),\n ...overrides,\n }\n}\n\nexport function validateDescriptorCurrencies(providerKey: string | null | undefined, currencies: string[]): void {\n if (!providerKey || currencies.length === 0) return\n const descriptor = getPaymentGatewayDescriptor(providerKey)\n const supported = descriptor?.sessionConfig?.supportedCurrencies\n if (!descriptor || !supported || supported === '*') return\n const unsupported = currencies.filter((currency) => !supported.includes(currency))\n if (unsupported.length > 0) {\n throw new CrudHttpError(422, {\n error: `Unsupported currency for provider ${providerKey}: ${unsupported.join(', ')}`,\n })\n }\n}\n\n/**\n * Generates a unique checkout link slug.\n *\n * NOTE: The slug uniqueness check runs GLOBALLY against all checkout links, and the\n * `scope` parameter is intentionally ignored. This is required because the public-facing\n * checkout routes (e.g., `/pay/[slug]`) do not have any tenant/organization discriminator\n * in their URL path, resolving links solely by the slug. Consequently, duplicate slugs\n * cannot exist across different tenants.\n *\n * @param em MikroORM EntityManager\n * @param _scope Tenant and organization scope (ignored in database query)\n * @param requestedSlug The slug requested by the user\n * @param fallbackText The title/name used to generate the slug if requestedSlug is empty\n * @param excludeId Optional ID of the checkout link to exclude from the duplicate check\n */\nexport async function ensureUniqueSlug(\n em: EntityManager,\n _scope: CheckoutScope,\n requestedSlug: string | null | undefined,\n fallbackText: string,\n excludeId?: string | null,\n): Promise<string> {\n const base = slugify(requestedSlug || fallbackText || 'pay-link') || 'pay-link'\n let candidate = base\n let counter = 1\n while (true) {\n const existing = await em.findOne(CheckoutLink, {\n slug: candidate,\n deletedAt: null,\n ...(excludeId ? { id: { $ne: excludeId } } : {}),\n })\n if (!existing) return candidate\n counter += 1\n candidate = `${base}-${counter}`\n }\n}\n\nexport async function hashCheckoutPassword(password: string | null | undefined): Promise<string | null> {\n const normalized = normalizeOptionalString(password)\n if (!normalized) return null\n return bcrypt.hash(normalized, 10)\n}\n\nexport async function verifyCheckoutPassword(password: string, passwordHash: string | null | undefined): Promise<boolean> {\n if (!passwordHash) return false\n return bcrypt.compare(password, passwordHash)\n}\n\nfunction getCheckoutAccessTokenSecret(): string {\n const secret = process.env.AUTH_SECRET\n || process.env.NEXTAUTH_SECRET\n || process.env.JWT_SECRET\n || process.env.TENANT_DATA_ENCRYPTION_FALLBACK_KEY\n if (!secret) {\n throw new Error(\n 'Checkout password sessions require AUTH_SECRET, NEXTAUTH_SECRET, JWT_SECRET, or TENANT_DATA_ENCRYPTION_FALLBACK_KEY',\n )\n }\n return secret\n}\n\nfunction normalizeCheckoutAccessSessionVersion(value: Date | string | null | undefined): string | null {\n if (!value) return null\n return value instanceof Date ? value.toISOString() : value\n}\n\n// Derive a non-reversible cookie-safe representation of `sessionVersion`\n// so the embedded payload never exposes the raw input (typically the\n// checkout link's bcrypt passwordHash \u2014 see #2675). The HMAC keeps\n// rotation semantics intact: any change to the input produces a fresh\n// digest, invalidating outstanding cookies.\nfunction deriveCheckoutAccessSessionVersion(value: Date | string | null | undefined): string | null {\n const normalized = normalizeCheckoutAccessSessionVersion(value)\n if (normalized == null) return null\n return createHmac('sha256', getCheckoutAccessTokenSecret()).update(normalized).digest('base64url')\n}\n\nexport function signCheckoutAccessToken(\n slug: string,\n options?: { linkId?: string | null; sessionVersion?: Date | string | null },\n): string {\n const payload = Buffer.from(JSON.stringify({\n slug,\n linkId: options?.linkId ?? null,\n sessionVersion: deriveCheckoutAccessSessionVersion(options?.sessionVersion),\n exp: Date.now() + (60 * 60 * 1000),\n }), 'utf-8').toString('base64url')\n const signature = createHmac('sha256', getCheckoutAccessTokenSecret()).update(payload).digest('base64url')\n return `${payload}.${signature}`\n}\n\nexport function verifyCheckoutAccessToken(\n token: string | null | undefined,\n slug: string,\n options?: { linkId?: string | null; sessionVersion?: Date | string | null },\n): boolean {\n if (!token) return false\n const [payload, signature] = token.split('.')\n if (!payload || !signature) return false\n const expected = createHmac('sha256', getCheckoutAccessTokenSecret()).update(payload).digest()\n const actual = Buffer.from(signature, 'base64url')\n if (expected.length !== actual.length || !timingSafeEqual(expected, actual)) return false\n try {\n const parsed = JSON.parse(Buffer.from(payload, 'base64url').toString('utf-8')) as {\n slug?: string\n linkId?: string | null\n sessionVersion?: string | null\n exp?: number\n }\n if (parsed.slug !== slug || typeof parsed.exp !== 'number' || parsed.exp <= Date.now()) return false\n if (options?.linkId && parsed.linkId !== options.linkId) return false\n if (options?.sessionVersion) {\n return parsed.sessionVersion === deriveCheckoutAccessSessionVersion(options.sessionVersion)\n }\n return true\n } catch {\n return false\n }\n}\n\nexport function mapGatewayStatusToCheckoutStatus(status: string | null | undefined): CheckoutTransaction['status'] {\n if (status === 'captured' || status === 'authorized') return 'completed'\n if (status === 'cancelled') return 'cancelled'\n if (status === 'expired') return 'expired'\n if (status === 'failed') return 'failed'\n return 'processing'\n}\n\nexport function isTerminalCheckoutStatus(status: string | null | undefined): boolean {\n return typeof status === 'string' && CHECKOUT_TERMINAL_STATUSES.has(status)\n}\n\nexport function isCheckoutLinkPublic(status: CheckoutLinkStatus | string | null | undefined): boolean {\n return status === 'active'\n}\n\nexport function applyTerminalTransactionState(\n link: Pick<CheckoutLink, 'activeReservationCount' | 'completionCount' | 'isLocked' | 'maxCompletions'>,\n status: CheckoutTransaction['status'],\n): { usageLimitReached: boolean } {\n link.activeReservationCount = Math.max(0, link.activeReservationCount - 1)\n if (status === 'completed') {\n link.completionCount += 1\n }\n link.isLocked = link.activeReservationCount > 0\n return {\n usageLimitReached: status === 'completed'\n && link.maxCompletions != null\n && link.completionCount >= link.maxCompletions,\n }\n}\n\n// Security model: the consent proof is a GDPR/consent audit trail, so `markdownHash`\n// must be tamper-evident. It is an HMAC keyed with the server-side checkout secret\n// (never a public constant), which an attacker who can edit a stored consent row\n// cannot recompute without the secret. The document key is folded into the HMAC\n// message to namespace each document while keeping a single server-held key.\nexport function computeConsentMarkdownHash(documentKey: string, markdown: string): string {\n return createHmac('sha256', getCheckoutAccessTokenSecret())\n .update(`${documentKey}\\n${markdown}`)\n .digest('hex')\n}\n\nexport function buildConsentProof(link: CheckoutLink, acceptedLegalConsents: PublicSubmitInput['acceptedLegalConsents']) {\n const proof: Record<string, unknown> = {}\n const legalDocuments = link.legalDocuments && typeof link.legalDocuments === 'object'\n ? link.legalDocuments as Record<string, { title?: string; markdown?: string; required?: boolean }>\n : {}\n for (const key of ['terms', 'privacyPolicy']) {\n const document = legalDocuments[key]\n if (!document?.markdown) continue\n const accepted = acceptedLegalConsents?.[key as keyof PublicSubmitInput['acceptedLegalConsents']] === true\n if (!accepted) continue\n proof[key] = {\n title: document.title ?? key,\n required: document.required === true,\n acceptedAt: new Date().toISOString(),\n markdownHash: computeConsentMarkdownHash(key, document.markdown),\n }\n }\n return proof\n}\n\nexport function resolveSubmittedAmount(link: CheckoutLink, input: PublicSubmitInput): { amount: number; currencyCode: string; selectedPriceItemId: string | null } {\n if (link.pricingMode === 'fixed') {\n const expected = toMoneyNumber(link.fixedPriceAmount)\n if (expected == null || !link.fixedPriceCurrencyCode) {\n throw new CrudHttpError(422, { error: 'checkout.payPage.errors.submit' })\n }\n if (input.amount != null && Number(input.amount) !== expected) {\n throw new CrudHttpError(422, { error: 'checkout.payPage.errors.submit' })\n }\n return { amount: expected, currencyCode: link.fixedPriceCurrencyCode, selectedPriceItemId: null }\n }\n if (link.pricingMode === 'custom_amount') {\n if (input.amount == null || !link.customAmountCurrencyCode) {\n throw new CrudHttpError(422, {\n error: 'checkout.payPage.validation.fixErrors',\n fieldErrors: { amount: 'checkout.payPage.validation.amountRequired' },\n })\n }\n const min = toMoneyNumber(link.customAmountMin) ?? 0\n const max = toMoneyNumber(link.customAmountMax)\n const amount = Number(input.amount)\n if (amount < min || (max != null && amount > max)) {\n throw new CrudHttpError(422, {\n error: 'checkout.payPage.validation.fixErrors',\n fieldErrors: { amount: 'checkout.payPage.errors.submit' },\n })\n }\n return { amount, currencyCode: link.customAmountCurrencyCode, selectedPriceItemId: null }\n }\n const selectedPriceItem = (link.priceListItems ?? []).find((item) => item.id === input.selectedPriceItemId)\n if (!selectedPriceItem) {\n throw new CrudHttpError(422, {\n error: 'checkout.payPage.validation.fixErrors',\n fieldErrors: { selectedPriceItemId: 'checkout.payPage.validation.priceSelectionRequired' },\n })\n }\n if (input.amount != null && Number(input.amount) !== Number(selectedPriceItem.amount)) {\n throw new CrudHttpError(422, { error: 'checkout.payPage.errors.submit' })\n }\n return {\n amount: Number(selectedPriceItem.amount),\n currencyCode: selectedPriceItem.currencyCode,\n selectedPriceItemId: selectedPriceItem.id,\n }\n}\n\nexport function serializeTemplateOrLink(record: CheckoutLinkTemplate | CheckoutLink) {\n const logoPreviewUrl = buildCheckoutAttachmentPreviewUrl(record.logoAttachmentId) ?? record.logoUrl ?? null\n return {\n id: record.id,\n name: record.name,\n title: record.title ?? null,\n subtitle: record.subtitle ?? null,\n description: record.description ?? null,\n logoAttachmentId: record.logoAttachmentId ?? null,\n logoUrl: record.logoUrl ?? null,\n logoPreviewUrl,\n primaryColor: record.primaryColor ?? null,\n secondaryColor: record.secondaryColor ?? null,\n backgroundColor: record.backgroundColor ?? null,\n themeMode: record.themeMode,\n pricingMode: record.pricingMode,\n fixedPriceAmount: toMoneyNumber(record.fixedPriceAmount),\n fixedPriceCurrencyCode: record.fixedPriceCurrencyCode ?? null,\n fixedPriceIncludesTax: record.fixedPriceIncludesTax,\n fixedPriceOriginalAmount: toMoneyNumber(record.fixedPriceOriginalAmount),\n customAmountMin: toMoneyNumber(record.customAmountMin),\n customAmountMax: toMoneyNumber(record.customAmountMax),\n customAmountCurrencyCode: record.customAmountCurrencyCode ?? null,\n priceListItems: record.priceListItems ?? [],\n gatewayProviderKey: record.gatewayProviderKey ?? null,\n gatewaySettings: normalizeJsonRecord(record.gatewaySettings),\n customFieldsetCode: record.customFieldsetCode ?? null,\n collectCustomerDetails: record.collectCustomerDetails,\n customerFieldsSchema: record.customerFieldsSchema ?? [],\n legalDocuments: record.legalDocuments ?? {},\n displayCustomFieldsOnPage: record.displayCustomFieldsOnPage,\n successTitle: record.successTitle ?? null,\n successMessage: record.successMessage ?? null,\n cancelTitle: record.cancelTitle ?? null,\n cancelMessage: record.cancelMessage ?? null,\n errorTitle: record.errorTitle ?? null,\n errorMessage: record.errorMessage ?? null,\n successEmailSubject: record.successEmailSubject ?? null,\n successEmailBody: record.successEmailBody ?? null,\n sendSuccessEmail: record.sendSuccessEmail,\n errorEmailSubject: record.errorEmailSubject ?? null,\n errorEmailBody: record.errorEmailBody ?? null,\n sendErrorEmail: record.sendErrorEmail,\n startEmailSubject: record.startEmailSubject ?? null,\n startEmailBody: record.startEmailBody ?? null,\n sendStartEmail: record.sendStartEmail,\n maxCompletions: record.maxCompletions ?? null,\n status: record.status,\n checkoutType: record.checkoutType,\n createdAt: toIsoString(record.createdAt),\n updatedAt: toIsoString(record.updatedAt),\n ...(isCheckoutLinkRecord(record) ? {\n slug: record.slug,\n templateId: record.templateId ?? null,\n completionCount: record.completionCount,\n activeReservationCount: record.activeReservationCount,\n isLocked: record.isLocked,\n } : {}),\n }\n}\n\nexport function serializePublicPayLink(record: CheckoutLink) {\n return {\n id: record.id,\n slug: record.slug,\n name: record.name,\n title: record.title ?? null,\n subtitle: record.subtitle ?? null,\n description: record.description ?? null,\n logoUrl: record.logoUrl ?? null,\n logoPreviewUrl: buildCheckoutAttachmentPreviewUrl(record.logoAttachmentId) ?? record.logoUrl ?? null,\n primaryColor: record.primaryColor ?? null,\n secondaryColor: record.secondaryColor ?? null,\n backgroundColor: record.backgroundColor ?? null,\n themeMode: record.themeMode,\n pricingMode: record.pricingMode,\n fixedPriceAmount: toMoneyNumber(record.fixedPriceAmount),\n fixedPriceCurrencyCode: record.fixedPriceCurrencyCode ?? null,\n fixedPriceIncludesTax: record.fixedPriceIncludesTax,\n fixedPriceOriginalAmount: toMoneyNumber(record.fixedPriceOriginalAmount),\n customAmountMin: toMoneyNumber(record.customAmountMin),\n customAmountMax: toMoneyNumber(record.customAmountMax),\n customAmountCurrencyCode: record.customAmountCurrencyCode ?? null,\n priceListItems: record.priceListItems ?? [],\n gatewayProviderKey: record.gatewayProviderKey ?? null,\n collectCustomerDetails: record.collectCustomerDetails,\n customerFieldsSchema: record.customerFieldsSchema ?? [],\n legalDocuments: record.legalDocuments ?? {},\n displayCustomFieldsOnPage: record.displayCustomFieldsOnPage,\n successTitle: record.successTitle ?? null,\n successMessage: record.successMessage ?? null,\n cancelTitle: record.cancelTitle ?? null,\n cancelMessage: record.cancelMessage ?? null,\n errorTitle: record.errorTitle ?? null,\n errorMessage: record.errorMessage ?? null,\n status: record.status,\n checkoutType: record.checkoutType,\n }\n}\n\nexport function serializeTransaction(record: CheckoutTransaction, link?: CheckoutLink | null, includePii = false) {\n return {\n id: record.id,\n linkId: record.linkId,\n linkName: link?.name ?? null,\n linkSlug: link?.slug ?? null,\n amount: toMoneyNumber(record.amount),\n currencyCode: record.currencyCode,\n status: record.status,\n paymentStatus: record.paymentStatus ?? null,\n gatewayTransactionId: record.gatewayTransactionId ?? null,\n selectedPriceItemId: record.selectedPriceItemId ?? null,\n acceptedLegalConsents: includePii ? normalizeMaybeStringifiedJsonObject(record.acceptedLegalConsents) : null,\n customerData: includePii ? normalizeMaybeStringifiedJsonObject(record.customerData) : null,\n firstName: includePii ? (record.firstName ?? null) : null,\n lastName: includePii ? (record.lastName ?? null) : null,\n email: includePii ? (record.email ?? null) : null,\n phone: includePii ? (record.phone ?? null) : null,\n ipAddress: includePii ? (record.ipAddress ?? null) : null,\n userAgent: includePii ? (record.userAgent ?? null) : null,\n createdAt: toIsoString(record.createdAt),\n updatedAt: toIsoString(record.updatedAt),\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,YAAY,uBAAuB;AAC5C,OAAO,YAAY;AACnB,SAAS,eAAe;AACxB,SAAS,qBAAqB;AAC9B,SAAS,oCAAoC;AAC7C,SAAS,gCAAgC;AAEzC,SAAS,mCAAmC;AAC5C,SAAS,oBAA+D;AACxE,SAAS,mCAAmC,+BAA+B;AAQ3E,SAAS,kCAAkC;AAC3C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAwBP,SAAS,SAAS,OAAkD;AAClE,SAAO,CAAC,CAAC,SAAS,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK;AACrE;AAEA,SAAS,qBAAqB,QAAqE;AACjG,SAAO,OAAQ,OAA8B,SAAS;AACxD;AAEA,SAAS,oCAAoC,OAAyC;AACpF,MAAI,SAAS,KAAK,EAAG,QAAO;AAC5B,MAAI,OAAO,UAAU,SAAU,QAAO,CAAC;AAEvC,QAAM,SAAS,yBAAyB,KAAK;AAC7C,SAAO,SAAS,MAAM,IAAI,SAAS,CAAC;AACtC;AAEO,SAAS,4BACd,UACA,QACiB;AACjB,MAAI,CAAC,SAAS,QAAQ,EAAG,QAAO,CAAC;AAEjC,QAAM,YAA6B,CAAC;AACpC,aAAW,OAAO,OAAO,KAAK,MAAM,GAA0B;AAC5D,QAAI,CAAC,OAAO,UAAU,eAAe,KAAK,UAAU,GAAG,EAAG;AAC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A,IACnD,uBAAuB,aAAa,oCAAoC,OAAO,qBAAqB,IAAI;AAAA,IACxG,cAAc,aAAa,oCAAoC,OAAO,YAAY,IAAI;AAAA,IACtF,WAAW,aAAc,OAAO,aAAa,OAAQ;AAAA,IACrD,UAAU,aAAc,OAAO,YAAY,OAAQ;AAAA,IACnD,OAAO,aAAc,OAAO,SAAS,OAAQ;AAAA,IAC7C,OAAO,aAAc,OAAO,SAAS,OAAQ;AAAA,IAC7C,WAAW,aAAc,OAAO,aAAa,OAAQ;AAAA,IACrD,WAAW,aAAc,OAAO,aAAa,OAAQ;AAAA,IACrD,WAAW,YAAY,OAAO,SAAS;AAAA,IACvC,WAAW,YAAY,OAAO,SAAS;AAAA,EACzC;AACF;",
|
|
4
|
+
"sourcesContent": ["import { createHmac, timingSafeEqual } from 'crypto'\nimport bcrypt from 'bcryptjs'\nimport { slugify } from '@open-mercato/shared/lib/slugify'\nimport { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'\nimport {\n decimalToNumber,\n decimalToString,\n parseDecimal,\n resolveExactDecimal,\n withExactAmounts,\n type WithExactAmounts,\n} from '@open-mercato/shared/lib/decimal'\nimport { normalizeCustomFieldResponse } from '@open-mercato/shared/lib/custom-fields/normalize'\nimport { parseDecryptedFieldValue } from '@open-mercato/shared/lib/encryption/tenantDataEncryptionService'\nimport type { EntityManager } from '@mikro-orm/postgresql'\nimport { getPaymentGatewayDescriptor } from '@open-mercato/shared/modules/payment_gateways/types'\nimport { CheckoutLink, CheckoutLinkTemplate, CheckoutTransaction } from '../data/entities'\nimport { buildCheckoutAttachmentPreviewUrl, normalizeOptionalString } from './client-utils'\nimport {\n assertExactCustomAmountRange,\n type CreateLinkInput,\n type CreateTemplateInput,\n type PublicSubmitInput,\n type UpdateLinkInput,\n type UpdateTemplateInput,\n} from '../data/validators'\nimport { CHECKOUT_TERMINAL_STATUSES } from './constants'\nexport {\n getCheckoutCustomerFieldSemanticType,\n isValidCheckoutEmail,\n isValidCheckoutPhone,\n validateCheckoutCustomerData,\n} from './customerDataValidation'\n\nexport type CheckoutScope = {\n organizationId: string\n tenantId: string\n}\n\nexport type CheckoutLinkStatus = 'draft' | 'active' | 'inactive'\n\nexport const CHECKOUT_MONEY_FIELDS = [\n 'fixedPriceAmount',\n 'fixedPriceOriginalAmount',\n 'customAmountMin',\n 'customAmountMax',\n 'amount',\n] as const\n\nexport type CheckoutMoneyField = (typeof CHECKOUT_MONEY_FIELDS)[number]\n\nexport type CheckoutPayloadWithCustomFields<TInput> = {\n parsed: WithExactAmounts<TInput, CheckoutMoneyField>\n customFields: Record<string, unknown>\n}\n\ntype TemplateOrLinkInput =\n | CreateTemplateInput\n | UpdateTemplateInput\n | CreateLinkInput\n | UpdateLinkInput\n\ntype TemplateOrLinkMutationInput = Omit<CreateLinkInput, 'password'> & {\n password?: string | null\n fixedPriceAmountExact?: string | null\n fixedPriceOriginalAmountExact?: string | null\n customAmountMinExact?: string | null\n customAmountMaxExact?: string | null\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return !!value && typeof value === 'object' && !Array.isArray(value)\n}\n\nfunction isCheckoutLinkRecord(record: CheckoutLinkTemplate | CheckoutLink): record is CheckoutLink {\n return typeof (record as { slug?: unknown }).slug === 'string'\n}\n\nfunction normalizeMaybeStringifiedJsonObject(value: unknown): Record<string, unknown> {\n if (isRecord(value)) return value\n if (typeof value !== 'string') return {}\n\n const parsed = parseDecryptedFieldValue(value)\n return isRecord(parsed) ? parsed : {}\n}\n\nexport function pickExplicitParsedOverrides<TInput extends Record<string, unknown>>(\n rawInput: unknown,\n parsed: TInput,\n): Partial<TInput> {\n if (!isRecord(rawInput)) return {}\n\n const overrides: Partial<TInput> = {}\n for (const key of Object.keys(parsed) as Array<keyof TInput & string>) {\n const sourceKey = key.endsWith('Exact') ? key.slice(0, -'Exact'.length) : key\n if (!Object.prototype.hasOwnProperty.call(rawInput, key) && !Object.prototype.hasOwnProperty.call(rawInput, sourceKey)) continue\n overrides[key] = parsed[key]\n }\n\n return overrides\n}\n\nexport function requireCheckoutScope(input: { auth?: { orgId?: string | null; tenantId?: string | null } | null }): CheckoutScope {\n const organizationId = input.auth?.orgId ?? null\n const tenantId = input.auth?.tenantId ?? null\n if (!organizationId || !tenantId) {\n throw new CrudHttpError(401, { error: 'Unauthorized' })\n }\n return { organizationId, tenantId }\n}\n\nexport function parseCheckoutInput<TInput>(raw: unknown, parser: (value: unknown) => TInput): CheckoutPayloadWithCustomFields<TInput> {\n const source = isRecord(raw) ? { ...raw } : {}\n const customFields = isRecord(source.customFields) ? source.customFields : {}\n delete source.customFields\n const parsed = withExactAmounts(parser(source) as TInput & object, source, CHECKOUT_MONEY_FIELDS)\n const items = (parsed as { priceListItems?: unknown }).priceListItems\n if (Array.isArray(items)) {\n const rawItems = Array.isArray(source.priceListItems) ? source.priceListItems : []\n ;(parsed as { priceListItems?: unknown }).priceListItems = items.map((item, index) =>\n isRecord(item) ? withExactAmounts(item, rawItems[index], ['amount'] as const) : item,\n )\n }\n assertExactCustomAmountRange(parsed)\n return { parsed, customFields }\n}\n\nexport function resolveLoadedCheckoutCustomFields(\n values: Record<string, unknown> | null | undefined,\n): Record<string, unknown> {\n return normalizeCustomFieldResponse(values) ?? {}\n}\n\nexport function toIsoString(value: unknown): string | null {\n if (!value) return null\n if (value instanceof Date) return value.toISOString()\n const parsed = new Date(value as string | number)\n return Number.isNaN(parsed.getTime()) ? null : parsed.toISOString()\n}\n\nexport function toMoneyNumber(value: string | number | null | undefined): number | null {\n if (value == null) return null\n const numeric = Number(value)\n return Number.isFinite(numeric) ? numeric : null\n}\n\n/** Exact decimal string for a money column (no rounding, no padding), or `null`. */\nexport function toMoneyString(value: string | number | null | undefined): string | null {\n const parsed = parseDecimal(value)\n return parsed ? decimalToString(parsed) : null\n}\n\nexport { normalizeOptionalString, buildCheckoutAttachmentPreviewUrl } from './client-utils'\n\nfunction normalizeJsonRecord(value: unknown): Record<string, unknown> {\n if (!value) return {}\n if (typeof value === 'object' && !Array.isArray(value)) return value as Record<string, unknown>\n if (typeof value !== 'string') return {}\n try {\n const parsed = JSON.parse(value)\n return parsed && typeof parsed === 'object' && !Array.isArray(parsed)\n ? parsed as Record<string, unknown>\n : {}\n } catch {\n return {}\n }\n}\n\nexport function deriveConfiguredCurrencies(input: TemplateOrLinkInput): string[] {\n const currencies = new Set<string>()\n if (input.pricingMode === 'fixed' && input.fixedPriceCurrencyCode) currencies.add(input.fixedPriceCurrencyCode)\n if (input.pricingMode === 'custom_amount' && input.customAmountCurrencyCode) currencies.add(input.customAmountCurrencyCode)\n if (input.pricingMode === 'price_list') {\n for (const item of input.priceListItems ?? []) currencies.add(item.currencyCode)\n }\n return Array.from(currencies)\n}\n\nexport function toTemplateOrLinkMutationInput(\n record: CheckoutLinkTemplate | CheckoutLink,\n overrides: Partial<TemplateOrLinkMutationInput> = {},\n): TemplateOrLinkMutationInput {\n return {\n name: record.name,\n title: record.title ?? null,\n subtitle: record.subtitle ?? null,\n description: record.description ?? null,\n logoAttachmentId: record.logoAttachmentId ?? null,\n logoUrl: record.logoUrl ?? null,\n primaryColor: record.primaryColor ?? null,\n secondaryColor: record.secondaryColor ?? null,\n backgroundColor: record.backgroundColor ?? null,\n themeMode: record.themeMode,\n pricingMode: record.pricingMode,\n fixedPriceAmount: toMoneyNumber(record.fixedPriceAmount),\n fixedPriceAmountExact: toMoneyString(record.fixedPriceAmount),\n fixedPriceCurrencyCode: record.fixedPriceCurrencyCode ?? null,\n fixedPriceIncludesTax: record.fixedPriceIncludesTax,\n fixedPriceOriginalAmount: toMoneyNumber(record.fixedPriceOriginalAmount),\n fixedPriceOriginalAmountExact: toMoneyString(record.fixedPriceOriginalAmount),\n customAmountMin: toMoneyNumber(record.customAmountMin),\n customAmountMinExact: toMoneyString(record.customAmountMin),\n customAmountMax: toMoneyNumber(record.customAmountMax),\n customAmountMaxExact: toMoneyString(record.customAmountMax),\n customAmountCurrencyCode: record.customAmountCurrencyCode ?? null,\n priceListItems: record.priceListItems ?? null,\n gatewayProviderKey: record.gatewayProviderKey ?? '',\n gatewaySettings: normalizeJsonRecord(record.gatewaySettings),\n customFieldsetCode: record.customFieldsetCode ?? null,\n collectCustomerDetails: record.collectCustomerDetails,\n customerFieldsSchema: (record.customerFieldsSchema ?? []) as CreateTemplateInput['customerFieldsSchema'],\n legalDocuments: (record.legalDocuments ?? undefined) as CreateTemplateInput['legalDocuments'],\n displayCustomFieldsOnPage: record.displayCustomFieldsOnPage,\n successTitle: record.successTitle ?? null,\n successMessage: record.successMessage ?? null,\n cancelTitle: record.cancelTitle ?? null,\n cancelMessage: record.cancelMessage ?? null,\n errorTitle: record.errorTitle ?? null,\n errorMessage: record.errorMessage ?? null,\n successEmailSubject: record.successEmailSubject ?? null,\n successEmailBody: record.successEmailBody ?? null,\n sendSuccessEmail: record.sendSuccessEmail,\n errorEmailSubject: record.errorEmailSubject ?? null,\n errorEmailBody: record.errorEmailBody ?? null,\n sendErrorEmail: record.sendErrorEmail,\n startEmailSubject: record.startEmailSubject ?? null,\n startEmailBody: record.startEmailBody ?? null,\n sendStartEmail: record.sendStartEmail,\n password: undefined,\n maxCompletions: record.maxCompletions ?? null,\n status: record.status,\n checkoutType: record.checkoutType,\n ...(isCheckoutLinkRecord(record) ? { slug: record.slug, templateId: record.templateId ?? null } : {}),\n ...overrides,\n }\n}\n\nexport function validateDescriptorCurrencies(providerKey: string | null | undefined, currencies: string[]): void {\n if (!providerKey || currencies.length === 0) return\n const descriptor = getPaymentGatewayDescriptor(providerKey)\n const supported = descriptor?.sessionConfig?.supportedCurrencies\n if (!descriptor || !supported || supported === '*') return\n const unsupported = currencies.filter((currency) => !supported.includes(currency))\n if (unsupported.length > 0) {\n throw new CrudHttpError(422, {\n error: `Unsupported currency for provider ${providerKey}: ${unsupported.join(', ')}`,\n })\n }\n}\n\n/**\n * Generates a unique checkout link slug.\n *\n * NOTE: The slug uniqueness check runs GLOBALLY against all checkout links, and the\n * `scope` parameter is intentionally ignored. This is required because the public-facing\n * checkout routes (e.g., `/pay/[slug]`) do not have any tenant/organization discriminator\n * in their URL path, resolving links solely by the slug. Consequently, duplicate slugs\n * cannot exist across different tenants.\n *\n * @param em MikroORM EntityManager\n * @param _scope Tenant and organization scope (ignored in database query)\n * @param requestedSlug The slug requested by the user\n * @param fallbackText The title/name used to generate the slug if requestedSlug is empty\n * @param excludeId Optional ID of the checkout link to exclude from the duplicate check\n */\nexport async function ensureUniqueSlug(\n em: EntityManager,\n _scope: CheckoutScope,\n requestedSlug: string | null | undefined,\n fallbackText: string,\n excludeId?: string | null,\n): Promise<string> {\n const base = slugify(requestedSlug || fallbackText || 'pay-link') || 'pay-link'\n let candidate = base\n let counter = 1\n while (true) {\n const existing = await em.findOne(CheckoutLink, {\n slug: candidate,\n deletedAt: null,\n ...(excludeId ? { id: { $ne: excludeId } } : {}),\n })\n if (!existing) return candidate\n counter += 1\n candidate = `${base}-${counter}`\n }\n}\n\nexport async function hashCheckoutPassword(password: string | null | undefined): Promise<string | null> {\n const normalized = normalizeOptionalString(password)\n if (!normalized) return null\n return bcrypt.hash(normalized, 10)\n}\n\nexport async function verifyCheckoutPassword(password: string, passwordHash: string | null | undefined): Promise<boolean> {\n if (!passwordHash) return false\n return bcrypt.compare(password, passwordHash)\n}\n\nfunction getCheckoutAccessTokenSecret(): string {\n const secret = process.env.AUTH_SECRET\n || process.env.NEXTAUTH_SECRET\n || process.env.JWT_SECRET\n || process.env.TENANT_DATA_ENCRYPTION_FALLBACK_KEY\n if (!secret) {\n throw new Error(\n 'Checkout password sessions require AUTH_SECRET, NEXTAUTH_SECRET, JWT_SECRET, or TENANT_DATA_ENCRYPTION_FALLBACK_KEY',\n )\n }\n return secret\n}\n\nfunction normalizeCheckoutAccessSessionVersion(value: Date | string | null | undefined): string | null {\n if (!value) return null\n return value instanceof Date ? value.toISOString() : value\n}\n\n// Derive a non-reversible cookie-safe representation of `sessionVersion`\n// so the embedded payload never exposes the raw input (typically the\n// checkout link's bcrypt passwordHash \u2014 see #2675). The HMAC keeps\n// rotation semantics intact: any change to the input produces a fresh\n// digest, invalidating outstanding cookies.\nfunction deriveCheckoutAccessSessionVersion(value: Date | string | null | undefined): string | null {\n const normalized = normalizeCheckoutAccessSessionVersion(value)\n if (normalized == null) return null\n return createHmac('sha256', getCheckoutAccessTokenSecret()).update(normalized).digest('base64url')\n}\n\nexport function signCheckoutAccessToken(\n slug: string,\n options?: { linkId?: string | null; sessionVersion?: Date | string | null },\n): string {\n const payload = Buffer.from(JSON.stringify({\n slug,\n linkId: options?.linkId ?? null,\n sessionVersion: deriveCheckoutAccessSessionVersion(options?.sessionVersion),\n exp: Date.now() + (60 * 60 * 1000),\n }), 'utf-8').toString('base64url')\n const signature = createHmac('sha256', getCheckoutAccessTokenSecret()).update(payload).digest('base64url')\n return `${payload}.${signature}`\n}\n\nexport function verifyCheckoutAccessToken(\n token: string | null | undefined,\n slug: string,\n options?: { linkId?: string | null; sessionVersion?: Date | string | null },\n): boolean {\n if (!token) return false\n const [payload, signature] = token.split('.')\n if (!payload || !signature) return false\n const expected = createHmac('sha256', getCheckoutAccessTokenSecret()).update(payload).digest()\n const actual = Buffer.from(signature, 'base64url')\n if (expected.length !== actual.length || !timingSafeEqual(expected, actual)) return false\n try {\n const parsed = JSON.parse(Buffer.from(payload, 'base64url').toString('utf-8')) as {\n slug?: string\n linkId?: string | null\n sessionVersion?: string | null\n exp?: number\n }\n if (parsed.slug !== slug || typeof parsed.exp !== 'number' || parsed.exp <= Date.now()) return false\n if (options?.linkId && parsed.linkId !== options.linkId) return false\n if (options?.sessionVersion) {\n return parsed.sessionVersion === deriveCheckoutAccessSessionVersion(options.sessionVersion)\n }\n return true\n } catch {\n return false\n }\n}\n\nexport function mapGatewayStatusToCheckoutStatus(status: string | null | undefined): CheckoutTransaction['status'] {\n if (status === 'captured' || status === 'authorized') return 'completed'\n if (status === 'cancelled') return 'cancelled'\n if (status === 'expired') return 'expired'\n if (status === 'failed') return 'failed'\n return 'processing'\n}\n\nexport function isTerminalCheckoutStatus(status: string | null | undefined): boolean {\n return typeof status === 'string' && CHECKOUT_TERMINAL_STATUSES.has(status)\n}\n\nexport function isCheckoutLinkPublic(status: CheckoutLinkStatus | string | null | undefined): boolean {\n return status === 'active'\n}\n\nexport function applyTerminalTransactionState(\n link: Pick<CheckoutLink, 'activeReservationCount' | 'completionCount' | 'isLocked' | 'maxCompletions'>,\n status: CheckoutTransaction['status'],\n): { usageLimitReached: boolean } {\n link.activeReservationCount = Math.max(0, link.activeReservationCount - 1)\n if (status === 'completed') {\n link.completionCount += 1\n }\n link.isLocked = link.activeReservationCount > 0\n return {\n usageLimitReached: status === 'completed'\n && link.maxCompletions != null\n && link.completionCount >= link.maxCompletions,\n }\n}\n\n// Security model: the consent proof is a GDPR/consent audit trail, so `markdownHash`\n// must be tamper-evident. It is an HMAC keyed with the server-side checkout secret\n// (never a public constant), which an attacker who can edit a stored consent row\n// cannot recompute without the secret. The document key is folded into the HMAC\n// message to namespace each document while keeping a single server-held key.\nexport function computeConsentMarkdownHash(documentKey: string, markdown: string): string {\n return createHmac('sha256', getCheckoutAccessTokenSecret())\n .update(`${documentKey}\\n${markdown}`)\n .digest('hex')\n}\n\nexport function buildConsentProof(link: CheckoutLink, acceptedLegalConsents: PublicSubmitInput['acceptedLegalConsents']) {\n const proof: Record<string, unknown> = {}\n const legalDocuments = link.legalDocuments && typeof link.legalDocuments === 'object'\n ? link.legalDocuments as Record<string, { title?: string; markdown?: string; required?: boolean }>\n : {}\n for (const key of ['terms', 'privacyPolicy']) {\n const document = legalDocuments[key]\n if (!document?.markdown) continue\n const accepted = acceptedLegalConsents?.[key as keyof PublicSubmitInput['acceptedLegalConsents']] === true\n if (!accepted) continue\n proof[key] = {\n title: document.title ?? key,\n required: document.required === true,\n acceptedAt: new Date().toISOString(),\n markdownHash: computeConsentMarkdownHash(key, document.markdown),\n }\n }\n return proof\n}\n\n/**\n * The amount a payer is charged, compared exactly against the link configuration.\n * `input.amountExact` (raw request digits) wins over the coerced float when present.\n */\nexport function resolveSubmittedAmount(\n link: CheckoutLink,\n input: PublicSubmitInput & { amountExact?: string | null },\n): { amount: number; amountExact: string; currencyCode: string; selectedPriceItemId: string | null } {\n const submitted = input.amount == null ? null : parseDecimal(resolveExactDecimal(input.amountExact, input.amount))\n if (link.pricingMode === 'fixed') {\n const expected = parseDecimal(link.fixedPriceAmount)\n if (expected == null || !link.fixedPriceCurrencyCode) {\n throw new CrudHttpError(422, { error: 'checkout.payPage.errors.submit' })\n }\n if (input.amount != null && (!submitted || !submitted.eq(expected))) {\n throw new CrudHttpError(422, { error: 'checkout.payPage.errors.submit' })\n }\n return withAmount(expected, link.fixedPriceCurrencyCode, null)\n }\n if (link.pricingMode === 'custom_amount') {\n if (input.amount == null || !submitted || !link.customAmountCurrencyCode) {\n throw new CrudHttpError(422, {\n error: 'checkout.payPage.validation.fixErrors',\n fieldErrors: { amount: 'checkout.payPage.validation.amountRequired' },\n })\n }\n const min = parseDecimal(link.customAmountMin)\n const max = parseDecimal(link.customAmountMax)\n if ((min && submitted.lt(min)) || (!min && submitted.lt(0)) || (max && submitted.gt(max))) {\n throw new CrudHttpError(422, {\n error: 'checkout.payPage.validation.fixErrors',\n fieldErrors: { amount: 'checkout.payPage.errors.submit' },\n })\n }\n return withAmount(submitted, link.customAmountCurrencyCode, null)\n }\n const selectedPriceItem = (link.priceListItems ?? []).find((item) => item.id === input.selectedPriceItemId)\n if (!selectedPriceItem) {\n throw new CrudHttpError(422, {\n error: 'checkout.payPage.validation.fixErrors',\n fieldErrors: { selectedPriceItemId: 'checkout.payPage.validation.priceSelectionRequired' },\n })\n }\n const itemAmount = parseDecimal(resolveExactDecimal(selectedPriceItem.amountExact, selectedPriceItem.amount))\n if (!itemAmount || (input.amount != null && (!submitted || !submitted.eq(itemAmount)))) {\n throw new CrudHttpError(422, { error: 'checkout.payPage.errors.submit' })\n }\n return withAmount(itemAmount, selectedPriceItem.currencyCode, selectedPriceItem.id)\n}\n\nfunction withAmount(amount: NonNullable<ReturnType<typeof parseDecimal>>, currencyCode: string, selectedPriceItemId: string | null) {\n return {\n amount: decimalToNumber(amount),\n amountExact: decimalToString(amount),\n currencyCode,\n selectedPriceItemId,\n }\n}\n\nexport function serializeTemplateOrLink(record: CheckoutLinkTemplate | CheckoutLink) {\n const logoPreviewUrl = buildCheckoutAttachmentPreviewUrl(record.logoAttachmentId) ?? record.logoUrl ?? null\n return {\n id: record.id,\n name: record.name,\n title: record.title ?? null,\n subtitle: record.subtitle ?? null,\n description: record.description ?? null,\n logoAttachmentId: record.logoAttachmentId ?? null,\n logoUrl: record.logoUrl ?? null,\n logoPreviewUrl,\n primaryColor: record.primaryColor ?? null,\n secondaryColor: record.secondaryColor ?? null,\n backgroundColor: record.backgroundColor ?? null,\n themeMode: record.themeMode,\n pricingMode: record.pricingMode,\n fixedPriceAmount: toMoneyNumber(record.fixedPriceAmount),\n fixedPriceAmountExact: toMoneyString(record.fixedPriceAmount),\n fixedPriceCurrencyCode: record.fixedPriceCurrencyCode ?? null,\n fixedPriceIncludesTax: record.fixedPriceIncludesTax,\n fixedPriceOriginalAmount: toMoneyNumber(record.fixedPriceOriginalAmount),\n fixedPriceOriginalAmountExact: toMoneyString(record.fixedPriceOriginalAmount),\n customAmountMin: toMoneyNumber(record.customAmountMin),\n customAmountMinExact: toMoneyString(record.customAmountMin),\n customAmountMax: toMoneyNumber(record.customAmountMax),\n customAmountMaxExact: toMoneyString(record.customAmountMax),\n customAmountCurrencyCode: record.customAmountCurrencyCode ?? null,\n priceListItems: record.priceListItems ?? [],\n gatewayProviderKey: record.gatewayProviderKey ?? null,\n gatewaySettings: normalizeJsonRecord(record.gatewaySettings),\n customFieldsetCode: record.customFieldsetCode ?? null,\n collectCustomerDetails: record.collectCustomerDetails,\n customerFieldsSchema: record.customerFieldsSchema ?? [],\n legalDocuments: record.legalDocuments ?? {},\n displayCustomFieldsOnPage: record.displayCustomFieldsOnPage,\n successTitle: record.successTitle ?? null,\n successMessage: record.successMessage ?? null,\n cancelTitle: record.cancelTitle ?? null,\n cancelMessage: record.cancelMessage ?? null,\n errorTitle: record.errorTitle ?? null,\n errorMessage: record.errorMessage ?? null,\n successEmailSubject: record.successEmailSubject ?? null,\n successEmailBody: record.successEmailBody ?? null,\n sendSuccessEmail: record.sendSuccessEmail,\n errorEmailSubject: record.errorEmailSubject ?? null,\n errorEmailBody: record.errorEmailBody ?? null,\n sendErrorEmail: record.sendErrorEmail,\n startEmailSubject: record.startEmailSubject ?? null,\n startEmailBody: record.startEmailBody ?? null,\n sendStartEmail: record.sendStartEmail,\n maxCompletions: record.maxCompletions ?? null,\n status: record.status,\n checkoutType: record.checkoutType,\n createdAt: toIsoString(record.createdAt),\n updatedAt: toIsoString(record.updatedAt),\n ...(isCheckoutLinkRecord(record) ? {\n slug: record.slug,\n templateId: record.templateId ?? null,\n completionCount: record.completionCount,\n activeReservationCount: record.activeReservationCount,\n isLocked: record.isLocked,\n } : {}),\n }\n}\n\nexport function serializePublicPayLink(record: CheckoutLink) {\n return {\n id: record.id,\n slug: record.slug,\n name: record.name,\n title: record.title ?? null,\n subtitle: record.subtitle ?? null,\n description: record.description ?? null,\n logoUrl: record.logoUrl ?? null,\n logoPreviewUrl: buildCheckoutAttachmentPreviewUrl(record.logoAttachmentId) ?? record.logoUrl ?? null,\n primaryColor: record.primaryColor ?? null,\n secondaryColor: record.secondaryColor ?? null,\n backgroundColor: record.backgroundColor ?? null,\n themeMode: record.themeMode,\n pricingMode: record.pricingMode,\n fixedPriceAmount: toMoneyNumber(record.fixedPriceAmount),\n fixedPriceAmountExact: toMoneyString(record.fixedPriceAmount),\n fixedPriceCurrencyCode: record.fixedPriceCurrencyCode ?? null,\n fixedPriceIncludesTax: record.fixedPriceIncludesTax,\n fixedPriceOriginalAmount: toMoneyNumber(record.fixedPriceOriginalAmount),\n fixedPriceOriginalAmountExact: toMoneyString(record.fixedPriceOriginalAmount),\n customAmountMin: toMoneyNumber(record.customAmountMin),\n customAmountMinExact: toMoneyString(record.customAmountMin),\n customAmountMax: toMoneyNumber(record.customAmountMax),\n customAmountMaxExact: toMoneyString(record.customAmountMax),\n customAmountCurrencyCode: record.customAmountCurrencyCode ?? null,\n priceListItems: record.priceListItems ?? [],\n gatewayProviderKey: record.gatewayProviderKey ?? null,\n collectCustomerDetails: record.collectCustomerDetails,\n customerFieldsSchema: record.customerFieldsSchema ?? [],\n legalDocuments: record.legalDocuments ?? {},\n displayCustomFieldsOnPage: record.displayCustomFieldsOnPage,\n successTitle: record.successTitle ?? null,\n successMessage: record.successMessage ?? null,\n cancelTitle: record.cancelTitle ?? null,\n cancelMessage: record.cancelMessage ?? null,\n errorTitle: record.errorTitle ?? null,\n errorMessage: record.errorMessage ?? null,\n status: record.status,\n checkoutType: record.checkoutType,\n }\n}\n\nexport function serializeTransaction(record: CheckoutTransaction, link?: CheckoutLink | null, includePii = false) {\n return {\n id: record.id,\n linkId: record.linkId,\n linkName: link?.name ?? null,\n linkSlug: link?.slug ?? null,\n amount: toMoneyNumber(record.amount),\n amountExact: toMoneyString(record.amount),\n currencyCode: record.currencyCode,\n status: record.status,\n paymentStatus: record.paymentStatus ?? null,\n gatewayTransactionId: record.gatewayTransactionId ?? null,\n selectedPriceItemId: record.selectedPriceItemId ?? null,\n acceptedLegalConsents: includePii ? normalizeMaybeStringifiedJsonObject(record.acceptedLegalConsents) : null,\n customerData: includePii ? normalizeMaybeStringifiedJsonObject(record.customerData) : null,\n firstName: includePii ? (record.firstName ?? null) : null,\n lastName: includePii ? (record.lastName ?? null) : null,\n email: includePii ? (record.email ?? null) : null,\n phone: includePii ? (record.phone ?? null) : null,\n ipAddress: includePii ? (record.ipAddress ?? null) : null,\n userAgent: includePii ? (record.userAgent ?? null) : null,\n createdAt: toIsoString(record.createdAt),\n updatedAt: toIsoString(record.updatedAt),\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,YAAY,uBAAuB;AAC5C,OAAO,YAAY;AACnB,SAAS,eAAe;AACxB,SAAS,qBAAqB;AAC9B;AAAA,EACE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WAAW,aAAc,OAAO,aAAa,OAAQ;AAAA,IACrD,WAAW,aAAc,OAAO,aAAa,OAAQ;AAAA,IACrD,WAAW,YAAY,OAAO,SAAS;AAAA,IACvC,WAAW,YAAY,OAAO,SAAS;AAAA,EACzC;AACF;",
|
|
6
6
|
"names": ["normalizeOptionalString", "buildCheckoutAttachmentPreviewUrl"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Migration } from "@mikro-orm/migrations";
|
|
2
|
+
class Migration20261014082519_checkout extends Migration {
|
|
3
|
+
constructor() {
|
|
4
|
+
super(...arguments);
|
|
5
|
+
this.name = "Migration20261014082519";
|
|
6
|
+
}
|
|
7
|
+
up() {
|
|
8
|
+
this.addSql(`alter table "checkout_links" alter column "custom_amount_max" type numeric using ("custom_amount_max"::numeric);`);
|
|
9
|
+
this.addSql(`alter table "checkout_links" alter column "custom_amount_min" type numeric using ("custom_amount_min"::numeric);`);
|
|
10
|
+
this.addSql(`alter table "checkout_links" alter column "fixed_price_amount" type numeric using ("fixed_price_amount"::numeric);`);
|
|
11
|
+
this.addSql(`alter table "checkout_links" alter column "fixed_price_original_amount" type numeric using ("fixed_price_original_amount"::numeric);`);
|
|
12
|
+
this.addSql(`alter table "checkout_link_templates" alter column "custom_amount_max" type numeric using ("custom_amount_max"::numeric);`);
|
|
13
|
+
this.addSql(`alter table "checkout_link_templates" alter column "custom_amount_min" type numeric using ("custom_amount_min"::numeric);`);
|
|
14
|
+
this.addSql(`alter table "checkout_link_templates" alter column "fixed_price_amount" type numeric using ("fixed_price_amount"::numeric);`);
|
|
15
|
+
this.addSql(`alter table "checkout_link_templates" alter column "fixed_price_original_amount" type numeric using ("fixed_price_original_amount"::numeric);`);
|
|
16
|
+
this.addSql(`alter table "checkout_transactions" alter column "amount" type numeric using ("amount"::numeric);`);
|
|
17
|
+
}
|
|
18
|
+
down() {
|
|
19
|
+
this.addSql(`alter table "checkout_link_templates" alter column "fixed_price_amount" type numeric(12,2) using ("fixed_price_amount"::numeric(12,2));`);
|
|
20
|
+
this.addSql(`alter table "checkout_link_templates" alter column "fixed_price_original_amount" type numeric(12,2) using ("fixed_price_original_amount"::numeric(12,2));`);
|
|
21
|
+
this.addSql(`alter table "checkout_link_templates" alter column "custom_amount_min" type numeric(12,2) using ("custom_amount_min"::numeric(12,2));`);
|
|
22
|
+
this.addSql(`alter table "checkout_link_templates" alter column "custom_amount_max" type numeric(12,2) using ("custom_amount_max"::numeric(12,2));`);
|
|
23
|
+
this.addSql(`alter table "checkout_links" alter column "fixed_price_amount" type numeric(12,2) using ("fixed_price_amount"::numeric(12,2));`);
|
|
24
|
+
this.addSql(`alter table "checkout_links" alter column "fixed_price_original_amount" type numeric(12,2) using ("fixed_price_original_amount"::numeric(12,2));`);
|
|
25
|
+
this.addSql(`alter table "checkout_links" alter column "custom_amount_min" type numeric(12,2) using ("custom_amount_min"::numeric(12,2));`);
|
|
26
|
+
this.addSql(`alter table "checkout_links" alter column "custom_amount_max" type numeric(12,2) using ("custom_amount_max"::numeric(12,2));`);
|
|
27
|
+
this.addSql(`alter table "checkout_transactions" alter column "amount" type numeric(12,2) using ("amount"::numeric(12,2));`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
Migration20261014082519_checkout
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=Migration20261014082519_checkout.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/modules/checkout/migrations/Migration20261014082519_checkout.ts"],
|
|
4
|
+
"sourcesContent": ["import { Migration } from '@mikro-orm/migrations';\n\nexport class Migration20261014082519_checkout extends Migration {\n\n override name = 'Migration20261014082519';\n\n override up(): void | Promise<void> {\n this.addSql(`alter table \"checkout_links\" alter column \"custom_amount_max\" type numeric using (\"custom_amount_max\"::numeric);`);\n this.addSql(`alter table \"checkout_links\" alter column \"custom_amount_min\" type numeric using (\"custom_amount_min\"::numeric);`);\n this.addSql(`alter table \"checkout_links\" alter column \"fixed_price_amount\" type numeric using (\"fixed_price_amount\"::numeric);`);\n this.addSql(`alter table \"checkout_links\" alter column \"fixed_price_original_amount\" type numeric using (\"fixed_price_original_amount\"::numeric);`);\n\n this.addSql(`alter table \"checkout_link_templates\" alter column \"custom_amount_max\" type numeric using (\"custom_amount_max\"::numeric);`);\n this.addSql(`alter table \"checkout_link_templates\" alter column \"custom_amount_min\" type numeric using (\"custom_amount_min\"::numeric);`);\n this.addSql(`alter table \"checkout_link_templates\" alter column \"fixed_price_amount\" type numeric using (\"fixed_price_amount\"::numeric);`);\n this.addSql(`alter table \"checkout_link_templates\" alter column \"fixed_price_original_amount\" type numeric using (\"fixed_price_original_amount\"::numeric);`);\n\n this.addSql(`alter table \"checkout_transactions\" alter column \"amount\" type numeric using (\"amount\"::numeric);`);\n }\n\n override down(): void | Promise<void> {\n this.addSql(`alter table \"checkout_link_templates\" alter column \"fixed_price_amount\" type numeric(12,2) using (\"fixed_price_amount\"::numeric(12,2));`);\n this.addSql(`alter table \"checkout_link_templates\" alter column \"fixed_price_original_amount\" type numeric(12,2) using (\"fixed_price_original_amount\"::numeric(12,2));`);\n this.addSql(`alter table \"checkout_link_templates\" alter column \"custom_amount_min\" type numeric(12,2) using (\"custom_amount_min\"::numeric(12,2));`);\n this.addSql(`alter table \"checkout_link_templates\" alter column \"custom_amount_max\" type numeric(12,2) using (\"custom_amount_max\"::numeric(12,2));`);\n\n this.addSql(`alter table \"checkout_links\" alter column \"fixed_price_amount\" type numeric(12,2) using (\"fixed_price_amount\"::numeric(12,2));`);\n this.addSql(`alter table \"checkout_links\" alter column \"fixed_price_original_amount\" type numeric(12,2) using (\"fixed_price_original_amount\"::numeric(12,2));`);\n this.addSql(`alter table \"checkout_links\" alter column \"custom_amount_min\" type numeric(12,2) using (\"custom_amount_min\"::numeric(12,2));`);\n this.addSql(`alter table \"checkout_links\" alter column \"custom_amount_max\" type numeric(12,2) using (\"custom_amount_max\"::numeric(12,2));`);\n\n this.addSql(`alter table \"checkout_transactions\" alter column \"amount\" type numeric(12,2) using (\"amount\"::numeric(12,2));`);\n }\n\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,iBAAiB;AAEnB,MAAM,yCAAyC,UAAU;AAAA,EAAzD;AAAA;AAEL,SAAS,OAAO;AAAA;AAAA,EAEP,KAA2B;AAClC,SAAK,OAAO,kHAAkH;AAC9H,SAAK,OAAO,kHAAkH;AAC9H,SAAK,OAAO,oHAAoH;AAChI,SAAK,OAAO,sIAAsI;AAElJ,SAAK,OAAO,2HAA2H;AACvI,SAAK,OAAO,2HAA2H;AACvI,SAAK,OAAO,6HAA6H;AACzI,SAAK,OAAO,+IAA+I;AAE3J,SAAK,OAAO,mGAAmG;AAAA,EACjH;AAAA,EAES,OAA6B;AACpC,SAAK,OAAO,yIAAyI;AACrJ,SAAK,OAAO,2JAA2J;AACvK,SAAK,OAAO,uIAAuI;AACnJ,SAAK,OAAO,uIAAuI;AAEnJ,SAAK,OAAO,gIAAgI;AAC5I,SAAK,OAAO,kJAAkJ;AAC9J,SAAK,OAAO,8HAA8H;AAC1I,SAAK,OAAO,8HAA8H;AAE1I,SAAK,OAAO,+GAA+G;AAAA,EAC7H;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { DEFAULT_NOTIFICATION_DELIVERY_CONFIG, resolveNotificationDeliveryConfig } from "@open-mercato/core/modules/notifications/lib/deliveryConfig";
|
|
2
2
|
import { sendEmail } from "@open-mercato/shared/lib/email/send";
|
|
3
3
|
import { findOneWithDecryption } from "@open-mercato/shared/lib/encryption/find";
|
|
4
|
+
import { resolveCurrencyDecimalPlaces } from "@open-mercato/shared/lib/currencyPrecision";
|
|
5
|
+
import { padDecimalPlaces, parseDecimal } from "@open-mercato/shared/lib/decimal";
|
|
4
6
|
import { resolveTranslations } from "@open-mercato/shared/lib/i18n/server";
|
|
5
7
|
import { CheckoutTransaction, CheckoutLink } from "../data/entities.js";
|
|
6
8
|
import PaymentStartEmail from "../emails/PaymentStartEmail.js";
|
|
@@ -96,8 +98,13 @@ async function handle(job, ctx) {
|
|
|
96
98
|
}, void 0, { organizationId: payload.organizationId, tenantId: payload.tenantId });
|
|
97
99
|
const firstName = transaction.firstName ?? t("checkout.systemEmails.common.customerFallback");
|
|
98
100
|
const linkTitle = link?.title ?? link?.name ?? t("checkout.systemEmails.common.linkTitleFallback");
|
|
99
|
-
const amount = String(transaction.amount ?? "0.00");
|
|
100
101
|
const currencyCode = transaction.currencyCode ?? "";
|
|
102
|
+
const currencyDecimalPlaces = await resolveCurrencyDecimalPlaces(ctx, {
|
|
103
|
+
code: currencyCode,
|
|
104
|
+
tenantId: payload.tenantId,
|
|
105
|
+
organizationId: payload.organizationId
|
|
106
|
+
});
|
|
107
|
+
const amount = padDecimalPlaces(parseDecimal(transaction.amount) ?? 0, currencyDecimalPlaces ?? 2);
|
|
101
108
|
const errorMessage = payload.type === "error" ? payload.errorMessage ?? null : null;
|
|
102
109
|
const variables = {
|
|
103
110
|
firstName,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/checkout/workers/send-email.worker.ts"],
|
|
4
|
-
"sourcesContent": ["import type { EntityManager } from '@mikro-orm/postgresql'\nimport { DEFAULT_NOTIFICATION_DELIVERY_CONFIG, resolveNotificationDeliveryConfig } from '@open-mercato/core/modules/notifications/lib/deliveryConfig'\nimport type { JobContext, QueuedJob, WorkerMeta } from '@open-mercato/queue'\nimport { sendEmail } from '@open-mercato/shared/lib/email/send'\nimport { findOneWithDecryption } from '@open-mercato/shared/lib/encryption/find'\nimport { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'\nimport { CheckoutTransaction, CheckoutLink } from '../data/entities'\nimport PaymentStartEmail from '../emails/PaymentStartEmail'\nimport PaymentSuccessEmail from '../emails/PaymentSuccessEmail'\nimport PaymentErrorEmail from '../emails/PaymentErrorEmail'\n\nexport const CHECKOUT_EMAIL_QUEUE = 'checkout-email'\n\nexport type CheckoutEmailJob =\n | { type: 'start'; transactionId: string; tenantId: string; organizationId: string }\n | { type: 'success'; transactionId: string; tenantId: string; organizationId: string }\n | { type: 'error'; transactionId: string; tenantId: string; organizationId: string; errorMessage?: string | null }\n\nexport const metadata: WorkerMeta = {\n queue: CHECKOUT_EMAIL_QUEUE,\n id: 'checkout:send-email',\n concurrency: 5,\n}\n\ntype HandlerContext = JobContext & {\n resolve: <T = unknown>(name: string) => T\n}\n\nfunction interpolateVariables(template: string, variables: Record<string, string>): string {\n return template.replace(/\\{\\{(\\w+)\\}\\}/g, (match, key: string) => variables[key] ?? match)\n}\n\nfunction escapeHtml(value: string): string {\n return value\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"')\n .replace(/'/g, ''')\n}\n\nfunction renderInlineMarkdown(value: string): string {\n let rendered = escapeHtml(value)\n rendered = rendered.replace(/`([^`]+)`/g, '<code>$1</code>')\n rendered = rendered.replace(/\\[([^\\]]+)\\]\\((https?:\\/\\/[^\\s)]+)\\)/g, '<a href=\"$2\">$1</a>')\n rendered = rendered.replace(/\\*\\*([^*]+)\\*\\*/g, '<strong>$1</strong>')\n rendered = rendered.replace(/__([^_]+)__/g, '<strong>$1</strong>')\n rendered = rendered.replace(/(^|[\\s(])\\*([^*]+)\\*(?=$|[\\s).,!?:;])/g, '$1<em>$2</em>')\n rendered = rendered.replace(/(^|[\\s(])_([^_]+)_(?=$|[\\s).,!?:;])/g, '$1<em>$2</em>')\n return rendered\n}\n\nfunction renderParagraph(lines: string[]): string {\n return `<p>${renderInlineMarkdown(lines.join(' '))}</p>`\n}\n\nfunction renderMarkdownBody(markdown: string): string {\n const normalized = markdown.replace(/\\r\\n/g, '\\n').trim()\n if (!normalized) return ''\n\n const blocks: string[] = []\n const lines = normalized.split('\\n')\n let paragraph: string[] = []\n let listItems: string[] = []\n\n const flushParagraph = () => {\n if (paragraph.length === 0) return\n blocks.push(renderParagraph(paragraph))\n paragraph = []\n }\n\n const flushList = () => {\n if (listItems.length === 0) return\n blocks.push(`<ul>${listItems.map((item) => `<li>${renderInlineMarkdown(item)}</li>`).join('')}</ul>`)\n listItems = []\n }\n\n for (const rawLine of lines) {\n const line = rawLine.trim()\n if (!line) {\n flushParagraph()\n flushList()\n continue\n }\n\n const headingMatch = /^(#{1,6})\\s+(.+)$/.exec(line)\n if (headingMatch) {\n flushParagraph()\n flushList()\n const level = headingMatch[1].length\n blocks.push(`<h${level}>${renderInlineMarkdown(headingMatch[2])}</h${level}>`)\n continue\n }\n\n const listMatch = /^[-*]\\s+(.+)$/.exec(line)\n if (listMatch) {\n flushParagraph()\n listItems.push(listMatch[1])\n continue\n }\n\n flushList()\n paragraph.push(line)\n }\n\n flushParagraph()\n flushList()\n\n return blocks.join('')\n}\n\nexport default async function handle(job: QueuedJob<CheckoutEmailJob>, ctx: HandlerContext): Promise<void> {\n const { payload } = job\n const em = (ctx.resolve('em') as EntityManager).fork()\n const { t } = await resolveTranslations()\n\n const transaction = await findOneWithDecryption<CheckoutTransaction>(em, CheckoutTransaction, {\n id: payload.transactionId,\n organizationId: payload.organizationId,\n tenantId: payload.tenantId,\n })\n if (!transaction) return\n\n const email = transaction.email\n if (!email) return\n\n const link = await findOneWithDecryption(em, CheckoutLink, {\n id: transaction.linkId,\n organizationId: payload.organizationId,\n tenantId: payload.tenantId,\n deletedAt: null,\n }, undefined, { organizationId: payload.organizationId, tenantId: payload.tenantId })\n\n const firstName = transaction.firstName ?? t('checkout.systemEmails.common.customerFallback')\n const linkTitle = link?.title ?? link?.name ?? t('checkout.systemEmails.common.linkTitleFallback')\n const
|
|
5
|
-
"mappings": "AACA,SAAS,sCAAsC,yCAAyC;AAExF,SAAS,iBAAiB;AAC1B,SAAS,6BAA6B;AACtC,SAAS,2BAA2B;AACpC,SAAS,qBAAqB,oBAAoB;AAClD,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;AAAA,IACxB,UAAU,QAAQ;AAAA,IAClB,WAAW;AAAA,EACb,GAAG,QAAW,EAAE,gBAAgB,QAAQ,gBAAgB,UAAU,QAAQ,SAAS,CAAC;AAEpF,QAAM,YAAY,YAAY,aAAa,EAAE,+CAA+C;AAC5F,QAAM,YAAY,MAAM,SAAS,MAAM,QAAQ,EAAE,gDAAgD;AACjG,QAAM,
|
|
4
|
+
"sourcesContent": ["import type { EntityManager } from '@mikro-orm/postgresql'\nimport { DEFAULT_NOTIFICATION_DELIVERY_CONFIG, resolveNotificationDeliveryConfig } from '@open-mercato/core/modules/notifications/lib/deliveryConfig'\nimport type { JobContext, QueuedJob, WorkerMeta } from '@open-mercato/queue'\nimport { sendEmail } from '@open-mercato/shared/lib/email/send'\nimport { findOneWithDecryption } from '@open-mercato/shared/lib/encryption/find'\nimport { resolveCurrencyDecimalPlaces } from '@open-mercato/shared/lib/currencyPrecision'\nimport { padDecimalPlaces, parseDecimal } from '@open-mercato/shared/lib/decimal'\nimport { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'\nimport { CheckoutTransaction, CheckoutLink } from '../data/entities'\nimport PaymentStartEmail from '../emails/PaymentStartEmail'\nimport PaymentSuccessEmail from '../emails/PaymentSuccessEmail'\nimport PaymentErrorEmail from '../emails/PaymentErrorEmail'\n\nexport const CHECKOUT_EMAIL_QUEUE = 'checkout-email'\n\nexport type CheckoutEmailJob =\n | { type: 'start'; transactionId: string; tenantId: string; organizationId: string }\n | { type: 'success'; transactionId: string; tenantId: string; organizationId: string }\n | { type: 'error'; transactionId: string; tenantId: string; organizationId: string; errorMessage?: string | null }\n\nexport const metadata: WorkerMeta = {\n queue: CHECKOUT_EMAIL_QUEUE,\n id: 'checkout:send-email',\n concurrency: 5,\n}\n\ntype HandlerContext = JobContext & {\n resolve: <T = unknown>(name: string) => T\n}\n\nfunction interpolateVariables(template: string, variables: Record<string, string>): string {\n return template.replace(/\\{\\{(\\w+)\\}\\}/g, (match, key: string) => variables[key] ?? match)\n}\n\nfunction escapeHtml(value: string): string {\n return value\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"')\n .replace(/'/g, ''')\n}\n\nfunction renderInlineMarkdown(value: string): string {\n let rendered = escapeHtml(value)\n rendered = rendered.replace(/`([^`]+)`/g, '<code>$1</code>')\n rendered = rendered.replace(/\\[([^\\]]+)\\]\\((https?:\\/\\/[^\\s)]+)\\)/g, '<a href=\"$2\">$1</a>')\n rendered = rendered.replace(/\\*\\*([^*]+)\\*\\*/g, '<strong>$1</strong>')\n rendered = rendered.replace(/__([^_]+)__/g, '<strong>$1</strong>')\n rendered = rendered.replace(/(^|[\\s(])\\*([^*]+)\\*(?=$|[\\s).,!?:;])/g, '$1<em>$2</em>')\n rendered = rendered.replace(/(^|[\\s(])_([^_]+)_(?=$|[\\s).,!?:;])/g, '$1<em>$2</em>')\n return rendered\n}\n\nfunction renderParagraph(lines: string[]): string {\n return `<p>${renderInlineMarkdown(lines.join(' '))}</p>`\n}\n\nfunction renderMarkdownBody(markdown: string): string {\n const normalized = markdown.replace(/\\r\\n/g, '\\n').trim()\n if (!normalized) return ''\n\n const blocks: string[] = []\n const lines = normalized.split('\\n')\n let paragraph: string[] = []\n let listItems: string[] = []\n\n const flushParagraph = () => {\n if (paragraph.length === 0) return\n blocks.push(renderParagraph(paragraph))\n paragraph = []\n }\n\n const flushList = () => {\n if (listItems.length === 0) return\n blocks.push(`<ul>${listItems.map((item) => `<li>${renderInlineMarkdown(item)}</li>`).join('')}</ul>`)\n listItems = []\n }\n\n for (const rawLine of lines) {\n const line = rawLine.trim()\n if (!line) {\n flushParagraph()\n flushList()\n continue\n }\n\n const headingMatch = /^(#{1,6})\\s+(.+)$/.exec(line)\n if (headingMatch) {\n flushParagraph()\n flushList()\n const level = headingMatch[1].length\n blocks.push(`<h${level}>${renderInlineMarkdown(headingMatch[2])}</h${level}>`)\n continue\n }\n\n const listMatch = /^[-*]\\s+(.+)$/.exec(line)\n if (listMatch) {\n flushParagraph()\n listItems.push(listMatch[1])\n continue\n }\n\n flushList()\n paragraph.push(line)\n }\n\n flushParagraph()\n flushList()\n\n return blocks.join('')\n}\n\nexport default async function handle(job: QueuedJob<CheckoutEmailJob>, ctx: HandlerContext): Promise<void> {\n const { payload } = job\n const em = (ctx.resolve('em') as EntityManager).fork()\n const { t } = await resolveTranslations()\n\n const transaction = await findOneWithDecryption<CheckoutTransaction>(em, CheckoutTransaction, {\n id: payload.transactionId,\n organizationId: payload.organizationId,\n tenantId: payload.tenantId,\n })\n if (!transaction) return\n\n const email = transaction.email\n if (!email) return\n\n const link = await findOneWithDecryption(em, CheckoutLink, {\n id: transaction.linkId,\n organizationId: payload.organizationId,\n tenantId: payload.tenantId,\n deletedAt: null,\n }, undefined, { organizationId: payload.organizationId, tenantId: payload.tenantId })\n\n const firstName = transaction.firstName ?? t('checkout.systemEmails.common.customerFallback')\n const linkTitle = link?.title ?? link?.name ?? t('checkout.systemEmails.common.linkTitleFallback')\n const currencyCode = transaction.currencyCode ?? ''\n const currencyDecimalPlaces = await resolveCurrencyDecimalPlaces(ctx, {\n code: currencyCode,\n tenantId: payload.tenantId,\n organizationId: payload.organizationId,\n })\n const amount = padDecimalPlaces(parseDecimal(transaction.amount) ?? 0, currencyDecimalPlaces ?? 2)\n const errorMessage = payload.type === 'error' ? (payload.errorMessage ?? null) : null\n\n const variables: Record<string, string> = {\n firstName,\n amount,\n currencyCode,\n linkTitle,\n transactionId: transaction.id,\n errorMessage: errorMessage ?? '',\n }\n const deliveryConfig = await resolveNotificationDeliveryConfig(ctx, {\n defaultValue: DEFAULT_NOTIFICATION_DELIVERY_CONFIG,\n })\n const from = deliveryConfig.strategies.email.from\n const replyTo = deliveryConfig.strategies.email.replyTo\n\n async function resolveEmailContent(\n subjectField: string | null | undefined,\n bodyField: string | null | undefined,\n defaultSubject: string,\n ): Promise<{ subject: string; bodyHtml: string | null }> {\n const subject = subjectField\n ? interpolateVariables(subjectField, variables)\n : defaultSubject\n const bodyHtml = bodyField\n ? renderMarkdownBody(interpolateVariables(bodyField, variables))\n : null\n return { subject, bodyHtml }\n }\n\n if (payload.type === 'start') {\n if (link?.sendStartEmail === false) return\n const { subject, bodyHtml } = await resolveEmailContent(\n link?.startEmailSubject,\n link?.startEmailBody,\n t('checkout.systemEmails.start.subject', 'Payment initiated - {linkTitle}', { linkTitle }),\n )\n await sendEmail({\n to: email,\n subject,\n from,\n replyTo,\n tenantId: payload.tenantId,\n organizationId: payload.organizationId,\n react: PaymentStartEmail({\n firstName,\n amount,\n currencyCode,\n linkTitle,\n bodyHtml,\n copy: {\n title: t('checkout.systemEmails.start.title'),\n preview: t('checkout.systemEmails.start.preview', { amount, currencyCode }),\n greeting: t('checkout.systemEmails.start.greeting', { firstName, linkTitle }),\n message: t('checkout.systemEmails.start.message'),\n hint: t('checkout.systemEmails.start.hint'),\n },\n }),\n })\n } else if (payload.type === 'success') {\n if (link?.sendSuccessEmail === false) return\n const { subject, bodyHtml } = await resolveEmailContent(\n link?.successEmailSubject,\n link?.successEmailBody,\n t('checkout.systemEmails.success.subject', 'Payment successful - {linkTitle}', { linkTitle }),\n )\n await sendEmail({\n to: email,\n subject,\n from,\n replyTo,\n tenantId: payload.tenantId,\n organizationId: payload.organizationId,\n react: PaymentSuccessEmail({\n firstName,\n amount,\n currencyCode,\n linkTitle,\n transactionId: transaction.id,\n bodyHtml,\n copy: {\n title: t('checkout.systemEmails.success.title'),\n preview: t('checkout.systemEmails.success.preview', { amount, currencyCode }),\n greeting: t('checkout.systemEmails.success.greeting', { firstName, linkTitle }),\n receipt: t('checkout.systemEmails.success.receipt'),\n hint: t('checkout.systemEmails.success.hint'),\n transactionLabel: t('checkout.systemEmails.success.transactionLabel'),\n },\n }),\n })\n } else if (payload.type === 'error') {\n if (link?.sendErrorEmail === false) return\n const { subject, bodyHtml } = await resolveEmailContent(\n link?.errorEmailSubject,\n link?.errorEmailBody,\n t('checkout.systemEmails.error.subject', 'Payment failed - {linkTitle}', { linkTitle }),\n )\n await sendEmail({\n to: email,\n subject,\n from,\n replyTo,\n tenantId: payload.tenantId,\n organizationId: payload.organizationId,\n react: PaymentErrorEmail({\n firstName,\n linkTitle,\n errorMessage,\n bodyHtml,\n copy: {\n title: t('checkout.systemEmails.error.title'),\n preview: t('checkout.systemEmails.error.preview', { linkTitle }),\n greeting: t('checkout.systemEmails.error.greeting', { firstName, linkTitle }),\n retry: t('checkout.systemEmails.error.retry'),\n hint: t('checkout.systemEmails.error.hint'),\n },\n }),\n })\n }\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,sCAAsC,yCAAyC;AAExF,SAAS,iBAAiB;AAC1B,SAAS,6BAA6B;AACtC,SAAS,oCAAoC;AAC7C,SAAS,kBAAkB,oBAAoB;AAC/C,SAAS,2BAA2B;AACpC,SAAS,qBAAqB,oBAAoB;AAClD,OAAO,uBAAuB;AAC9B,OAAO,yBAAyB;AAChC,OAAO,uBAAuB;AAEvB,MAAM,uBAAuB;AAO7B,MAAM,WAAuB;AAAA,EAClC,OAAO;AAAA,EACP,IAAI;AAAA,EACJ,aAAa;AACf;AAMA,SAAS,qBAAqB,UAAkB,WAA2C;AACzF,SAAO,SAAS,QAAQ,kBAAkB,CAAC,OAAO,QAAgB,UAAU,GAAG,KAAK,KAAK;AAC3F;AAEA,SAAS,WAAW,OAAuB;AACzC,SAAO,MACJ,QAAQ,MAAM,OAAO,EACrB,QAAQ,MAAM,MAAM,EACpB,QAAQ,MAAM,MAAM,EACpB,QAAQ,MAAM,QAAQ,EACtB,QAAQ,MAAM,OAAO;AAC1B;AAEA,SAAS,qBAAqB,OAAuB;AACnD,MAAI,WAAW,WAAW,KAAK;AAC/B,aAAW,SAAS,QAAQ,cAAc,iBAAiB;AAC3D,aAAW,SAAS,QAAQ,yCAAyC,qBAAqB;AAC1F,aAAW,SAAS,QAAQ,oBAAoB,qBAAqB;AACrE,aAAW,SAAS,QAAQ,gBAAgB,qBAAqB;AACjE,aAAW,SAAS,QAA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.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-mercato/checkout",
|
|
3
|
-
"version": "0.10.1-develop.
|
|
3
|
+
"version": "0.10.1-develop.8291.1.6ec3aee41c",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"build": "node build.mjs",
|
|
9
9
|
"watch": "node build.mjs --watch",
|
|
10
10
|
"test": "jest --config jest.config.cjs",
|
|
11
|
+
"test:pg-integration": "cross-env OM_PG_INTEGRATION=1 jest --config jest.config.cjs --runInBand 'src/modules/checkout/migrations/.+\\.integration\\.test\\.ts$'",
|
|
11
12
|
"typecheck": "tsc --noEmit"
|
|
12
13
|
},
|
|
13
14
|
"exports": {
|
|
@@ -62,30 +63,32 @@
|
|
|
62
63
|
}
|
|
63
64
|
},
|
|
64
65
|
"dependencies": {
|
|
65
|
-
"@open-mercato/core": "0.10.1-develop.
|
|
66
|
-
"@open-mercato/ui": "0.10.1-develop.
|
|
66
|
+
"@open-mercato/core": "0.10.1-develop.8291.1.6ec3aee41c",
|
|
67
|
+
"@open-mercato/ui": "0.10.1-develop.8291.1.6ec3aee41c",
|
|
67
68
|
"bcryptjs": "^3.0.3"
|
|
68
69
|
},
|
|
69
70
|
"peerDependencies": {
|
|
70
71
|
"@mikro-orm/postgresql": "^7.0.14",
|
|
71
|
-
"@open-mercato/ai-assistant": "0.10.1-develop.
|
|
72
|
-
"@open-mercato/shared": "0.10.1-develop.
|
|
72
|
+
"@open-mercato/ai-assistant": "0.10.1-develop.8291.1.6ec3aee41c",
|
|
73
|
+
"@open-mercato/shared": "0.10.1-develop.8291.1.6ec3aee41c",
|
|
73
74
|
"react": "^19.0.0",
|
|
74
75
|
"react-dom": "^19.0.0",
|
|
75
76
|
"react-is": ">=18.0.0"
|
|
76
77
|
},
|
|
77
78
|
"devDependencies": {
|
|
78
|
-
"@open-mercato/ai-assistant": "0.10.1-develop.
|
|
79
|
-
"@open-mercato/shared": "0.10.1-develop.
|
|
79
|
+
"@open-mercato/ai-assistant": "0.10.1-develop.8291.1.6ec3aee41c",
|
|
80
|
+
"@open-mercato/shared": "0.10.1-develop.8291.1.6ec3aee41c",
|
|
80
81
|
"@types/jest": "^30.0.0",
|
|
81
82
|
"@types/react": "^19.2.18",
|
|
82
83
|
"@types/react-dom": "^19.2.5",
|
|
84
|
+
"cross-env": "^10.1.0",
|
|
83
85
|
"esbuild": "^0.28.2",
|
|
84
86
|
"glob": "^14.0.6",
|
|
85
87
|
"jest": "^30.4.2",
|
|
86
88
|
"react": "19.2.8",
|
|
87
89
|
"react-dom": "19.2.8",
|
|
88
90
|
"react-is": "^19.2.8",
|
|
91
|
+
"testcontainers": "^12.0.3",
|
|
89
92
|
"ts-jest": "^29.4.12",
|
|
90
93
|
"typescript": "7.0.2"
|
|
91
94
|
},
|