@scopetickets/checkout 0.6.0 → 0.6.2

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.cjs CHANGED
@@ -8524,7 +8524,7 @@ function param(value) {
8524
8524
  }
8525
8525
 
8526
8526
  // src/version.ts
8527
- var CHECKOUT_VERSION = "0.6.0";
8527
+ var CHECKOUT_VERSION = "0.6.2";
8528
8528
 
8529
8529
  // src/data/useCheckoutEvents.ts
8530
8530
  function useCheckoutEvents(observed, { applicationKey, inventories, onEvent, logger = browserLogger }) {
@@ -9975,32 +9975,24 @@ function createOrderStore(parts, seed = IDLE_ORDER) {
9975
9975
  saveAnswers,
9976
9976
  charge,
9977
9977
  /*
9978
- * CHECKED FIRST, THEN APPLIED — two calls, and the first one is the only thing that
9979
- * can say WHY. A check that could not be MADE is not a code that was refused: the card
9980
- * goes quiet and the fault travels, which is where `notices` takes it.
9978
+ * APPLIED STRAIGHT TO THE CART — one call, no `checkPromo` first. The cart's write is
9979
+ * the authority: it applies the code or refuses it with the platform's reason
9980
+ * ("The promo code does not apply to any of the items"), which `writePromo` puts on
9981
+ * the card. The check asked the same question of the whole platform instead of this
9982
+ * cart, and on production it cost ~8 s per row of the code: 25 s for a code with a row
9983
+ * on each of three days, a 500 at 30 s past that — measured 2026-11-10, while the cart
9984
+ * write answered in 0.03 s. A write that could not be MADE is not a code that was
9985
+ * refused: the card goes quiet and the fault travels, which is where `notices` takes it.
9981
9986
  */
9982
9987
  applyPromo: async (code) => {
9983
- const taken = state.reservation;
9984
- const cart = state.cart;
9985
- if (cart === null) return false;
9988
+ if (state.cart === null) return false;
9986
9989
  const typed = code.trim();
9987
- dispatch({ kind: "PROMO_WRITING" });
9988
- let checked;
9989
9990
  try {
9990
- checked = await parts.gateway.checkPromo(typed, cart.EventId);
9991
+ return await writePromo((cartKey) => parts.gateway.writePromo(cartKey, typed));
9991
9992
  } catch (cause) {
9992
9993
  dispatch({ kind: "PROMO_SETTLED" });
9993
9994
  throw cause;
9994
9995
  }
9995
- if (!stillOurs(taken)) {
9996
- dispatch({ kind: "PROMO_SETTLED" });
9997
- return false;
9998
- }
9999
- if (!checked.ok) {
10000
- dispatch({ kind: "PROMO_REFUSED", reason: checked.reason });
10001
- return false;
10002
- }
10003
- return writePromo((cartKey) => parts.gateway.writePromo(cartKey, typed));
10004
9996
  },
10005
9997
  removePromo: () => writePromo((cartKey) => parts.gateway.clearPromo(cartKey)),
10006
9998
  /*
@@ -10544,7 +10536,7 @@ function cartLines(items, context = {}) {
10544
10536
  // ../checkout-core/src/domain/promo.ts
10545
10537
  function promoSaved(cart, currency) {
10546
10538
  if (currency === void 0) return null;
10547
- const saved = cart.DiscountAmount;
10539
+ const saved = cart.PromoSavingAmount;
10548
10540
  if (typeof saved !== "number" || !Number.isFinite(saved) || saved <= 0) return null;
10549
10541
  return formatMoney(saved, currency);
10550
10542
  }