@vectoriox/iox-ui 5.93.0 → 5.94.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,8 @@ declare enum MoneyErrorCode {
7
7
  CurrencyMismatch = "currency-mismatch",
8
8
  NotWhole = "not-whole",
9
9
  Negative = "negative",
10
- Overflow = "overflow"
10
+ Overflow = "overflow",
11
+ OutOfRange = "out-of-range"
11
12
  }
12
13
  declare class MoneyError extends Error {
13
14
  readonly code: MoneyErrorCode;
@@ -84,5 +85,554 @@ declare function formatMoney(value: Money, locale: string): string;
84
85
  */
85
86
  declare function migrateMajorPrice(value: unknown, currency: CurrencyCode): number | null;
86
87
 
87
- export { CURRENCY_CODES, CURRENCY_EXPONENTS, CurrencyCode, MoneyError, MoneyErrorCode, addMoney, currencyExponent, formatMoney, isCurrencyCode, isMoney, majorToMinor, migrateMajorPrice, minorToMajor, money, percentOf, subtractMoney, timesMoney };
88
- export type { Money };
88
+ /**
89
+ * The words a refusal or a state is shown with. A string-rendered site and iox-cms's emails have no translation
90
+ * service, so the core carries English and Hebrew itself (the `blurbHe` / `sentWord` precedent); a host with its
91
+ * own translations may key them by the stable code instead.
92
+ */
93
+ declare enum CommerceLanguage {
94
+ En = "en",
95
+ He = "he"
96
+ }
97
+ interface CommerceLabel {
98
+ readonly en: string;
99
+ readonly he: string;
100
+ }
101
+ declare function commerceLanguage(lang: string | null | undefined): CommerceLanguage;
102
+ declare function labelIn(label: CommerceLabel, lang: string | null | undefined): string;
103
+
104
+ /** A cart holds at most this many distinct lines; more are dropped (`too-many-lines`). */
105
+ declare const MAX_CART_LINES = 100;
106
+ /** One line's quantity is capped here (`quantity-capped`), before stock. */
107
+ declare const MAX_LINE_QUANTITY = 999;
108
+ /**
109
+ * The largest subtotal, shipping price or threshold, in minor units. Subtotal + shipping stays far below 2^53, and
110
+ * the included-VAT arithmetic never forms a product past it.
111
+ */
112
+ declare const MAX_CART_AMOUNT: number;
113
+
114
+ declare const MAX_VAT_PERCENT = 100;
115
+ /** 17, 18, 7.7, 8.1 — four decimals is more than any rate in force; it also keeps the arithmetic below 2^53. */
116
+ declare const VAT_PERCENT_MAX_DECIMALS = 4;
117
+ declare function isVatPercent(value: unknown): value is number;
118
+ /**
119
+ * The VAT a VAT-INCLUSIVE amount already holds (C-D8): amount × v / (100 + v), rounded ONCE to a minor unit,
120
+ * half-to-even. Exact: v is read as the integer R = v·10^s (s ≤ 4 decimals), so the share is
121
+ * amount × R / (100·10^s + R) in whole numbers. 118.00 at 18 % → 18.00; 100.00 at 17 % → 14.53.
122
+ */
123
+ declare function includedVat(total: Money, vatPercent: number): Money;
124
+
125
+ /** The storefront's stock word (iox-cms `storefront-projection.ts` speaks the same values). */
126
+ declare enum Availability {
127
+ InStock = "in_stock",
128
+ Low = "low",
129
+ Out = "out"
130
+ }
131
+ /**
132
+ * One sellable unit as the seller knows it, in minor units: a product with no options is ONE entry with no
133
+ * `variantId`; a product with options is one entry per variant. iox-cms builds it from the product row (with the
134
+ * stock COUNT); the engine builds it from the storefront projection (with the availability WORD only).
135
+ */
136
+ interface CatalogEntry {
137
+ productId: string;
138
+ variantId?: string | null;
139
+ title: string;
140
+ variantName?: string | null;
141
+ /** null = no price set yet (a sample's placeholder): never sold. */
142
+ unitPrice: Money | null;
143
+ compareAt?: Money | null;
144
+ /** The count, where the caller knows it (iox-cms). Wins over `availability`. */
145
+ stock?: number | null;
146
+ /** The word, where only it is known (the engine). */
147
+ availability?: Availability | null;
148
+ /** A variant's switch; a product with no options is `true`. */
149
+ enabled: boolean;
150
+ published: boolean;
151
+ /** false = a digital product: no delivery address, no shipping method. */
152
+ requiresShipping: boolean;
153
+ image?: string | null;
154
+ }
155
+ /** How many units may be sold: the count, else 0 for `out` or nothing known, else null = unbounded here (the server checks the count). */
156
+ declare function sellableQuantity(entry: CatalogEntry): number | null;
157
+ declare const catalogKey: (productId: string, variantId?: string | null) => string;
158
+
159
+ /** Shipping v1 (C-D9): methods per studio, one country. Zones and weights come later. */
160
+ declare enum ShippingMethodKind {
161
+ Pickup = "pickup",
162
+ Flat = "flat",
163
+ /** A flat price that becomes free once the goods reach `freeOver`. */
164
+ FreeOver = "freeOver",
165
+ /** No address, nothing shipped — offered only when nothing in the cart ships. */
166
+ Digital = "digital"
167
+ }
168
+ /** What an owner must fill for a method of a kind. */
169
+ declare enum ShippingField {
170
+ Price = "price",
171
+ FreeOver = "freeOver",
172
+ PickupAddress = "pickupAddress"
173
+ }
174
+ interface ShippingMethod {
175
+ id: string;
176
+ kind: ShippingMethodKind;
177
+ name: string;
178
+ enabled: boolean;
179
+ price?: Money | null;
180
+ freeOver?: Money | null;
181
+ pickupAddress?: string | null;
182
+ pickupHours?: string | null;
183
+ }
184
+ interface ShippingKindRule {
185
+ readonly needsAddress: boolean;
186
+ /** Offered for a cart where something ships (true) or for one where nothing does (false). */
187
+ readonly forPhysical: boolean;
188
+ readonly requires: readonly ShippingField[];
189
+ readonly price: (method: ShippingMethod, goods: Money) => Money;
190
+ readonly label: CommerceLabel;
191
+ }
192
+ declare const SHIPPING_KINDS: Readonly<Record<ShippingMethodKind, ShippingKindRule>>;
193
+ declare const isShippingMethodKind: (value: unknown) => value is ShippingMethodKind;
194
+ declare function shippingNeedsAddress(kind: ShippingMethodKind): boolean;
195
+ /** The fields a method lacks (or holds in another currency) — empty = it can be offered. */
196
+ declare function shippingMethodProblems(method: ShippingMethod, currency: CurrencyCode): ShippingField[];
197
+ /** Enabled, complete, with an id and a name: the ONE rule both the offer and the checkout gate read. */
198
+ declare function shippingMethodReady(method: ShippingMethod, currency: CurrencyCode): boolean;
199
+ interface ShippingQuote {
200
+ methodId: string;
201
+ kind: ShippingMethodKind;
202
+ name: string;
203
+ price: Money;
204
+ /** A free-over method whose threshold the goods reached. */
205
+ free: boolean;
206
+ needsAddress: boolean;
207
+ }
208
+ /** What a quote reads of a cart. */
209
+ interface ShippingGoods {
210
+ currency: CurrencyCode;
211
+ /** The goods after discounts — what a free-over threshold is compared with. */
212
+ goods: Money;
213
+ requiresShipping: boolean;
214
+ lineCount: number;
215
+ }
216
+ /** The part of a `PricedCart` the offer reads. */
217
+ interface ShippingCart {
218
+ currency: CurrencyCode;
219
+ subtotal: Money;
220
+ discount: Money;
221
+ requiresShipping: boolean;
222
+ lines: readonly unknown[];
223
+ }
224
+ declare function quoteShipping(methods: readonly ShippingMethod[], cart: ShippingGoods): ShippingQuote[];
225
+ /**
226
+ * The methods a buyer may choose for this cart, each priced for it (free over: free when the goods after
227
+ * discounts are AT or above the threshold). A cart where nothing ships is offered Digital methods only; a cart
228
+ * where anything ships never is.
229
+ */
230
+ declare function availableShippingMethods(methods: readonly ShippingMethod[], pricedCart: ShippingCart): ShippingQuote[];
231
+
232
+ /** A cart names what and how many — never a price (C-D16, trap T1): every read prices it again. */
233
+ interface CartLine {
234
+ productId: string;
235
+ variantId?: string | null;
236
+ quantity: number;
237
+ }
238
+ interface Cart {
239
+ lines: readonly CartLine[];
240
+ }
241
+ interface StudioCommerce {
242
+ currency: CurrencyCode;
243
+ /** Prices INCLUDE it (C-D8). */
244
+ vatPercent: number;
245
+ shippingMethods: readonly ShippingMethod[];
246
+ }
247
+ interface PricingChoice {
248
+ shippingMethodId?: string | null;
249
+ }
250
+ declare enum CartIssueCode {
251
+ /** Not a whole number ≥ 1: the line is dropped. */
252
+ InvalidQuantity = "invalid-quantity",
253
+ /** The same product and variant twice: merged into the first. */
254
+ DuplicateLine = "duplicate-line",
255
+ TooManyLines = "too-many-lines",
256
+ QuantityCapped = "quantity-capped",
257
+ UnknownProduct = "unknown-product",
258
+ /** The product exists, this variant does not (or the product needs a variant chosen). */
259
+ UnknownVariant = "unknown-variant",
260
+ Unpublished = "unpublished",
261
+ VariantDisabled = "variant-disabled",
262
+ NoPrice = "no-price",
263
+ CurrencyMismatch = "currency-mismatch",
264
+ OutOfStock = "out-of-stock",
265
+ /** Fewer left than asked: the line keeps what is left. */
266
+ QuantityClamped = "quantity-clamped",
267
+ /** The line would push the subtotal past `MAX_CART_AMOUNT`: dropped. */
268
+ AmountTooLarge = "amount-too-large",
269
+ /** The chosen shipping method is not offered for this cart: no shipping is priced. */
270
+ ShippingUnavailable = "shipping-unavailable",
271
+ /** The studio's VAT is not a usable rate: the VAT line reads 0. */
272
+ VatInvalid = "vat-invalid"
273
+ }
274
+ declare const CART_ISSUE_LABELS: Readonly<Record<CartIssueCode, CommerceLabel>>;
275
+ interface CartIssue {
276
+ code: CartIssueCode;
277
+ productId?: string;
278
+ variantId?: string | null;
279
+ /** What the cart asked for. */
280
+ requested?: number;
281
+ /** What the priced line holds now (clamped / capped). */
282
+ quantity?: number;
283
+ shippingMethodId?: string;
284
+ }
285
+ interface PricedLine {
286
+ productId: string;
287
+ variantId: string | null;
288
+ title: string;
289
+ variantName: string | null;
290
+ quantity: number;
291
+ unitPrice: Money;
292
+ /** Shown struck through — only when it is above the price. */
293
+ compareAt: Money | null;
294
+ lineTotal: Money;
295
+ requiresShipping: boolean;
296
+ image: string | null;
297
+ }
298
+ interface PricedCart {
299
+ currency: CurrencyCode;
300
+ lines: PricedLine[];
301
+ subtotal: Money;
302
+ /** Zero until coupons (E4); `total` already subtracts it. */
303
+ discount: Money;
304
+ shipping: Money;
305
+ shippingMethod: ShippingQuote | null;
306
+ requiresShipping: boolean;
307
+ /** subtotal − discount + shipping: what the buyer pays. VAT is INSIDE it. */
308
+ total: Money;
309
+ /** The VAT `total` includes: total × v / (100 + v), rounded once half-to-even (`includedVat`). */
310
+ vat: Money;
311
+ vatPercent: number;
312
+ issues: CartIssue[];
313
+ }
314
+ /**
315
+ * THE pricing function (C-D7, trap T1): the engine shows its result, iox-cms recomputes it at checkout and at
316
+ * payment. Prices come from the catalog only — a cart line carries no number but a quantity. Every money value
317
+ * out is whole minor units in the studio currency. An unusable line is dropped or adjusted and SAID in `issues`.
318
+ */
319
+ declare function priceCart(cart: Cart, catalog: readonly CatalogEntry[], studio: StudioCommerce, choice?: PricingChoice | null): PricedCart;
320
+ /** The cart a priced cart stands for — what to store back once the buyer has seen the issues. */
321
+ declare function cartOf(priced: PricedCart): Cart;
322
+ /** Sign-in merge (E3): b's lines join a's; the same product and variant add up. priceCart caps and clamps later. */
323
+ declare function mergeCarts(a: Cart, b: Cart): Cart;
324
+
325
+ declare enum PaymentChannel {
326
+ /** The owner marks the order paid (C-D11). */
327
+ Manual = "manual",
328
+ /** The studio's PSP; only its verified callback marks the order paid. */
329
+ Online = "online"
330
+ }
331
+ declare enum PaymentMethodKind {
332
+ BankTransfer = "bankTransfer",
333
+ PayOnPickup = "payOnPickup",
334
+ CashOnDelivery = "cashOnDelivery",
335
+ Bit = "bit",
336
+ /** A PSP's hosted page (E2, Cardcom first) — typed now, not offered yet. */
337
+ Online = "online"
338
+ }
339
+ declare enum PaymentProvider {
340
+ Cardcom = "cardcom"
341
+ }
342
+ /** What an owner fills for a method. */
343
+ declare enum PaymentField {
344
+ AccountName = "accountName",
345
+ Bank = "bank",
346
+ Branch = "branch",
347
+ AccountNumber = "accountNumber",
348
+ BitPhone = "bitPhone",
349
+ Provider = "provider"
350
+ }
351
+ /** Which deliveries a method can be used with. */
352
+ declare enum DeliveryFit {
353
+ Any = "any",
354
+ /** Paid at the counter: only with a pickup method. */
355
+ PickupOnly = "pickupOnly",
356
+ /** Paid to the courier: only with a method that delivers to an address. */
357
+ AddressOnly = "addressOnly"
358
+ }
359
+ interface PaymentMethodRule {
360
+ readonly channel: PaymentChannel;
361
+ /** false = typed for a later phase, never shown to a buyer. */
362
+ readonly offered: boolean;
363
+ readonly fields: readonly PaymentField[];
364
+ readonly fit: DeliveryFit;
365
+ readonly label: CommerceLabel;
366
+ /** What the buyer reads after placing the order; `{total}`, `{orderNumber}` and the method's fields fill in. */
367
+ readonly instructions: CommerceLabel;
368
+ }
369
+ declare const PAYMENT_METHODS: Readonly<Record<PaymentMethodKind, PaymentMethodRule>>;
370
+ declare const PAYMENT_FIELD_LABELS: Readonly<Record<PaymentField, CommerceLabel>>;
371
+ interface PaymentMethodConfig {
372
+ kind: PaymentMethodKind;
373
+ enabled: boolean;
374
+ details?: Partial<Record<PaymentField, string>> | null;
375
+ /** The owner's own words, shown after the instructions. */
376
+ note?: string | null;
377
+ }
378
+ declare const isPaymentMethodKind: (value: unknown) => value is PaymentMethodKind;
379
+ declare function paymentChannelOf(kind: PaymentMethodKind): PaymentChannel;
380
+ /** The fields a method lacks or holds in a form it cannot be paid with. */
381
+ declare function paymentMethodProblems(config: PaymentMethodConfig): PaymentField[];
382
+ /** Enabled, offered in this phase, complete: the ONE rule the checkout and its gate read. */
383
+ declare function paymentMethodReady(config: PaymentMethodConfig): boolean;
384
+ /** The methods a buyer may pick with this delivery (null = nothing ships). */
385
+ declare function usablePaymentMethods(configs: readonly PaymentMethodConfig[], shippingKind?: ShippingMethodKind | null): PaymentMethodConfig[];
386
+ /** What the buyer is told to do, in their language: the method's sentence with the order, the amount and the owner's details, then the owner's note. */
387
+ declare function paymentInstructions(config: PaymentMethodConfig, order: {
388
+ orderNumber: string;
389
+ total: Money;
390
+ }, lang: string | null | undefined, locale?: string): string;
391
+
392
+ /** C-D11 — the order's closed states. */
393
+ declare enum OrderState {
394
+ /** A manual method: waiting for the owner to see the money. */
395
+ AwaitingPayment = "awaiting_payment",
396
+ /** An online method: the PSP's page is open. */
397
+ PendingPayment = "pending_payment",
398
+ Paid = "paid",
399
+ Fulfilled = "fulfilled",
400
+ Delivered = "delivered",
401
+ Cancelled = "cancelled",
402
+ PaymentFailed = "payment_failed",
403
+ Refunded = "refunded",
404
+ PartiallyRefunded = "partially_refunded"
405
+ }
406
+ declare enum OrderEvent {
407
+ /** The buyer tries to pay again after a failure. */
408
+ StartPayment = "startPayment",
409
+ /** The PSP's verified callback says paid. */
410
+ ConfirmPayment = "confirmPayment",
411
+ FailPayment = "failPayment",
412
+ /** The owner saw the money of a manual method. */
413
+ MarkPaid = "markPaid",
414
+ Fulfil = "fulfil",
415
+ Deliver = "deliver",
416
+ Cancel = "cancel",
417
+ /** Nobody paid in time (the jobs runner). */
418
+ Expire = "expire",
419
+ Refund = "refund",
420
+ PartialRefund = "partialRefund"
421
+ }
422
+ declare enum OrderActor {
423
+ Buyer = "buyer",
424
+ Owner = "owner",
425
+ /** A VERIFIED payment callback (trap T2) — never the browser's return redirect. */
426
+ PaymentCallback = "paymentCallback",
427
+ System = "system"
428
+ }
429
+ /** What an order holds of the stock in a state (C-D10). */
430
+ declare enum StockHold {
431
+ None = "none",
432
+ /** Held for `STOCK_RESERVATION_MINUTES` while a PSP payment is open. */
433
+ Reserved = "reserved",
434
+ /** Decremented: sold, or promised to a manual order. */
435
+ Taken = "taken"
436
+ }
437
+ /** What the server does to stock when an order moves — read from data, never decided per call site. */
438
+ declare enum StockEffect {
439
+ None = "none",
440
+ Reserve = "reserve",
441
+ CommitReservation = "commitReservation",
442
+ ReleaseReservation = "releaseReservation",
443
+ /** The conditional atomic decrement (E0's `takeStock`). */
444
+ Take = "take",
445
+ GiveBack = "giveBack"
446
+ }
447
+ declare enum OrderRefusal {
448
+ /** The event does not apply in this state. */
449
+ InvalidTransition = "invalid-transition",
450
+ /** It applies — but not from this actor (e.g. the owner marking an online payment paid). */
451
+ ActorNotAllowed = "actor-not-allowed",
452
+ /** Cancelled and refunded orders move no more. */
453
+ OrderFinal = "order-final"
454
+ }
455
+ declare const STOCK_RESERVATION_MINUTES = 15;
456
+ declare const ORDER_STOCK_HOLD: Readonly<Record<OrderState, StockHold>>;
457
+ /** from-hold → to-hold → effect. Taken → Reserved never happens (the transitions spec proves it). */
458
+ declare const STOCK_EFFECTS: Readonly<Record<StockHold, Readonly<Record<StockHold, StockEffect>>>>;
459
+ declare const FINAL_ORDER_STATES: readonly OrderState[];
460
+ interface OrderTransition {
461
+ readonly from: OrderState;
462
+ readonly event: OrderEvent;
463
+ readonly to: OrderState;
464
+ readonly actors: readonly OrderActor[];
465
+ }
466
+ /** THE order state machine (C-D11). Anything not listed is refused. */
467
+ declare const ORDER_TRANSITIONS: readonly OrderTransition[];
468
+ type OrderMove = {
469
+ ok: true;
470
+ state: OrderState;
471
+ stock: StockEffect;
472
+ } | {
473
+ ok: false;
474
+ refusal: OrderRefusal;
475
+ };
476
+ declare function stockEffect(from: OrderState | null, to: OrderState): StockEffect;
477
+ /** The ONE place an order moves: the next state and what to do to the stock, or why not. */
478
+ declare function nextOrderState(state: OrderState, event: OrderEvent, actor: OrderActor): OrderMove;
479
+ /** A new order's state and stock effect: a manual order takes its stock at once, an online one reserves it. */
480
+ declare function openingOrderState(kind: PaymentMethodKind): {
481
+ state: OrderState;
482
+ stock: StockEffect;
483
+ };
484
+ declare function reservationExpiresAt(now: Date): Date;
485
+ declare const ORDER_STATE_LABELS: Readonly<Record<OrderState, CommerceLabel>>;
486
+
487
+ /** The fixed checkout's steps, in order (C-D3); a checkout keeps the FURTHEST it reached (the journey, §3g). */
488
+ declare enum CheckoutStep {
489
+ Contact = "contact",
490
+ Delivery = "delivery",
491
+ Payment = "payment",
492
+ Paid = "paid"
493
+ }
494
+ declare const CHECKOUT_STEPS: readonly CheckoutStep[];
495
+ declare const CHECKOUT_STEP_LABELS: Readonly<Record<CheckoutStep, CommerceLabel>>;
496
+ declare function furthestStep(a: CheckoutStep | null | undefined, b: CheckoutStep | null | undefined): CheckoutStep;
497
+ /** The pages the OWNER writes and links from checkout (§3k). IOX never writes their text (T14). */
498
+ declare enum LegalPage {
499
+ Terms = "terms",
500
+ Returns = "returns",
501
+ Shipping = "shipping",
502
+ Privacy = "privacy"
503
+ }
504
+ /** Who sells, as Israel's Consumer Protection Law asks a distance seller to say (§3k). */
505
+ interface BusinessIdentity {
506
+ legalName?: string | null;
507
+ /** עוסק מורשה / ח.פ / ת.ז */
508
+ businessNumber?: string | null;
509
+ address?: string | null;
510
+ email?: string | null;
511
+ phone?: string | null;
512
+ }
513
+ interface CheckoutGateFacts {
514
+ currency: unknown;
515
+ vatPercent: unknown;
516
+ paymentMethods: readonly PaymentMethodConfig[];
517
+ shippingMethods: readonly ShippingMethod[];
518
+ /** Any product of the studio that is not digital. */
519
+ anyProductShips: boolean;
520
+ business: BusinessIdentity;
521
+ /** Each page exists and checkout links it. */
522
+ legalPages: Partial<Record<LegalPage, boolean>>;
523
+ }
524
+ declare enum CheckoutGateArea {
525
+ Payment = "payment",
526
+ Money = "money",
527
+ Shipping = "shipping",
528
+ Business = "business",
529
+ LegalPages = "legalPages"
530
+ }
531
+ declare enum CheckoutGateCode {
532
+ NoPaymentMethod = "no-payment-method",
533
+ CurrencyNotSet = "currency-not-set",
534
+ VatNotSet = "vat-not-set",
535
+ NoShippingMethod = "no-shipping-method",
536
+ BusinessNameMissing = "business-name-missing",
537
+ BusinessNumberMissing = "business-number-missing",
538
+ BusinessAddressMissing = "business-address-missing",
539
+ BusinessEmailMissing = "business-email-missing",
540
+ BusinessPhoneMissing = "business-phone-missing",
541
+ TermsPageMissing = "terms-page-missing",
542
+ ReturnsPageMissing = "returns-page-missing",
543
+ ShippingPageMissing = "shipping-page-missing",
544
+ PrivacyPageMissing = "privacy-page-missing"
545
+ }
546
+ interface CheckoutGateRule {
547
+ readonly code: CheckoutGateCode;
548
+ readonly area: CheckoutGateArea;
549
+ readonly refuses: (facts: CheckoutGateFacts) => boolean;
550
+ readonly label: CommerceLabel;
551
+ }
552
+ /** THE checkout gate (C-D19), in the order the owner fixes things. The server refuses with it; the admin shows the same rows. */
553
+ declare const CHECKOUT_GATE_RULES: readonly CheckoutGateRule[];
554
+ interface CheckoutGateRefusal {
555
+ code: CheckoutGateCode;
556
+ area: CheckoutGateArea;
557
+ label: CommerceLabel;
558
+ }
559
+ interface CheckoutGateResult {
560
+ open: boolean;
561
+ refusals: CheckoutGateRefusal[];
562
+ }
563
+ /** Checkout opens only when no rule refuses (C-D19, trap T9: the server's, never a hidden button). */
564
+ declare function checkoutGate(facts: CheckoutGateFacts): CheckoutGateResult;
565
+
566
+ interface PostalAddress {
567
+ line1: string;
568
+ line2?: string | null;
569
+ city: string;
570
+ postalCode?: string | null;
571
+ /** ISO 3166-1 alpha-2 — one country in v1 (C-D9). */
572
+ country: string;
573
+ }
574
+ interface OrderBuyer {
575
+ email: string;
576
+ name: string;
577
+ phone?: string | null;
578
+ /** Needed when the delivery method delivers to an address. */
579
+ address?: PostalAddress | null;
580
+ }
581
+ declare enum OrderSnapshotRefusal {
582
+ EmptyCart = "empty-cart",
583
+ /** The priced cart has issues the buyer has not seen: show them the priced cart first. */
584
+ CartChanged = "cart-changed",
585
+ ShippingNotChosen = "shipping-not-chosen",
586
+ AddressRequired = "address-required",
587
+ EmailRequired = "email-required",
588
+ NameRequired = "name-required",
589
+ /** Not enabled, not complete, not offered yet, or not usable with this delivery. */
590
+ PaymentMethodUnusable = "payment-method-unusable"
591
+ }
592
+ interface OrderSnapshotLine {
593
+ readonly productId: string;
594
+ readonly variantId: string | null;
595
+ readonly title: string;
596
+ readonly variantName: string | null;
597
+ readonly quantity: number;
598
+ readonly unitPrice: Money;
599
+ readonly lineTotal: Money;
600
+ readonly requiresShipping: boolean;
601
+ }
602
+ /** What an order stores: frozen, so a later price, name or bank-detail change never changes a placed order. */
603
+ interface OrderSnapshot {
604
+ readonly currency: CurrencyCode;
605
+ readonly lines: readonly OrderSnapshotLine[];
606
+ readonly subtotal: Money;
607
+ readonly discount: Money;
608
+ readonly shipping: Money;
609
+ readonly delivery: {
610
+ readonly methodId: string;
611
+ readonly kind: ShippingMethodKind;
612
+ readonly name: string;
613
+ } | null;
614
+ readonly total: Money;
615
+ readonly vat: {
616
+ readonly percent: number;
617
+ readonly amount: Money;
618
+ };
619
+ readonly payment: {
620
+ readonly kind: PaymentMethodKind;
621
+ readonly channel: PaymentChannel;
622
+ readonly details: Readonly<Partial<Record<PaymentField, string>>>;
623
+ readonly note: string | null;
624
+ };
625
+ readonly buyer: Readonly<OrderBuyer>;
626
+ }
627
+ type OrderSnapshotResult = {
628
+ ok: true;
629
+ snapshot: OrderSnapshot;
630
+ } | {
631
+ ok: false;
632
+ refusals: OrderSnapshotRefusal[];
633
+ };
634
+ /** Freezes what an order stores (lines, unit prices, totals, VAT, currency, delivery, payment, buyer) — or says why it cannot. */
635
+ declare function orderSnapshot(pricedCart: PricedCart, payment: PaymentMethodConfig, buyer: OrderBuyer): OrderSnapshotResult;
636
+
637
+ export { Availability, CART_ISSUE_LABELS, CHECKOUT_GATE_RULES, CHECKOUT_STEPS, CHECKOUT_STEP_LABELS, CURRENCY_CODES, CURRENCY_EXPONENTS, CartIssueCode, CheckoutGateArea, CheckoutGateCode, CheckoutStep, CommerceLanguage, CurrencyCode, DeliveryFit, FINAL_ORDER_STATES, LegalPage, MAX_CART_AMOUNT, MAX_CART_LINES, MAX_LINE_QUANTITY, MAX_VAT_PERCENT, MoneyError, MoneyErrorCode, ORDER_STATE_LABELS, ORDER_STOCK_HOLD, ORDER_TRANSITIONS, OrderActor, OrderEvent, OrderRefusal, OrderSnapshotRefusal, OrderState, PAYMENT_FIELD_LABELS, PAYMENT_METHODS, PaymentChannel, PaymentField, PaymentMethodKind, PaymentProvider, SHIPPING_KINDS, STOCK_EFFECTS, STOCK_RESERVATION_MINUTES, ShippingField, ShippingMethodKind, StockEffect, StockHold, VAT_PERCENT_MAX_DECIMALS, addMoney, availableShippingMethods, cartOf, catalogKey, checkoutGate, commerceLanguage, currencyExponent, formatMoney, furthestStep, includedVat, isCurrencyCode, isMoney, isPaymentMethodKind, isShippingMethodKind, isVatPercent, labelIn, majorToMinor, mergeCarts, migrateMajorPrice, minorToMajor, money, nextOrderState, openingOrderState, orderSnapshot, paymentChannelOf, paymentInstructions, paymentMethodProblems, paymentMethodReady, percentOf, priceCart, quoteShipping, reservationExpiresAt, sellableQuantity, shippingMethodProblems, shippingMethodReady, shippingNeedsAddress, stockEffect, subtractMoney, timesMoney, usablePaymentMethods };
638
+ export type { BusinessIdentity, Cart, CartIssue, CartLine, CatalogEntry, CheckoutGateFacts, CheckoutGateRefusal, CheckoutGateResult, CommerceLabel, Money, OrderBuyer, OrderMove, OrderSnapshot, OrderSnapshotLine, OrderSnapshotResult, OrderTransition, PaymentMethodConfig, PostalAddress, PricedCart, PricedLine, PricingChoice, ShippingCart, ShippingGoods, ShippingMethod, ShippingQuote, StudioCommerce };