@open-mercato/checkout 0.10.1-develop.8287.1.7313a0fe67 → 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
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Migration } from '@mikro-orm/migrations';
|
|
2
|
+
|
|
3
|
+
export class Migration20261014082519_checkout extends Migration {
|
|
4
|
+
|
|
5
|
+
override name = 'Migration20261014082519';
|
|
6
|
+
|
|
7
|
+
override up(): void | Promise<void> {
|
|
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
|
+
|
|
13
|
+
this.addSql(`alter table "checkout_link_templates" alter column "custom_amount_max" type numeric using ("custom_amount_max"::numeric);`);
|
|
14
|
+
this.addSql(`alter table "checkout_link_templates" alter column "custom_amount_min" type numeric using ("custom_amount_min"::numeric);`);
|
|
15
|
+
this.addSql(`alter table "checkout_link_templates" alter column "fixed_price_amount" type numeric using ("fixed_price_amount"::numeric);`);
|
|
16
|
+
this.addSql(`alter table "checkout_link_templates" alter column "fixed_price_original_amount" type numeric using ("fixed_price_original_amount"::numeric);`);
|
|
17
|
+
|
|
18
|
+
this.addSql(`alter table "checkout_transactions" alter column "amount" type numeric using ("amount"::numeric);`);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
override down(): void | Promise<void> {
|
|
22
|
+
this.addSql(`alter table "checkout_link_templates" alter column "fixed_price_amount" type numeric(12,2) using ("fixed_price_amount"::numeric(12,2));`);
|
|
23
|
+
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));`);
|
|
24
|
+
this.addSql(`alter table "checkout_link_templates" alter column "custom_amount_min" type numeric(12,2) using ("custom_amount_min"::numeric(12,2));`);
|
|
25
|
+
this.addSql(`alter table "checkout_link_templates" alter column "custom_amount_max" type numeric(12,2) using ("custom_amount_max"::numeric(12,2));`);
|
|
26
|
+
|
|
27
|
+
this.addSql(`alter table "checkout_links" alter column "fixed_price_amount" type numeric(12,2) using ("fixed_price_amount"::numeric(12,2));`);
|
|
28
|
+
this.addSql(`alter table "checkout_links" alter column "fixed_price_original_amount" type numeric(12,2) using ("fixed_price_original_amount"::numeric(12,2));`);
|
|
29
|
+
this.addSql(`alter table "checkout_links" alter column "custom_amount_min" type numeric(12,2) using ("custom_amount_min"::numeric(12,2));`);
|
|
30
|
+
this.addSql(`alter table "checkout_links" alter column "custom_amount_max" type numeric(12,2) using ("custom_amount_max"::numeric(12,2));`);
|
|
31
|
+
|
|
32
|
+
this.addSql(`alter table "checkout_transactions" alter column "amount" type numeric(12,2) using ("amount"::numeric(12,2));`);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { describeNumericWideningMigrations } from '@open-mercato/core/__tests__/__fixtures__/numericWideningMigrationHarness'
|
|
2
|
+
import { Migration20261014082519_checkout } from '../Migration20261014082519_checkout'
|
|
3
|
+
|
|
4
|
+
describeNumericWideningMigrations('Checkout money columns widened to unconstrained numeric', [
|
|
5
|
+
{ migration: Migration20261014082519_checkout, legacy: { precision: 12, scale: 2 } },
|
|
6
|
+
])
|
|
@@ -111,4 +111,47 @@ describe('checkout send-email worker', () => {
|
|
|
111
111
|
}),
|
|
112
112
|
)
|
|
113
113
|
})
|
|
114
|
+
|
|
115
|
+
it('shows the amount with the currency decimals', async () => {
|
|
116
|
+
findOneWithDecryption
|
|
117
|
+
.mockResolvedValueOnce({
|
|
118
|
+
id: 'txn-2',
|
|
119
|
+
linkId: 'link-2',
|
|
120
|
+
email: 'buyer@example.com',
|
|
121
|
+
firstName: 'Piotr',
|
|
122
|
+
amount: '12.5',
|
|
123
|
+
currencyCode: 'USD',
|
|
124
|
+
})
|
|
125
|
+
.mockResolvedValueOnce({
|
|
126
|
+
id: 'link-2',
|
|
127
|
+
title: 'Spring Gala 2026',
|
|
128
|
+
name: 'Spring Gala 2026',
|
|
129
|
+
successEmailSubject: null,
|
|
130
|
+
successEmailBody: null,
|
|
131
|
+
sendSuccessEmail: true,
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
const { default: handle } = await import('../send-email.worker')
|
|
135
|
+
|
|
136
|
+
await handle(
|
|
137
|
+
{
|
|
138
|
+
payload: {
|
|
139
|
+
type: 'success',
|
|
140
|
+
transactionId: 'txn-2',
|
|
141
|
+
tenantId: 'tenant-1',
|
|
142
|
+
organizationId: 'org-1',
|
|
143
|
+
},
|
|
144
|
+
} as never,
|
|
145
|
+
{
|
|
146
|
+
resolve: (name: string) => {
|
|
147
|
+
if (name === 'em') return { fork: () => ({}) }
|
|
148
|
+
throw new Error(`Missing dependency: ${name}`)
|
|
149
|
+
},
|
|
150
|
+
} as never,
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
expect(sendEmail).toHaveBeenCalledWith(
|
|
154
|
+
expect.objectContaining({ react: expect.objectContaining({ amount: '12.50', currencyCode: 'USD' }) }),
|
|
155
|
+
)
|
|
156
|
+
})
|
|
114
157
|
})
|
|
@@ -3,6 +3,8 @@ import { DEFAULT_NOTIFICATION_DELIVERY_CONFIG, resolveNotificationDeliveryConfig
|
|
|
3
3
|
import type { JobContext, QueuedJob, WorkerMeta } from '@open-mercato/queue'
|
|
4
4
|
import { sendEmail } from '@open-mercato/shared/lib/email/send'
|
|
5
5
|
import { findOneWithDecryption } from '@open-mercato/shared/lib/encryption/find'
|
|
6
|
+
import { resolveCurrencyDecimalPlaces } from '@open-mercato/shared/lib/currencyPrecision'
|
|
7
|
+
import { padDecimalPlaces, parseDecimal } from '@open-mercato/shared/lib/decimal'
|
|
6
8
|
import { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'
|
|
7
9
|
import { CheckoutTransaction, CheckoutLink } from '../data/entities'
|
|
8
10
|
import PaymentStartEmail from '../emails/PaymentStartEmail'
|
|
@@ -133,8 +135,13 @@ export default async function handle(job: QueuedJob<CheckoutEmailJob>, ctx: Hand
|
|
|
133
135
|
|
|
134
136
|
const firstName = transaction.firstName ?? t('checkout.systemEmails.common.customerFallback')
|
|
135
137
|
const linkTitle = link?.title ?? link?.name ?? t('checkout.systemEmails.common.linkTitleFallback')
|
|
136
|
-
const amount = String(transaction.amount ?? '0.00')
|
|
137
138
|
const currencyCode = transaction.currencyCode ?? ''
|
|
139
|
+
const currencyDecimalPlaces = await resolveCurrencyDecimalPlaces(ctx, {
|
|
140
|
+
code: currencyCode,
|
|
141
|
+
tenantId: payload.tenantId,
|
|
142
|
+
organizationId: payload.organizationId,
|
|
143
|
+
})
|
|
144
|
+
const amount = padDecimalPlaces(parseDecimal(transaction.amount) ?? 0, currencyDecimalPlaces ?? 2)
|
|
138
145
|
const errorMessage = payload.type === 'error' ? (payload.errorMessage ?? null) : null
|
|
139
146
|
|
|
140
147
|
const variables: Record<string, string> = {
|