@fire-spark/core 0.3.4 → 0.4.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/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { PaymentAdapter, PaymentCollectAt, PaymentContext, PaymentResult, PaymentStorage, PaymentUI, isRealPaymentMethod } from "@fire-spark/payments";
1
+ import { PaymentAdapter, PaymentCollectAt, PaymentContext, PaymentResult, PaymentStorage, PaymentUI, isRealPaymentMethod, orderPaymentRedeems } from "@fire-spark/payments";
2
2
  import { AndConditions, CheckoutMode, CheckoutResolved, CmsBlock, Condition, Customer, CustomerIdentifyInput, CustomerRegisterInput, CustomerUpdateInput, Fulfillment, FulfillmentListInput, GroupDisplayType, KioskDeviceConfig, KioskDeviceOverrides, KioskHealthBatchInput, KioskHealthBatchResult, KioskHeartbeatInput, KioskHeartbeatResult, KioskRealtimeToken, MatchResult, MatchableRule, Menu, Menu as Menu$1, MenuLookup, MenuLookup as MenuLookup$1, MerchantPayment, ModifierControlType, ModifierGroup, OrConditions, Order as Order$1, Order as Order$2, OrderFulfillment, OrderInsertInput, OrderLine, OrderListInput, OrderRecordPaymentInput, OrderRedeem, OrderRedemptionStep, OrderReorderInput, OrderTotals, OrderUpdateInput, OrderValidateInput, OrderValidateOutput, PaymentCollectAt as PaymentCollectAt$1, PaymentIntentPutInput, PaymentMethod, PaymentProvider, PaymentTender, PaymentTenderInput, PlaceOrderResult, PosCatalog, PosHealthBatchInput, PosHealthBatchResult, PosHeartbeatInput, PosHeartbeatResult, PosKioskOrder, PosKioskSettleInput, PosKioskSettleResult, PosOrderInput, PosOrderResult, PricingModifier, Product, Product as Product$1, Recommendation, RecurringDateCronResult, RecurringDateCronValues, RulesEngineOrderLine, RulesEngineParams, RulesEngineRuntime, Schedule, SdkLogContext, SdkLogErrorInfo, SdkLogLevel, SdkLogOptions, Store, StoreGetInput, StoreListInput, StoreNearbyInput, StorefrontAvailability, StorefrontMenu, StorefrontMenuScope, StorefrontMenuStreamOptions, StorefrontPaymentsListInput, StorefrontPreferences, TenderRefundInput, TenderReplaceInput, TenderVoidInput, Variant, VariantGroup } from "@fire-spark/types";
3
3
  import { Big } from "big.js";
4
4
  //#region src/productCustomization/types.d.ts
@@ -408,7 +408,7 @@ type ApplyRedeemInput = {
408
408
  reward_id: string;
409
409
  /**
410
410
  * Reward units to redeem (integer ≥ 1). With `payment_id` it is
411
- * informational: `amount` and `points` already cover every unit.
411
+ * informational: `amount` already covers every unit.
412
412
  */
413
413
  quantity: number;
414
414
  /** 0–1, compounded per unit over the remaining value. */
@@ -423,19 +423,17 @@ type ApplyRedeemInput = {
423
423
  /** Root line to discount; omit to discount the whole order (prorated). */
424
424
  line_uid?: string;
425
425
  /**
426
- * Points / balance: the merchant `REDEMPTION` payment that pays `amount`
427
- * (a tender, not a discount). Requires `amount` and `points`. Redeems
428
- * with the same `payment_id` share one tender (`details.rewards[]`).
426
+ * Reward paid as a tender (voucher, balance…, not a discount): the
427
+ * merchant `REDEMPTION` payment that pays `amount`. Requires `amount`.
428
+ * Redeems with the same `payment_id` share one tender
429
+ * (`details.rewards[]`).
429
430
  */
430
431
  payment_id?: string;
431
432
  /**
432
- * Total money the points cover for the whole entry (all `quantity`
433
+ * Total money the reward covers for the whole entry (all `quantity`
433
434
  * units, not per unit); trimmed to total − tip − delivery.
434
435
  */
435
436
  amount?: number;
436
- /** Total points spent for the whole entry (not per unit). */
437
- points?: number;
438
- program?: string;
439
437
  /** Provider of the REDEMPTION payment (default `firespark`). */
440
438
  provider?: PaymentProvider;
441
439
  /** ISO datetime with offset; validation fails once it has passed. */
@@ -517,9 +515,9 @@ declare class Order {
517
515
  emptyOrder(): void;
518
516
  /**
519
517
  * Appends a redeem to `line_uid` (root line) or to the order. Steps keep
520
- * the order in which redeems were applied. With `payment_id` (points /
521
- * balance) it is not a discount: `amount` and `points` are totals of the
522
- * whole entry (every unit, not per unit) and `quantity` is informational.
518
+ * the order in which redeems were applied. With `payment_id` (voucher,
519
+ * balance…) it is not a discount: `amount` is the total of the whole
520
+ * entry (every unit, not per unit) and `quantity` is informational.
523
521
  * Every redeem with the same `payment_id` is paid by one REDEMPTION
524
522
  * tender whose `details.rewards[]` lists them; their summed amount is
525
523
  * capped at total − tip − delivery (D15, D18, D19).
@@ -528,9 +526,8 @@ declare class Order {
528
526
  /**
529
527
  * Removes `quantity` units of `reward_id` from `line_uid` or the order,
530
528
  * latest applied first. Removing more units than applied clears them all
531
- * (and the REDEMPTION tender of a points / balance redeem). A points /
532
- * balance entry that keeps some units keeps the same share of its
533
- * `amount` and `points`.
529
+ * (and the REDEMPTION tender of a payment redeem). A payment redeem that
530
+ * keeps some units keeps the same share of its `amount`.
534
531
  */
535
532
  removeRedeem(input: RemoveRedeemInput): void;
536
533
  private rememberLogScope;
@@ -544,7 +541,7 @@ declare class Order {
544
541
  cancelOrder(): Promise<void>;
545
542
  /**
546
543
  * Reopens this placed, unpaid order: the server voids every payment
547
- * (REDEMPTION points released), cancels it as `VOIDED` and opens a new
544
+ * (REDEMPTION rewards released), cancels it as `VOIDED` and opens a new
548
545
  * `OPEN` order with the same content. This instance is closed afterwards;
549
546
  * replace it with the returned `Order` (same HTTP options and listener).
550
547
  *
@@ -556,8 +553,9 @@ declare class Order {
556
553
  refundOrder(): Promise<void>;
557
554
  validateOrder(): Promise<void>;
558
555
  /**
559
- * Tenders of the next intent: real ones plus one per payment redeem.
560
- * When the payment redeems cover the total, only REDEMPTION tenders.
556
+ * Tenders of the next intent: real ones plus one per payment redeem
557
+ * `payment_id`, on the order or on a line. When the payment redeems
558
+ * cover the total, only REDEMPTION tenders.
561
559
  */
562
560
  getTenders(payment?: PlaceOrderInput["payment"]): PaymentTenderInput[];
563
561
  /**
@@ -855,7 +853,7 @@ declare const listMenusStream: (scope?: StorefrontMenuScope, options?: ListMenus
855
853
  //#endregion
856
854
  //#region src/services/payments.d.ts
857
855
  type ListPaymentsOptions = ServiceHttpOptions & {
858
- /** Keep `REDEMPTION` payments (points / balance) for redeem flows. */
856
+ /** Keep `REDEMPTION` payments (vouchers, balance…) for redeem flows. */
859
857
  includeRedemptions?: boolean;
860
858
  };
861
859
  /**
@@ -1318,4 +1316,4 @@ declare const validateCardholderName: (value: string) => CardholderNameError | n
1318
1316
  */
1319
1317
  declare const cardPreviewGroups: (value: string) => CardPreviewSlot[][];
1320
1318
  //#endregion
1321
- export { type ApplyRedeemInput, type AuthConfigureOptions, CARD_BRANDS, type CardBrand, type CardBrandSpec, type CardCvcError, type CardExpiry, type CardExpiryError, type CardNumberError, type CardPreviewSlot, type CardholderNameError, type CreateOrderOptions, type CreateSessionOptions, type CustomizationPath, type CustomizationSession, DEFAULT_RECOMMENDATION_TYPES, type ExchangeOptions, type FailedCharge, type FlatMenuCategory, type GroupDisplayType, type IdBuilder, type ListMenusStreamOptions, type ListPaymentsOptions, type Menu, type MenuCategoryNode, type MenuLookup, type MilestoneSteps, type MilestoneTrackItem, type ModifierControlType, type ModifierCtx, type ModifierGroupCtx, type NestedMenuCategory, Order, type OrderCustomerSource, type OrderDraft, type OrderIssue, type OrderIssueCode, type OrderLineDiff, type OrderLineIssue, type OrderLineIssueCode, type OrderScope, OrderSyncPendingError, OrderValidationError, type OrderValidationResult, type PayIntentOptions, type PayIntentResult, type PayOptions, type PaymentCardBrand, type PaymentProgressEvent, type PaymentProgressListener, type PaymentRunOptions, type PaymentSessionOptions, type PricingModifier, type Product, type ProductCtx, type QuantitiesByPath, type RecommendationType, RecurringDateCron, type RemoveRedeemInput, type ReorderOrderOptions, type ResetOptions, type ReversalOutcome, type ReverseAllOptions, RulesEngine, type ScheduleWindow, type SelectionStatus, type SelectionsByPath, type SerializedError, type ServiceHttpOptions, type SimpleTenderPayment, type Snapshot, type StorefrontAccessToken, type StorefrontErrorDetails, StorefrontHttpError, type TrackWorkflow, type ValidateOptions, type ValidateOrderAgainstMenuInput, type Variant, type VariantGroup, type VariantGroupCtx, type VariantOptionCtx, type VariantSelection, type VerifyWebhookSignatureInput, type VisitedState, addLines, auth, buildCustomerSnapshot, cardBrandSpec, cardDigits, cardNumberGaps, cardNumberMaxLength, cardPreviewGroups, caretAfterDigits, collectOrderLineDiffs, computeStartingPrice, countCartProducts, coveredAmount, createSession, currentNodes, cvcMaxLength, defaultConditionError, detectCardBrand, flattenMenuCategories, flushLogs, formatCardNumber, formatCvc, formatExpiry, fromOrderLines, genId, genOrderId, getLogContext, getScheduleWindow, indexMenu, isCardNumberComplete, isCardNumberDefinitelyInvalid, isCheckoutFieldFilled, isCvcComplete, isDeviceCharged, isDeviceNotLinked, isExpiryComplete, isKioskUnauthorized, isMilestoneStepDone, isOnSchedule, isOrderValidationError, isPosDeviceNotLinked, isPosUnauthorized, isRealPaymentMethod, isStorefrontNotFound, isVariantBase, listMenusStream, localizePosError, log, logError, luhnCheck, matchAbsoluteDateOperator, matchBooleanOperator, matchCurrencyOperator, matchEnumOperator, matchNumberOperator, matchRecurringDateOperator, matchRelativeDateOperator, matchStringOperator, milestoneSteps, milestoneTrack, nestMenuCategories, normalizeCardholderName, parseExpiry, paymentMatchesClientConditions, recomputeRedemptions, recomputeTotals, redemptionCap, remainingAmount, removeLine, replaceLine, resolveCheckout, reversePayment, runPaymentAttempt, selectablePayments, serializeError, services, setLineQuantity, storefrontJson, stripRedemptionLines, toOrderLines, toPaymentCardBrand, validateCardNumber, validateCardholderName, validateCvc, validateExpiry, validateOrderAgainstMenu, verifyWebhookSignature, visitedStates };
1319
+ export { type ApplyRedeemInput, type AuthConfigureOptions, CARD_BRANDS, type CardBrand, type CardBrandSpec, type CardCvcError, type CardExpiry, type CardExpiryError, type CardNumberError, type CardPreviewSlot, type CardholderNameError, type CreateOrderOptions, type CreateSessionOptions, type CustomizationPath, type CustomizationSession, DEFAULT_RECOMMENDATION_TYPES, type ExchangeOptions, type FailedCharge, type FlatMenuCategory, type GroupDisplayType, type IdBuilder, type ListMenusStreamOptions, type ListPaymentsOptions, type Menu, type MenuCategoryNode, type MenuLookup, type MilestoneSteps, type MilestoneTrackItem, type ModifierControlType, type ModifierCtx, type ModifierGroupCtx, type NestedMenuCategory, Order, type OrderCustomerSource, type OrderDraft, type OrderIssue, type OrderIssueCode, type OrderLineDiff, type OrderLineIssue, type OrderLineIssueCode, type OrderScope, OrderSyncPendingError, OrderValidationError, type OrderValidationResult, type PayIntentOptions, type PayIntentResult, type PayOptions, type PaymentCardBrand, type PaymentProgressEvent, type PaymentProgressListener, type PaymentRunOptions, type PaymentSessionOptions, type PricingModifier, type Product, type ProductCtx, type QuantitiesByPath, type RecommendationType, RecurringDateCron, type RemoveRedeemInput, type ReorderOrderOptions, type ResetOptions, type ReversalOutcome, type ReverseAllOptions, RulesEngine, type ScheduleWindow, type SelectionStatus, type SelectionsByPath, type SerializedError, type ServiceHttpOptions, type SimpleTenderPayment, type Snapshot, type StorefrontAccessToken, type StorefrontErrorDetails, StorefrontHttpError, type TrackWorkflow, type ValidateOptions, type ValidateOrderAgainstMenuInput, type Variant, type VariantGroup, type VariantGroupCtx, type VariantOptionCtx, type VariantSelection, type VerifyWebhookSignatureInput, type VisitedState, addLines, auth, buildCustomerSnapshot, cardBrandSpec, cardDigits, cardNumberGaps, cardNumberMaxLength, cardPreviewGroups, caretAfterDigits, collectOrderLineDiffs, computeStartingPrice, countCartProducts, coveredAmount, createSession, currentNodes, cvcMaxLength, defaultConditionError, detectCardBrand, flattenMenuCategories, flushLogs, formatCardNumber, formatCvc, formatExpiry, fromOrderLines, genId, genOrderId, getLogContext, getScheduleWindow, indexMenu, isCardNumberComplete, isCardNumberDefinitelyInvalid, isCheckoutFieldFilled, isCvcComplete, isDeviceCharged, isDeviceNotLinked, isExpiryComplete, isKioskUnauthorized, isMilestoneStepDone, isOnSchedule, isOrderValidationError, isPosDeviceNotLinked, isPosUnauthorized, isRealPaymentMethod, isStorefrontNotFound, isVariantBase, listMenusStream, localizePosError, log, logError, luhnCheck, matchAbsoluteDateOperator, matchBooleanOperator, matchCurrencyOperator, matchEnumOperator, matchNumberOperator, matchRecurringDateOperator, matchRelativeDateOperator, matchStringOperator, milestoneSteps, milestoneTrack, nestMenuCategories, normalizeCardholderName, orderPaymentRedeems, parseExpiry, paymentMatchesClientConditions, recomputeRedemptions, recomputeTotals, redemptionCap, remainingAmount, removeLine, replaceLine, resolveCheckout, reversePayment, runPaymentAttempt, selectablePayments, serializeError, services, setLineQuantity, storefrontJson, stripRedemptionLines, toOrderLines, toPaymentCardBrand, validateCardNumber, validateCardholderName, validateCvc, validateExpiry, validateOrderAgainstMenu, verifyWebhookSignature, visitedStates };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { DIGITAL_COLLECT_AT, PARTIAL_APPROVAL_ERROR, activeIntent, amountTolerance, createAttemptReference, createPaymentError, currencyDecimals, currentIntent, defaultReversalFor, discountRedeems, groupPaymentRedeems, isDeliveryFee, isPaymentError, isPaymentRedeem, isRealPaymentMethod, isRealPaymentMethod as isRealPaymentMethod$1, isTenderSettled, isTipFee, liveTenders, memoryPaymentStorage, missingDeviceFields, paymentRedeemsCoverTotal, resolvePaymentPolicy, resolveProviderEnvironment, roundTo, scopedPaymentStorage, taxBreakdown, toChargeAmount, withTerminalLock } from "@fire-spark/payments";
1
+ import { DIGITAL_COLLECT_AT, PARTIAL_APPROVAL_ERROR, activeIntent, amountTolerance, createAttemptReference, createPaymentError, currencyDecimals, currentIntent, defaultReversalFor, discountRedeems, groupPaymentRedeems, isDeliveryFee, isPaymentError, isPaymentRedeem, isRealPaymentMethod, isRealPaymentMethod as isRealPaymentMethod$1, isTenderSettled, isTipFee, liveTenders, memoryPaymentStorage, missingDeviceFields, orderPaymentRedeems, orderPaymentRedeems as orderPaymentRedeems$1, paymentRedeemsCoverTotal, resolvePaymentPolicy, resolveProviderEnvironment, roundTo, scopedPaymentStorage, taxBreakdown, toChargeAmount, withTerminalLock } from "@fire-spark/payments";
2
2
  import advancedFormat from "dayjs/plugin/advancedFormat.js";
3
3
  import isBetween from "dayjs/plugin/isBetween.js";
4
4
  import isSameOrAfter from "dayjs/plugin/isSameOrAfter.js";
@@ -3471,8 +3471,17 @@ const redemptionCap = (order) => {
3471
3471
  return Math.max(roundTo(order.totals.total - primaryOnly, decimals), 0);
3472
3472
  };
3473
3473
  /**
3474
- * Trims payment redeems in application order so their sum fits the cap;
3475
- * points shrink in proportion. Discount redeems are left untouched.
3474
+ * Room left for order-level payment redeems: the D18 cap minus what the
3475
+ * payment redeems kept on lines already cover.
3476
+ */
3477
+ const orderRedeemCap = (order) => {
3478
+ const used = orderPaymentRedeems({ lines: order.lines }).reduce((sum, item) => sum + (item.amount ?? 0), 0);
3479
+ const decimals = currencyDecimals(order.totals.currency);
3480
+ return Math.max(roundTo(redemptionCap(order) - used, decimals), 0);
3481
+ };
3482
+ /**
3483
+ * Trims payment redeems in application order so their sum fits the cap.
3484
+ * Discount redeems are left untouched.
3476
3485
  */
3477
3486
  const clampPaymentRedeems = (redeem, cap, currency) => {
3478
3487
  const decimals = currencyDecimals(currency);
@@ -3484,12 +3493,9 @@ const clampPaymentRedeems = (redeem, cap, currency) => {
3484
3493
  left = roundTo(left - fits, decimals);
3485
3494
  if (fits <= 0) return [];
3486
3495
  if (fits + amountTolerance(currency) >= amount) return [item];
3487
- const ratio = amount > 0 ? fits / amount : 0;
3488
- const points = roundTo((item.points ?? 0) * ratio, 0);
3489
3496
  return [{
3490
3497
  ...item,
3491
- amount: fits,
3492
- points
3498
+ amount: fits
3493
3499
  }];
3494
3500
  });
3495
3501
  };
@@ -4713,17 +4719,14 @@ const emptyTotals = (currency = "USD") => {
4713
4719
  //#region src/order/redemptions.ts
4714
4720
  const ORDER_KEY = "ORDER";
4715
4721
  const buildPaymentRedeem = (input) => {
4716
- const { reward_id, quantity, payment_id, amount, points } = input;
4722
+ const { reward_id, quantity, payment_id, amount } = input;
4717
4723
  if (amount === void 0 || !(amount > 0)) throw new Error("Redeem with payment_id requires amount > 0");
4718
- if (points === void 0 || !(points >= 0)) throw new Error("Redeem with payment_id requires points ≥ 0");
4719
4724
  const redeem = {
4720
4725
  reward_id,
4721
4726
  quantity,
4722
4727
  payment_id,
4723
4728
  amount
4724
4729
  };
4725
- redeem.points = points;
4726
- if (input.program !== void 0) redeem.program = input.program;
4727
4730
  if (input.expires_at !== void 0) redeem.expires_at = input.expires_at;
4728
4731
  return redeem;
4729
4732
  };
@@ -4757,12 +4760,10 @@ const keepUnits = (item, rest) => {
4757
4760
  };
4758
4761
  const ratio = new Big(rest).div(item.quantity);
4759
4762
  const amount = new Big(item.amount ?? 0).times(ratio).round(6).toNumber();
4760
- const points = new Big(item.points ?? 0).times(ratio).round(0).toNumber();
4761
4763
  return {
4762
4764
  ...item,
4763
4765
  quantity: rest,
4764
- amount,
4765
- points
4766
+ amount
4766
4767
  };
4767
4768
  };
4768
4769
  /**
@@ -5085,7 +5086,7 @@ const cloneOrder = (order) => {
5085
5086
  };
5086
5087
  const redeemSignature$1 = (items) => {
5087
5088
  return items.map((item) => {
5088
- return `${`${item.reward_id}:${item.quantity}:${item.payment_id ?? ""}`}:${`${item.amount ?? ""}:${item.points ?? ""}`}:${`${item.discount_rate ?? ""}:${item.discount_amount ?? ""}`}`;
5089
+ return `${`${item.reward_id}:${item.quantity}:${item.payment_id ?? ""}`}:${`${item.amount ?? ""}`}:${`${item.discount_rate ?? ""}:${item.discount_amount ?? ""}`}`;
5089
5090
  }).join("|");
5090
5091
  };
5091
5092
  const buildHttpOptions = (options) => {
@@ -5500,9 +5501,9 @@ var Order = class Order {
5500
5501
  }
5501
5502
  /**
5502
5503
  * Appends a redeem to `line_uid` (root line) or to the order. Steps keep
5503
- * the order in which redeems were applied. With `payment_id` (points /
5504
- * balance) it is not a discount: `amount` and `points` are totals of the
5505
- * whole entry (every unit, not per unit) and `quantity` is informational.
5504
+ * the order in which redeems were applied. With `payment_id` (voucher,
5505
+ * balance…) it is not a discount: `amount` is the total of the whole
5506
+ * entry (every unit, not per unit) and `quantity` is informational.
5506
5507
  * Every redeem with the same `payment_id` is paid by one REDEMPTION
5507
5508
  * tender whose `details.rewards[]` lists them; their summed amount is
5508
5509
  * capped at total − tip − delivery (D15, D18, D19).
@@ -5511,7 +5512,7 @@ var Order = class Order {
5511
5512
  if (this.deleted) return;
5512
5513
  const { line_uid, provider, ...rest } = input;
5513
5514
  const redeem = buildRedeem(rest);
5514
- if (isPaymentRedeem(redeem) && line_uid !== void 0) throw new Error("Points / balance redeems apply to the whole order");
5515
+ if (isPaymentRedeem(redeem) && line_uid !== void 0) throw new Error("Payment redeems apply to the whole order");
5515
5516
  if (redeem.payment_id && provider) this.redemptionProviders.set(redeem.payment_id, provider);
5516
5517
  if (line_uid === void 0) {
5517
5518
  this.commitLines({ redeem: [...this.appliedRedeem(), redeem] });
@@ -5531,9 +5532,8 @@ var Order = class Order {
5531
5532
  /**
5532
5533
  * Removes `quantity` units of `reward_id` from `line_uid` or the order,
5533
5534
  * latest applied first. Removing more units than applied clears them all
5534
- * (and the REDEMPTION tender of a points / balance redeem). A points /
5535
- * balance entry that keeps some units keeps the same share of its
5536
- * `amount` and `points`.
5535
+ * (and the REDEMPTION tender of a payment redeem). A payment redeem that
5536
+ * keeps some units keeps the same share of its `amount`.
5537
5537
  */
5538
5538
  removeRedeem(input) {
5539
5539
  if (this.deleted) return;
@@ -5640,7 +5640,7 @@ var Order = class Order {
5640
5640
  }
5641
5641
  /**
5642
5642
  * Reopens this placed, unpaid order: the server voids every payment
5643
- * (REDEMPTION points released), cancels it as `VOIDED` and opens a new
5643
+ * (REDEMPTION rewards released), cancels it as `VOIDED` and opens a new
5644
5644
  * `OPEN` order with the same content. This instance is closed afterwards;
5645
5645
  * replace it with the returned `Order` (same HTTP options and listener).
5646
5646
  *
@@ -5704,11 +5704,12 @@ var Order = class Order {
5704
5704
  await services.orders.validate(body, this.http);
5705
5705
  }
5706
5706
  /**
5707
- * Tenders of the next intent: real ones plus one per payment redeem.
5708
- * When the payment redeems cover the total, only REDEMPTION tenders.
5707
+ * Tenders of the next intent: real ones plus one per payment redeem
5708
+ * `payment_id`, on the order or on a line. When the payment redeems
5709
+ * cover the total, only REDEMPTION tenders.
5709
5710
  */
5710
5711
  getTenders(payment) {
5711
- const redeem = this.draft.redeem ?? [];
5712
+ const redeem = orderPaymentRedeems$1(this.draft);
5712
5713
  const providers = this.redemptionProviders;
5713
5714
  const redemption = redemptionTenderInputs(redeem, providers);
5714
5715
  if (paymentRedeemsCoverTotal(redeem, this.draft.totals)) return redemption;
@@ -5890,7 +5891,7 @@ var Order = class Order {
5890
5891
  redemption_steps: steps,
5891
5892
  currency
5892
5893
  });
5893
- const redeem = clampPaymentRedeems(applied, redemptionCap({
5894
+ const redeem = clampPaymentRedeems(applied, orderRedeemCap({
5894
5895
  lines,
5895
5896
  totals
5896
5897
  }), currency);
@@ -8615,4 +8616,4 @@ const cardPreviewGroups = (value) => {
8615
8616
  return groups;
8616
8617
  };
8617
8618
  //#endregion
8618
- export { CARD_BRANDS, DEFAULT_RECOMMENDATION_TYPES, Order, OrderSyncPendingError, OrderValidationError, RecurringDateCron, RulesEngine, StorefrontHttpError, addLines, auth, buildCustomerSnapshot, cardBrandSpec, cardDigits, cardNumberGaps, cardNumberMaxLength, cardPreviewGroups, caretAfterDigits, collectOrderLineDiffs, computeStartingPrice, countCartProducts, coveredAmount, createSession, currentNodes, cvcMaxLength, defaultConditionError, detectCardBrand, flattenMenuCategories, flushLogs, formatCardNumber, formatCvc, formatExpiry, fromOrderLines, genId, genOrderId, getLogContext, getScheduleWindow, indexMenu, isCardNumberComplete, isCardNumberDefinitelyInvalid, isCheckoutFieldFilled, isCvcComplete, isDeviceCharged, isDeviceNotLinked, isExpiryComplete, isKioskUnauthorized, isMilestoneStepDone, isOnSchedule, isOrderValidationError, isPosDeviceNotLinked, isPosUnauthorized, isRealPaymentMethod, isStorefrontNotFound, isVariantBase, listMenusStream, localizePosError, log, logError, luhnCheck, matchAbsoluteDateOperator, matchBooleanOperator, matchCurrencyOperator, matchEnumOperator, matchNumberOperator, matchRecurringDateOperator, matchRelativeDateOperator, matchStringOperator, milestoneSteps, milestoneTrack, nestMenuCategories, normalizeCardholderName, parseExpiry, paymentMatchesClientConditions, recomputeRedemptions, recomputeTotals, redemptionCap, remainingAmount, removeLine, replaceLine, resolveCheckout, reversePayment, runPaymentAttempt, selectablePayments, serializeError, services, setLineQuantity, storefrontJson, stripRedemptionLines, toOrderLines, toPaymentCardBrand, validateCardNumber, validateCardholderName, validateCvc, validateExpiry, validateOrderAgainstMenu, verifyWebhookSignature, visitedStates };
8619
+ export { CARD_BRANDS, DEFAULT_RECOMMENDATION_TYPES, Order, OrderSyncPendingError, OrderValidationError, RecurringDateCron, RulesEngine, StorefrontHttpError, addLines, auth, buildCustomerSnapshot, cardBrandSpec, cardDigits, cardNumberGaps, cardNumberMaxLength, cardPreviewGroups, caretAfterDigits, collectOrderLineDiffs, computeStartingPrice, countCartProducts, coveredAmount, createSession, currentNodes, cvcMaxLength, defaultConditionError, detectCardBrand, flattenMenuCategories, flushLogs, formatCardNumber, formatCvc, formatExpiry, fromOrderLines, genId, genOrderId, getLogContext, getScheduleWindow, indexMenu, isCardNumberComplete, isCardNumberDefinitelyInvalid, isCheckoutFieldFilled, isCvcComplete, isDeviceCharged, isDeviceNotLinked, isExpiryComplete, isKioskUnauthorized, isMilestoneStepDone, isOnSchedule, isOrderValidationError, isPosDeviceNotLinked, isPosUnauthorized, isRealPaymentMethod, isStorefrontNotFound, isVariantBase, listMenusStream, localizePosError, log, logError, luhnCheck, matchAbsoluteDateOperator, matchBooleanOperator, matchCurrencyOperator, matchEnumOperator, matchNumberOperator, matchRecurringDateOperator, matchRelativeDateOperator, matchStringOperator, milestoneSteps, milestoneTrack, nestMenuCategories, normalizeCardholderName, orderPaymentRedeems, parseExpiry, paymentMatchesClientConditions, recomputeRedemptions, recomputeTotals, redemptionCap, remainingAmount, removeLine, replaceLine, resolveCheckout, reversePayment, runPaymentAttempt, selectablePayments, serializeError, services, setLineQuantity, storefrontJson, stripRedemptionLines, toOrderLines, toPaymentCardBrand, validateCardNumber, validateCardholderName, validateCvc, validateExpiry, validateOrderAgainstMenu, verifyWebhookSignature, visitedStates };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fire-spark/core",
3
- "version": "0.3.4",
3
+ "version": "0.4.0",
4
4
  "description": "Fire Spark headless SDK",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -20,8 +20,8 @@
20
20
  "big.js": "6.2.1",
21
21
  "dayjs": "1.11.9",
22
22
  "@types/big.js": "6.2.2",
23
- "@fire-spark/payments": "^0.3.4",
24
- "@fire-spark/types": "^0.3.4"
23
+ "@fire-spark/payments": "^0.4.0",
24
+ "@fire-spark/types": "^0.4.0"
25
25
  },
26
26
  "devDependencies": {
27
27
  "tsdown": "^0.22.14",