@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.js CHANGED
@@ -6320,7 +6320,7 @@ function param(value) {
6320
6320
  }
6321
6321
 
6322
6322
  // src/version.ts
6323
- var CHECKOUT_VERSION = "0.6.0";
6323
+ var CHECKOUT_VERSION = "0.6.2";
6324
6324
 
6325
6325
  // src/data/useCheckoutEvents.ts
6326
6326
  function useCheckoutEvents(observed, { applicationKey, inventories, onEvent, logger = browserLogger }) {
@@ -7771,32 +7771,24 @@ function createOrderStore(parts, seed = IDLE_ORDER) {
7771
7771
  saveAnswers,
7772
7772
  charge,
7773
7773
  /*
7774
- * CHECKED FIRST, THEN APPLIED — two calls, and the first one is the only thing that
7775
- * can say WHY. A check that could not be MADE is not a code that was refused: the card
7776
- * goes quiet and the fault travels, which is where `notices` takes it.
7774
+ * APPLIED STRAIGHT TO THE CART — one call, no `checkPromo` first. The cart's write is
7775
+ * the authority: it applies the code or refuses it with the platform's reason
7776
+ * ("The promo code does not apply to any of the items"), which `writePromo` puts on
7777
+ * the card. The check asked the same question of the whole platform instead of this
7778
+ * cart, and on production it cost ~8 s per row of the code: 25 s for a code with a row
7779
+ * on each of three days, a 500 at 30 s past that — measured 2026-11-10, while the cart
7780
+ * write answered in 0.03 s. A write that could not be MADE is not a code that was
7781
+ * refused: the card goes quiet and the fault travels, which is where `notices` takes it.
7777
7782
  */
7778
7783
  applyPromo: async (code) => {
7779
- const taken = state.reservation;
7780
- const cart = state.cart;
7781
- if (cart === null) return false;
7784
+ if (state.cart === null) return false;
7782
7785
  const typed = code.trim();
7783
- dispatch({ kind: "PROMO_WRITING" });
7784
- let checked;
7785
7786
  try {
7786
- checked = await parts.gateway.checkPromo(typed, cart.EventId);
7787
+ return await writePromo((cartKey) => parts.gateway.writePromo(cartKey, typed));
7787
7788
  } catch (cause) {
7788
7789
  dispatch({ kind: "PROMO_SETTLED" });
7789
7790
  throw cause;
7790
7791
  }
7791
- if (!stillOurs(taken)) {
7792
- dispatch({ kind: "PROMO_SETTLED" });
7793
- return false;
7794
- }
7795
- if (!checked.ok) {
7796
- dispatch({ kind: "PROMO_REFUSED", reason: checked.reason });
7797
- return false;
7798
- }
7799
- return writePromo((cartKey) => parts.gateway.writePromo(cartKey, typed));
7800
7792
  },
7801
7793
  removePromo: () => writePromo((cartKey) => parts.gateway.clearPromo(cartKey)),
7802
7794
  /*
@@ -8340,7 +8332,7 @@ function cartLines(items, context = {}) {
8340
8332
  // ../checkout-core/src/domain/promo.ts
8341
8333
  function promoSaved(cart, currency) {
8342
8334
  if (currency === void 0) return null;
8343
- const saved = cart.DiscountAmount;
8335
+ const saved = cart.PromoSavingAmount;
8344
8336
  if (typeof saved !== "number" || !Number.isFinite(saved) || saved <= 0) return null;
8345
8337
  return formatMoney(saved, currency);
8346
8338
  }