@final-commerce/common 2.11.1-online.7 → 2.11.1-online.9

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/dist/index.d.mts CHANGED
@@ -1128,6 +1128,17 @@ interface LineStockMove {
1128
1128
  }
1129
1129
  declare function lineStockMoves(item: StockLine, quantity: number, reservations?: readonly StockReservationLink[]): LineStockMove[];
1130
1130
 
1131
+ declare function emailKey(email: string | null | undefined): string | null;
1132
+ declare function phoneKey(phone: string | null | undefined): string | null;
1133
+ declare const CUSTOMER_CONTACT_VERIFIED = "CUSTOMER_CONTACT_VERIFIED";
1134
+ type ContactSide = {
1135
+ email?: string | null;
1136
+ phone?: string | null;
1137
+ };
1138
+ declare function verifiedContactChange(existing: ContactSide & {
1139
+ verifiedShopperAt?: Date | string | null;
1140
+ }, change: ContactSide): 'email' | 'phone' | null;
1141
+
1131
1142
  declare const SYSTEM_FAMILY_IDS: {
1132
1143
  readonly COUNT: "count";
1133
1144
  readonly WEIGHT: "weight-metric";
@@ -1175,7 +1186,7 @@ declare function isSystemFamilyCode(code: string): boolean;
1175
1186
  declare function deriveUnitId(abbreviation: string, documentId: string): string;
1176
1187
 
1177
1188
  type PaymentState = 'unpaid' | 'payment_pending' | 'partially_paid' | 'paid' | 'partially_refunded' | 'refunded' | 'voided';
1178
- type FulfillmentState = 'draft' | 'pending' | 'on_hold' | 'in_progress' | 'fulfilled' | 'partially_fulfilled' | 'returned' | 'partially_returned' | 'cancelled';
1189
+ type FulfillmentState = 'draft' | 'pending' | 'on_hold' | 'in_progress' | 'fulfilled' | 'partially_fulfilled' | 'return_pending' | 'returned' | 'partially_returned' | 'cancelled';
1179
1190
  declare const PAYMENT_STATES: readonly PaymentState[];
1180
1191
  declare const FULFILLMENT_STATES: readonly FulfillmentState[];
1181
1192
  declare function isPaymentState(value: string): value is PaymentState;
@@ -2075,10 +2086,18 @@ interface ShopperCard {
2075
2086
  brand: string;
2076
2087
  lastFour: string;
2077
2088
  }
2089
+ type ShopperPaymentKind = 'card' | 'cash' | 'gift_card' | 'pay_later' | 'other';
2090
+ interface ShopperPayment {
2091
+ kind: ShopperPaymentKind;
2092
+ name: string | null;
2093
+ lastFour: string | null;
2094
+ amount: number;
2095
+ }
2078
2096
  interface ShopperOrderDetail extends ShopperOrderRow {
2079
2097
  items: ShopperOrderItem[];
2080
2098
  totals: ShopperOrderTotals;
2081
2099
  card: ShopperCard | null;
2100
+ payments?: ShopperPayment[];
2082
2101
  delivery: {
2083
2102
  type: 'pickup' | 'shipping';
2084
2103
  place: string | null;
@@ -2158,7 +2177,18 @@ declare function normalizeShopperEmail(email: unknown): string | null;
2158
2177
  declare function cardFromProcessorData(processorData: unknown): {
2159
2178
  cardBrand?: string;
2160
2179
  cardLastFour?: string;
2180
+ cardIssuer?: string;
2181
+ };
2182
+
2183
+ type PaymentLegLike = {
2184
+ paymentType?: string;
2185
+ amount?: number;
2186
+ tip?: {
2187
+ amount?: number;
2188
+ } | null;
2189
+ emv?: string | null;
2161
2190
  };
2191
+ declare function shopperPaymentsOf(legs: readonly PaymentLegLike[] | null | undefined): ShopperPayment[];
2162
2192
 
2163
2193
  interface CurrencyRate {
2164
2194
  rate: number;
@@ -2228,4 +2258,4 @@ declare const EXPENSE_DEFAULT_CATEGORIES: readonly [{
2228
2258
  }];
2229
2259
  type ExpenseDefaultCategoryKey = (typeof EXPENSE_DEFAULT_CATEGORIES)[number]['key'];
2230
2260
 
2231
- export { ADYEN_JOB_TITLE_ASSOCIATION_TYPES, ADYEN_LEGAL_ENTITY_STATE_PROVINCE_COUNTRIES, ADYEN_NO_TAX_NUMBER_ABSENT_COUNTRIES, ADYEN_ROLLOUT_COUNTRY_CODES, ADYEN_STORE_STATE_PROVINCE_COUNTRIES, ADYEN_TAX_NUMBER_FORMATS, ADYEN_TAX_NUMBER_MIN_LENGTH, AFFIRM_COUNTRY_CODES, AFFIRM_PRICE_PLANS, type AddressLike, type AdyenBnplSettings, type AdyenBnplSkippedStore, type AdyenBnplUpdateResult, type AffirmPricePlan, type Amount, type AssignUserChange, AttributeType, type AutomaticTaxPart, type AutomaticTaxRateRow, type AutomaticTaxRowStatus, type AutomaticTaxRuleRow, type AutomaticTaxTable, type AutomaticTaxTypeRow, type AvailabilityInput, type AvailabilitySlot, type AvailableTransition, BNPL_METHOD_STATUS, BNPL_SKIP_REASON, type BnplMethodStatus, type BnplSkipReason, type BookingOccupancy, BookingRatePeriod, type BookingResourceInput, BookingResourceKind, BookingResourceStatus, BookingRulesError, type BookingRulesInput, BookingType, type BusyWindow, CANADA_PROVINCES, CONDITION_OPERATORS, COUNTRY_CURRENCIES, CURRENCY_CONFIG, type CartDiscountBucket, type CartFeeBucket, type CashDrawer, type CashRoundingTuple, type CategoryModifierRow, type CategoryRow, CompanyType, type CompositeAvailabilityRows, type CompositeMakeable, type CompositeMakeableRow, type CompositePriceItem, type CompositePricePart, type CompositeReservationOrder, type CompositeShelf, type CompositeStockPart, type Condition, type ConditionGroup, type ConditionOperator, type ConfigUpdatedPayload, type ConfigValidationError, type ConfigValidationResult, type ConfigValidationWarning, type CountryOption, type CrossAxisRequires, type CrossAxisRule, type CrossAxisTrigger, CurrencyCode, type CurrencyConfig, type CurrencyRate, CustomTableAvailability, CustomerPlatform, DEFAULT_CONFIG, DEFAULT_CROSS_AXIS_RULES, DEFAULT_DISPLAY_STATE_MAP, DEFAULT_HOLD_MINUTES, DEFAULT_RESOLVED_CONFIG, DEFAULT_UNIT_ID, type DeleteStateConfigFragmentParams, type DeleteStateConfigFragmentResponse, type DiscountsBreakdown, type DiscountsTuple, type DisplayStateResult, type DisplayStateRule, DualWriteStrategy, EUFixedRates, EUROPE, EVERYWHERE_KEY, EXPENSE_DEFAULT_CATEGORIES, EXPENSE_NAME_MAX_LENGTH, EXPENSE_PAYMENT_METHOD_PRESETS, type EndOfSessionReport, type ExpenseDefaultCategoryKey, ExtensionCategory, FINANCIAL_INVARIANTS, FULFILLMENT_STATES, type FailedCondition, type FeesBreakdown, FeesCustomBillingStatus, type FeesTuple, type FinancialInvariant, type FragmentParam, type FragmentValidationResult, type FulfillmentState, type FulfillmentStateDefinition, type FulfillmentTransitionPath, type GetAvailableTransitionsParams, type GetAvailableTransitionsResponse, type GetOrderDisplayStateParams, type GetOrderDisplayStateResponse, type GetOrderStateConfigParams, type GetOrderStateConfigResponse, type GetStateConfigFragmentParams, type GetStateConfigFragmentResponse, type GridSlot, HttpMethod, InventoryBaseActionEnum, type InventoryBaseActionType, InventorySpecificActionType, InvoiceStatus, LegacyWriteStrategy, LibraryItemType, type LineStockMove, MAX_PRECISION, type Measurable, type MeasurementBase, type MeasurementUnit, type MeasurementUnitFamily, MenuProject, type ModifierChoiceRow, type ModifierRow, type ModifiersBreakdown, type ModifiersTuple, NAFixedRates, NORTH_AMERICA, NonRevenueItemType, type NormalizedAddress, ORDER_STATE_ACTIONS, ORDER_STATE_EVENTS, ORDER_STATE_TOPIC, type OrderContext, type OrderLikeForAssignedUsers, type OrderLikeForContext, type OrderLikeForInCart, type OrderLikeForLegacyInference, type OrderLineItem, type OrderMutationData, type OrderPaymentMethod, OrderPlatform, type OrderRefund, type OrderReservationForContext, type OrderStateEventPayload, type OrderStateWritable, type OrderStatusDefinition, type OrderStatusValidationError, type OrderTaxSkip, type OrderWriteStrategy, OtherFixedRates, OutOfProvinceTaxes, OwnerType, PATH_MODES, PAYMENT_CHANNELS, PAYMENT_STATES, POS_VALID_INITIAL_STATES, type PathMode, type PaymentChannel, PaymentMethod, PaymentProcessor, type PaymentState, type PaymentStateDefinition, type PaymentTransitionPath, type PlanWindowInput, Platform, type PoolDrawing, PreviewImageMode, PricingLevel, PricingPlanEnum, PricingRegionEnum, ProcessorType, type ProductDiscountBucket, type ProductFeeBucket, ProductSalesChartStep, ProductSalesReportCompare, ProductStatus, ProductType, type Province, PublicationAvailability, type PublicationConfig, PublicationStatus, REGION_MAPPING, REPORT_NEGATE_PATHS, ReceiptSendChannel, ReceiptType, type RefundsBreakdown, ReservationStatus, ResidualPaymentMethod, ResidualStatus, type ResolveInputs, type ResolveShippingInput, type ResolveTemplateResult, type ResourceAvailability, ResourceAvailabilityState, type ResourceInWindow, type ResourcePresenceRow, SHIPPING_COUNTRIES, SHOPPER_CONSENT_SOURCES, SHOPPER_ERROR_CODES, SHOPPER_RETURN_DECLINE_REASON_MAX, SHOPPER_RETURN_METHODS, SHOPPER_RETURN_STATUSES, STANDARD_TAX_TYPE, STATE_SCHEMA, STRIPE_SUPPORTED_COUNTRIES, SYSTEM_FAMILIES, SYSTEM_FAMILY_IDS, SYSTEM_UNITS, SYSTEM_UNIT_IDS, SalesLineAction, SalesLineSourceArray, type SalesSummary, type SaveStateConfigFragmentParams, type SaveStateConfigFragmentResponse, type SettlementBreakdown, type SettlementBuckets, type SettlementCardSection, type SettlementCashSection, type SettlementCustomEntry, ShippingChannel, type ShippingDuration, ShippingNoOptionReason, type ShippingOptionRule, ShippingOptionType, type ShippingPlace, type ShippingPriceTier, type ShippingQuoteOption, ShippingRateType, type ShippingResolution, type ShippingTuple, ShippingZoneError, ShippingZoneKind, type ShippingZoneProblem, type ShippingZoneRule, type ShopperAddressInput, type ShopperCard, type ShopperConsentSource, type ShopperErrorCode, type ShopperIdentity, type ShopperNotificationChoices, type ShopperOrderDetail, type ShopperOrderItem, type ShopperOrderRow, type ShopperOrderStatus, type ShopperOrderTotals, type ShopperPaymentMethod, type ShopperProfile, type ShopperReturnMethod, type ShopperReturnRequestInput, type ShopperReturnRequestState, type ShopperReturnStatus, type ShopperSavedAddress, type ShopperScope, type ShopperStore, type ShopperStoreRef, type SplitPayment, type SplitPaymentPayment, type StaffSales, type StaffSalesEntry, type StateConfig, type StateConfigFragment, type StateDefinition, type StatePair, type StateSchema, type StateTransitionBlockedPayload, type StateTransitionCompletedPayload, StationStatus, type StockLine, type StockLineComponent, type StockReservationLink, type StoredStateConfig, StripeCurrencyCode, StripeStatus, TAX_EXCEPTION_REASON_MAX, type TaxBreakdown, type TaxBreakdownRateEntry, type TaxBreakdownSection, type TaxBreakdownSubtotal, type TaxException, TaxExceptionSource, type TaxRegistration, TaxRegistrationKind, TaxSource, TaxWarningCode, type TaxesTuple, TimePeriod, type TipEntry, type TipsBreakdown, type TipsTuple, TopMetericsSort, type TransitionBlockedBy, type TransitionConditionSet, type TransitionOrderStateParams, type TransitionOrderStateResponse, type TransitionPath, type TransitionRequest, type TransitionResult, UserTypes, type WeeklyHours, addAmounts, addressPlaceKeys, adyenLegalEntityRequiresStateOrProvince, adyenRequiresJobTitle, adyenStoreRequiresStateOrProvince, adyenSupportsTaxNumberAbsent, adyenTaxNumberFormat, amountToString, ancestorChain, applyAssignment, assertUnitSane, automaticTaxTableVersion, availableIn, baseFor, baseFulfillmentDefinitions, baseOf, basePaymentDefinitions, buildAutomaticTaxTable, buildAvailability, buildGrid, buildOrderContext, buildPosPresetConfig, buildResolvedConfig, calculatePercentage, canTransition, cardFromProcessorData, cheapestCompositeItem, cheapestCompositePrice, compositeItemCost, compositeItemUnavailable, compositeMakeable, compositeModifierMismatches, compositeReservationMismatches, compositeVariantInStock, conditionSummary, convertFixedFeeToLocalCurrency, createAmount, crossAxisRuleApplies, currentAssignees, deriveDisplayState, deriveFamilyCode, deriveUnitId, displayRuleMatchesPair, divideAmount, evaluateCondition, evaluateConditionSet, extendPrice, extendPriceFor, formatCurrency, formatInUnit, formatMinorUnitsToString, formatQuantity, formatShippingDuration, fromBase, fromMinorUnits, generateMongoID, getAvailableTransitions, getCashAmountDue, getCountriesByRegion, getCurrencyConfig, getCurrentISODate, getFinancialInvariantViolations, getGoodsPortion, getLineSubtotal, getMinorUnitMultiplier, getMinorUnits, getPaymentLegTotal, getPricingRegionFromCountry, getSettlementTotal, getTotalCollected, hasInCartFlag, hasSellableChoice, holdExpiresAt, inferStatesFromLegacyStatus, isAdyenRolloutCountry, isAffirmCountry, isAffirmPricePlan, isChoiceAvailableAtOutlet, isConditionOperator, isFulfillmentState, isInCart, isPaymentState, isSupportedCurrency, isSystemFamilyCode, isValidQuantity, isWhole, lineStockMoves, listCountries, listProvinces, listShippingCountries, mapToLegacyStatus, maxPrecisionFor, mergeFragment, modifiersSellable, multiplyAmount, normalizeAddress, normalizeCityKey, normalizeCountry, normalizeMongoIdString, normalizePostCode, normalizeProvince, normalizeShopperEmail, occupancyIn, orderAssignments, parseAmountToMinorUnits, parseCurrencyCode, parseStripeCurrencyCode, placeKey, planWindow, poolDemand, poolOf, poolShortfall, poolStockAt, postCodeMatchesProvince, presentAt, priceForTotal, provincesForPostCode, registrationPlacesByKind, removeFragment, resolveFamily, resolveModifiersForProduct, resolveShipping, resolveTemplate, resolveUnit, roundToPrecision, sameFamily, setOrderState, sha1Hex, shippingDuration, shipsToCountry, shopDayKey, shopDayRange, signReportForDisplay, slotsForWindow, stringifyMinorUnits, subtractAmounts, toBase, toMinorUnits, validateConfig, validateFragmentCompatibility, validateOrderStatuses, validateShippingZone, violatesFinancialInvariant, windowEndsAt, withinPresence };
2261
+ export { ADYEN_JOB_TITLE_ASSOCIATION_TYPES, ADYEN_LEGAL_ENTITY_STATE_PROVINCE_COUNTRIES, ADYEN_NO_TAX_NUMBER_ABSENT_COUNTRIES, ADYEN_ROLLOUT_COUNTRY_CODES, ADYEN_STORE_STATE_PROVINCE_COUNTRIES, ADYEN_TAX_NUMBER_FORMATS, ADYEN_TAX_NUMBER_MIN_LENGTH, AFFIRM_COUNTRY_CODES, AFFIRM_PRICE_PLANS, type AddressLike, type AdyenBnplSettings, type AdyenBnplSkippedStore, type AdyenBnplUpdateResult, type AffirmPricePlan, type Amount, type AssignUserChange, AttributeType, type AutomaticTaxPart, type AutomaticTaxRateRow, type AutomaticTaxRowStatus, type AutomaticTaxRuleRow, type AutomaticTaxTable, type AutomaticTaxTypeRow, type AvailabilityInput, type AvailabilitySlot, type AvailableTransition, BNPL_METHOD_STATUS, BNPL_SKIP_REASON, type BnplMethodStatus, type BnplSkipReason, type BookingOccupancy, BookingRatePeriod, type BookingResourceInput, BookingResourceKind, BookingResourceStatus, BookingRulesError, type BookingRulesInput, BookingType, type BusyWindow, CANADA_PROVINCES, CONDITION_OPERATORS, COUNTRY_CURRENCIES, CURRENCY_CONFIG, CUSTOMER_CONTACT_VERIFIED, type CartDiscountBucket, type CartFeeBucket, type CashDrawer, type CashRoundingTuple, type CategoryModifierRow, type CategoryRow, CompanyType, type CompositeAvailabilityRows, type CompositeMakeable, type CompositeMakeableRow, type CompositePriceItem, type CompositePricePart, type CompositeReservationOrder, type CompositeShelf, type CompositeStockPart, type Condition, type ConditionGroup, type ConditionOperator, type ConfigUpdatedPayload, type ConfigValidationError, type ConfigValidationResult, type ConfigValidationWarning, type CountryOption, type CrossAxisRequires, type CrossAxisRule, type CrossAxisTrigger, CurrencyCode, type CurrencyConfig, type CurrencyRate, CustomTableAvailability, CustomerPlatform, DEFAULT_CONFIG, DEFAULT_CROSS_AXIS_RULES, DEFAULT_DISPLAY_STATE_MAP, DEFAULT_HOLD_MINUTES, DEFAULT_RESOLVED_CONFIG, DEFAULT_UNIT_ID, type DeleteStateConfigFragmentParams, type DeleteStateConfigFragmentResponse, type DiscountsBreakdown, type DiscountsTuple, type DisplayStateResult, type DisplayStateRule, DualWriteStrategy, EUFixedRates, EUROPE, EVERYWHERE_KEY, EXPENSE_DEFAULT_CATEGORIES, EXPENSE_NAME_MAX_LENGTH, EXPENSE_PAYMENT_METHOD_PRESETS, type EndOfSessionReport, type ExpenseDefaultCategoryKey, ExtensionCategory, FINANCIAL_INVARIANTS, FULFILLMENT_STATES, type FailedCondition, type FeesBreakdown, FeesCustomBillingStatus, type FeesTuple, type FinancialInvariant, type FragmentParam, type FragmentValidationResult, type FulfillmentState, type FulfillmentStateDefinition, type FulfillmentTransitionPath, type GetAvailableTransitionsParams, type GetAvailableTransitionsResponse, type GetOrderDisplayStateParams, type GetOrderDisplayStateResponse, type GetOrderStateConfigParams, type GetOrderStateConfigResponse, type GetStateConfigFragmentParams, type GetStateConfigFragmentResponse, type GridSlot, HttpMethod, InventoryBaseActionEnum, type InventoryBaseActionType, InventorySpecificActionType, InvoiceStatus, LegacyWriteStrategy, LibraryItemType, type LineStockMove, MAX_PRECISION, type Measurable, type MeasurementBase, type MeasurementUnit, type MeasurementUnitFamily, MenuProject, type ModifierChoiceRow, type ModifierRow, type ModifiersBreakdown, type ModifiersTuple, NAFixedRates, NORTH_AMERICA, NonRevenueItemType, type NormalizedAddress, ORDER_STATE_ACTIONS, ORDER_STATE_EVENTS, ORDER_STATE_TOPIC, type OrderContext, type OrderLikeForAssignedUsers, type OrderLikeForContext, type OrderLikeForInCart, type OrderLikeForLegacyInference, type OrderLineItem, type OrderMutationData, type OrderPaymentMethod, OrderPlatform, type OrderRefund, type OrderReservationForContext, type OrderStateEventPayload, type OrderStateWritable, type OrderStatusDefinition, type OrderStatusValidationError, type OrderTaxSkip, type OrderWriteStrategy, OtherFixedRates, OutOfProvinceTaxes, OwnerType, PATH_MODES, PAYMENT_CHANNELS, PAYMENT_STATES, POS_VALID_INITIAL_STATES, type PathMode, type PaymentChannel, type PaymentLegLike, PaymentMethod, PaymentProcessor, type PaymentState, type PaymentStateDefinition, type PaymentTransitionPath, type PlanWindowInput, Platform, type PoolDrawing, PreviewImageMode, PricingLevel, PricingPlanEnum, PricingRegionEnum, ProcessorType, type ProductDiscountBucket, type ProductFeeBucket, ProductSalesChartStep, ProductSalesReportCompare, ProductStatus, ProductType, type Province, PublicationAvailability, type PublicationConfig, PublicationStatus, REGION_MAPPING, REPORT_NEGATE_PATHS, ReceiptSendChannel, ReceiptType, type RefundsBreakdown, ReservationStatus, ResidualPaymentMethod, ResidualStatus, type ResolveInputs, type ResolveShippingInput, type ResolveTemplateResult, type ResourceAvailability, ResourceAvailabilityState, type ResourceInWindow, type ResourcePresenceRow, SHIPPING_COUNTRIES, SHOPPER_CONSENT_SOURCES, SHOPPER_ERROR_CODES, SHOPPER_RETURN_DECLINE_REASON_MAX, SHOPPER_RETURN_METHODS, SHOPPER_RETURN_STATUSES, STANDARD_TAX_TYPE, STATE_SCHEMA, STRIPE_SUPPORTED_COUNTRIES, SYSTEM_FAMILIES, SYSTEM_FAMILY_IDS, SYSTEM_UNITS, SYSTEM_UNIT_IDS, SalesLineAction, SalesLineSourceArray, type SalesSummary, type SaveStateConfigFragmentParams, type SaveStateConfigFragmentResponse, type SettlementBreakdown, type SettlementBuckets, type SettlementCardSection, type SettlementCashSection, type SettlementCustomEntry, ShippingChannel, type ShippingDuration, ShippingNoOptionReason, type ShippingOptionRule, ShippingOptionType, type ShippingPlace, type ShippingPriceTier, type ShippingQuoteOption, ShippingRateType, type ShippingResolution, type ShippingTuple, ShippingZoneError, ShippingZoneKind, type ShippingZoneProblem, type ShippingZoneRule, type ShopperAddressInput, type ShopperCard, type ShopperConsentSource, type ShopperErrorCode, type ShopperIdentity, type ShopperNotificationChoices, type ShopperOrderDetail, type ShopperOrderItem, type ShopperOrderRow, type ShopperOrderStatus, type ShopperOrderTotals, type ShopperPayment, type ShopperPaymentKind, type ShopperPaymentMethod, type ShopperProfile, type ShopperReturnMethod, type ShopperReturnRequestInput, type ShopperReturnRequestState, type ShopperReturnStatus, type ShopperSavedAddress, type ShopperScope, type ShopperStore, type ShopperStoreRef, type SplitPayment, type SplitPaymentPayment, type StaffSales, type StaffSalesEntry, type StateConfig, type StateConfigFragment, type StateDefinition, type StatePair, type StateSchema, type StateTransitionBlockedPayload, type StateTransitionCompletedPayload, StationStatus, type StockLine, type StockLineComponent, type StockReservationLink, type StoredStateConfig, StripeCurrencyCode, StripeStatus, TAX_EXCEPTION_REASON_MAX, type TaxBreakdown, type TaxBreakdownRateEntry, type TaxBreakdownSection, type TaxBreakdownSubtotal, type TaxException, TaxExceptionSource, type TaxRegistration, TaxRegistrationKind, TaxSource, TaxWarningCode, type TaxesTuple, TimePeriod, type TipEntry, type TipsBreakdown, type TipsTuple, TopMetericsSort, type TransitionBlockedBy, type TransitionConditionSet, type TransitionOrderStateParams, type TransitionOrderStateResponse, type TransitionPath, type TransitionRequest, type TransitionResult, UserTypes, type WeeklyHours, addAmounts, addressPlaceKeys, adyenLegalEntityRequiresStateOrProvince, adyenRequiresJobTitle, adyenStoreRequiresStateOrProvince, adyenSupportsTaxNumberAbsent, adyenTaxNumberFormat, amountToString, ancestorChain, applyAssignment, assertUnitSane, automaticTaxTableVersion, availableIn, baseFor, baseFulfillmentDefinitions, baseOf, basePaymentDefinitions, buildAutomaticTaxTable, buildAvailability, buildGrid, buildOrderContext, buildPosPresetConfig, buildResolvedConfig, calculatePercentage, canTransition, cardFromProcessorData, cheapestCompositeItem, cheapestCompositePrice, compositeItemCost, compositeItemUnavailable, compositeMakeable, compositeModifierMismatches, compositeReservationMismatches, compositeVariantInStock, conditionSummary, convertFixedFeeToLocalCurrency, createAmount, crossAxisRuleApplies, currentAssignees, deriveDisplayState, deriveFamilyCode, deriveUnitId, displayRuleMatchesPair, divideAmount, emailKey, evaluateCondition, evaluateConditionSet, extendPrice, extendPriceFor, formatCurrency, formatInUnit, formatMinorUnitsToString, formatQuantity, formatShippingDuration, fromBase, fromMinorUnits, generateMongoID, getAvailableTransitions, getCashAmountDue, getCountriesByRegion, getCurrencyConfig, getCurrentISODate, getFinancialInvariantViolations, getGoodsPortion, getLineSubtotal, getMinorUnitMultiplier, getMinorUnits, getPaymentLegTotal, getPricingRegionFromCountry, getSettlementTotal, getTotalCollected, hasInCartFlag, hasSellableChoice, holdExpiresAt, inferStatesFromLegacyStatus, isAdyenRolloutCountry, isAffirmCountry, isAffirmPricePlan, isChoiceAvailableAtOutlet, isConditionOperator, isFulfillmentState, isInCart, isPaymentState, isSupportedCurrency, isSystemFamilyCode, isValidQuantity, isWhole, lineStockMoves, listCountries, listProvinces, listShippingCountries, mapToLegacyStatus, maxPrecisionFor, mergeFragment, modifiersSellable, multiplyAmount, normalizeAddress, normalizeCityKey, normalizeCountry, normalizeMongoIdString, normalizePostCode, normalizeProvince, normalizeShopperEmail, occupancyIn, orderAssignments, parseAmountToMinorUnits, parseCurrencyCode, parseStripeCurrencyCode, phoneKey, placeKey, planWindow, poolDemand, poolOf, poolShortfall, poolStockAt, postCodeMatchesProvince, presentAt, priceForTotal, provincesForPostCode, registrationPlacesByKind, removeFragment, resolveFamily, resolveModifiersForProduct, resolveShipping, resolveTemplate, resolveUnit, roundToPrecision, sameFamily, setOrderState, sha1Hex, shippingDuration, shipsToCountry, shopDayKey, shopDayRange, shopperPaymentsOf, signReportForDisplay, slotsForWindow, stringifyMinorUnits, subtractAmounts, toBase, toMinorUnits, validateConfig, validateFragmentCompatibility, validateOrderStatuses, validateShippingZone, verifiedContactChange, violatesFinancialInvariant, windowEndsAt, withinPresence };
package/dist/index.d.ts CHANGED
@@ -1128,6 +1128,17 @@ interface LineStockMove {
1128
1128
  }
1129
1129
  declare function lineStockMoves(item: StockLine, quantity: number, reservations?: readonly StockReservationLink[]): LineStockMove[];
1130
1130
 
1131
+ declare function emailKey(email: string | null | undefined): string | null;
1132
+ declare function phoneKey(phone: string | null | undefined): string | null;
1133
+ declare const CUSTOMER_CONTACT_VERIFIED = "CUSTOMER_CONTACT_VERIFIED";
1134
+ type ContactSide = {
1135
+ email?: string | null;
1136
+ phone?: string | null;
1137
+ };
1138
+ declare function verifiedContactChange(existing: ContactSide & {
1139
+ verifiedShopperAt?: Date | string | null;
1140
+ }, change: ContactSide): 'email' | 'phone' | null;
1141
+
1131
1142
  declare const SYSTEM_FAMILY_IDS: {
1132
1143
  readonly COUNT: "count";
1133
1144
  readonly WEIGHT: "weight-metric";
@@ -1175,7 +1186,7 @@ declare function isSystemFamilyCode(code: string): boolean;
1175
1186
  declare function deriveUnitId(abbreviation: string, documentId: string): string;
1176
1187
 
1177
1188
  type PaymentState = 'unpaid' | 'payment_pending' | 'partially_paid' | 'paid' | 'partially_refunded' | 'refunded' | 'voided';
1178
- type FulfillmentState = 'draft' | 'pending' | 'on_hold' | 'in_progress' | 'fulfilled' | 'partially_fulfilled' | 'returned' | 'partially_returned' | 'cancelled';
1189
+ type FulfillmentState = 'draft' | 'pending' | 'on_hold' | 'in_progress' | 'fulfilled' | 'partially_fulfilled' | 'return_pending' | 'returned' | 'partially_returned' | 'cancelled';
1179
1190
  declare const PAYMENT_STATES: readonly PaymentState[];
1180
1191
  declare const FULFILLMENT_STATES: readonly FulfillmentState[];
1181
1192
  declare function isPaymentState(value: string): value is PaymentState;
@@ -2075,10 +2086,18 @@ interface ShopperCard {
2075
2086
  brand: string;
2076
2087
  lastFour: string;
2077
2088
  }
2089
+ type ShopperPaymentKind = 'card' | 'cash' | 'gift_card' | 'pay_later' | 'other';
2090
+ interface ShopperPayment {
2091
+ kind: ShopperPaymentKind;
2092
+ name: string | null;
2093
+ lastFour: string | null;
2094
+ amount: number;
2095
+ }
2078
2096
  interface ShopperOrderDetail extends ShopperOrderRow {
2079
2097
  items: ShopperOrderItem[];
2080
2098
  totals: ShopperOrderTotals;
2081
2099
  card: ShopperCard | null;
2100
+ payments?: ShopperPayment[];
2082
2101
  delivery: {
2083
2102
  type: 'pickup' | 'shipping';
2084
2103
  place: string | null;
@@ -2158,7 +2177,18 @@ declare function normalizeShopperEmail(email: unknown): string | null;
2158
2177
  declare function cardFromProcessorData(processorData: unknown): {
2159
2178
  cardBrand?: string;
2160
2179
  cardLastFour?: string;
2180
+ cardIssuer?: string;
2181
+ };
2182
+
2183
+ type PaymentLegLike = {
2184
+ paymentType?: string;
2185
+ amount?: number;
2186
+ tip?: {
2187
+ amount?: number;
2188
+ } | null;
2189
+ emv?: string | null;
2161
2190
  };
2191
+ declare function shopperPaymentsOf(legs: readonly PaymentLegLike[] | null | undefined): ShopperPayment[];
2162
2192
 
2163
2193
  interface CurrencyRate {
2164
2194
  rate: number;
@@ -2228,4 +2258,4 @@ declare const EXPENSE_DEFAULT_CATEGORIES: readonly [{
2228
2258
  }];
2229
2259
  type ExpenseDefaultCategoryKey = (typeof EXPENSE_DEFAULT_CATEGORIES)[number]['key'];
2230
2260
 
2231
- export { ADYEN_JOB_TITLE_ASSOCIATION_TYPES, ADYEN_LEGAL_ENTITY_STATE_PROVINCE_COUNTRIES, ADYEN_NO_TAX_NUMBER_ABSENT_COUNTRIES, ADYEN_ROLLOUT_COUNTRY_CODES, ADYEN_STORE_STATE_PROVINCE_COUNTRIES, ADYEN_TAX_NUMBER_FORMATS, ADYEN_TAX_NUMBER_MIN_LENGTH, AFFIRM_COUNTRY_CODES, AFFIRM_PRICE_PLANS, type AddressLike, type AdyenBnplSettings, type AdyenBnplSkippedStore, type AdyenBnplUpdateResult, type AffirmPricePlan, type Amount, type AssignUserChange, AttributeType, type AutomaticTaxPart, type AutomaticTaxRateRow, type AutomaticTaxRowStatus, type AutomaticTaxRuleRow, type AutomaticTaxTable, type AutomaticTaxTypeRow, type AvailabilityInput, type AvailabilitySlot, type AvailableTransition, BNPL_METHOD_STATUS, BNPL_SKIP_REASON, type BnplMethodStatus, type BnplSkipReason, type BookingOccupancy, BookingRatePeriod, type BookingResourceInput, BookingResourceKind, BookingResourceStatus, BookingRulesError, type BookingRulesInput, BookingType, type BusyWindow, CANADA_PROVINCES, CONDITION_OPERATORS, COUNTRY_CURRENCIES, CURRENCY_CONFIG, type CartDiscountBucket, type CartFeeBucket, type CashDrawer, type CashRoundingTuple, type CategoryModifierRow, type CategoryRow, CompanyType, type CompositeAvailabilityRows, type CompositeMakeable, type CompositeMakeableRow, type CompositePriceItem, type CompositePricePart, type CompositeReservationOrder, type CompositeShelf, type CompositeStockPart, type Condition, type ConditionGroup, type ConditionOperator, type ConfigUpdatedPayload, type ConfigValidationError, type ConfigValidationResult, type ConfigValidationWarning, type CountryOption, type CrossAxisRequires, type CrossAxisRule, type CrossAxisTrigger, CurrencyCode, type CurrencyConfig, type CurrencyRate, CustomTableAvailability, CustomerPlatform, DEFAULT_CONFIG, DEFAULT_CROSS_AXIS_RULES, DEFAULT_DISPLAY_STATE_MAP, DEFAULT_HOLD_MINUTES, DEFAULT_RESOLVED_CONFIG, DEFAULT_UNIT_ID, type DeleteStateConfigFragmentParams, type DeleteStateConfigFragmentResponse, type DiscountsBreakdown, type DiscountsTuple, type DisplayStateResult, type DisplayStateRule, DualWriteStrategy, EUFixedRates, EUROPE, EVERYWHERE_KEY, EXPENSE_DEFAULT_CATEGORIES, EXPENSE_NAME_MAX_LENGTH, EXPENSE_PAYMENT_METHOD_PRESETS, type EndOfSessionReport, type ExpenseDefaultCategoryKey, ExtensionCategory, FINANCIAL_INVARIANTS, FULFILLMENT_STATES, type FailedCondition, type FeesBreakdown, FeesCustomBillingStatus, type FeesTuple, type FinancialInvariant, type FragmentParam, type FragmentValidationResult, type FulfillmentState, type FulfillmentStateDefinition, type FulfillmentTransitionPath, type GetAvailableTransitionsParams, type GetAvailableTransitionsResponse, type GetOrderDisplayStateParams, type GetOrderDisplayStateResponse, type GetOrderStateConfigParams, type GetOrderStateConfigResponse, type GetStateConfigFragmentParams, type GetStateConfigFragmentResponse, type GridSlot, HttpMethod, InventoryBaseActionEnum, type InventoryBaseActionType, InventorySpecificActionType, InvoiceStatus, LegacyWriteStrategy, LibraryItemType, type LineStockMove, MAX_PRECISION, type Measurable, type MeasurementBase, type MeasurementUnit, type MeasurementUnitFamily, MenuProject, type ModifierChoiceRow, type ModifierRow, type ModifiersBreakdown, type ModifiersTuple, NAFixedRates, NORTH_AMERICA, NonRevenueItemType, type NormalizedAddress, ORDER_STATE_ACTIONS, ORDER_STATE_EVENTS, ORDER_STATE_TOPIC, type OrderContext, type OrderLikeForAssignedUsers, type OrderLikeForContext, type OrderLikeForInCart, type OrderLikeForLegacyInference, type OrderLineItem, type OrderMutationData, type OrderPaymentMethod, OrderPlatform, type OrderRefund, type OrderReservationForContext, type OrderStateEventPayload, type OrderStateWritable, type OrderStatusDefinition, type OrderStatusValidationError, type OrderTaxSkip, type OrderWriteStrategy, OtherFixedRates, OutOfProvinceTaxes, OwnerType, PATH_MODES, PAYMENT_CHANNELS, PAYMENT_STATES, POS_VALID_INITIAL_STATES, type PathMode, type PaymentChannel, PaymentMethod, PaymentProcessor, type PaymentState, type PaymentStateDefinition, type PaymentTransitionPath, type PlanWindowInput, Platform, type PoolDrawing, PreviewImageMode, PricingLevel, PricingPlanEnum, PricingRegionEnum, ProcessorType, type ProductDiscountBucket, type ProductFeeBucket, ProductSalesChartStep, ProductSalesReportCompare, ProductStatus, ProductType, type Province, PublicationAvailability, type PublicationConfig, PublicationStatus, REGION_MAPPING, REPORT_NEGATE_PATHS, ReceiptSendChannel, ReceiptType, type RefundsBreakdown, ReservationStatus, ResidualPaymentMethod, ResidualStatus, type ResolveInputs, type ResolveShippingInput, type ResolveTemplateResult, type ResourceAvailability, ResourceAvailabilityState, type ResourceInWindow, type ResourcePresenceRow, SHIPPING_COUNTRIES, SHOPPER_CONSENT_SOURCES, SHOPPER_ERROR_CODES, SHOPPER_RETURN_DECLINE_REASON_MAX, SHOPPER_RETURN_METHODS, SHOPPER_RETURN_STATUSES, STANDARD_TAX_TYPE, STATE_SCHEMA, STRIPE_SUPPORTED_COUNTRIES, SYSTEM_FAMILIES, SYSTEM_FAMILY_IDS, SYSTEM_UNITS, SYSTEM_UNIT_IDS, SalesLineAction, SalesLineSourceArray, type SalesSummary, type SaveStateConfigFragmentParams, type SaveStateConfigFragmentResponse, type SettlementBreakdown, type SettlementBuckets, type SettlementCardSection, type SettlementCashSection, type SettlementCustomEntry, ShippingChannel, type ShippingDuration, ShippingNoOptionReason, type ShippingOptionRule, ShippingOptionType, type ShippingPlace, type ShippingPriceTier, type ShippingQuoteOption, ShippingRateType, type ShippingResolution, type ShippingTuple, ShippingZoneError, ShippingZoneKind, type ShippingZoneProblem, type ShippingZoneRule, type ShopperAddressInput, type ShopperCard, type ShopperConsentSource, type ShopperErrorCode, type ShopperIdentity, type ShopperNotificationChoices, type ShopperOrderDetail, type ShopperOrderItem, type ShopperOrderRow, type ShopperOrderStatus, type ShopperOrderTotals, type ShopperPaymentMethod, type ShopperProfile, type ShopperReturnMethod, type ShopperReturnRequestInput, type ShopperReturnRequestState, type ShopperReturnStatus, type ShopperSavedAddress, type ShopperScope, type ShopperStore, type ShopperStoreRef, type SplitPayment, type SplitPaymentPayment, type StaffSales, type StaffSalesEntry, type StateConfig, type StateConfigFragment, type StateDefinition, type StatePair, type StateSchema, type StateTransitionBlockedPayload, type StateTransitionCompletedPayload, StationStatus, type StockLine, type StockLineComponent, type StockReservationLink, type StoredStateConfig, StripeCurrencyCode, StripeStatus, TAX_EXCEPTION_REASON_MAX, type TaxBreakdown, type TaxBreakdownRateEntry, type TaxBreakdownSection, type TaxBreakdownSubtotal, type TaxException, TaxExceptionSource, type TaxRegistration, TaxRegistrationKind, TaxSource, TaxWarningCode, type TaxesTuple, TimePeriod, type TipEntry, type TipsBreakdown, type TipsTuple, TopMetericsSort, type TransitionBlockedBy, type TransitionConditionSet, type TransitionOrderStateParams, type TransitionOrderStateResponse, type TransitionPath, type TransitionRequest, type TransitionResult, UserTypes, type WeeklyHours, addAmounts, addressPlaceKeys, adyenLegalEntityRequiresStateOrProvince, adyenRequiresJobTitle, adyenStoreRequiresStateOrProvince, adyenSupportsTaxNumberAbsent, adyenTaxNumberFormat, amountToString, ancestorChain, applyAssignment, assertUnitSane, automaticTaxTableVersion, availableIn, baseFor, baseFulfillmentDefinitions, baseOf, basePaymentDefinitions, buildAutomaticTaxTable, buildAvailability, buildGrid, buildOrderContext, buildPosPresetConfig, buildResolvedConfig, calculatePercentage, canTransition, cardFromProcessorData, cheapestCompositeItem, cheapestCompositePrice, compositeItemCost, compositeItemUnavailable, compositeMakeable, compositeModifierMismatches, compositeReservationMismatches, compositeVariantInStock, conditionSummary, convertFixedFeeToLocalCurrency, createAmount, crossAxisRuleApplies, currentAssignees, deriveDisplayState, deriveFamilyCode, deriveUnitId, displayRuleMatchesPair, divideAmount, evaluateCondition, evaluateConditionSet, extendPrice, extendPriceFor, formatCurrency, formatInUnit, formatMinorUnitsToString, formatQuantity, formatShippingDuration, fromBase, fromMinorUnits, generateMongoID, getAvailableTransitions, getCashAmountDue, getCountriesByRegion, getCurrencyConfig, getCurrentISODate, getFinancialInvariantViolations, getGoodsPortion, getLineSubtotal, getMinorUnitMultiplier, getMinorUnits, getPaymentLegTotal, getPricingRegionFromCountry, getSettlementTotal, getTotalCollected, hasInCartFlag, hasSellableChoice, holdExpiresAt, inferStatesFromLegacyStatus, isAdyenRolloutCountry, isAffirmCountry, isAffirmPricePlan, isChoiceAvailableAtOutlet, isConditionOperator, isFulfillmentState, isInCart, isPaymentState, isSupportedCurrency, isSystemFamilyCode, isValidQuantity, isWhole, lineStockMoves, listCountries, listProvinces, listShippingCountries, mapToLegacyStatus, maxPrecisionFor, mergeFragment, modifiersSellable, multiplyAmount, normalizeAddress, normalizeCityKey, normalizeCountry, normalizeMongoIdString, normalizePostCode, normalizeProvince, normalizeShopperEmail, occupancyIn, orderAssignments, parseAmountToMinorUnits, parseCurrencyCode, parseStripeCurrencyCode, placeKey, planWindow, poolDemand, poolOf, poolShortfall, poolStockAt, postCodeMatchesProvince, presentAt, priceForTotal, provincesForPostCode, registrationPlacesByKind, removeFragment, resolveFamily, resolveModifiersForProduct, resolveShipping, resolveTemplate, resolveUnit, roundToPrecision, sameFamily, setOrderState, sha1Hex, shippingDuration, shipsToCountry, shopDayKey, shopDayRange, signReportForDisplay, slotsForWindow, stringifyMinorUnits, subtractAmounts, toBase, toMinorUnits, validateConfig, validateFragmentCompatibility, validateOrderStatuses, validateShippingZone, violatesFinancialInvariant, windowEndsAt, withinPresence };
2261
+ export { ADYEN_JOB_TITLE_ASSOCIATION_TYPES, ADYEN_LEGAL_ENTITY_STATE_PROVINCE_COUNTRIES, ADYEN_NO_TAX_NUMBER_ABSENT_COUNTRIES, ADYEN_ROLLOUT_COUNTRY_CODES, ADYEN_STORE_STATE_PROVINCE_COUNTRIES, ADYEN_TAX_NUMBER_FORMATS, ADYEN_TAX_NUMBER_MIN_LENGTH, AFFIRM_COUNTRY_CODES, AFFIRM_PRICE_PLANS, type AddressLike, type AdyenBnplSettings, type AdyenBnplSkippedStore, type AdyenBnplUpdateResult, type AffirmPricePlan, type Amount, type AssignUserChange, AttributeType, type AutomaticTaxPart, type AutomaticTaxRateRow, type AutomaticTaxRowStatus, type AutomaticTaxRuleRow, type AutomaticTaxTable, type AutomaticTaxTypeRow, type AvailabilityInput, type AvailabilitySlot, type AvailableTransition, BNPL_METHOD_STATUS, BNPL_SKIP_REASON, type BnplMethodStatus, type BnplSkipReason, type BookingOccupancy, BookingRatePeriod, type BookingResourceInput, BookingResourceKind, BookingResourceStatus, BookingRulesError, type BookingRulesInput, BookingType, type BusyWindow, CANADA_PROVINCES, CONDITION_OPERATORS, COUNTRY_CURRENCIES, CURRENCY_CONFIG, CUSTOMER_CONTACT_VERIFIED, type CartDiscountBucket, type CartFeeBucket, type CashDrawer, type CashRoundingTuple, type CategoryModifierRow, type CategoryRow, CompanyType, type CompositeAvailabilityRows, type CompositeMakeable, type CompositeMakeableRow, type CompositePriceItem, type CompositePricePart, type CompositeReservationOrder, type CompositeShelf, type CompositeStockPart, type Condition, type ConditionGroup, type ConditionOperator, type ConfigUpdatedPayload, type ConfigValidationError, type ConfigValidationResult, type ConfigValidationWarning, type CountryOption, type CrossAxisRequires, type CrossAxisRule, type CrossAxisTrigger, CurrencyCode, type CurrencyConfig, type CurrencyRate, CustomTableAvailability, CustomerPlatform, DEFAULT_CONFIG, DEFAULT_CROSS_AXIS_RULES, DEFAULT_DISPLAY_STATE_MAP, DEFAULT_HOLD_MINUTES, DEFAULT_RESOLVED_CONFIG, DEFAULT_UNIT_ID, type DeleteStateConfigFragmentParams, type DeleteStateConfigFragmentResponse, type DiscountsBreakdown, type DiscountsTuple, type DisplayStateResult, type DisplayStateRule, DualWriteStrategy, EUFixedRates, EUROPE, EVERYWHERE_KEY, EXPENSE_DEFAULT_CATEGORIES, EXPENSE_NAME_MAX_LENGTH, EXPENSE_PAYMENT_METHOD_PRESETS, type EndOfSessionReport, type ExpenseDefaultCategoryKey, ExtensionCategory, FINANCIAL_INVARIANTS, FULFILLMENT_STATES, type FailedCondition, type FeesBreakdown, FeesCustomBillingStatus, type FeesTuple, type FinancialInvariant, type FragmentParam, type FragmentValidationResult, type FulfillmentState, type FulfillmentStateDefinition, type FulfillmentTransitionPath, type GetAvailableTransitionsParams, type GetAvailableTransitionsResponse, type GetOrderDisplayStateParams, type GetOrderDisplayStateResponse, type GetOrderStateConfigParams, type GetOrderStateConfigResponse, type GetStateConfigFragmentParams, type GetStateConfigFragmentResponse, type GridSlot, HttpMethod, InventoryBaseActionEnum, type InventoryBaseActionType, InventorySpecificActionType, InvoiceStatus, LegacyWriteStrategy, LibraryItemType, type LineStockMove, MAX_PRECISION, type Measurable, type MeasurementBase, type MeasurementUnit, type MeasurementUnitFamily, MenuProject, type ModifierChoiceRow, type ModifierRow, type ModifiersBreakdown, type ModifiersTuple, NAFixedRates, NORTH_AMERICA, NonRevenueItemType, type NormalizedAddress, ORDER_STATE_ACTIONS, ORDER_STATE_EVENTS, ORDER_STATE_TOPIC, type OrderContext, type OrderLikeForAssignedUsers, type OrderLikeForContext, type OrderLikeForInCart, type OrderLikeForLegacyInference, type OrderLineItem, type OrderMutationData, type OrderPaymentMethod, OrderPlatform, type OrderRefund, type OrderReservationForContext, type OrderStateEventPayload, type OrderStateWritable, type OrderStatusDefinition, type OrderStatusValidationError, type OrderTaxSkip, type OrderWriteStrategy, OtherFixedRates, OutOfProvinceTaxes, OwnerType, PATH_MODES, PAYMENT_CHANNELS, PAYMENT_STATES, POS_VALID_INITIAL_STATES, type PathMode, type PaymentChannel, type PaymentLegLike, PaymentMethod, PaymentProcessor, type PaymentState, type PaymentStateDefinition, type PaymentTransitionPath, type PlanWindowInput, Platform, type PoolDrawing, PreviewImageMode, PricingLevel, PricingPlanEnum, PricingRegionEnum, ProcessorType, type ProductDiscountBucket, type ProductFeeBucket, ProductSalesChartStep, ProductSalesReportCompare, ProductStatus, ProductType, type Province, PublicationAvailability, type PublicationConfig, PublicationStatus, REGION_MAPPING, REPORT_NEGATE_PATHS, ReceiptSendChannel, ReceiptType, type RefundsBreakdown, ReservationStatus, ResidualPaymentMethod, ResidualStatus, type ResolveInputs, type ResolveShippingInput, type ResolveTemplateResult, type ResourceAvailability, ResourceAvailabilityState, type ResourceInWindow, type ResourcePresenceRow, SHIPPING_COUNTRIES, SHOPPER_CONSENT_SOURCES, SHOPPER_ERROR_CODES, SHOPPER_RETURN_DECLINE_REASON_MAX, SHOPPER_RETURN_METHODS, SHOPPER_RETURN_STATUSES, STANDARD_TAX_TYPE, STATE_SCHEMA, STRIPE_SUPPORTED_COUNTRIES, SYSTEM_FAMILIES, SYSTEM_FAMILY_IDS, SYSTEM_UNITS, SYSTEM_UNIT_IDS, SalesLineAction, SalesLineSourceArray, type SalesSummary, type SaveStateConfigFragmentParams, type SaveStateConfigFragmentResponse, type SettlementBreakdown, type SettlementBuckets, type SettlementCardSection, type SettlementCashSection, type SettlementCustomEntry, ShippingChannel, type ShippingDuration, ShippingNoOptionReason, type ShippingOptionRule, ShippingOptionType, type ShippingPlace, type ShippingPriceTier, type ShippingQuoteOption, ShippingRateType, type ShippingResolution, type ShippingTuple, ShippingZoneError, ShippingZoneKind, type ShippingZoneProblem, type ShippingZoneRule, type ShopperAddressInput, type ShopperCard, type ShopperConsentSource, type ShopperErrorCode, type ShopperIdentity, type ShopperNotificationChoices, type ShopperOrderDetail, type ShopperOrderItem, type ShopperOrderRow, type ShopperOrderStatus, type ShopperOrderTotals, type ShopperPayment, type ShopperPaymentKind, type ShopperPaymentMethod, type ShopperProfile, type ShopperReturnMethod, type ShopperReturnRequestInput, type ShopperReturnRequestState, type ShopperReturnStatus, type ShopperSavedAddress, type ShopperScope, type ShopperStore, type ShopperStoreRef, type SplitPayment, type SplitPaymentPayment, type StaffSales, type StaffSalesEntry, type StateConfig, type StateConfigFragment, type StateDefinition, type StatePair, type StateSchema, type StateTransitionBlockedPayload, type StateTransitionCompletedPayload, StationStatus, type StockLine, type StockLineComponent, type StockReservationLink, type StoredStateConfig, StripeCurrencyCode, StripeStatus, TAX_EXCEPTION_REASON_MAX, type TaxBreakdown, type TaxBreakdownRateEntry, type TaxBreakdownSection, type TaxBreakdownSubtotal, type TaxException, TaxExceptionSource, type TaxRegistration, TaxRegistrationKind, TaxSource, TaxWarningCode, type TaxesTuple, TimePeriod, type TipEntry, type TipsBreakdown, type TipsTuple, TopMetericsSort, type TransitionBlockedBy, type TransitionConditionSet, type TransitionOrderStateParams, type TransitionOrderStateResponse, type TransitionPath, type TransitionRequest, type TransitionResult, UserTypes, type WeeklyHours, addAmounts, addressPlaceKeys, adyenLegalEntityRequiresStateOrProvince, adyenRequiresJobTitle, adyenStoreRequiresStateOrProvince, adyenSupportsTaxNumberAbsent, adyenTaxNumberFormat, amountToString, ancestorChain, applyAssignment, assertUnitSane, automaticTaxTableVersion, availableIn, baseFor, baseFulfillmentDefinitions, baseOf, basePaymentDefinitions, buildAutomaticTaxTable, buildAvailability, buildGrid, buildOrderContext, buildPosPresetConfig, buildResolvedConfig, calculatePercentage, canTransition, cardFromProcessorData, cheapestCompositeItem, cheapestCompositePrice, compositeItemCost, compositeItemUnavailable, compositeMakeable, compositeModifierMismatches, compositeReservationMismatches, compositeVariantInStock, conditionSummary, convertFixedFeeToLocalCurrency, createAmount, crossAxisRuleApplies, currentAssignees, deriveDisplayState, deriveFamilyCode, deriveUnitId, displayRuleMatchesPair, divideAmount, emailKey, evaluateCondition, evaluateConditionSet, extendPrice, extendPriceFor, formatCurrency, formatInUnit, formatMinorUnitsToString, formatQuantity, formatShippingDuration, fromBase, fromMinorUnits, generateMongoID, getAvailableTransitions, getCashAmountDue, getCountriesByRegion, getCurrencyConfig, getCurrentISODate, getFinancialInvariantViolations, getGoodsPortion, getLineSubtotal, getMinorUnitMultiplier, getMinorUnits, getPaymentLegTotal, getPricingRegionFromCountry, getSettlementTotal, getTotalCollected, hasInCartFlag, hasSellableChoice, holdExpiresAt, inferStatesFromLegacyStatus, isAdyenRolloutCountry, isAffirmCountry, isAffirmPricePlan, isChoiceAvailableAtOutlet, isConditionOperator, isFulfillmentState, isInCart, isPaymentState, isSupportedCurrency, isSystemFamilyCode, isValidQuantity, isWhole, lineStockMoves, listCountries, listProvinces, listShippingCountries, mapToLegacyStatus, maxPrecisionFor, mergeFragment, modifiersSellable, multiplyAmount, normalizeAddress, normalizeCityKey, normalizeCountry, normalizeMongoIdString, normalizePostCode, normalizeProvince, normalizeShopperEmail, occupancyIn, orderAssignments, parseAmountToMinorUnits, parseCurrencyCode, parseStripeCurrencyCode, phoneKey, placeKey, planWindow, poolDemand, poolOf, poolShortfall, poolStockAt, postCodeMatchesProvince, presentAt, priceForTotal, provincesForPostCode, registrationPlacesByKind, removeFragment, resolveFamily, resolveModifiersForProduct, resolveShipping, resolveTemplate, resolveUnit, roundToPrecision, sameFamily, setOrderState, sha1Hex, shippingDuration, shipsToCountry, shopDayKey, shopDayRange, shopperPaymentsOf, signReportForDisplay, slotsForWindow, stringifyMinorUnits, subtractAmounts, toBase, toMinorUnits, validateConfig, validateFragmentCompatibility, validateOrderStatuses, validateShippingZone, verifiedContactChange, violatesFinancialInvariant, windowEndsAt, withinPresence };
package/dist/index.js CHANGED
@@ -40,6 +40,7 @@ __export(index_exports, {
40
40
  CONDITION_OPERATORS: () => CONDITION_OPERATORS,
41
41
  COUNTRY_CURRENCIES: () => COUNTRY_CURRENCIES,
42
42
  CURRENCY_CONFIG: () => CURRENCY_CONFIG,
43
+ CUSTOMER_CONTACT_VERIFIED: () => CUSTOMER_CONTACT_VERIFIED,
43
44
  CompanyType: () => CompanyType,
44
45
  CurrencyCode: () => CurrencyCode,
45
46
  CustomTableAvailability: () => CustomTableAvailability,
@@ -181,6 +182,7 @@ __export(index_exports, {
181
182
  deriveUnitId: () => deriveUnitId,
182
183
  displayRuleMatchesPair: () => displayRuleMatchesPair,
183
184
  divideAmount: () => divideAmount,
185
+ emailKey: () => emailKey,
184
186
  evaluateCondition: () => evaluateCondition,
185
187
  evaluateConditionSet: () => evaluateConditionSet,
186
188
  extendPrice: () => extendPrice,
@@ -244,6 +246,7 @@ __export(index_exports, {
244
246
  parseAmountToMinorUnits: () => parseAmountToMinorUnits,
245
247
  parseCurrencyCode: () => parseCurrencyCode,
246
248
  parseStripeCurrencyCode: () => parseStripeCurrencyCode,
249
+ phoneKey: () => phoneKey,
247
250
  placeKey: () => placeKey,
248
251
  planWindow: () => planWindow,
249
252
  poolDemand: () => poolDemand,
@@ -269,6 +272,7 @@ __export(index_exports, {
269
272
  shipsToCountry: () => shipsToCountry,
270
273
  shopDayKey: () => shopDayKey,
271
274
  shopDayRange: () => shopDayRange,
275
+ shopperPaymentsOf: () => shopperPaymentsOf,
272
276
  signReportForDisplay: () => signReportForDisplay,
273
277
  slotsForWindow: () => slotsForWindow,
274
278
  stringifyMinorUnits: () => stringifyMinorUnits,
@@ -279,6 +283,7 @@ __export(index_exports, {
279
283
  validateFragmentCompatibility: () => validateFragmentCompatibility,
280
284
  validateOrderStatuses: () => validateOrderStatuses,
281
285
  validateShippingZone: () => validateShippingZone,
286
+ verifiedContactChange: () => verifiedContactChange,
282
287
  violatesFinancialInvariant: () => violatesFinancialInvariant,
283
288
  windowEndsAt: () => windowEndsAt,
284
289
  withinPresence: () => withinPresence
@@ -2092,6 +2097,31 @@ function lineStockMoves(item, quantity, reservations = []) {
2092
2097
  });
2093
2098
  }
2094
2099
 
2100
+ // utils/contact-keys.util.ts
2101
+ function emailKey(email) {
2102
+ const key = email?.trim().toLowerCase();
2103
+ return key && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(key) ? key : null;
2104
+ }
2105
+ function phoneKey(phone) {
2106
+ const raw = phone?.trim();
2107
+ if (!raw) return null;
2108
+ const digits = raw.replace(/\D/g, "");
2109
+ if (raw.startsWith("+")) return digits.length >= 8 && digits.length <= 15 ? `+${digits}` : null;
2110
+ if (digits.length === 10) return `+1${digits}`;
2111
+ if (digits.length === 11 && digits.startsWith("1")) return `+${digits}`;
2112
+ return null;
2113
+ }
2114
+ var CUSTOMER_CONTACT_VERIFIED = "CUSTOMER_CONTACT_VERIFIED";
2115
+ function sameContact(a, b, key) {
2116
+ return (key(a) ?? a?.trim().toLowerCase() ?? "") === (key(b) ?? b?.trim().toLowerCase() ?? "");
2117
+ }
2118
+ function verifiedContactChange(existing, change) {
2119
+ if (!existing.verifiedShopperAt) return null;
2120
+ if (change.email !== void 0 && !sameContact(existing.email, change.email, emailKey)) return "email";
2121
+ if (change.phone !== void 0 && !sameContact(existing.phone, change.phone, phoneKey)) return "phone";
2122
+ return null;
2123
+ }
2124
+
2095
2125
  // units/family-code.ts
2096
2126
  var MAX_SLUG_LENGTH = 32;
2097
2127
  var FALLBACK_SLUG = "family";
@@ -2134,6 +2164,7 @@ var FULFILLMENT_STATES = [
2134
2164
  "in_progress",
2135
2165
  "fulfilled",
2136
2166
  "partially_fulfilled",
2167
+ "return_pending",
2137
2168
  "returned",
2138
2169
  "partially_returned",
2139
2170
  "cancelled"
@@ -2159,10 +2190,7 @@ var CONDITION_OPERATORS = [
2159
2190
  function isConditionOperator(value) {
2160
2191
  return CONDITION_OPERATORS.includes(value);
2161
2192
  }
2162
- var PATH_MODES = [
2163
- "strict",
2164
- "permissive"
2165
- ];
2193
+ var PATH_MODES = ["strict", "permissive"];
2166
2194
 
2167
2195
  // order-state-machine/state-schema.ts
2168
2196
  var PAYMENT_DEFS = [
@@ -2183,6 +2211,9 @@ var FULFILLMENT_DEFS = [
2183
2211
  { id: "in_progress", label: "In Progress", terminal: false },
2184
2212
  { id: "fulfilled", label: "Fulfilled", terminal: true },
2185
2213
  { id: "partially_fulfilled", label: "Partially Fulfilled", terminal: false },
2214
+ // The store accepted the shopper's return request: the goods are on their way back, no money has moved yet.
2215
+ // The refund lands `partially_returned` / `returned` as it does from `fulfilled`.
2216
+ { id: "return_pending", label: "Return Accepted", terminal: false },
2186
2217
  { id: "returned", label: "Returned", terminal: true },
2187
2218
  { id: "partially_returned", label: "Partially Returned", terminal: false },
2188
2219
  { id: "cancelled", label: "Cancelled", terminal: true }
@@ -2212,6 +2243,8 @@ var STATE_SCHEMA = Object.freeze({
2212
2243
  var REFUND_ALLOWED_FULFILLMENT = /* @__PURE__ */ new Set(["fulfilled", "returned", "partially_returned", "cancelled"]);
2213
2244
  var PAYMENT_COLLECTION_ORDER = ["unpaid", "partially_paid", "paid"];
2214
2245
  var UNRETURNED_MONEY_STATES = /* @__PURE__ */ new Set(["partially_paid", "paid", "partially_refunded"]);
2246
+ var RETURN_FROM_FULFILLMENT = /* @__PURE__ */ new Set(["fulfilled", "partially_fulfilled", "partially_returned"]);
2247
+ var RETURN_PENDING_PAYMENTS = /* @__PURE__ */ new Set(["paid", "partially_refunded"]);
2215
2248
  var REFUNDED_FULFILLMENT_LANDINGS = /* @__PURE__ */ new Set(["returned", "cancelled"]);
2216
2249
  var FINANCIAL_INVARIANTS = [
2217
2250
  {
@@ -2259,6 +2292,11 @@ var FINANCIAL_INVARIANTS = [
2259
2292
  description: "A voided order exists only at cancelled fulfillment: a voided order cannot re-enter fulfillment, and a voided \xD7 non-cancelled pair cannot be materialized from nothing (complements no-leave-voided, which only freezes the payment axis). Moves INTO voided from a live payment state are the void flow\u2019s concern, not this rule\u2019s",
2260
2293
  check: (from, to) => (from === null || from.payment === "voided") && to.payment === "voided" && to.fulfillment !== "cancelled"
2261
2294
  },
2295
+ {
2296
+ id: "return-pending-needs-goods-out",
2297
+ description: "Fulfillment enters return_pending (return accepted) only from fulfilled, partially_fulfilled or partially_returned, and holds it only while payment is paid or partially_refunded \u2014 goods must have gone out and money must still be held",
2298
+ check: (from, to) => to.fulfillment === "return_pending" && (!RETURN_PENDING_PAYMENTS.has(to.payment) || from?.fulfillment !== "return_pending" && !(from && RETURN_FROM_FULFILLMENT.has(from.fulfillment)))
2299
+ },
2262
2300
  {
2263
2301
  id: "no-reopen-refunded-fulfillment",
2264
2302
  description: "A fully refunded order cannot re-enter fulfillment \u2014 it may only relabel between its canonical landings, returned and cancelled (complements no-leave-refunded, which only freezes the payment axis)",
@@ -2350,7 +2388,9 @@ var DISPLAY_LABEL_OVERRIDES = {
2350
2388
  "paid|on_hold": "Parked - Paid",
2351
2389
  "paid|fulfilled": "Completed",
2352
2390
  "partially_refunded|fulfilled": "Partially Refunded",
2353
- "partially_refunded|partially_returned": "Partially Refunded"
2391
+ "partially_refunded|partially_returned": "Partially Refunded",
2392
+ "paid|return_pending": "Return Accepted",
2393
+ "partially_refunded|return_pending": "Return Accepted"
2354
2394
  };
2355
2395
  var TERMINAL_LABEL_OVERRIDES = {
2356
2396
  voided: "Cancelled"
@@ -2492,6 +2532,7 @@ function buildOrderContext(order, extras) {
2492
2532
  }
2493
2533
 
2494
2534
  // order-state-machine/display-state.ts
2535
+ var ATOMS_ADDED_AFTER_SNAPSHOT = /* @__PURE__ */ new Set(["return_pending"]);
2495
2536
  function atomLabel(atom, defs) {
2496
2537
  return defs.find((d) => d.id === atom)?.label ?? atom;
2497
2538
  }
@@ -2505,6 +2546,10 @@ function deriveDisplayState(payment, fulfillment, config) {
2505
2546
  return { label: rule.label, color: rule.color, icon: rule.icon };
2506
2547
  }
2507
2548
  }
2549
+ if (ATOMS_ADDED_AFTER_SNAPSHOT.has(fulfillment)) {
2550
+ const fallback = DEFAULT_DISPLAY_STATE_MAP.find((rule) => displayRuleMatchesPair(rule, payment, fulfillment));
2551
+ if (fallback) return { label: fallback.label, color: fallback.color, icon: fallback.icon };
2552
+ }
2508
2553
  return {
2509
2554
  label: `${atomLabel(payment, STATE_SCHEMA.paymentStates)} / ${atomLabel(fulfillment, STATE_SCHEMA.fulfillmentStates)}`
2510
2555
  };
@@ -4565,12 +4610,38 @@ function cardFromProcessorData(processorData) {
4565
4610
  const text = (...keys) => keys.map((key) => fields.get(key)).find((value) => typeof value === "string" && !!value.trim());
4566
4611
  const brand = text("Brand", "brand")?.trim();
4567
4612
  const digits = text("Card Number", "card", "card_number")?.replace(/\D/g, "");
4613
+ const issuer = text("Issuer", "issuer")?.trim();
4568
4614
  return {
4569
4615
  ...brand ? { cardBrand: brand.charAt(0).toUpperCase() + brand.slice(1) } : {},
4570
- ...digits && digits.length >= 4 ? { cardLastFour: digits.slice(-4) } : {}
4616
+ ...digits && digits.length >= 4 ? { cardLastFour: digits.slice(-4) } : {},
4617
+ ...issuer ? { cardIssuer: issuer } : {}
4571
4618
  };
4572
4619
  }
4573
4620
 
4621
+ // shopper/payments.ts
4622
+ var CARD_TYPES = /* @__PURE__ */ new Set(["card", "terminal", "taptopay", "moto", "cloud", "bluetooth"]);
4623
+ function kindOf(paymentType) {
4624
+ if (paymentType === "cash") return "cash";
4625
+ if (paymentType === "redeem") return "gift_card";
4626
+ if (paymentType === "pay_later") return "pay_later";
4627
+ if (CARD_TYPES.has(paymentType)) return "card";
4628
+ return "other";
4629
+ }
4630
+ function shopperPaymentsOf(legs) {
4631
+ return (legs ?? []).map((leg) => {
4632
+ const type = (leg.paymentType ?? "").trim();
4633
+ const kind = kindOf(type.toLowerCase());
4634
+ const card = kind === "card" ? cardFromProcessorData(leg.emv) : {};
4635
+ return {
4636
+ kind,
4637
+ // Cards: the issuer's name, else the brand. Other tenders the store named itself keep that name.
4638
+ name: kind === "card" ? card.cardIssuer ?? card.cardBrand ?? null : kind === "other" ? type || null : null,
4639
+ lastFour: card.cardLastFour ?? null,
4640
+ amount: (leg.amount ?? 0) + (leg.tip?.amount ?? 0)
4641
+ };
4642
+ });
4643
+ }
4644
+
4574
4645
  // constants/adyen.constants.ts
4575
4646
  var ADYEN_ROLLOUT_COUNTRY_CODES = /* @__PURE__ */ new Set(["CA"]);
4576
4647
  function isAdyenRolloutCountry(alpha2) {
@@ -4687,6 +4758,7 @@ var EXPENSE_DEFAULT_CATEGORIES = [
4687
4758
  CONDITION_OPERATORS,
4688
4759
  COUNTRY_CURRENCIES,
4689
4760
  CURRENCY_CONFIG,
4761
+ CUSTOMER_CONTACT_VERIFIED,
4690
4762
  CompanyType,
4691
4763
  CurrencyCode,
4692
4764
  CustomTableAvailability,
@@ -4828,6 +4900,7 @@ var EXPENSE_DEFAULT_CATEGORIES = [
4828
4900
  deriveUnitId,
4829
4901
  displayRuleMatchesPair,
4830
4902
  divideAmount,
4903
+ emailKey,
4831
4904
  evaluateCondition,
4832
4905
  evaluateConditionSet,
4833
4906
  extendPrice,
@@ -4891,6 +4964,7 @@ var EXPENSE_DEFAULT_CATEGORIES = [
4891
4964
  parseAmountToMinorUnits,
4892
4965
  parseCurrencyCode,
4893
4966
  parseStripeCurrencyCode,
4967
+ phoneKey,
4894
4968
  placeKey,
4895
4969
  planWindow,
4896
4970
  poolDemand,
@@ -4916,6 +4990,7 @@ var EXPENSE_DEFAULT_CATEGORIES = [
4916
4990
  shipsToCountry,
4917
4991
  shopDayKey,
4918
4992
  shopDayRange,
4993
+ shopperPaymentsOf,
4919
4994
  signReportForDisplay,
4920
4995
  slotsForWindow,
4921
4996
  stringifyMinorUnits,
@@ -4926,6 +5001,7 @@ var EXPENSE_DEFAULT_CATEGORIES = [
4926
5001
  validateFragmentCompatibility,
4927
5002
  validateOrderStatuses,
4928
5003
  validateShippingZone,
5004
+ verifiedContactChange,
4929
5005
  violatesFinancialInvariant,
4930
5006
  windowEndsAt,
4931
5007
  withinPresence