@vectoriox/iox-ui 5.119.0 → 5.120.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/commerce-core/index.d.ts +169 -5
- package/fesm2022/vectoriox-iox-ui-commerce-core.mjs +214 -5
- package/fesm2022/vectoriox-iox-ui-commerce-core.mjs.map +1 -1
- package/package.json +1 -1
- package/src/commerce-core/payment-sessions.ts +213 -0
- package/src/commerce-core/payments.ts +21 -4
- package/src/commerce-core/public-api.ts +1 -0
- package/src/commerce-core/site-checkout.ts +61 -1
package/commerce-core/index.d.ts
CHANGED
|
@@ -467,7 +467,7 @@ declare enum PaymentMethodKind {
|
|
|
467
467
|
PayOnPickup = "payOnPickup",
|
|
468
468
|
CashOnDelivery = "cashOnDelivery",
|
|
469
469
|
Bit = "bit",
|
|
470
|
-
/** A PSP's hosted page (E2, Cardcom first)
|
|
470
|
+
/** A PSP's hosted page (E2, Cardcom first): the buyer pays there, never on a card field of ours. */
|
|
471
471
|
Online = "online"
|
|
472
472
|
}
|
|
473
473
|
declare enum PaymentProvider {
|
|
@@ -494,6 +494,8 @@ interface PaymentMethodRule {
|
|
|
494
494
|
readonly channel: PaymentChannel;
|
|
495
495
|
/** false = typed for a later phase, never shown to a buyer. */
|
|
496
496
|
readonly offered: boolean;
|
|
497
|
+
/** Ready only while the studio's payment connector answers (E2): the server says so in `connected`. */
|
|
498
|
+
readonly needsConnection: boolean;
|
|
497
499
|
readonly fields: readonly PaymentField[];
|
|
498
500
|
readonly fit: DeliveryFit;
|
|
499
501
|
readonly label: CommerceLabel;
|
|
@@ -508,12 +510,19 @@ interface PaymentMethodConfig {
|
|
|
508
510
|
details?: Partial<Record<PaymentField, string>> | null;
|
|
509
511
|
/** The owner's own words, shown after the instructions. */
|
|
510
512
|
note?: string | null;
|
|
513
|
+
/**
|
|
514
|
+
* A FACT the server adds, never stored: the studio's payment connector answered its last check (E2). Only a method
|
|
515
|
+
* that `needsConnection` reads it — a card method whose terminal does not answer is not a way to get paid.
|
|
516
|
+
*/
|
|
517
|
+
connected?: boolean | null;
|
|
511
518
|
}
|
|
512
519
|
declare const isPaymentMethodKind: (value: unknown) => value is PaymentMethodKind;
|
|
513
520
|
declare function paymentChannelOf(kind: PaymentMethodKind): PaymentChannel;
|
|
514
521
|
/** The fields a method lacks or holds in a form it cannot be paid with. */
|
|
515
522
|
declare function paymentMethodProblems(config: PaymentMethodConfig): PaymentField[];
|
|
516
|
-
/**
|
|
523
|
+
/** A method that needs no connection, or whose connection answered (E2). */
|
|
524
|
+
declare function paymentMethodConnected(config: PaymentMethodConfig): boolean;
|
|
525
|
+
/** Enabled, offered in this phase, complete and — for a card method — connected: the ONE rule the checkout and its gate read. */
|
|
517
526
|
declare function paymentMethodReady(config: PaymentMethodConfig): boolean;
|
|
518
527
|
/** The methods a buyer may pick with this delivery (null = nothing ships). */
|
|
519
528
|
declare function usablePaymentMethods(configs: readonly PaymentMethodConfig[], shippingKind?: ShippingMethodKind | null): PaymentMethodConfig[];
|
|
@@ -618,6 +627,122 @@ declare function openingOrderState(kind: PaymentMethodKind): {
|
|
|
618
627
|
declare function reservationExpiresAt(now: Date): Date;
|
|
619
628
|
declare const ORDER_STATE_LABELS: Readonly<Record<OrderState, CommerceLabel>>;
|
|
620
629
|
|
|
630
|
+
/**
|
|
631
|
+
* Card payments (commerce E2, C-D2, trap T2): what a payment provider's answer MEANS for an order. The provider's
|
|
632
|
+
* adapter (iox-cms) asks the provider itself — never the buyer's browser, never a webhook's body — and normalises its
|
|
633
|
+
* answer to a `PaymentResult`; `paymentVerdict` decides. Pure: no clock (the caller passes `now`), no provider names.
|
|
634
|
+
*/
|
|
635
|
+
declare enum PaymentResultStatus {
|
|
636
|
+
/** The provider took the money: a transaction exists. */
|
|
637
|
+
Paid = "paid",
|
|
638
|
+
/** The page is open (the buyer has not paid yet, or a card was declined and the page still waits). */
|
|
639
|
+
Pending = "pending",
|
|
640
|
+
/** The provider closed the session without a payment. */
|
|
641
|
+
Failed = "failed",
|
|
642
|
+
/** The provider does not know the session (or did not answer): nothing is decided. */
|
|
643
|
+
Unknown = "unknown"
|
|
644
|
+
}
|
|
645
|
+
/** One provider answer about one session, as its adapter read it. */
|
|
646
|
+
interface PaymentResult {
|
|
647
|
+
status: PaymentResultStatus;
|
|
648
|
+
/** The provider's session id, as the provider said it. */
|
|
649
|
+
sessionId: string | null;
|
|
650
|
+
/** Our reference, echoed back by the provider (what we sent when the session was made). */
|
|
651
|
+
reference: string | null;
|
|
652
|
+
/** The provider's transaction id — what a refund names. */
|
|
653
|
+
transactionId: string | null;
|
|
654
|
+
/** What was charged, in minor units of the charged currency. */
|
|
655
|
+
amount: Money | null;
|
|
656
|
+
/** The provider's words for the last declined try while the page still waits — shown to the buyer. */
|
|
657
|
+
declined?: string | null;
|
|
658
|
+
/** What the owner may read of the card that paid (never more than a brand and the last four digits). */
|
|
659
|
+
card?: PaidCard | null;
|
|
660
|
+
}
|
|
661
|
+
interface PaidCard {
|
|
662
|
+
brand: string | null;
|
|
663
|
+
last4: string | null;
|
|
664
|
+
}
|
|
665
|
+
/** One time the buyer was sent to the provider's page for an order. */
|
|
666
|
+
declare enum PaymentAttemptStatus {
|
|
667
|
+
Open = "open",
|
|
668
|
+
Paid = "paid",
|
|
669
|
+
Failed = "failed",
|
|
670
|
+
/** The order expired or was cancelled while this page was open. */
|
|
671
|
+
Closed = "closed"
|
|
672
|
+
}
|
|
673
|
+
interface PaymentAttempt {
|
|
674
|
+
/** Our reference: the provider echoes it, so a result for another order is refused. */
|
|
675
|
+
reference: string;
|
|
676
|
+
provider: string;
|
|
677
|
+
sessionId: string;
|
|
678
|
+
/** Where the buyer pays (the provider's hosted page). */
|
|
679
|
+
url: string;
|
|
680
|
+
status: PaymentAttemptStatus;
|
|
681
|
+
createdAt: Date | string;
|
|
682
|
+
}
|
|
683
|
+
declare enum PaymentVerdictKind {
|
|
684
|
+
/** Paid and every fact matches: the order moves to paid (the machine's `confirmPayment`). */
|
|
685
|
+
Confirm = "confirm",
|
|
686
|
+
/** The provider closed the session unpaid: `failPayment`, the reservation released. */
|
|
687
|
+
Fail = "fail",
|
|
688
|
+
/** Still open: show "Confirming…" and ask again. */
|
|
689
|
+
Wait = "wait",
|
|
690
|
+
/** Nothing to do (an unknown session, a pending page of an order that moved on). */
|
|
691
|
+
Ignore = "ignore",
|
|
692
|
+
/** The answer does not belong to this order or does not match it: nothing changes, the owner is told. */
|
|
693
|
+
Refuse = "refuse",
|
|
694
|
+
/** The same transaction was already recorded: a replayed answer, a second webhook, the return racing the webhook. */
|
|
695
|
+
AlreadyPaid = "alreadyPaid",
|
|
696
|
+
/** A SECOND transaction paid an order already paid (two tabs): kept for the owner to refund. */
|
|
697
|
+
PaidTwice = "paidTwice",
|
|
698
|
+
/** Paid after the order was cancelled (the reservation ran out): kept for the owner to refund. */
|
|
699
|
+
PaidAfterClose = "paidAfterClose"
|
|
700
|
+
}
|
|
701
|
+
declare enum PaymentMismatch {
|
|
702
|
+
Session = "session-mismatch",
|
|
703
|
+
Reference = "reference-mismatch",
|
|
704
|
+
Currency = "currency-mismatch",
|
|
705
|
+
Amount = "amount-mismatch",
|
|
706
|
+
NoTransaction = "no-transaction"
|
|
707
|
+
}
|
|
708
|
+
interface PaymentVerdict {
|
|
709
|
+
kind: PaymentVerdictKind;
|
|
710
|
+
mismatches: PaymentMismatch[];
|
|
711
|
+
}
|
|
712
|
+
interface PaymentVerdictInput {
|
|
713
|
+
state: OrderState;
|
|
714
|
+
/** The order's total — what must have been charged. */
|
|
715
|
+
total: Money;
|
|
716
|
+
/** The attempt this answer is about (found by OUR records, never by the answer). */
|
|
717
|
+
attempt: Pick<PaymentAttempt, 'reference' | 'sessionId'>;
|
|
718
|
+
/** The transaction already recorded as paying this order, if any. */
|
|
719
|
+
paidTransactionId: string | null;
|
|
720
|
+
result: PaymentResult;
|
|
721
|
+
}
|
|
722
|
+
/** THE decision on a provider's answer (T2): only a paid answer for THIS attempt, of exactly this total, pays — once. */
|
|
723
|
+
declare function paymentVerdict(input: PaymentVerdictInput): PaymentVerdict;
|
|
724
|
+
/** A page made this recently is sent again instead of a new one (a double click, a second tab) — while the stock is held. */
|
|
725
|
+
declare function reusableAttempt(attempts: readonly PaymentAttempt[] | null | undefined, now: number): PaymentAttempt | null;
|
|
726
|
+
/** The reservation ran out: the payment sweep asks the provider one last time, then expires the order (C-D10). */
|
|
727
|
+
declare function reservationDue(reservedUntil: Date | string | null | undefined, now: number): boolean;
|
|
728
|
+
/** What the buyer's order page shows about paying (the engine's "Confirming your payment…"). */
|
|
729
|
+
declare enum BuyerPaymentStage {
|
|
730
|
+
/** A manual method: how to pay. */
|
|
731
|
+
Instructions = "instructions",
|
|
732
|
+
/** A card payment is open: confirming with the provider. */
|
|
733
|
+
Confirming = "confirming",
|
|
734
|
+
Paid = "paid",
|
|
735
|
+
/** The card payment did not go through: the buyer may try again. */
|
|
736
|
+
Failed = "failed",
|
|
737
|
+
/** Cancelled (by the owner, or not paid in time). */
|
|
738
|
+
Closed = "closed"
|
|
739
|
+
}
|
|
740
|
+
declare function buyerPaymentStage(state: OrderState, channel: PaymentChannel): BuyerPaymentStage;
|
|
741
|
+
/** The buyer may (re)open the payment page: still within the open states of a card order. */
|
|
742
|
+
declare function buyerMayPay(state: OrderState, channel: PaymentChannel): boolean;
|
|
743
|
+
/** What happened to a card payment, as the order's history and the admin say it. */
|
|
744
|
+
declare const PAYMENT_VERDICT_LABELS: Readonly<Record<PaymentVerdictKind, CommerceLabel>>;
|
|
745
|
+
|
|
621
746
|
/** The fixed checkout's steps, in order (C-D3); a checkout keeps the FURTHEST it reached (the journey, §3g). */
|
|
622
747
|
declare enum CheckoutStep {
|
|
623
748
|
Contact = "contact",
|
|
@@ -1115,6 +1240,12 @@ declare enum SiteCommerceRoute {
|
|
|
1115
1240
|
Unsubscribe = "marketing/unsubscribe",
|
|
1116
1241
|
Order = "order"
|
|
1117
1242
|
}
|
|
1243
|
+
/** What the buyer does to a card order through its link (E2): `pay` opens (or re-opens) the provider's page. */
|
|
1244
|
+
declare enum SiteOrderAction {
|
|
1245
|
+
Pay = "pay"
|
|
1246
|
+
}
|
|
1247
|
+
/** `POST /api/site/<org>/order/<token>/pay` — root-relative, like every site route. */
|
|
1248
|
+
declare function siteOrderActionPath(orgId: string, token: string, action: SiteOrderAction): string;
|
|
1118
1249
|
/** A public commerce route of one org, ROOT-relative (the same rule as `cartEndpointPath`). */
|
|
1119
1250
|
declare function siteCommercePath(orgId: string, route: SiteCommerceRoute, id?: string | null): string;
|
|
1120
1251
|
/** The cart cookie iox-cms sets for one org (httpOnly — a site script never reads it; SSR forwards it). */
|
|
@@ -1220,11 +1351,29 @@ interface SiteBuyerOrder {
|
|
|
1220
1351
|
snapshot: OrderSnapshot;
|
|
1221
1352
|
paymentLabel: string;
|
|
1222
1353
|
instructions: string | null;
|
|
1354
|
+
/** How paying stands (E2): the stage the page shows, whether the buyer may open the payment page, a declined card's words. */
|
|
1355
|
+
payment: SiteOrderPayment;
|
|
1356
|
+
}
|
|
1357
|
+
interface SiteOrderPayment {
|
|
1358
|
+
channel: PaymentChannel;
|
|
1359
|
+
stage: BuyerPaymentStage;
|
|
1360
|
+
canPay: boolean;
|
|
1361
|
+
declined: string | null;
|
|
1362
|
+
}
|
|
1363
|
+
/** Where to send the buyer to pay — a card order only (E2); `null` when the page could not be made (they try again from the order page). */
|
|
1364
|
+
interface SitePaymentRedirect {
|
|
1365
|
+
redirectUrl: string;
|
|
1223
1366
|
}
|
|
1224
1367
|
/** `POST checkout/place` — 201. */
|
|
1225
1368
|
interface SitePlacedOrder {
|
|
1226
1369
|
order: SiteBuyerOrder;
|
|
1227
1370
|
viewToken: string;
|
|
1371
|
+
payment?: SitePaymentRedirect | null;
|
|
1372
|
+
}
|
|
1373
|
+
/** `POST order/:token/pay` — the order as it stands and where to pay. */
|
|
1374
|
+
interface SitePayAnswer {
|
|
1375
|
+
order: SiteBuyerOrder;
|
|
1376
|
+
payment: SitePaymentRedirect | null;
|
|
1228
1377
|
}
|
|
1229
1378
|
/**
|
|
1230
1379
|
* The step to SHOW: no checkout yet is Contact; then the first step still missing what it needs — a delivery chosen
|
|
@@ -1282,7 +1431,18 @@ declare enum CheckoutWord {
|
|
|
1282
1431
|
Coupon = "coupon",
|
|
1283
1432
|
ApplyCoupon = "applyCoupon",
|
|
1284
1433
|
RemoveCoupon = "removeCoupon",
|
|
1285
|
-
Discount = "discount"
|
|
1434
|
+
Discount = "discount",
|
|
1435
|
+
PayOrder = "payOrder",
|
|
1436
|
+
PayNote = "payNote",
|
|
1437
|
+
ToPaymentPage = "toPaymentPage",
|
|
1438
|
+
ConfirmingPayment = "confirmingPayment",
|
|
1439
|
+
ConfirmingSlow = "confirmingSlow",
|
|
1440
|
+
PaymentConfirmed = "paymentConfirmed",
|
|
1441
|
+
PaymentFailed = "paymentFailed",
|
|
1442
|
+
PaymentDeclined = "paymentDeclined",
|
|
1443
|
+
TryAgain = "tryAgain",
|
|
1444
|
+
PayNow = "payNow",
|
|
1445
|
+
OrderClosed = "orderClosed"
|
|
1286
1446
|
}
|
|
1287
1447
|
/** `{name}`, `{n}`, `{of}`, `{amount}`, `{percent}`, `{number}`, `{email}`, `{total}`, `{place}` are filled by `checkoutWord`. */
|
|
1288
1448
|
declare const CHECKOUT_WORDS: Readonly<Record<CheckoutWord, CommerceLabel>>;
|
|
@@ -1350,6 +1510,10 @@ declare enum SiteRefusalCode {
|
|
|
1350
1510
|
RecoveryDone = "recovery-done",
|
|
1351
1511
|
/** A reminder's link whose bag is gone, or a link that is not one. */
|
|
1352
1512
|
RecoveryExpired = "recovery-expired",
|
|
1513
|
+
/** The payment page could not be made right now (the provider did not answer) — the order stands; try again (E2). */
|
|
1514
|
+
PaymentUnavailable = "payment-unavailable",
|
|
1515
|
+
/** This order cannot be paid any more (paid, or cancelled). */
|
|
1516
|
+
PaymentClosed = "payment-closed",
|
|
1353
1517
|
Network = "network"
|
|
1354
1518
|
}
|
|
1355
1519
|
interface RefusalRule {
|
|
@@ -1575,5 +1739,5 @@ declare const looksLikeEmail: (value: unknown) => boolean;
|
|
|
1575
1739
|
/** A phone a person can be called on: 7–15 digits once spaces, dashes, brackets and a leading + are dropped. */
|
|
1576
1740
|
declare const looksLikePhone: (value: unknown) => boolean;
|
|
1577
1741
|
|
|
1578
|
-
export { ABANDONED_AFTER_MS, Availability, CART_COOKIE_PREFIX, CART_ISSUE_LABELS, CART_TRANSPORT_ERROR_LABELS, CHECKOUT_FORM_STEPS, CHECKOUT_GATE_RULES, CHECKOUT_PATH, CHECKOUT_STEPS, CHECKOUT_STEP_LABELS, CHECKOUT_WORDS, COUPON_CODE_MAX, COUPON_CODE_MIN, COUPON_REFUSAL_LABELS, CURRENCY_CODES, CURRENCY_EXPONENTS, CartIssueCode, CartTransportError, CartTransportErrorCode, CheckoutAskedField, CheckoutFieldMode, CheckoutGateArea, CheckoutGateCode, CheckoutSlot, CheckoutStep, CheckoutWord, CommerceLanguage, CouponKind, CouponProblem, CouponRefusal, CurrencyCode, DEFAULT_JOURNEY_DAYS, DEFAULT_MONEY_LOCALE, DEFAULT_REMINDER_SETTINGS, DEFAULT_VARIANT_NAME, DeliveryFit, FINAL_ORDER_STATES, FUNNEL_STAGES, FunnelStage, JOURNEY_PERIODS_DAYS, JourneyEventKind, LegalPage, MAX_CART_AMOUNT, MAX_CART_LINES, MAX_LINE_QUANTITY, MAX_VAT_PERCENT, MIN_LINE_QUANTITY, MoneyError, MoneyErrorCode, NO_CART_TRANSPORT, ORDER_PATH, ORDER_STATE_LABELS, ORDER_STOCK_HOLD, ORDER_TRANSITIONS, OrderActor, OrderEvent, OrderRefusal, OrderSnapshotRefusal, OrderState, PAYMENT_FIELD_LABELS, PAYMENT_METHODS, PaymentChannel, PaymentField, PaymentMethodKind, PaymentProvider, QuantityStep, RECOVERY_PATH, RECOVERY_WORDS, REMINDER_LATE_MS, REMINDER_SEQUENCE, REMINDER_STEPS, REMINDER_SUBJECT_WORDS, REMINDER_WORDS_MAX, RecoveryWord, ReminderOutcome, ReminderSkip, ReminderStep, ReminderStop, SAMPLE_CART_LINE, SAMPLE_PRODUCT, SAMPLE_STUDIO, SAMPLE_SWATCHES, SHIPPING_KINDS, SHOP_SLOTS, SHOP_WORDS, SITE_REFUSALS, STOCK_EFFECTS, STOCK_RESERVATION_MINUTES, STOREFRONT_COMPUTED_FIELDS, STOREFRONT_FIELDS, ShippingField, ShippingMethodKind, ShopSlot, ShopWord, SiteCommerceRoute, SiteRefusalCode, StockEffect, StockHold, StorefrontCollection, UNSUBSCRIBE_PATH, VARIANT_NAME_SEPARATOR, VAT_PERCENT_MAX_DECIMALS, addMoney, addressLine, availableShippingMethods, biggestDrop, canBuy, canStep, cartCookieName, cartEndpointPath, cartIssueWords, cartLineId, cartOf, cartTransportErrorFor, cartViewOf, catalogKey, checkoutGate, checkoutHref, checkoutWord, chooseValue, clampQuantity, commerceLanguage, couponDiscount, couponOfferWords, couponProblems, couponRefusalWords, currencyExponent, currentCheckoutStep, defaultChoice, emptyCartView, fieldAsked, fieldRequired, findVariant, formatMoney, formatMoneyValue, freeShippingRemaining, funnelOf, furthestStep, includedVat, isAbandoned, isCouponCode, isCurrencyCode, isMoney, isPaymentMethodKind, isShippingMethodKind, isStorefrontField, isStorefrontProduct, isVatPercent, labelIn, looksLikeEmail, looksLikePhone, majorToMinor, marketingAllowed, maskEmail, mergeCarts, migrateMajorPrice, minorToMajor, money, nextOrderState, nextReminder, normalizeCouponCode, openingOrderState, optionValueStates, orderHref, orderSnapshot, paymentChannelOf, paymentInstructions, paymentMethodProblems, paymentMethodReady, percentOf, priceCart, productCurrency, productInScope, productOptions, productVariants, quantityBounds, quoteShipping, recoveryHref, recoveryWord, reminderNumber, reminderSettingsOf, reservationExpiresAt, sellableQuantity, shippingMethodProblems, shippingMethodReady, shippingNeedsAddress, shopWord, simulatedCartTransport, siteCartView, siteCommercePath, siteRefusalsOf, stepQuantity, stockEffect, stoppedAt, storefrontBindPaths, storefrontCatalog, storefrontMoney, subtractMoney, timesMoney, unsubscribeHref, usablePaymentMethods, variantChoiceOf, variantSlotOf, variantWords };
|
|
1579
|
-
export type { AddToCartRequest, AppliedCoupon, BusinessIdentity, Cart, CartIssue, CartLine, CartTransport, CartView, CartViewLine, CatalogEntry, CheckoutFieldModes, CheckoutGateFacts, CheckoutGateRefusal, CheckoutGateResult, CommerceLabel, ConsentDecision, Coupon, CouponCheck, FunnelRow, Money, OptionState, OptionValueState, OrderBuyer, OrderMove, OrderSnapshot, OrderSnapshotLine, OrderSnapshotResult, OrderTransition, PaymentMethodConfig, PostalAddress, PricedCart, PricedLine, PricingChoice, ProductOption, ProductVariantView, QuantityBounds, ReminderFacts, ReminderPlan, ReminderSettings, ReminderTiming, ReminderWords, ShippingCart, ShippingGoods, ShippingMethod, ShippingQuote, SimulatedCartTransport, SiteBuyerOrder, SiteCartView, SiteCheckoutContact, SiteCheckoutOptions, SiteCheckoutView, SiteLegalLink, SitePaymentOption, SitePlacedOrder, SiteRefusal, SiteShippingMethod, SiteShippingOption, SiteUnsubscribeState, StorefrontFieldSpec, StorefrontProduct, StorefrontVariant, StudioCommerce, VariantChoice, VariantSlot };
|
|
1742
|
+
export { ABANDONED_AFTER_MS, Availability, BuyerPaymentStage, CART_COOKIE_PREFIX, CART_ISSUE_LABELS, CART_TRANSPORT_ERROR_LABELS, CHECKOUT_FORM_STEPS, CHECKOUT_GATE_RULES, CHECKOUT_PATH, CHECKOUT_STEPS, CHECKOUT_STEP_LABELS, CHECKOUT_WORDS, COUPON_CODE_MAX, COUPON_CODE_MIN, COUPON_REFUSAL_LABELS, CURRENCY_CODES, CURRENCY_EXPONENTS, CartIssueCode, CartTransportError, CartTransportErrorCode, CheckoutAskedField, CheckoutFieldMode, CheckoutGateArea, CheckoutGateCode, CheckoutSlot, CheckoutStep, CheckoutWord, CommerceLanguage, CouponKind, CouponProblem, CouponRefusal, CurrencyCode, DEFAULT_JOURNEY_DAYS, DEFAULT_MONEY_LOCALE, DEFAULT_REMINDER_SETTINGS, DEFAULT_VARIANT_NAME, DeliveryFit, FINAL_ORDER_STATES, FUNNEL_STAGES, FunnelStage, JOURNEY_PERIODS_DAYS, JourneyEventKind, LegalPage, MAX_CART_AMOUNT, MAX_CART_LINES, MAX_LINE_QUANTITY, MAX_VAT_PERCENT, MIN_LINE_QUANTITY, MoneyError, MoneyErrorCode, NO_CART_TRANSPORT, ORDER_PATH, ORDER_STATE_LABELS, ORDER_STOCK_HOLD, ORDER_TRANSITIONS, OrderActor, OrderEvent, OrderRefusal, OrderSnapshotRefusal, OrderState, PAYMENT_FIELD_LABELS, PAYMENT_METHODS, PAYMENT_VERDICT_LABELS, PaymentAttemptStatus, PaymentChannel, PaymentField, PaymentMethodKind, PaymentMismatch, PaymentProvider, PaymentResultStatus, PaymentVerdictKind, QuantityStep, RECOVERY_PATH, RECOVERY_WORDS, REMINDER_LATE_MS, REMINDER_SEQUENCE, REMINDER_STEPS, REMINDER_SUBJECT_WORDS, REMINDER_WORDS_MAX, RecoveryWord, ReminderOutcome, ReminderSkip, ReminderStep, ReminderStop, SAMPLE_CART_LINE, SAMPLE_PRODUCT, SAMPLE_STUDIO, SAMPLE_SWATCHES, SHIPPING_KINDS, SHOP_SLOTS, SHOP_WORDS, SITE_REFUSALS, STOCK_EFFECTS, STOCK_RESERVATION_MINUTES, STOREFRONT_COMPUTED_FIELDS, STOREFRONT_FIELDS, ShippingField, ShippingMethodKind, ShopSlot, ShopWord, SiteCommerceRoute, SiteOrderAction, SiteRefusalCode, StockEffect, StockHold, StorefrontCollection, UNSUBSCRIBE_PATH, VARIANT_NAME_SEPARATOR, VAT_PERCENT_MAX_DECIMALS, addMoney, addressLine, availableShippingMethods, biggestDrop, buyerMayPay, buyerPaymentStage, canBuy, canStep, cartCookieName, cartEndpointPath, cartIssueWords, cartLineId, cartOf, cartTransportErrorFor, cartViewOf, catalogKey, checkoutGate, checkoutHref, checkoutWord, chooseValue, clampQuantity, commerceLanguage, couponDiscount, couponOfferWords, couponProblems, couponRefusalWords, currencyExponent, currentCheckoutStep, defaultChoice, emptyCartView, fieldAsked, fieldRequired, findVariant, formatMoney, formatMoneyValue, freeShippingRemaining, funnelOf, furthestStep, includedVat, isAbandoned, isCouponCode, isCurrencyCode, isMoney, isPaymentMethodKind, isShippingMethodKind, isStorefrontField, isStorefrontProduct, isVatPercent, labelIn, looksLikeEmail, looksLikePhone, majorToMinor, marketingAllowed, maskEmail, mergeCarts, migrateMajorPrice, minorToMajor, money, nextOrderState, nextReminder, normalizeCouponCode, openingOrderState, optionValueStates, orderHref, orderSnapshot, paymentChannelOf, paymentInstructions, paymentMethodConnected, paymentMethodProblems, paymentMethodReady, paymentVerdict, percentOf, priceCart, productCurrency, productInScope, productOptions, productVariants, quantityBounds, quoteShipping, recoveryHref, recoveryWord, reminderNumber, reminderSettingsOf, reservationDue, reservationExpiresAt, reusableAttempt, sellableQuantity, shippingMethodProblems, shippingMethodReady, shippingNeedsAddress, shopWord, simulatedCartTransport, siteCartView, siteCommercePath, siteOrderActionPath, siteRefusalsOf, stepQuantity, stockEffect, stoppedAt, storefrontBindPaths, storefrontCatalog, storefrontMoney, subtractMoney, timesMoney, unsubscribeHref, usablePaymentMethods, variantChoiceOf, variantSlotOf, variantWords };
|
|
1743
|
+
export type { AddToCartRequest, AppliedCoupon, BusinessIdentity, Cart, CartIssue, CartLine, CartTransport, CartView, CartViewLine, CatalogEntry, CheckoutFieldModes, CheckoutGateFacts, CheckoutGateRefusal, CheckoutGateResult, CommerceLabel, ConsentDecision, Coupon, CouponCheck, FunnelRow, Money, OptionState, OptionValueState, OrderBuyer, OrderMove, OrderSnapshot, OrderSnapshotLine, OrderSnapshotResult, OrderTransition, PaidCard, PaymentAttempt, PaymentMethodConfig, PaymentResult, PaymentVerdict, PaymentVerdictInput, PostalAddress, PricedCart, PricedLine, PricingChoice, ProductOption, ProductVariantView, QuantityBounds, ReminderFacts, ReminderPlan, ReminderSettings, ReminderTiming, ReminderWords, ShippingCart, ShippingGoods, ShippingMethod, ShippingQuote, SimulatedCartTransport, SiteBuyerOrder, SiteCartView, SiteCheckoutContact, SiteCheckoutOptions, SiteCheckoutView, SiteLegalLink, SiteOrderPayment, SitePayAnswer, SitePaymentOption, SitePaymentRedirect, SitePlacedOrder, SiteRefusal, SiteShippingMethod, SiteShippingOption, SiteUnsubscribeState, StorefrontFieldSpec, StorefrontProduct, StorefrontVariant, StudioCommerce, VariantChoice, VariantSlot };
|
|
@@ -1027,7 +1027,7 @@ var PaymentMethodKind;
|
|
|
1027
1027
|
PaymentMethodKind["PayOnPickup"] = "payOnPickup";
|
|
1028
1028
|
PaymentMethodKind["CashOnDelivery"] = "cashOnDelivery";
|
|
1029
1029
|
PaymentMethodKind["Bit"] = "bit";
|
|
1030
|
-
/** A PSP's hosted page (E2, Cardcom first)
|
|
1030
|
+
/** A PSP's hosted page (E2, Cardcom first): the buyer pays there, never on a card field of ours. */
|
|
1031
1031
|
PaymentMethodKind["Online"] = "online";
|
|
1032
1032
|
})(PaymentMethodKind || (PaymentMethodKind = {}));
|
|
1033
1033
|
var PaymentProvider;
|
|
@@ -1057,6 +1057,7 @@ const PAYMENT_METHODS = Object.freeze({
|
|
|
1057
1057
|
[PaymentMethodKind.BankTransfer]: {
|
|
1058
1058
|
channel: PaymentChannel.Manual,
|
|
1059
1059
|
offered: true,
|
|
1060
|
+
needsConnection: false,
|
|
1060
1061
|
fields: [PaymentField.AccountName, PaymentField.Bank, PaymentField.Branch, PaymentField.AccountNumber],
|
|
1061
1062
|
fit: DeliveryFit.Any,
|
|
1062
1063
|
label: { en: 'Bank transfer', he: 'העברה בנקאית' },
|
|
@@ -1068,6 +1069,7 @@ const PAYMENT_METHODS = Object.freeze({
|
|
|
1068
1069
|
[PaymentMethodKind.PayOnPickup]: {
|
|
1069
1070
|
channel: PaymentChannel.Manual,
|
|
1070
1071
|
offered: true,
|
|
1072
|
+
needsConnection: false,
|
|
1071
1073
|
fields: [],
|
|
1072
1074
|
fit: DeliveryFit.PickupOnly,
|
|
1073
1075
|
label: { en: 'Pay on pickup', he: 'תשלום באיסוף' },
|
|
@@ -1079,6 +1081,7 @@ const PAYMENT_METHODS = Object.freeze({
|
|
|
1079
1081
|
[PaymentMethodKind.CashOnDelivery]: {
|
|
1080
1082
|
channel: PaymentChannel.Manual,
|
|
1081
1083
|
offered: true,
|
|
1084
|
+
needsConnection: false,
|
|
1082
1085
|
fields: [],
|
|
1083
1086
|
fit: DeliveryFit.AddressOnly,
|
|
1084
1087
|
label: { en: 'Cash on delivery', he: 'מזומן במסירה' },
|
|
@@ -1090,6 +1093,7 @@ const PAYMENT_METHODS = Object.freeze({
|
|
|
1090
1093
|
[PaymentMethodKind.Bit]: {
|
|
1091
1094
|
channel: PaymentChannel.Manual,
|
|
1092
1095
|
offered: true,
|
|
1096
|
+
needsConnection: false,
|
|
1093
1097
|
fields: [PaymentField.BitPhone],
|
|
1094
1098
|
fit: DeliveryFit.Any,
|
|
1095
1099
|
label: { en: 'Bit', he: 'ביט' },
|
|
@@ -1100,7 +1104,8 @@ const PAYMENT_METHODS = Object.freeze({
|
|
|
1100
1104
|
},
|
|
1101
1105
|
[PaymentMethodKind.Online]: {
|
|
1102
1106
|
channel: PaymentChannel.Online,
|
|
1103
|
-
offered:
|
|
1107
|
+
offered: true,
|
|
1108
|
+
needsConnection: true,
|
|
1104
1109
|
fields: [PaymentField.Provider],
|
|
1105
1110
|
fit: DeliveryFit.Any,
|
|
1106
1111
|
label: { en: 'Card', he: 'כרטיס אשראי' },
|
|
@@ -1143,10 +1148,14 @@ function paymentMethodProblems(config) {
|
|
|
1143
1148
|
const details = config.details ?? {};
|
|
1144
1149
|
return PAYMENT_METHODS[config.kind].fields.filter(field => !PAYMENT_FIELD_CHECKS[field](details[field]));
|
|
1145
1150
|
}
|
|
1146
|
-
/**
|
|
1151
|
+
/** A method that needs no connection, or whose connection answered (E2). */
|
|
1152
|
+
function paymentMethodConnected(config) {
|
|
1153
|
+
return !!config && isPaymentMethodKind(config.kind) && (!PAYMENT_METHODS[config.kind].needsConnection || config.connected === true);
|
|
1154
|
+
}
|
|
1155
|
+
/** Enabled, offered in this phase, complete and — for a card method — connected: the ONE rule the checkout and its gate read. */
|
|
1147
1156
|
function paymentMethodReady(config) {
|
|
1148
1157
|
return !!config && isPaymentMethodKind(config.kind) && config.enabled === true
|
|
1149
|
-
&& PAYMENT_METHODS[config.kind].offered && paymentMethodProblems(config).length === 0;
|
|
1158
|
+
&& PAYMENT_METHODS[config.kind].offered && paymentMethodProblems(config).length === 0 && paymentMethodConnected(config);
|
|
1150
1159
|
}
|
|
1151
1160
|
/** The methods a buyer may pick with this delivery (null = nothing ships). */
|
|
1152
1161
|
function usablePaymentMethods(configs, shippingKind) {
|
|
@@ -1318,6 +1327,169 @@ const ORDER_STATE_LABELS = Object.freeze({
|
|
|
1318
1327
|
[OrderState.PartiallyRefunded]: { en: 'Partly refunded', he: 'זוכתה חלקית' },
|
|
1319
1328
|
});
|
|
1320
1329
|
|
|
1330
|
+
/**
|
|
1331
|
+
* Card payments (commerce E2, C-D2, trap T2): what a payment provider's answer MEANS for an order. The provider's
|
|
1332
|
+
* adapter (iox-cms) asks the provider itself — never the buyer's browser, never a webhook's body — and normalises its
|
|
1333
|
+
* answer to a `PaymentResult`; `paymentVerdict` decides. Pure: no clock (the caller passes `now`), no provider names.
|
|
1334
|
+
*/
|
|
1335
|
+
var PaymentResultStatus;
|
|
1336
|
+
(function (PaymentResultStatus) {
|
|
1337
|
+
/** The provider took the money: a transaction exists. */
|
|
1338
|
+
PaymentResultStatus["Paid"] = "paid";
|
|
1339
|
+
/** The page is open (the buyer has not paid yet, or a card was declined and the page still waits). */
|
|
1340
|
+
PaymentResultStatus["Pending"] = "pending";
|
|
1341
|
+
/** The provider closed the session without a payment. */
|
|
1342
|
+
PaymentResultStatus["Failed"] = "failed";
|
|
1343
|
+
/** The provider does not know the session (or did not answer): nothing is decided. */
|
|
1344
|
+
PaymentResultStatus["Unknown"] = "unknown";
|
|
1345
|
+
})(PaymentResultStatus || (PaymentResultStatus = {}));
|
|
1346
|
+
/** One time the buyer was sent to the provider's page for an order. */
|
|
1347
|
+
var PaymentAttemptStatus;
|
|
1348
|
+
(function (PaymentAttemptStatus) {
|
|
1349
|
+
PaymentAttemptStatus["Open"] = "open";
|
|
1350
|
+
PaymentAttemptStatus["Paid"] = "paid";
|
|
1351
|
+
PaymentAttemptStatus["Failed"] = "failed";
|
|
1352
|
+
/** The order expired or was cancelled while this page was open. */
|
|
1353
|
+
PaymentAttemptStatus["Closed"] = "closed";
|
|
1354
|
+
})(PaymentAttemptStatus || (PaymentAttemptStatus = {}));
|
|
1355
|
+
var PaymentVerdictKind;
|
|
1356
|
+
(function (PaymentVerdictKind) {
|
|
1357
|
+
/** Paid and every fact matches: the order moves to paid (the machine's `confirmPayment`). */
|
|
1358
|
+
PaymentVerdictKind["Confirm"] = "confirm";
|
|
1359
|
+
/** The provider closed the session unpaid: `failPayment`, the reservation released. */
|
|
1360
|
+
PaymentVerdictKind["Fail"] = "fail";
|
|
1361
|
+
/** Still open: show "Confirming…" and ask again. */
|
|
1362
|
+
PaymentVerdictKind["Wait"] = "wait";
|
|
1363
|
+
/** Nothing to do (an unknown session, a pending page of an order that moved on). */
|
|
1364
|
+
PaymentVerdictKind["Ignore"] = "ignore";
|
|
1365
|
+
/** The answer does not belong to this order or does not match it: nothing changes, the owner is told. */
|
|
1366
|
+
PaymentVerdictKind["Refuse"] = "refuse";
|
|
1367
|
+
/** The same transaction was already recorded: a replayed answer, a second webhook, the return racing the webhook. */
|
|
1368
|
+
PaymentVerdictKind["AlreadyPaid"] = "alreadyPaid";
|
|
1369
|
+
/** A SECOND transaction paid an order already paid (two tabs): kept for the owner to refund. */
|
|
1370
|
+
PaymentVerdictKind["PaidTwice"] = "paidTwice";
|
|
1371
|
+
/** Paid after the order was cancelled (the reservation ran out): kept for the owner to refund. */
|
|
1372
|
+
PaymentVerdictKind["PaidAfterClose"] = "paidAfterClose";
|
|
1373
|
+
})(PaymentVerdictKind || (PaymentVerdictKind = {}));
|
|
1374
|
+
var PaymentMismatch;
|
|
1375
|
+
(function (PaymentMismatch) {
|
|
1376
|
+
PaymentMismatch["Session"] = "session-mismatch";
|
|
1377
|
+
PaymentMismatch["Reference"] = "reference-mismatch";
|
|
1378
|
+
PaymentMismatch["Currency"] = "currency-mismatch";
|
|
1379
|
+
PaymentMismatch["Amount"] = "amount-mismatch";
|
|
1380
|
+
PaymentMismatch["NoTransaction"] = "no-transaction";
|
|
1381
|
+
})(PaymentMismatch || (PaymentMismatch = {}));
|
|
1382
|
+
const PAID_STATES = Object.freeze([
|
|
1383
|
+
OrderState.Paid, OrderState.Fulfilled, OrderState.Delivered, OrderState.PartiallyRefunded, OrderState.Refunded,
|
|
1384
|
+
]);
|
|
1385
|
+
const OPEN_STATES = Object.freeze([OrderState.PendingPayment, OrderState.PaymentFailed]);
|
|
1386
|
+
const verdict = (kind, mismatches = []) => ({ kind, mismatches });
|
|
1387
|
+
/** The mismatches that make an answer not this order's: another session, another reference. */
|
|
1388
|
+
function identityMismatches(input) {
|
|
1389
|
+
const { result, attempt } = input;
|
|
1390
|
+
const found = [];
|
|
1391
|
+
if (result.sessionId !== null && result.sessionId !== attempt.sessionId)
|
|
1392
|
+
found.push(PaymentMismatch.Session);
|
|
1393
|
+
if (result.reference !== attempt.reference)
|
|
1394
|
+
found.push(PaymentMismatch.Reference);
|
|
1395
|
+
return found;
|
|
1396
|
+
}
|
|
1397
|
+
/** A paid answer must name a transaction and have charged exactly the order's total, in its currency. */
|
|
1398
|
+
function moneyMismatches(input) {
|
|
1399
|
+
const { result, total } = input;
|
|
1400
|
+
if (!result.transactionId)
|
|
1401
|
+
return [PaymentMismatch.NoTransaction];
|
|
1402
|
+
if (!isMoney(result.amount) || result.amount.currency !== total.currency)
|
|
1403
|
+
return [PaymentMismatch.Currency];
|
|
1404
|
+
return result.amount.amount === total.amount ? [] : [PaymentMismatch.Amount];
|
|
1405
|
+
}
|
|
1406
|
+
/** THE decision on a provider's answer (T2): only a paid answer for THIS attempt, of exactly this total, pays — once. */
|
|
1407
|
+
function paymentVerdict(input) {
|
|
1408
|
+
const { result, state } = input;
|
|
1409
|
+
if (result.status === PaymentResultStatus.Unknown)
|
|
1410
|
+
return verdict(PaymentVerdictKind.Ignore);
|
|
1411
|
+
const identity = identityMismatches(input);
|
|
1412
|
+
if (identity.length)
|
|
1413
|
+
return verdict(PaymentVerdictKind.Refuse, identity);
|
|
1414
|
+
if (result.status === PaymentResultStatus.Paid) {
|
|
1415
|
+
const money = moneyMismatches(input);
|
|
1416
|
+
if (money.length)
|
|
1417
|
+
return verdict(PaymentVerdictKind.Refuse, money);
|
|
1418
|
+
if (input.paidTransactionId && input.paidTransactionId === result.transactionId)
|
|
1419
|
+
return verdict(PaymentVerdictKind.AlreadyPaid);
|
|
1420
|
+
if (OPEN_STATES.includes(state))
|
|
1421
|
+
return verdict(PaymentVerdictKind.Confirm);
|
|
1422
|
+
if (PAID_STATES.includes(state))
|
|
1423
|
+
return verdict(PaymentVerdictKind.PaidTwice);
|
|
1424
|
+
if (state === OrderState.Cancelled)
|
|
1425
|
+
return verdict(PaymentVerdictKind.PaidAfterClose);
|
|
1426
|
+
return verdict(PaymentVerdictKind.Ignore);
|
|
1427
|
+
}
|
|
1428
|
+
if (state !== OrderState.PendingPayment)
|
|
1429
|
+
return verdict(PaymentVerdictKind.Ignore);
|
|
1430
|
+
return verdict(result.status === PaymentResultStatus.Failed ? PaymentVerdictKind.Fail : PaymentVerdictKind.Wait);
|
|
1431
|
+
}
|
|
1432
|
+
/** A page made this recently is sent again instead of a new one (a double click, a second tab) — while the stock is held. */
|
|
1433
|
+
function reusableAttempt(attempts, now) {
|
|
1434
|
+
const open = (attempts ?? []).filter(attempt => attempt.status === PaymentAttemptStatus.Open);
|
|
1435
|
+
const last = open[open.length - 1];
|
|
1436
|
+
if (!last)
|
|
1437
|
+
return null;
|
|
1438
|
+
return now - new Date(last.createdAt).getTime() < STOCK_RESERVATION_MINUTES * 60000 ? last : null;
|
|
1439
|
+
}
|
|
1440
|
+
/** The reservation ran out: the payment sweep asks the provider one last time, then expires the order (C-D10). */
|
|
1441
|
+
function reservationDue(reservedUntil, now) {
|
|
1442
|
+
if (!reservedUntil)
|
|
1443
|
+
return false;
|
|
1444
|
+
const until = new Date(reservedUntil).getTime();
|
|
1445
|
+
return Number.isFinite(until) && until <= now;
|
|
1446
|
+
}
|
|
1447
|
+
/** What the buyer's order page shows about paying (the engine's "Confirming your payment…"). */
|
|
1448
|
+
var BuyerPaymentStage;
|
|
1449
|
+
(function (BuyerPaymentStage) {
|
|
1450
|
+
/** A manual method: how to pay. */
|
|
1451
|
+
BuyerPaymentStage["Instructions"] = "instructions";
|
|
1452
|
+
/** A card payment is open: confirming with the provider. */
|
|
1453
|
+
BuyerPaymentStage["Confirming"] = "confirming";
|
|
1454
|
+
BuyerPaymentStage["Paid"] = "paid";
|
|
1455
|
+
/** The card payment did not go through: the buyer may try again. */
|
|
1456
|
+
BuyerPaymentStage["Failed"] = "failed";
|
|
1457
|
+
/** Cancelled (by the owner, or not paid in time). */
|
|
1458
|
+
BuyerPaymentStage["Closed"] = "closed";
|
|
1459
|
+
})(BuyerPaymentStage || (BuyerPaymentStage = {}));
|
|
1460
|
+
const ONLINE_STAGES = Object.freeze({
|
|
1461
|
+
[OrderState.AwaitingPayment]: BuyerPaymentStage.Instructions,
|
|
1462
|
+
[OrderState.PendingPayment]: BuyerPaymentStage.Confirming,
|
|
1463
|
+
[OrderState.PaymentFailed]: BuyerPaymentStage.Failed,
|
|
1464
|
+
[OrderState.Paid]: BuyerPaymentStage.Paid,
|
|
1465
|
+
[OrderState.Fulfilled]: BuyerPaymentStage.Paid,
|
|
1466
|
+
[OrderState.Delivered]: BuyerPaymentStage.Paid,
|
|
1467
|
+
[OrderState.Refunded]: BuyerPaymentStage.Paid,
|
|
1468
|
+
[OrderState.PartiallyRefunded]: BuyerPaymentStage.Paid,
|
|
1469
|
+
[OrderState.Cancelled]: BuyerPaymentStage.Closed,
|
|
1470
|
+
});
|
|
1471
|
+
function buyerPaymentStage(state, channel) {
|
|
1472
|
+
const stage = ONLINE_STAGES[state] ?? BuyerPaymentStage.Closed;
|
|
1473
|
+
if (channel === PaymentChannel.Manual && (stage === BuyerPaymentStage.Confirming || stage === BuyerPaymentStage.Failed))
|
|
1474
|
+
return BuyerPaymentStage.Instructions;
|
|
1475
|
+
return stage;
|
|
1476
|
+
}
|
|
1477
|
+
/** The buyer may (re)open the payment page: still within the open states of a card order. */
|
|
1478
|
+
function buyerMayPay(state, channel) {
|
|
1479
|
+
return channel === PaymentChannel.Online && OPEN_STATES.includes(state);
|
|
1480
|
+
}
|
|
1481
|
+
/** What happened to a card payment, as the order's history and the admin say it. */
|
|
1482
|
+
const PAYMENT_VERDICT_LABELS = Object.freeze({
|
|
1483
|
+
[PaymentVerdictKind.Confirm]: { en: 'Paid by card', he: 'שולם בכרטיס אשראי' },
|
|
1484
|
+
[PaymentVerdictKind.Fail]: { en: 'The card payment did not go through', he: 'התשלום בכרטיס לא עבר' },
|
|
1485
|
+
[PaymentVerdictKind.Wait]: { en: 'Waiting for the payment', he: 'ממתינים לתשלום' },
|
|
1486
|
+
[PaymentVerdictKind.Ignore]: { en: 'Nothing changed', he: 'לא השתנה דבר' },
|
|
1487
|
+
[PaymentVerdictKind.Refuse]: { en: 'A payment answer that does not match this order was refused', he: 'תשובת תשלום שלא תואמת להזמנה נדחתה' },
|
|
1488
|
+
[PaymentVerdictKind.AlreadyPaid]: { en: 'Already recorded', he: 'כבר נרשם' },
|
|
1489
|
+
[PaymentVerdictKind.PaidTwice]: { en: 'Paid a second time — refund the extra payment', he: 'שולם פעמיים — יש לזכות את התשלום הנוסף' },
|
|
1490
|
+
[PaymentVerdictKind.PaidAfterClose]: { en: 'Paid after the order was cancelled — refund it', he: 'שולם אחרי שההזמנה בוטלה — יש לזכות' },
|
|
1491
|
+
});
|
|
1492
|
+
|
|
1321
1493
|
/** The fixed checkout's steps, in order (C-D3); a checkout keeps the FURTHEST it reached (the journey, §3g). */
|
|
1322
1494
|
var CheckoutStep;
|
|
1323
1495
|
(function (CheckoutStep) {
|
|
@@ -2114,6 +2286,15 @@ var SiteCommerceRoute;
|
|
|
2114
2286
|
SiteCommerceRoute["Unsubscribe"] = "marketing/unsubscribe";
|
|
2115
2287
|
SiteCommerceRoute["Order"] = "order";
|
|
2116
2288
|
})(SiteCommerceRoute || (SiteCommerceRoute = {}));
|
|
2289
|
+
/** What the buyer does to a card order through its link (E2): `pay` opens (or re-opens) the provider's page. */
|
|
2290
|
+
var SiteOrderAction;
|
|
2291
|
+
(function (SiteOrderAction) {
|
|
2292
|
+
SiteOrderAction["Pay"] = "pay";
|
|
2293
|
+
})(SiteOrderAction || (SiteOrderAction = {}));
|
|
2294
|
+
/** `POST /api/site/<org>/order/<token>/pay` — root-relative, like every site route. */
|
|
2295
|
+
function siteOrderActionPath(orgId, token, action) {
|
|
2296
|
+
return `${siteCommercePath(orgId, SiteCommerceRoute.Order, token)}/${action}`;
|
|
2297
|
+
}
|
|
2117
2298
|
/** A public commerce route of one org, ROOT-relative (the same rule as `cartEndpointPath`). */
|
|
2118
2299
|
function siteCommercePath(orgId, route, id) {
|
|
2119
2300
|
const base = `/api/site/${encodeURIComponent(orgId)}/${route}`;
|
|
@@ -2220,6 +2401,17 @@ var CheckoutWord;
|
|
|
2220
2401
|
CheckoutWord["ApplyCoupon"] = "applyCoupon";
|
|
2221
2402
|
CheckoutWord["RemoveCoupon"] = "removeCoupon";
|
|
2222
2403
|
CheckoutWord["Discount"] = "discount";
|
|
2404
|
+
CheckoutWord["PayOrder"] = "payOrder";
|
|
2405
|
+
CheckoutWord["PayNote"] = "payNote";
|
|
2406
|
+
CheckoutWord["ToPaymentPage"] = "toPaymentPage";
|
|
2407
|
+
CheckoutWord["ConfirmingPayment"] = "confirmingPayment";
|
|
2408
|
+
CheckoutWord["ConfirmingSlow"] = "confirmingSlow";
|
|
2409
|
+
CheckoutWord["PaymentConfirmed"] = "paymentConfirmed";
|
|
2410
|
+
CheckoutWord["PaymentFailed"] = "paymentFailed";
|
|
2411
|
+
CheckoutWord["PaymentDeclined"] = "paymentDeclined";
|
|
2412
|
+
CheckoutWord["TryAgain"] = "tryAgain";
|
|
2413
|
+
CheckoutWord["PayNow"] = "payNow";
|
|
2414
|
+
CheckoutWord["OrderClosed"] = "orderClosed";
|
|
2223
2415
|
})(CheckoutWord || (CheckoutWord = {}));
|
|
2224
2416
|
/** `{name}`, `{n}`, `{of}`, `{amount}`, `{percent}`, `{number}`, `{email}`, `{total}`, `{place}` are filled by `checkoutWord`. */
|
|
2225
2417
|
const CHECKOUT_WORDS = Object.freeze({
|
|
@@ -2268,6 +2460,17 @@ const CHECKOUT_WORDS = Object.freeze({
|
|
|
2268
2460
|
[CheckoutWord.ApplyCoupon]: { en: 'Apply', he: 'החלה' },
|
|
2269
2461
|
[CheckoutWord.RemoveCoupon]: { en: 'Remove', he: 'הסרה' },
|
|
2270
2462
|
[CheckoutWord.Discount]: { en: 'Discount · {code}', he: 'הנחה · {code}' },
|
|
2463
|
+
[CheckoutWord.PayOrder]: { en: 'Pay · {total}', he: 'לתשלום · {total}' },
|
|
2464
|
+
[CheckoutWord.PayNote]: { en: 'You pay on a secure payment page. We never see your card.', he: 'התשלום מתבצע בעמוד תשלום מאובטח. איננו רואים את פרטי הכרטיס.' },
|
|
2465
|
+
[CheckoutWord.ToPaymentPage]: { en: 'Taking you to the payment page…', he: 'מעבירים אותך לעמוד התשלום…' },
|
|
2466
|
+
[CheckoutWord.ConfirmingPayment]: { en: 'Confirming your payment…', he: 'מאשרים את התשלום…' },
|
|
2467
|
+
[CheckoutWord.ConfirmingSlow]: { en: 'This is taking longer than usual. You can close this page — we will email you once the payment is confirmed.', he: 'זה לוקח יותר זמן מהרגיל. אפשר לסגור את העמוד — נשלח אימייל כשהתשלום יאושר.' },
|
|
2468
|
+
[CheckoutWord.PaymentConfirmed]: { en: 'Payment confirmed', he: 'התשלום אושר' },
|
|
2469
|
+
[CheckoutWord.PaymentFailed]: { en: 'The payment did not go through. Nothing was charged.', he: 'התשלום לא עבר. לא חויבתם.' },
|
|
2470
|
+
[CheckoutWord.PaymentDeclined]: { en: 'The card was declined: {reason}', he: 'הכרטיס נדחה: {reason}' },
|
|
2471
|
+
[CheckoutWord.TryAgain]: { en: 'Try again', he: 'נסו שוב' },
|
|
2472
|
+
[CheckoutWord.PayNow]: { en: 'Pay now · {total}', he: 'לתשלום עכשיו · {total}' },
|
|
2473
|
+
[CheckoutWord.OrderClosed]: { en: 'This order was cancelled.', he: 'ההזמנה הזו בוטלה.' },
|
|
2271
2474
|
});
|
|
2272
2475
|
function checkoutWord(word, lang, fill = {}) {
|
|
2273
2476
|
return labelIn(CHECKOUT_WORDS[word], lang).replace(/\{(\w+)\}/g, (all, key) => (key in fill ? String(fill[key]) : all));
|
|
@@ -2338,6 +2541,10 @@ var SiteRefusalCode;
|
|
|
2338
2541
|
SiteRefusalCode["RecoveryDone"] = "recovery-done";
|
|
2339
2542
|
/** A reminder's link whose bag is gone, or a link that is not one. */
|
|
2340
2543
|
SiteRefusalCode["RecoveryExpired"] = "recovery-expired";
|
|
2544
|
+
/** The payment page could not be made right now (the provider did not answer) — the order stands; try again (E2). */
|
|
2545
|
+
SiteRefusalCode["PaymentUnavailable"] = "payment-unavailable";
|
|
2546
|
+
/** This order cannot be paid any more (paid, or cancelled). */
|
|
2547
|
+
SiteRefusalCode["PaymentClosed"] = "payment-closed";
|
|
2341
2548
|
SiteRefusalCode["Network"] = "network";
|
|
2342
2549
|
})(SiteRefusalCode || (SiteRefusalCode = {}));
|
|
2343
2550
|
const ENTER_EMAIL = { en: 'Enter an email address, like name@example.com.', he: 'הקלידו כתובת אימייל, למשל name@example.com.' };
|
|
@@ -2386,6 +2593,8 @@ const SITE_REFUSALS = Object.freeze({
|
|
|
2386
2593
|
[SiteRefusalCode.CouponNotUsable]: { slot: CheckoutSlot.Coupon, label: COUPON_REFUSAL_LABELS[CouponRefusal.NotUsable] },
|
|
2387
2594
|
[SiteRefusalCode.RecoveryDone]: { slot: CheckoutSlot.Page, label: { en: 'This purchase was already completed.', he: 'הרכישה הזו כבר הושלמה.' } },
|
|
2388
2595
|
[SiteRefusalCode.RecoveryExpired]: { slot: CheckoutSlot.Page, label: { en: 'This bag is no longer kept. You are welcome to shop again.', he: 'הסל הזה כבר לא שמור. אפשר לקנות שוב.' } },
|
|
2596
|
+
[SiteRefusalCode.PaymentUnavailable]: { slot: CheckoutSlot.Page, label: { en: 'The payment page is not available right now. Your order is saved — try again in a moment.', he: 'עמוד התשלום לא זמין כרגע. ההזמנה נשמרה — נסו שוב בעוד רגע.' } },
|
|
2597
|
+
[SiteRefusalCode.PaymentClosed]: { slot: CheckoutSlot.Page, label: { en: 'This order cannot be paid any more.', he: 'כבר אי אפשר לשלם על ההזמנה הזו.' } },
|
|
2389
2598
|
[SiteRefusalCode.Network]: { slot: CheckoutSlot.Page, label: { en: 'We could not reach the shop. Try again.', he: 'לא הצלחנו להגיע לחנות. נסו שוב.' } },
|
|
2390
2599
|
});
|
|
2391
2600
|
const isRefusalCode = (code) => typeof code === 'string' && Object.values(SiteRefusalCode).includes(code);
|
|
@@ -2721,5 +2930,5 @@ const REMINDER_SUBJECT_WORDS = Object.freeze({
|
|
|
2721
2930
|
* Generated bundle index. Do not edit.
|
|
2722
2931
|
*/
|
|
2723
2932
|
|
|
2724
|
-
export { ABANDONED_AFTER_MS, Availability, CART_COOKIE_PREFIX, CART_ISSUE_LABELS, CART_TRANSPORT_ERROR_LABELS, CHECKOUT_FORM_STEPS, CHECKOUT_GATE_RULES, CHECKOUT_PATH, CHECKOUT_STEPS, CHECKOUT_STEP_LABELS, CHECKOUT_WORDS, COUPON_CODE_MAX, COUPON_CODE_MIN, COUPON_REFUSAL_LABELS, CURRENCY_CODES, CURRENCY_EXPONENTS, CartIssueCode, CartTransportError, CartTransportErrorCode, CheckoutAskedField, CheckoutFieldMode, CheckoutGateArea, CheckoutGateCode, CheckoutSlot, CheckoutStep, CheckoutWord, CommerceLanguage, CouponKind, CouponProblem, CouponRefusal, CurrencyCode, DEFAULT_JOURNEY_DAYS, DEFAULT_MONEY_LOCALE, DEFAULT_REMINDER_SETTINGS, DEFAULT_VARIANT_NAME, DeliveryFit, FINAL_ORDER_STATES, FUNNEL_STAGES, FunnelStage, JOURNEY_PERIODS_DAYS, JourneyEventKind, LegalPage, MAX_CART_AMOUNT, MAX_CART_LINES, MAX_LINE_QUANTITY, MAX_VAT_PERCENT, MIN_LINE_QUANTITY, MoneyError, MoneyErrorCode, NO_CART_TRANSPORT, ORDER_PATH, ORDER_STATE_LABELS, ORDER_STOCK_HOLD, ORDER_TRANSITIONS, OrderActor, OrderEvent, OrderRefusal, OrderSnapshotRefusal, OrderState, PAYMENT_FIELD_LABELS, PAYMENT_METHODS, PaymentChannel, PaymentField, PaymentMethodKind, PaymentProvider, QuantityStep, RECOVERY_PATH, RECOVERY_WORDS, REMINDER_LATE_MS, REMINDER_SEQUENCE, REMINDER_STEPS, REMINDER_SUBJECT_WORDS, REMINDER_WORDS_MAX, RecoveryWord, ReminderOutcome, ReminderSkip, ReminderStep, ReminderStop, SAMPLE_CART_LINE, SAMPLE_PRODUCT, SAMPLE_STUDIO, SAMPLE_SWATCHES, SHIPPING_KINDS, SHOP_SLOTS, SHOP_WORDS, SITE_REFUSALS, STOCK_EFFECTS, STOCK_RESERVATION_MINUTES, STOREFRONT_COMPUTED_FIELDS, STOREFRONT_FIELDS, ShippingField, ShippingMethodKind, ShopSlot, ShopWord, SiteCommerceRoute, SiteRefusalCode, StockEffect, StockHold, StorefrontCollection, UNSUBSCRIBE_PATH, VARIANT_NAME_SEPARATOR, VAT_PERCENT_MAX_DECIMALS, addMoney, addressLine, availableShippingMethods, biggestDrop, canBuy, canStep, cartCookieName, cartEndpointPath, cartIssueWords, cartLineId, cartOf, cartTransportErrorFor, cartViewOf, catalogKey, checkoutGate, checkoutHref, checkoutWord, chooseValue, clampQuantity, commerceLanguage, couponDiscount, couponOfferWords, couponProblems, couponRefusalWords, currencyExponent, currentCheckoutStep, defaultChoice, emptyCartView, fieldAsked, fieldRequired, findVariant, formatMoney, formatMoneyValue, freeShippingRemaining, funnelOf, furthestStep, includedVat, isAbandoned, isCouponCode, isCurrencyCode, isMoney, isPaymentMethodKind, isShippingMethodKind, isStorefrontField, isStorefrontProduct, isVatPercent, labelIn, looksLikeEmail, looksLikePhone, majorToMinor, marketingAllowed, maskEmail, mergeCarts, migrateMajorPrice, minorToMajor, money, nextOrderState, nextReminder, normalizeCouponCode, openingOrderState, optionValueStates, orderHref, orderSnapshot, paymentChannelOf, paymentInstructions, paymentMethodProblems, paymentMethodReady, percentOf, priceCart, productCurrency, productInScope, productOptions, productVariants, quantityBounds, quoteShipping, recoveryHref, recoveryWord, reminderNumber, reminderSettingsOf, reservationExpiresAt, sellableQuantity, shippingMethodProblems, shippingMethodReady, shippingNeedsAddress, shopWord, simulatedCartTransport, siteCartView, siteCommercePath, siteRefusalsOf, stepQuantity, stockEffect, stoppedAt, storefrontBindPaths, storefrontCatalog, storefrontMoney, subtractMoney, timesMoney, unsubscribeHref, usablePaymentMethods, variantChoiceOf, variantSlotOf, variantWords };
|
|
2933
|
+
export { ABANDONED_AFTER_MS, Availability, BuyerPaymentStage, CART_COOKIE_PREFIX, CART_ISSUE_LABELS, CART_TRANSPORT_ERROR_LABELS, CHECKOUT_FORM_STEPS, CHECKOUT_GATE_RULES, CHECKOUT_PATH, CHECKOUT_STEPS, CHECKOUT_STEP_LABELS, CHECKOUT_WORDS, COUPON_CODE_MAX, COUPON_CODE_MIN, COUPON_REFUSAL_LABELS, CURRENCY_CODES, CURRENCY_EXPONENTS, CartIssueCode, CartTransportError, CartTransportErrorCode, CheckoutAskedField, CheckoutFieldMode, CheckoutGateArea, CheckoutGateCode, CheckoutSlot, CheckoutStep, CheckoutWord, CommerceLanguage, CouponKind, CouponProblem, CouponRefusal, CurrencyCode, DEFAULT_JOURNEY_DAYS, DEFAULT_MONEY_LOCALE, DEFAULT_REMINDER_SETTINGS, DEFAULT_VARIANT_NAME, DeliveryFit, FINAL_ORDER_STATES, FUNNEL_STAGES, FunnelStage, JOURNEY_PERIODS_DAYS, JourneyEventKind, LegalPage, MAX_CART_AMOUNT, MAX_CART_LINES, MAX_LINE_QUANTITY, MAX_VAT_PERCENT, MIN_LINE_QUANTITY, MoneyError, MoneyErrorCode, NO_CART_TRANSPORT, ORDER_PATH, ORDER_STATE_LABELS, ORDER_STOCK_HOLD, ORDER_TRANSITIONS, OrderActor, OrderEvent, OrderRefusal, OrderSnapshotRefusal, OrderState, PAYMENT_FIELD_LABELS, PAYMENT_METHODS, PAYMENT_VERDICT_LABELS, PaymentAttemptStatus, PaymentChannel, PaymentField, PaymentMethodKind, PaymentMismatch, PaymentProvider, PaymentResultStatus, PaymentVerdictKind, QuantityStep, RECOVERY_PATH, RECOVERY_WORDS, REMINDER_LATE_MS, REMINDER_SEQUENCE, REMINDER_STEPS, REMINDER_SUBJECT_WORDS, REMINDER_WORDS_MAX, RecoveryWord, ReminderOutcome, ReminderSkip, ReminderStep, ReminderStop, SAMPLE_CART_LINE, SAMPLE_PRODUCT, SAMPLE_STUDIO, SAMPLE_SWATCHES, SHIPPING_KINDS, SHOP_SLOTS, SHOP_WORDS, SITE_REFUSALS, STOCK_EFFECTS, STOCK_RESERVATION_MINUTES, STOREFRONT_COMPUTED_FIELDS, STOREFRONT_FIELDS, ShippingField, ShippingMethodKind, ShopSlot, ShopWord, SiteCommerceRoute, SiteOrderAction, SiteRefusalCode, StockEffect, StockHold, StorefrontCollection, UNSUBSCRIBE_PATH, VARIANT_NAME_SEPARATOR, VAT_PERCENT_MAX_DECIMALS, addMoney, addressLine, availableShippingMethods, biggestDrop, buyerMayPay, buyerPaymentStage, canBuy, canStep, cartCookieName, cartEndpointPath, cartIssueWords, cartLineId, cartOf, cartTransportErrorFor, cartViewOf, catalogKey, checkoutGate, checkoutHref, checkoutWord, chooseValue, clampQuantity, commerceLanguage, couponDiscount, couponOfferWords, couponProblems, couponRefusalWords, currencyExponent, currentCheckoutStep, defaultChoice, emptyCartView, fieldAsked, fieldRequired, findVariant, formatMoney, formatMoneyValue, freeShippingRemaining, funnelOf, furthestStep, includedVat, isAbandoned, isCouponCode, isCurrencyCode, isMoney, isPaymentMethodKind, isShippingMethodKind, isStorefrontField, isStorefrontProduct, isVatPercent, labelIn, looksLikeEmail, looksLikePhone, majorToMinor, marketingAllowed, maskEmail, mergeCarts, migrateMajorPrice, minorToMajor, money, nextOrderState, nextReminder, normalizeCouponCode, openingOrderState, optionValueStates, orderHref, orderSnapshot, paymentChannelOf, paymentInstructions, paymentMethodConnected, paymentMethodProblems, paymentMethodReady, paymentVerdict, percentOf, priceCart, productCurrency, productInScope, productOptions, productVariants, quantityBounds, quoteShipping, recoveryHref, recoveryWord, reminderNumber, reminderSettingsOf, reservationDue, reservationExpiresAt, reusableAttempt, sellableQuantity, shippingMethodProblems, shippingMethodReady, shippingNeedsAddress, shopWord, simulatedCartTransport, siteCartView, siteCommercePath, siteOrderActionPath, siteRefusalsOf, stepQuantity, stockEffect, stoppedAt, storefrontBindPaths, storefrontCatalog, storefrontMoney, subtractMoney, timesMoney, unsubscribeHref, usablePaymentMethods, variantChoiceOf, variantSlotOf, variantWords };
|
|
2725
2934
|
//# sourceMappingURL=vectoriox-iox-ui-commerce-core.mjs.map
|