@aglyn/plugins-commerce 1.0.0-beta.290 → 1.0.0-beta.292

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.
Files changed (183) hide show
  1. package/README.md +4 -2
  2. package/package.json +13 -13
  3. package/src/lib/components/cart-fulfillment.d.ts +3 -0
  4. package/src/lib/components/cart-fulfillment.js.map +1 -1
  5. package/src/lib/components/cart.js +14 -4
  6. package/src/lib/components/cart.js.map +1 -1
  7. package/src/lib/components/commerce-console-page.js +2 -1
  8. package/src/lib/components/commerce-console-page.js.map +1 -1
  9. package/src/lib/components/console/host-orders-card.component.d.ts +6 -0
  10. package/src/lib/components/console/host-orders-card.component.js +3 -2
  11. package/src/lib/components/console/host-orders-card.component.js.map +1 -1
  12. package/src/lib/components/console/invoice-send.component.d.ts +44 -0
  13. package/src/lib/components/console/invoice-send.component.js +237 -0
  14. package/src/lib/components/console/invoice-send.component.js.map +1 -0
  15. package/src/lib/components/console/order-detail-dialog.component.d.ts +5 -0
  16. package/src/lib/components/console/order-detail-dialog.component.js +9 -2
  17. package/src/lib/components/console/order-detail-dialog.component.js.map +1 -1
  18. package/src/lib/components/console/order-invoice.component.d.ts +9 -0
  19. package/src/lib/components/console/order-invoice.component.js +27 -2
  20. package/src/lib/components/console/order-invoice.component.js.map +1 -1
  21. package/src/lib/components/console/pos/pos-item-dialog.component.js +3 -2
  22. package/src/lib/components/console/pos/pos-item-dialog.component.js.map +1 -1
  23. package/src/lib/components/console/pos-kiosk-page.component.js +2 -1
  24. package/src/lib/components/console/pos-kiosk-page.component.js.map +1 -1
  25. package/src/lib/components/console/pos-page.component.js +1 -1
  26. package/src/lib/components/console/pos-page.component.js.map +1 -1
  27. package/src/lib/components/console/product-add-ons-fields.component.d.ts +41 -0
  28. package/src/lib/components/console/product-add-ons-fields.component.js +356 -0
  29. package/src/lib/components/console/product-add-ons-fields.component.js.map +1 -0
  30. package/src/lib/components/console/product-editor-dialog.component.js +31 -5
  31. package/src/lib/components/console/product-editor-dialog.component.js.map +1 -1
  32. package/src/lib/components/console/product-register-fields.component.d.ts +4 -5
  33. package/src/lib/components/console/product-register-fields.component.js +8 -197
  34. package/src/lib/components/console/product-register-fields.component.js.map +1 -1
  35. package/src/lib/components/console/products-hub-zone.component.js +6 -0
  36. package/src/lib/components/console/products-hub-zone.component.js.map +1 -1
  37. package/src/lib/components/console/quote-editor-dialog.component.d.ts +29 -0
  38. package/src/lib/components/console/quote-editor-dialog.component.js +102 -4
  39. package/src/lib/components/console/quote-editor-dialog.component.js.map +1 -1
  40. package/src/lib/components/console/quote-pay-link.component.d.ts +8 -1
  41. package/src/lib/components/console/quote-pay-link.component.js +29 -3
  42. package/src/lib/components/console/quote-pay-link.component.js.map +1 -1
  43. package/src/lib/components/console/quote-proofs.component.d.ts +11 -0
  44. package/src/lib/components/console/quote-proofs.component.js +68 -0
  45. package/src/lib/components/console/quote-proofs.component.js.map +1 -1
  46. package/src/lib/components/console/quote-send.component.d.ts +42 -0
  47. package/src/lib/components/console/quote-send.component.js +304 -0
  48. package/src/lib/components/console/quote-send.component.js.map +1 -0
  49. package/src/lib/components/console/quote-start.component.d.ts +45 -0
  50. package/src/lib/components/console/quote-start.component.js +182 -0
  51. package/src/lib/components/console/quote-start.component.js.map +1 -0
  52. package/src/lib/components/product-add-ons.d.ts +28 -0
  53. package/src/lib/components/product-add-ons.js +136 -0
  54. package/src/lib/components/product-add-ons.js.map +1 -0
  55. package/src/lib/components/product-detail.d.ts +16 -0
  56. package/src/lib/components/product-detail.js +112 -19
  57. package/src/lib/components/product-detail.js.map +1 -1
  58. package/src/lib/components/product-grid.d.ts +8 -2
  59. package/src/lib/components/product-grid.js +6 -1
  60. package/src/lib/components/product-grid.js.map +1 -1
  61. package/src/lib/components/product-options-field-body.d.ts +44 -0
  62. package/src/lib/components/product-options-field-body.js +260 -0
  63. package/src/lib/components/product-options-field-body.js.map +1 -0
  64. package/src/lib/components/product-options-field.d.ts +32 -0
  65. package/src/lib/components/product-options-field.js +128 -0
  66. package/src/lib/components/product-options-field.js.map +1 -0
  67. package/src/lib/components/quote-page-body.js +39 -20
  68. package/src/lib/components/quote-page-body.js.map +1 -1
  69. package/src/lib/model/commerce-cart.d.ts +15 -3
  70. package/src/lib/model/commerce-cart.js +10 -3
  71. package/src/lib/model/commerce-cart.js.map +1 -1
  72. package/src/lib/model/commerce-invoices.d.ts +139 -0
  73. package/src/lib/model/commerce-invoices.js +343 -0
  74. package/src/lib/model/commerce-invoices.js.map +1 -0
  75. package/src/lib/model/commerce-orders.d.ts +35 -5
  76. package/src/lib/model/commerce-orders.js +3 -0
  77. package/src/lib/model/commerce-orders.js.map +1 -1
  78. package/src/lib/model/commerce-pos-kiosk.d.ts +1 -1
  79. package/src/lib/model/commerce-pos-kiosk.js +3 -2
  80. package/src/lib/model/commerce-pos-kiosk.js.map +1 -1
  81. package/src/lib/model/commerce-product-field.d.ts +23 -0
  82. package/src/lib/model/commerce-product-field.js +26 -0
  83. package/src/lib/model/commerce-product-field.js.map +1 -0
  84. package/src/lib/model/commerce-quote-email.d.ts +81 -0
  85. package/src/lib/model/commerce-quote-email.js +170 -0
  86. package/src/lib/model/commerce-quote-email.js.map +1 -0
  87. package/src/lib/model/commerce-quote-pay.d.ts +49 -6
  88. package/src/lib/model/commerce-quote-pay.js +69 -36
  89. package/src/lib/model/commerce-quote-pay.js.map +1 -1
  90. package/src/lib/model/commerce-quote-request.d.ts +93 -0
  91. package/src/lib/model/commerce-quote-request.js +207 -0
  92. package/src/lib/model/commerce-quote-request.js.map +1 -0
  93. package/src/lib/model/commerce-quotes.d.ts +81 -0
  94. package/src/lib/model/commerce-quotes.js +1 -1
  95. package/src/lib/model/commerce-quotes.js.map +1 -1
  96. package/src/lib/model/commerce.d.ts +18 -0
  97. package/src/lib/model/commerce.js +26 -0
  98. package/src/lib/model/commerce.js.map +1 -1
  99. package/src/lib/model/index.d.ts +3 -0
  100. package/src/lib/model/index.js +3 -0
  101. package/src/lib/model/index.js.map +1 -1
  102. package/src/lib/model/product-modifiers.d.ts +74 -4
  103. package/src/lib/model/product-modifiers.js +131 -10
  104. package/src/lib/model/product-modifiers.js.map +1 -1
  105. package/src/lib/plugin.js +19 -0
  106. package/src/lib/plugin.js.map +1 -1
  107. package/src/lib/server/billing-webhook.js +164 -98
  108. package/src/lib/server/billing-webhook.js.map +1 -1
  109. package/src/lib/server/cart-checkout.js +14 -2
  110. package/src/lib/server/cart-checkout.js.map +1 -1
  111. package/src/lib/server/cart.d.ts +5 -0
  112. package/src/lib/server/cart.js +41 -4
  113. package/src/lib/server/cart.js.map +1 -1
  114. package/src/lib/server/catalog.d.ts +6 -0
  115. package/src/lib/server/catalog.js +2 -0
  116. package/src/lib/server/catalog.js.map +1 -1
  117. package/src/lib/server/checkout-extras.js +3 -1
  118. package/src/lib/server/checkout-extras.js.map +1 -1
  119. package/src/lib/server/checkout.js +28 -3
  120. package/src/lib/server/checkout.js.map +1 -1
  121. package/src/lib/server/commerce-pdf.d.ts +5 -1
  122. package/src/lib/server/commerce-pdf.js +37 -10
  123. package/src/lib/server/commerce-pdf.js.map +1 -1
  124. package/src/lib/server/draft-order.js +23 -3
  125. package/src/lib/server/draft-order.js.map +1 -1
  126. package/src/lib/server/invoice-email.d.ts +76 -0
  127. package/src/lib/server/invoice-email.js +183 -0
  128. package/src/lib/server/invoice-email.js.map +1 -0
  129. package/src/lib/server/local-fulfillment.js +5 -1
  130. package/src/lib/server/local-fulfillment.js.map +1 -1
  131. package/src/lib/server/order-invoice-send.d.ts +43 -0
  132. package/src/lib/server/order-invoice-send.js +218 -0
  133. package/src/lib/server/order-invoice-send.js.map +1 -0
  134. package/src/lib/server/order-status.d.ts +11 -0
  135. package/src/lib/server/order-status.js +44 -8
  136. package/src/lib/server/order-status.js.map +1 -1
  137. package/src/lib/server/person-eraser.d.ts +3 -2
  138. package/src/lib/server/person-eraser.js +25 -6
  139. package/src/lib/server/person-eraser.js.map +1 -1
  140. package/src/lib/server/pos-offline-sync.js +1 -1
  141. package/src/lib/server/pos-offline-sync.js.map +1 -1
  142. package/src/lib/server/pos-order.js +1 -1
  143. package/src/lib/server/pos-order.js.map +1 -1
  144. package/src/lib/server/product.d.ts +26 -0
  145. package/src/lib/server/product.js +18 -0
  146. package/src/lib/server/product.js.map +1 -1
  147. package/src/lib/server/products-write.js +5 -2
  148. package/src/lib/server/products-write.js.map +1 -1
  149. package/src/lib/server/quote-email.d.ts +85 -0
  150. package/src/lib/server/quote-email.js +211 -0
  151. package/src/lib/server/quote-email.js.map +1 -0
  152. package/src/lib/server/quote-link-token.d.ts +11 -0
  153. package/src/lib/server/quote-link-token.js +21 -0
  154. package/src/lib/server/quote-link-token.js.map +1 -1
  155. package/src/lib/server/quote-pay.d.ts +8 -3
  156. package/src/lib/server/quote-pay.js +105 -43
  157. package/src/lib/server/quote-pay.js.map +1 -1
  158. package/src/lib/server/quote.d.ts +11 -0
  159. package/src/lib/server/quote.js +309 -12
  160. package/src/lib/server/quote.js.map +1 -1
  161. package/src/lib/server/site-page-resolver.js +2 -1
  162. package/src/lib/server/site-page-resolver.js.map +1 -1
  163. package/src/lib/server.js +5 -0
  164. package/src/lib/server.js.map +1 -1
  165. package/src/lib/site.js +8 -0
  166. package/src/lib/site.js.map +1 -1
  167. package/src/lib/tenant-emails.js +243 -0
  168. package/src/lib/tenant-emails.js.map +1 -1
  169. package/src/lib/utils/add-to-cart.d.ts +8 -0
  170. package/src/lib/utils/add-to-cart.js +10 -2
  171. package/src/lib/utils/add-to-cart.js.map +1 -1
  172. package/src/lib/utils/commerce-document-pdf.d.ts +5 -0
  173. package/src/lib/utils/commerce-document-pdf.js +6 -1
  174. package/src/lib/utils/commerce-document-pdf.js.map +1 -1
  175. package/src/lib/utils/invoice-email-content.d.ts +45 -0
  176. package/src/lib/utils/invoice-email-content.js +126 -0
  177. package/src/lib/utils/invoice-email-content.js.map +1 -0
  178. package/src/lib/utils/order-invoice.d.ts +1 -1
  179. package/src/lib/utils/order-invoice.js +14 -6
  180. package/src/lib/utils/order-invoice.js.map +1 -1
  181. package/src/lib/utils/quote-email-content.d.ts +63 -0
  182. package/src/lib/utils/quote-email-content.js +157 -0
  183. package/src/lib/utils/quote-email-content.js.map +1 -0
@@ -1892,7 +1892,7 @@ async function findOrderForDispute(paymentIntentId) {
1892
1892
  const { hostId, productId } = (_object_metadata15 = object.metadata) != null ? _object_metadata15 : {};
1893
1893
  if (hostId && productId) {
1894
1894
  var _productForSnapshot_data, _ref9, _productForSnapshot_get, _subTotals_totalCents, _productForSnapshot_get1, _ref10;
1895
- var _object_metadata16, _liftedForSnapshot_subscription, _object_customer_details, _object_customer_details1, _object_customer_details2;
1895
+ var _object_metadata16, _object_metadata17, _liftedForSnapshot_subscription, _object_customer_details, _object_customer_details1, _object_customer_details2;
1896
1896
  const firestore = firebaseAdmin.app().firestore();
1897
1897
  const hostRef = firestore.collection('hosts').doc(String(hostId));
1898
1898
  // AGL-1732: this branch used to write the subscription doc and stop —
@@ -1923,10 +1923,16 @@ async function findOrderForDispute(paymentIntentId) {
1923
1923
  });
1924
1924
  const soldVariant = ((_object_metadata16 = object.metadata) == null ? void 0 : _object_metadata16.variantId) ? liftedForSnapshot.variants.find((item)=>item.id === String(object.metadata.variantId)) : liftedForSnapshot.variants[0];
1925
1925
  const variantOptions = Object.values((_ref9 = soldVariant == null ? void 0 : soldVariant.options) != null ? _ref9 : {});
1926
+ // The add-ons bought with it (AGL-4100), named from the product; their
1927
+ // price is already in the session's `unitAmountCents`.
1928
+ const subModifiers = CommerceModel.soldLineModifiers(liftedForSnapshot, CommerceModel.decodeModifierSelection((_object_metadata17 = object.metadata) == null ? void 0 : _object_metadata17.modifiers), soldVariant == null ? void 0 : soldVariant.id);
1929
+ const subLabel = CommerceModel.lineLabelWithModifiers(variantOptions.length ? variantOptions.join(' / ') : undefined, subModifiers);
1926
1930
  const { lineItems: subLineItems, totals: subTotals } = CommerceModel.computeBuyNowOrder(object, _extends({
1927
1931
  name: String((_productForSnapshot_get = productForSnapshot.get('name')) != null ? _productForSnapshot_get : 'Product')
1928
- }, variantOptions.length ? {
1929
- variantLabel: variantOptions.join(' / ')
1932
+ }, subLabel ? {
1933
+ variantLabel: subLabel
1934
+ } : {}, subModifiers.length ? {
1935
+ modifiers: subModifiers
1930
1936
  } : {}, (soldVariant == null ? void 0 : soldVariant.sku) ? {
1931
1937
  sku: soldVariant.sku
1932
1938
  } : {}, liftedForSnapshot.type ? {
@@ -2617,11 +2623,11 @@ async function findOrderForDispute(paymentIntentId) {
2617
2623
  }
2618
2624
  // Reservations (AGL-310): payment confirms the pending hold.
2619
2625
  if (type === 'checkout.session.completed' && (object == null ? void 0 : (_object_metadata1 = object.metadata) == null ? void 0 : _object_metadata1.type) === 'commerce-reservation' && (object == null ? void 0 : object.payment_status) === 'paid') {
2620
- var _object_metadata17;
2621
- const { hostId, reservationId } = (_object_metadata17 = object.metadata) != null ? _object_metadata17 : {};
2626
+ var _object_metadata18;
2627
+ const { hostId, reservationId } = (_object_metadata18 = object.metadata) != null ? _object_metadata18 : {};
2622
2628
  if (hostId && reservationId) {
2623
2629
  var _ref30, _ref31;
2624
- var _object_metadata18;
2630
+ var _object_metadata19;
2625
2631
  const firestore = firebaseAdmin.app().firestore();
2626
2632
  const reservationRef = firestore.collection('hosts').doc(String(hostId)).collection('reservations').doc(String(reservationId));
2627
2633
  // THE MERCHANT'S LODGING TAX, SEPARATED FROM THE STAY (AGL-1969).
@@ -2633,7 +2639,7 @@ async function findOrderForDispute(paymentIntentId) {
2633
2639
  // `amount_total` is stay-plus-tax and Stripe's own tax fields read
2634
2640
  // zero; the session's metadata is the only witness, exactly as it is
2635
2641
  // for a buy-now sale.
2636
- const taxCents = Math.max(0, Math.round(Number((_ref30 = object == null ? void 0 : (_object_metadata18 = object.metadata) == null ? void 0 : _object_metadata18.taxCents) != null ? _ref30 : 0)));
2642
+ const taxCents = Math.max(0, Math.round(Number((_ref30 = object == null ? void 0 : (_object_metadata19 = object.metadata) == null ? void 0 : _object_metadata19.taxCents) != null ? _ref30 : 0)));
2637
2643
  // What the guest actually handed over, MINUS that tax. This is the
2638
2644
  // DEPOSIT when the resource has one (`reserve.ts` charges
2639
2645
  // `depositCents || totalCents`), never the stay's `totalCents` — see
@@ -2850,11 +2856,11 @@ async function findOrderForDispute(paymentIntentId) {
2850
2856
  // Cart orders (AGL-293): one multi-line order from the cart doc;
2851
2857
  // clears the cart and decrements each line's stock.
2852
2858
  if (type === 'checkout.session.completed' && (object == null ? void 0 : (_object_metadata2 = object.metadata) == null ? void 0 : _object_metadata2.type) === 'commerce-cart' && (object == null ? void 0 : object.payment_status) === 'paid') {
2853
- var _object_metadata19;
2854
- const { hostId, cartId, feeCents, couponCode } = (_object_metadata19 = object.metadata) != null ? _object_metadata19 : {};
2859
+ var _object_metadata20;
2860
+ const { hostId, cartId, feeCents, couponCode } = (_object_metadata20 = object.metadata) != null ? _object_metadata20 : {};
2855
2861
  if (hostId && cartId) {
2856
2862
  var _cartSnapshot_data, _ref40, _object_shipping_details_address_postal_code, _object_shipping_details_address_country, _ref41, _ref42, _ref43, _ref44, _ref45;
2857
- var _object_shipping_details, _object_customer_details7, _object_metadata20, _object_customer_details8, _object_customer_details9, _object_customer_details10, _object_metadata21, _this2, _object_metadata22;
2863
+ var _object_shipping_details, _object_customer_details7, _object_metadata21, _object_customer_details8, _object_customer_details9, _object_customer_details10, _object_metadata22, _this2, _object_metadata23;
2858
2864
  const firestore = firebaseAdmin.app().firestore();
2859
2865
  const hostRef = firestore.collection('hosts').doc(String(hostId));
2860
2866
  const cartRef = hostRef.collection('carts').doc(String(cartId));
@@ -2900,6 +2906,12 @@ async function findOrderForDispute(paymentIntentId) {
2900
2906
  const product = productsById.get(line.productId);
2901
2907
  if (!product) return null;
2902
2908
  const variant = line.variantId ? product.variants.find((item)=>item.id === line.variantId) : product.variants[0];
2909
+ // The add-ons on the line (AGL-4100), priced from the product as
2910
+ // `cart-checkout.ts` priced them on the variant sold, and named
2911
+ // on the line as the register names its modifiers.
2912
+ const modifiers = CommerceModel.soldLineModifiers(product, line.modifiers, variant == null ? void 0 : variant.id);
2913
+ const extraCents = modifiers.reduce((sum, modifier)=>sum + modifier.priceCents, 0);
2914
+ const variantLabel = CommerceModel.lineLabelWithModifiers(variant && Object.keys((_variant_options = variant.options) != null ? _variant_options : {}).length ? Object.values((_variant_options1 = variant.options) != null ? _variant_options1 : {}).join(' / ') : undefined, modifiers);
2903
2915
  return _extends({
2904
2916
  productId: line.productId
2905
2917
  }, line.variantId ? {
@@ -2908,8 +2920,10 @@ async function findOrderForDispute(paymentIntentId) {
2908
2920
  useDayKey: line.useDayKey
2909
2921
  } : {}, {
2910
2922
  name: product.name
2911
- }, variant && Object.keys((_variant_options = variant.options) != null ? _variant_options : {}).length ? {
2912
- variantLabel: Object.values((_variant_options1 = variant.options) != null ? _variant_options1 : {}).join(' / ')
2923
+ }, variantLabel ? {
2924
+ variantLabel
2925
+ } : {}, modifiers.length ? {
2926
+ modifiers
2913
2927
  } : {}, (variant == null ? void 0 : variant.sku) ? {
2914
2928
  sku: variant.sku
2915
2929
  } : {}, {
@@ -2918,7 +2932,7 @@ async function findOrderForDispute(paymentIntentId) {
2918
2932
  supplierId: product.supplierId
2919
2933
  } : {}, {
2920
2934
  quantity: line.quantity,
2921
- unitAmountCents: Math.round(Number((_ref = variant == null ? void 0 : variant.priceUsd) != null ? _ref : 0) * 100)
2935
+ unitAmountCents: Math.round(Number((_ref = variant == null ? void 0 : variant.priceUsd) != null ? _ref : 0) * 100) + extraCents
2922
2936
  });
2923
2937
  }).filter(Boolean);
2924
2938
  const shipping = (_ref40 = object == null ? void 0 : object.shipping_details) != null ? _ref40 : object == null ? void 0 : object.customer_details;
@@ -3314,7 +3328,7 @@ async function findOrderForDispute(paymentIntentId) {
3314
3328
  // is byte-identical to what it was before this issue for exactly that
3315
3329
  // reason. The hold refuses the SECOND shopper; it never gates the
3316
3330
  // first one's goods.
3317
- await releaseStockHold(hostRef, String((_ref41 = (_object_metadata20 = object.metadata) == null ? void 0 : _object_metadata20.stockHoldKey) != null ? _ref41 : ''));
3331
+ await releaseStockHold(hostRef, String((_ref41 = (_object_metadata21 = object.metadata) == null ? void 0 : _object_metadata21.stockHoldKey) != null ? _ref41 : ''));
3318
3332
  const cartOrderTotal = `$${(Number((_ref42 = object == null ? void 0 : object.amount_total) != null ? _ref42 : 0) / 100).toFixed(2)}`;
3319
3333
  const cartUnits = lineItems.reduce((sum, line)=>sum + line.quantity, 0);
3320
3334
  void notifyHostManagers(String(hostId), {
@@ -3357,22 +3371,22 @@ async function findOrderForDispute(paymentIntentId) {
3357
3371
  }));
3358
3372
  if (couponCode) {
3359
3373
  var _ref52;
3360
- var _object_metadata23;
3374
+ var _object_metadata24;
3361
3375
  await settleRedemption({
3362
3376
  firestore,
3363
3377
  ref: hostRef.collection('coupons').doc(String(couponCode)),
3364
- holdKey: String((_ref52 = (_object_metadata23 = object.metadata) == null ? void 0 : _object_metadata23.couponHoldKey) != null ? _ref52 : ''),
3378
+ holdKey: String((_ref52 = (_object_metadata24 = object.metadata) == null ? void 0 : _object_metadata24.couponHoldKey) != null ? _ref52 : ''),
3365
3379
  orderRef,
3366
3380
  label: `coupon ${couponCode}`,
3367
3381
  detail: `Coupon ${couponCode} was applied to this order but no longer ` + 'exists, so the redemption is uncounted against its limit.'
3368
3382
  });
3369
3383
  }
3370
3384
  // Gift card balance settlement (AGL-322, made a settlement by AGL-2449).
3371
- if ((_object_metadata21 = object.metadata) == null ? void 0 : _object_metadata21.giftCardCode) {
3385
+ if ((_object_metadata22 = object.metadata) == null ? void 0 : _object_metadata22.giftCardCode) {
3372
3386
  var _ref53, _ref54;
3373
- var _object_metadata24, _object_metadata25;
3374
- const giftCardCents = Number((_ref53 = (_object_metadata24 = object.metadata) == null ? void 0 : _object_metadata24.giftCardCents) != null ? _ref53 : 0);
3375
- const holdKey = String((_ref54 = (_object_metadata25 = object.metadata) == null ? void 0 : _object_metadata25.giftCardHoldKey) != null ? _ref54 : '');
3387
+ var _object_metadata25, _object_metadata26;
3388
+ const giftCardCents = Number((_ref53 = (_object_metadata25 = object.metadata) == null ? void 0 : _object_metadata25.giftCardCents) != null ? _ref53 : 0);
3389
+ const holdKey = String((_ref54 = (_object_metadata26 = object.metadata) == null ? void 0 : _object_metadata26.giftCardHoldKey) != null ? _ref54 : '');
3376
3390
  const cardRef = hostRef.collection('giftCards').doc(String(object.metadata.giftCardCode));
3377
3391
  const orphanNote = `$${(giftCardCents / 100).toFixed(2)} was applied from gift card ` + `${object.metadata.giftCardCode}, which no longer exists. The ` + 'balance was not deducted from any card.';
3378
3392
  if (!holdKey) {
@@ -3538,13 +3552,13 @@ async function findOrderForDispute(paymentIntentId) {
3538
3552
  }
3539
3553
  }
3540
3554
  // Discounts engine redemptions (AGL-305).
3541
- if ((_object_metadata22 = object.metadata) == null ? void 0 : _object_metadata22.discountId) {
3555
+ if ((_object_metadata23 = object.metadata) == null ? void 0 : _object_metadata23.discountId) {
3542
3556
  var _ref58;
3543
- var _object_metadata26;
3557
+ var _object_metadata27;
3544
3558
  await settleRedemption({
3545
3559
  firestore,
3546
3560
  ref: hostRef.collection('discounts').doc(String(object.metadata.discountId)),
3547
- holdKey: String((_ref58 = (_object_metadata26 = object.metadata) == null ? void 0 : _object_metadata26.discountHoldKey) != null ? _ref58 : ''),
3561
+ holdKey: String((_ref58 = (_object_metadata27 = object.metadata) == null ? void 0 : _object_metadata27.discountHoldKey) != null ? _ref58 : ''),
3548
3562
  orderRef,
3549
3563
  label: `discount ${object.metadata.discountId}`,
3550
3564
  detail: `Discount ${object.metadata.discountId} was applied to this ` + 'order but no longer exists, so the redemption is uncounted ' + 'against its limit.'
@@ -3558,8 +3572,8 @@ async function findOrderForDispute(paymentIntentId) {
3558
3572
  // this type and the quote's own id as `orderId`, and the quote document is
3559
3573
  // what becomes the order.
3560
3574
  if (type === 'checkout.session.completed' && (object == null ? void 0 : (_object_metadata3 = object.metadata) == null ? void 0 : _object_metadata3.type) === 'commerce-draft' && (object == null ? void 0 : object.payment_status) === 'paid') {
3561
- var _object_metadata27;
3562
- const { hostId, orderId, productId } = (_object_metadata27 = object.metadata) != null ? _object_metadata27 : {};
3575
+ var _object_metadata28;
3576
+ const { hostId, orderId, productId } = (_object_metadata28 = object.metadata) != null ? _object_metadata28 : {};
3563
3577
  if (hostId && orderId) {
3564
3578
  var _ref59, _ref60, _ref61;
3565
3579
  var _object_total_details, _object_total_details1;
@@ -3631,9 +3645,11 @@ async function findOrderForDispute(paymentIntentId) {
3631
3645
  // A payment a quote could not take (AGL-4094), reported below.
3632
3646
  let quoteUnmatched = null;
3633
3647
  let quoteLabel = '';
3648
+ // What the money was for, as the alert says it (AGL-4099).
3649
+ let unmatchedNoun = 'quote';
3634
3650
  const flipped = await firestore.runTransaction(async (transaction)=>{
3635
3651
  var _snapshot_data, _snapshot_data1, _snapshot_data2, _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _lifted_totals, _ref6, _shipTo_name, _shipTo_address_line1, _shipTo_address_line2, _shipTo_address_city, _shipTo_address_state, _shipTo_address_postal_code, _shipTo_address_country;
3636
- var _object_customer_details, _object_metadata, _object_customer_details1, _lifted_totals1;
3652
+ var _object_metadata, _object_customer_details, _object_metadata1, _object_customer_details1, _lifted_totals1;
3637
3653
  const snapshot = await transaction.get(orderRef);
3638
3654
  if (!snapshot.exists) return false;
3639
3655
  const raw = (_snapshot_data = snapshot.data()) != null ? _snapshot_data : null;
@@ -3644,20 +3660,20 @@ async function findOrderForDispute(paymentIntentId) {
3644
3660
  // and the business is told, as a paid-after-cancel payment is.
3645
3661
  if (raw && CommerceModel.isQuote(raw) && raw.quote) {
3646
3662
  var _ref7, _ref8, _ref9, _ref10, _ref11, _ref12, _ref13, _ref14;
3647
- var _object_metadata1, _object_metadata2, _object_customer_details2, _object_customer_details3, _object_metadata3, _object_metadata4;
3663
+ var _object_metadata2, _object_metadata3, _object_customer_details2, _object_customer_details3, _object_metadata4, _object_metadata5;
3648
3664
  const facts = {
3649
3665
  sessionId: String((_ref7 = object == null ? void 0 : object.id) != null ? _ref7 : ''),
3650
3666
  paymentIntentId: String((_ref8 = object == null ? void 0 : object.payment_intent) != null ? _ref8 : '') || null,
3651
- linkVersion: (_ref9 = object == null ? void 0 : (_object_metadata1 = object.metadata) == null ? void 0 : _object_metadata1.quoteLinkVersion) != null ? _ref9 : null,
3652
- quoteUpdatedAtMs: (_ref10 = object == null ? void 0 : (_object_metadata2 = object.metadata) == null ? void 0 : _object_metadata2.quoteUpdatedAtMs) != null ? _ref10 : null,
3667
+ linkVersion: (_ref9 = object == null ? void 0 : (_object_metadata2 = object.metadata) == null ? void 0 : _object_metadata2.quoteLinkVersion) != null ? _ref9 : null,
3668
+ quoteUpdatedAtMs: (_ref10 = object == null ? void 0 : (_object_metadata3 = object.metadata) == null ? void 0 : _object_metadata3.quoteUpdatedAtMs) != null ? _ref10 : null,
3653
3669
  paidAtMs: Date.now(),
3654
3670
  email: (_ref11 = object == null ? void 0 : (_object_customer_details2 = object.customer_details) == null ? void 0 : _object_customer_details2.email) != null ? _ref11 : null,
3655
3671
  name: (_ref12 = object == null ? void 0 : (_object_customer_details3 = object.customer_details) == null ? void 0 : _object_customer_details3.name) != null ? _ref12 : null,
3656
3672
  amountTotalCents: Number.isFinite(chargedTotalCents) ? chargedTotalCents : null,
3657
3673
  shippingCents,
3658
3674
  taxCents: stripeTaxCents,
3659
- feeCents: Number((_ref13 = object == null ? void 0 : (_object_metadata3 = object.metadata) == null ? void 0 : _object_metadata3.feeCents) != null ? _ref13 : 0) || 0,
3660
- taxMode: storefrontTaxModeOf(object, Number((_ref14 = object == null ? void 0 : (_object_metadata4 = object.metadata) == null ? void 0 : _object_metadata4.taxCents) != null ? _ref14 : 0)),
3675
+ feeCents: Number((_ref13 = object == null ? void 0 : (_object_metadata4 = object.metadata) == null ? void 0 : _object_metadata4.feeCents) != null ? _ref13 : 0) || 0,
3676
+ taxMode: storefrontTaxModeOf(object, Number((_ref14 = object == null ? void 0 : (_object_metadata5 = object.metadata) == null ? void 0 : _object_metadata5.taxCents) != null ? _ref14 : 0)),
3661
3677
  shippingAddress: (shipTo == null ? void 0 : shipTo.address) ? Object.fromEntries(Object.entries({
3662
3678
  name: shipTo.name,
3663
3679
  line1: shipTo.address.line1,
@@ -3696,6 +3712,47 @@ async function findOrderForDispute(paymentIntentId) {
3696
3712
  return true;
3697
3713
  }
3698
3714
  const lifted = CommerceModel.liftLegacyOrder((_snapshot_data1 = snapshot.data()) != null ? _snapshot_data1 : {});
3715
+ // AN INVOICE'S PAY LINK (AGL-4099). A draft order paid through the
3716
+ // lasting link its invoice carries answers as a quote's link does:
3717
+ // a payment through a replaced link, or a second payment after the
3718
+ // order was paid, is recorded on the order (`payLink`) and the
3719
+ // business is told, never fulfilled and never lost. A payment for
3720
+ // it as it stands falls through to the flip below, which is the
3721
+ // draft's own: it restates the list fields from the document, so
3722
+ // the draft's are not stamped twice, and moves stock for catalog
3723
+ // lines only. A canceled order keeps AGL-2244's handling below.
3724
+ const invoiceLinkVersion = object == null ? void 0 : (_object_metadata = object.metadata) == null ? void 0 : _object_metadata.payLinkVersion;
3725
+ if (invoiceLinkVersion != null && invoiceLinkVersion !== '' && lifted.status !== 'cancelled') {
3726
+ var _ref15, _ref16;
3727
+ const facts = {
3728
+ sessionId: String((_ref15 = object == null ? void 0 : object.id) != null ? _ref15 : ''),
3729
+ paymentIntentId: String((_ref16 = object == null ? void 0 : object.payment_intent) != null ? _ref16 : '') || null,
3730
+ linkVersion: invoiceLinkVersion,
3731
+ paidAtMs: Date.now(),
3732
+ amountTotalCents: Number.isFinite(chargedTotalCents) ? chargedTotalCents : null
3733
+ };
3734
+ const disposition = CommerceModel.quotePaymentDisposition(lifted, facts);
3735
+ if (disposition === 'redelivery') return false;
3736
+ if (disposition !== 'pay') {
3737
+ var _lifted_payLink;
3738
+ const entry = CommerceModel.quoteUnmatchedPayment(facts, disposition);
3739
+ quoteUnmatched = entry;
3740
+ quoteLabel = CommerceModel.formatInvoiceNumber(lifted, String(orderId));
3741
+ unmatchedNoun = 'invoice';
3742
+ transaction.set(orderRef, {
3743
+ payLink: _extends({}, (_lifted_payLink = lifted.payLink) != null ? _lifted_payLink : {}, {
3744
+ unmatchedPayments: [
3745
+ ...CommerceModel.orderPayLinkUnmatched(lifted),
3746
+ entry
3747
+ ]
3748
+ }),
3749
+ timeline: CommerceModel.appendOrderEvent(lifted, 'invoice-payment-unmatched', CommerceModel.quoteUnmatchedPaymentDetail(entry, 'invoice'), facts.paidAtMs)
3750
+ }, {
3751
+ merge: true
3752
+ });
3753
+ return false;
3754
+ }
3755
+ }
3699
3756
  if (lifted.status !== 'pending') {
3700
3757
  var _lifted_timeline;
3701
3758
  // NOT ALL NON-`pending` ORDERS ARE REDELIVERIES (AGL-2244), and
@@ -3750,7 +3807,7 @@ async function findOrderForDispute(paymentIntentId) {
3750
3807
  // record that any of the charge was tax (AGL-1953). Without it
3751
3808
  // every register card sale would stamp `none` beside an order
3752
3809
  // plainly carrying tax.
3753
- taxMode: storefrontTaxModeOf(object, Number((_ref2 = object == null ? void 0 : (_object_metadata = object.metadata) == null ? void 0 : _object_metadata.taxCents) != null ? _ref2 : 0)),
3810
+ taxMode: storefrontTaxModeOf(object, Number((_ref2 = object == null ? void 0 : (_object_metadata1 = object.metadata) == null ? void 0 : _object_metadata1.taxCents) != null ? _ref2 : 0)),
3754
3811
  paymentIntentId: String((_ref3 = object == null ? void 0 : object.payment_intent) != null ? _ref3 : '') || null,
3755
3812
  customerEmail: (_ref4 = (_ref5 = object == null ? void 0 : (_object_customer_details1 = object.customer_details) == null ? void 0 : _object_customer_details1.email) != null ? _ref5 : lifted.customerEmail) != null ? _ref4 : null,
3756
3813
  timeline: CommerceModel.appendOrderEvent(lifted, 'paid'),
@@ -3791,7 +3848,7 @@ async function findOrderForDispute(paymentIntentId) {
3791
3848
  await notifyHostManagers(String(hostId), {
3792
3849
  type: 'content.order',
3793
3850
  title: unmatched.reason === 'already-paid' ? `${quoteLabel} was paid twice` : `A replaced link for ${quoteLabel} was paid`,
3794
- body: `${quoteLabel} on {site}: ${CommerceModel.quoteUnmatchedPaymentDetail(unmatched)}`,
3851
+ body: `${quoteLabel} on {site}: ${CommerceModel.quoteUnmatchedPaymentDetail(unmatched, unmatchedNoun)}`,
3795
3852
  link: `/${hostId}/products/orders`
3796
3853
  });
3797
3854
  }
@@ -3804,8 +3861,8 @@ async function findOrderForDispute(paymentIntentId) {
3804
3861
  });
3805
3862
  }
3806
3863
  if (flipped) {
3807
- var _ref62, _ref63, _ref64, _ref65, _ref66, _ref67;
3808
- var _object_metadata28, _object_customer_details15, _order_totals, _object_customer_details16;
3864
+ var _ref62, _ref63, _ref64, _ref65, _ref66, _ref67, _ref68;
3865
+ var _object_metadata29, _object_customer_details15, _order_totals, _object_metadata30, _object_customer_details16;
3809
3866
  const order = paidOrder;
3810
3867
  // A legacy register QR sale is a register sale completing (AGL-3607).
3811
3868
  if (order.channel === 'pos') {
@@ -3829,13 +3886,13 @@ async function findOrderForDispute(paymentIntentId) {
3829
3886
  // `increment(1)` for uncapped promotions and sessions minted before
3830
3887
  // the hold existed, which Stripe's at-least-once delivery would run
3831
3888
  // twice. The transition is what makes it once.
3832
- if ((_object_metadata28 = object.metadata) == null ? void 0 : _object_metadata28.discountId) {
3833
- var _ref68;
3834
- var _object_metadata29;
3889
+ if ((_object_metadata29 = object.metadata) == null ? void 0 : _object_metadata29.discountId) {
3890
+ var _ref69;
3891
+ var _object_metadata31;
3835
3892
  await settleRedemption({
3836
3893
  firestore,
3837
3894
  ref: hostRef.collection('discounts').doc(String(object.metadata.discountId)),
3838
- holdKey: String((_ref68 = (_object_metadata29 = object.metadata) == null ? void 0 : _object_metadata29.discountHoldKey) != null ? _ref68 : ''),
3895
+ holdKey: String((_ref69 = (_object_metadata31 = object.metadata) == null ? void 0 : _object_metadata31.discountHoldKey) != null ? _ref69 : ''),
3839
3896
  orderRef,
3840
3897
  label: `discount ${object.metadata.discountId}`,
3841
3898
  detail: `Discount ${object.metadata.discountId} was applied to this ` + 'order but no longer exists, so the redemption is uncounted ' + 'against its limit.'
@@ -3845,11 +3902,13 @@ async function findOrderForDispute(paymentIntentId) {
3845
3902
  const draftPayer = (_ref62 = (_ref63 = object == null ? void 0 : (_object_customer_details15 = object.customer_details) == null ? void 0 : _object_customer_details15.email) != null ? _ref63 : order.customerEmail) != null ? _ref62 : null;
3846
3903
  const draftPaidCents = Number((_ref64 = object == null ? void 0 : object.amount_total) != null ? _ref64 : 0) || Number((_ref65 = (_order_totals = order.totals) == null ? void 0 : _order_totals.totalCents) != null ? _ref65 : 0);
3847
3904
  const isQuotePayment = CommerceModel.isQuote(order);
3905
+ // A draft paid through its invoice's link (AGL-4099).
3906
+ const isInvoicePayment = !isQuotePayment && String((_ref66 = object == null ? void 0 : (_object_metadata30 = object.metadata) == null ? void 0 : _object_metadata30.payLinkVersion) != null ? _ref66 : '') !== '';
3848
3907
  void notifyHostManagers(String(hostId), {
3849
3908
  type: 'content.order',
3850
- title: isQuotePayment ? `Quote paid — ${CommerceModel.formatQuoteNumber(order, String(orderId))}` : `Draft order paid — ${draftLabel}`,
3909
+ title: isQuotePayment ? `Quote paid — ${CommerceModel.formatQuoteNumber(order, String(orderId))}` : isInvoicePayment ? `Invoice paid — ${draftLabel}` : `Draft order paid — ${draftLabel}`,
3851
3910
  // Who paid what, and where (AGL-3432).
3852
- body: isQuotePayment ? `${draftPayer != null ? draftPayer : 'The customer'} paid ${CommerceModel.formatQuoteNumber(order, String(orderId))} ` + `on {site}: $${(draftPaidCents / 100).toFixed(2)}. It is order ${draftLabel} now.` : `${draftPayer != null ? draftPayer : 'The buyer'} paid draft order ${draftLabel} ` + `on {site}: $${(draftPaidCents / 100).toFixed(2)}.`,
3911
+ body: isQuotePayment ? `${draftPayer != null ? draftPayer : 'The customer'} paid ${CommerceModel.formatQuoteNumber(order, String(orderId))} ` + `on {site}: $${(draftPaidCents / 100).toFixed(2)}. It is order ${draftLabel} now.` : isInvoicePayment ? `${draftPayer != null ? draftPayer : 'The buyer'} paid the invoice for draft order ${draftLabel} ` + `on {site}: $${(draftPaidCents / 100).toFixed(2)}.` : `${draftPayer != null ? draftPayer : 'The buyer'} paid draft order ${draftLabel} ` + `on {site}: $${(draftPaidCents / 100).toFixed(2)}.`,
3853
3912
  link: `/${hostId}/products`
3854
3913
  });
3855
3914
  // Contacts ingestion (AGL-1748): this branch flipped the order,
@@ -3864,17 +3923,17 @@ async function findOrderForDispute(paymentIntentId) {
3864
3923
  // figure the draft was priced at, and the two agree by construction,
3865
3924
  // but only one of them is the money that moved. Stored totals remain
3866
3925
  // the fallback for a session shape that reports no total.
3867
- const draftEmail = (_ref66 = (_ref67 = object == null ? void 0 : (_object_customer_details16 = object.customer_details) == null ? void 0 : _object_customer_details16.email) != null ? _ref67 : order.customerEmail) != null ? _ref66 : null;
3926
+ const draftEmail = (_ref67 = (_ref68 = object == null ? void 0 : (_object_customer_details16 = object.customer_details) == null ? void 0 : _object_customer_details16.email) != null ? _ref68 : order.customerEmail) != null ? _ref67 : null;
3868
3927
  if (draftEmail) {
3869
- var _ref69, _ref70, _ref71, _ref72;
3928
+ var _ref70, _ref71, _ref72, _ref73;
3870
3929
  var _order_totals1, _object_customer_details17;
3871
- const chargedCents = Number((_ref69 = object == null ? void 0 : object.amount_total) != null ? _ref69 : 0) || Number((_ref70 = (_order_totals1 = order.totals) == null ? void 0 : _order_totals1.totalCents) != null ? _ref70 : 0);
3930
+ const chargedCents = Number((_ref70 = object == null ? void 0 : object.amount_total) != null ? _ref70 : 0) || Number((_ref71 = (_order_totals1 = order.totals) == null ? void 0 : _order_totals1.totalCents) != null ? _ref71 : 0);
3872
3931
  await recordCapturedContact(_extends({
3873
3932
  orgId: '',
3874
3933
  hostId: String(hostId),
3875
3934
  identity: {
3876
3935
  email: draftEmail,
3877
- name: (_ref71 = (_ref72 = object == null ? void 0 : (_object_customer_details17 = object.customer_details) == null ? void 0 : _object_customer_details17.name) != null ? _ref72 : order.customerName) != null ? _ref71 : null
3936
+ name: (_ref72 = (_ref73 = object == null ? void 0 : (_object_customer_details17 = object.customer_details) == null ? void 0 : _object_customer_details17.name) != null ? _ref73 : order.customerName) != null ? _ref72 : null
3878
3937
  },
3879
3938
  surface: 'relationship',
3880
3939
  lifecycleFloor: 'customer'
@@ -3901,15 +3960,15 @@ async function findOrderForDispute(paymentIntentId) {
3901
3960
  key: 'paid'
3902
3961
  });
3903
3962
  if (productId) {
3904
- var _productSnapshot_data, _ref73, _ref74;
3905
- var _object_metadata30, _lifted_variants_, _order_lineItems_, _order_lineItems;
3963
+ var _productSnapshot_data, _ref74, _ref75;
3964
+ var _object_metadata32, _lifted_variants_, _order_lineItems_, _order_lineItems;
3906
3965
  const productRef = hostRef.collection('products').doc(String(productId));
3907
3966
  const productSnapshot = await productRef.get();
3908
3967
  const lifted = CommerceModel.liftLegacyProduct((_productSnapshot_data = productSnapshot.data()) != null ? _productSnapshot_data : {
3909
3968
  name: 'Product'
3910
3969
  });
3911
- const soldVariantId = String((_ref73 = (_object_metadata30 = object.metadata) == null ? void 0 : _object_metadata30.variantId) != null ? _ref73 : '') || ((_lifted_variants_ = lifted.variants[0]) == null ? void 0 : _lifted_variants_.id);
3912
- const quantity = (_ref74 = (_order_lineItems = order.lineItems) == null ? void 0 : (_order_lineItems_ = _order_lineItems[0]) == null ? void 0 : _order_lineItems_.quantity) != null ? _ref74 : 1;
3970
+ const soldVariantId = String((_ref74 = (_object_metadata32 = object.metadata) == null ? void 0 : _object_metadata32.variantId) != null ? _ref74 : '') || ((_lifted_variants_ = lifted.variants[0]) == null ? void 0 : _lifted_variants_.id);
3971
+ const quantity = (_ref75 = (_order_lineItems = order.lineItems) == null ? void 0 : (_order_lineItems_ = _order_lineItems[0]) == null ? void 0 : _order_lineItems_.quantity) != null ? _ref75 : 1;
3913
3972
  if (soldVariantId) {
3914
3973
  // Atomic since AGL-2320.
3915
3974
  const moved = await decrementVariantStock({
@@ -3961,10 +4020,10 @@ async function findOrderForDispute(paymentIntentId) {
3961
4020
  // would decrement it twice.
3962
4021
  const paidProducts = new Map();
3963
4022
  for (const line of (_order_lineItems1 = order.lineItems) != null ? _order_lineItems1 : []){
3964
- var _ref75, _ref76, _line_variantId1;
4023
+ var _ref76, _ref77, _line_variantId1;
3965
4024
  var _lineProduct_variants_;
3966
- const lineProductId = String((_ref75 = line == null ? void 0 : line.productId) != null ? _ref75 : '');
3967
- const soldQty = Math.round(Number((_ref76 = line == null ? void 0 : line.quantity) != null ? _ref76 : 0));
4025
+ const lineProductId = String((_ref76 = line == null ? void 0 : line.productId) != null ? _ref76 : '');
4026
+ const soldQty = Math.round(Number((_ref77 = line == null ? void 0 : line.quantity) != null ? _ref77 : 0));
3968
4027
  if (!lineProductId || !(soldQty > 0)) continue;
3969
4028
  // Firestore reserves `__…__` ids and `.doc()` throws
3970
4029
  // synchronously on one; a corrupt line must not fail the
@@ -4024,11 +4083,11 @@ async function findOrderForDispute(paymentIntentId) {
4024
4083
  }
4025
4084
  // Commerce Starter orders (AGL-90): recorded under the selling host.
4026
4085
  if (type === 'checkout.session.completed' && (object == null ? void 0 : (_object_metadata4 = object.metadata) == null ? void 0 : _object_metadata4.type) === 'commerce-order' && (object == null ? void 0 : object.payment_status) === 'paid') {
4027
- var _object_metadata31;
4028
- const { hostId, productId, feeCents, couponCode } = (_object_metadata31 = object.metadata) != null ? _object_metadata31 : {};
4086
+ var _object_metadata33;
4087
+ const { hostId, productId, feeCents, couponCode } = (_object_metadata33 = object.metadata) != null ? _object_metadata33 : {};
4029
4088
  if (hostId && productId) {
4030
- var _ref77, _productForSnapshot_get2, _productForSnapshot_data1, _ref78, _ref79, _object_shipping_details_address_postal_code1, _object_shipping_details_address_country1, _ref80, _ref81, _ref82, _ref83, _ref84;
4031
- var _object_metadata32, _buyNowLineItems_, _object_shipping_details1, _object_customer_details18, _object_customer_details19, _object_customer_details20, _object_metadata33;
4089
+ var _ref78, _productForSnapshot_get2, _productForSnapshot_data1, _ref79, _ref80, _object_shipping_details_address_postal_code1, _object_shipping_details_address_country1, _ref81, _ref82, _ref83, _ref84, _ref85;
4090
+ var _object_metadata34, _object_metadata35, _buyNowLineItems_, _object_shipping_details1, _object_customer_details18, _object_customer_details19, _object_customer_details20, _object_metadata36;
4032
4091
  const firestore = firebaseAdmin.app().firestore();
4033
4092
  const hostRef = firestore.collection('hosts').doc(String(hostId));
4034
4093
  // Orders v1 (AGL-283): line-item snapshot + totals + timeline with
@@ -4038,7 +4097,7 @@ async function findOrderForDispute(paymentIntentId) {
4038
4097
  // is bounded to Stripe's at-least-once edge).
4039
4098
  const orderRef = hostRef.collection('orders').doc(String(object.id));
4040
4099
  const counterRef = hostRef.collection('counters').doc('orders');
4041
- const amountCents = Number((_ref77 = object == null ? void 0 : object.amount_total) != null ? _ref77 : 0);
4100
+ const amountCents = Number((_ref78 = object == null ? void 0 : object.amount_total) != null ? _ref78 : 0);
4042
4101
  const productForSnapshot = await hostRef.collection('products').doc(String(productId)).get();
4043
4102
  const snapshotName = String((_productForSnapshot_get2 = productForSnapshot.get('name')) != null ? _productForSnapshot_get2 : 'Product');
4044
4103
  // AGL-1711: the line item and totals used to be fabricated from
@@ -4050,12 +4109,19 @@ async function findOrderForDispute(paymentIntentId) {
4050
4109
  const liftedForSnapshot = CommerceModel.liftLegacyProduct((_productForSnapshot_data1 = productForSnapshot.data()) != null ? _productForSnapshot_data1 : {
4051
4110
  name: snapshotName
4052
4111
  });
4053
- const soldVariant = ((_object_metadata32 = object.metadata) == null ? void 0 : _object_metadata32.variantId) ? liftedForSnapshot.variants.find((item)=>item.id === String(object.metadata.variantId)) : liftedForSnapshot.variants[0];
4054
- const variantOptions = Object.values((_ref78 = soldVariant == null ? void 0 : soldVariant.options) != null ? _ref78 : {});
4112
+ const soldVariant = ((_object_metadata34 = object.metadata) == null ? void 0 : _object_metadata34.variantId) ? liftedForSnapshot.variants.find((item)=>item.id === String(object.metadata.variantId)) : liftedForSnapshot.variants[0];
4113
+ const variantOptions = Object.values((_ref79 = soldVariant == null ? void 0 : soldVariant.options) != null ? _ref79 : {});
4114
+ // The add-ons bought with it (AGL-4100), named from the product; their
4115
+ // price is already in the session's `unitAmountCents`, so a price
4116
+ // edit since the sale moves no money on the record.
4117
+ const buyNowModifiers = CommerceModel.soldLineModifiers(liftedForSnapshot, CommerceModel.decodeModifierSelection((_object_metadata35 = object.metadata) == null ? void 0 : _object_metadata35.modifiers), soldVariant == null ? void 0 : soldVariant.id);
4118
+ const buyNowLabel = CommerceModel.lineLabelWithModifiers(variantOptions.length ? variantOptions.join(' / ') : undefined, buyNowModifiers);
4055
4119
  const { lineItems: buyNowLineItems, totals: buyNowTotals } = CommerceModel.computeBuyNowOrder(object, _extends({
4056
4120
  name: snapshotName
4057
- }, variantOptions.length ? {
4058
- variantLabel: variantOptions.join(' / ')
4121
+ }, buyNowLabel ? {
4122
+ variantLabel: buyNowLabel
4123
+ } : {}, buyNowModifiers.length ? {
4124
+ modifiers: buyNowModifiers
4059
4125
  } : {}, (soldVariant == null ? void 0 : soldVariant.sku) ? {
4060
4126
  sku: soldVariant.sku
4061
4127
  } : {}, liftedForSnapshot.type ? {
@@ -4063,7 +4129,7 @@ async function findOrderForDispute(paymentIntentId) {
4063
4129
  } : {}, liftedForSnapshot.supplierId ? {
4064
4130
  supplierId: liftedForSnapshot.supplierId
4065
4131
  } : {}));
4066
- const soldQuantity = (_ref79 = (_buyNowLineItems_ = buyNowLineItems[0]) == null ? void 0 : _buyNowLineItems_.quantity) != null ? _ref79 : 1;
4132
+ const soldQuantity = (_ref80 = (_buyNowLineItems_ = buyNowLineItems[0]) == null ? void 0 : _buyNowLineItems_.quantity) != null ? _ref80 : 1;
4067
4133
  // The number the merchant knows this order by, for the notices below
4068
4134
  // (AGL-3432).
4069
4135
  let buyNowOrderNumber;
@@ -4164,7 +4230,7 @@ async function findOrderForDispute(paymentIntentId) {
4164
4230
  // In-app order notification (wave v6): host managers see sales
4165
4231
  // in the bell, not just the owner's email: what came in, from whom
4166
4232
  // and where (AGL-3432).
4167
- const buyNowTotal = `$${(Number((_ref80 = object == null ? void 0 : object.amount_total) != null ? _ref80 : 0) / 100).toFixed(2)}`;
4233
+ const buyNowTotal = `$${(Number((_ref81 = object == null ? void 0 : object.amount_total) != null ? _ref81 : 0) / 100).toFixed(2)}`;
4168
4234
  void notifyHostManagers(String(hostId), {
4169
4235
  type: 'content.order',
4170
4236
  title: `New order on {site} — ${buyNowTotal}`,
@@ -4313,15 +4379,15 @@ async function findOrderForDispute(paymentIntentId) {
4313
4379
  hostId: String(hostId),
4314
4380
  identity: {
4315
4381
  email: object == null ? void 0 : (_object_customer_details19 = object.customer_details) == null ? void 0 : _object_customer_details19.email,
4316
- name: (_ref81 = object == null ? void 0 : (_object_customer_details20 = object.customer_details) == null ? void 0 : _object_customer_details20.name) != null ? _ref81 : null
4382
+ name: (_ref82 = object == null ? void 0 : (_object_customer_details20 = object.customer_details) == null ? void 0 : _object_customer_details20.name) != null ? _ref82 : null
4317
4383
  },
4318
4384
  surface: 'relationship',
4319
4385
  lifecycleFloor: 'customer',
4320
- purchaseCents: Number((_ref82 = object == null ? void 0 : object.amount_total) != null ? _ref82 : 0),
4386
+ purchaseCents: Number((_ref83 = object == null ? void 0 : object.amount_total) != null ? _ref83 : 0),
4321
4387
  interaction: {
4322
4388
  source: 'order',
4323
4389
  refId: String(object.id),
4324
- summary: `Placed an order ($${(Number((_ref83 = object == null ? void 0 : object.amount_total) != null ? _ref83 : 0) / 100).toFixed(2)})`
4390
+ summary: `Placed an order ($${(Number((_ref84 = object == null ? void 0 : object.amount_total) != null ? _ref84 : 0) / 100).toFixed(2)})`
4325
4391
  }
4326
4392
  });
4327
4393
  const productRef = hostRef.collection('products').doc(String(productId));
@@ -4339,12 +4405,12 @@ async function findOrderForDispute(paymentIntentId) {
4339
4405
  // serialize; the snapshot above is still read, for the product NAME on
4340
4406
  // the receipt below, and no longer decides any count.
4341
4407
  {
4342
- var _productSnapshot_data2, _ref85;
4343
- var _object_metadata34, _lifted_variants_1;
4408
+ var _productSnapshot_data2, _ref86;
4409
+ var _object_metadata37, _lifted_variants_1;
4344
4410
  const lifted = CommerceModel.liftLegacyProduct((_productSnapshot_data2 = productSnapshot.data()) != null ? _productSnapshot_data2 : {
4345
4411
  name: 'Product'
4346
4412
  });
4347
- const soldVariantId = String((_ref85 = (_object_metadata34 = object.metadata) == null ? void 0 : _object_metadata34.variantId) != null ? _ref85 : '') || ((_lifted_variants_1 = lifted.variants[0]) == null ? void 0 : _lifted_variants_1.id);
4413
+ const soldVariantId = String((_ref86 = (_object_metadata37 = object.metadata) == null ? void 0 : _object_metadata37.variantId) != null ? _ref86 : '') || ((_lifted_variants_1 = lifted.variants[0]) == null ? void 0 : _lifted_variants_1.id);
4348
4414
  if (soldVariantId) {
4349
4415
  // AGL-1711: `-1` regardless of how many units were bought, so a
4350
4416
  // 3-unit buy-now sale decremented stock by one and the difference
@@ -4377,14 +4443,14 @@ async function findOrderForDispute(paymentIntentId) {
4377
4443
  // Settlement, the same way round and for the same reason as the cart
4378
4444
  // branch above (AGL-2356): the decrement lands first, then the
4379
4445
  // reservation is dropped.
4380
- await releaseStockHold(hostRef, String((_ref84 = (_object_metadata33 = object.metadata) == null ? void 0 : _object_metadata33.stockHoldKey) != null ? _ref84 : ''));
4446
+ await releaseStockHold(hostRef, String((_ref85 = (_object_metadata36 = object.metadata) == null ? void 0 : _object_metadata36.stockHoldKey) != null ? _ref85 : ''));
4381
4447
  if (couponCode) {
4382
- var _ref86;
4383
- var _object_metadata35;
4448
+ var _ref87;
4449
+ var _object_metadata38;
4384
4450
  await settleRedemption({
4385
4451
  firestore,
4386
4452
  ref: hostRef.collection('coupons').doc(String(couponCode)),
4387
- holdKey: String((_ref86 = (_object_metadata35 = object.metadata) == null ? void 0 : _object_metadata35.couponHoldKey) != null ? _ref86 : ''),
4453
+ holdKey: String((_ref87 = (_object_metadata38 = object.metadata) == null ? void 0 : _object_metadata38.couponHoldKey) != null ? _ref87 : ''),
4388
4454
  orderRef,
4389
4455
  label: `coupon ${couponCode}`,
4390
4456
  detail: `Coupon ${couponCode} was applied to this order but no longer ` + 'exists, so the redemption is uncounted against its limit.'
@@ -4399,19 +4465,19 @@ async function findOrderForDispute(paymentIntentId) {
4399
4465
  // Receipt + seller notification (AGL-96): env-gated like every
4400
4466
  // other outbound email; failures never fail the webhook.
4401
4467
  if (isEmailConfigured()) {
4402
- var _productSnapshot_get, _ref87;
4468
+ var _productSnapshot_get, _ref88;
4403
4469
  var _object_customer_details21, _org, _this3;
4404
4470
  const productName = String((_productSnapshot_get = productSnapshot.get('name')) != null ? _productSnapshot_get : 'your purchase');
4405
- const amount = (Number((_ref87 = object == null ? void 0 : object.amount_total) != null ? _ref87 : 0) / 100).toFixed(2);
4471
+ const amount = (Number((_ref88 = object == null ? void 0 : object.amount_total) != null ? _ref88 : 0) / 100).toFixed(2);
4406
4472
  const buyerEmail = object == null ? void 0 : (_object_customer_details21 = object.customer_details) == null ? void 0 : _object_customer_details21.email;
4407
4473
  const orderTotal = `$${amount}`;
4408
4474
  // The store's receipt switch and the status link (AGL-3610).
4409
4475
  const receiptExtras = await onlineReceiptExtras(String(hostId), String(object.id));
4410
4476
  if (buyerEmail && receiptExtras.enabled) {
4411
- var _ref88, _ref89;
4477
+ var _ref89, _ref90;
4412
4478
  // The store's own Receipt footer, as the cart receipt carries it
4413
4479
  // (AGL-3432).
4414
- const receiptFooter = String((_ref88 = await hostRef.collection('settings').doc('store').get().then((snapshot)=>snapshot.get('receiptFooter')).catch(()=>'')) != null ? _ref88 : '');
4480
+ const receiptFooter = String((_ref89 = await hostRef.collection('settings').doc('store').get().then((snapshot)=>snapshot.get('receiptFooter')).catch(()=>'')) != null ? _ref89 : '');
4415
4481
  // The quantity with the name (AGL-3432), so a three-unit sale
4416
4482
  // does not read as one item at the whole total.
4417
4483
  const receiptLine = `${soldQuantity}× ${productName}` + // Where to collect it, or when it is coming (AGL-3624).
@@ -4426,7 +4492,7 @@ async function findOrderForDispute(paymentIntentId) {
4426
4492
  }, receiptExtras.tokens));
4427
4493
  await sendEmail(_extends({
4428
4494
  to: String(buyerEmail),
4429
- subject: (_ref89 = designed == null ? void 0 : designed.subject) != null ? _ref89 : `Receipt: ${productName}`,
4495
+ subject: (_ref90 = designed == null ? void 0 : designed.subject) != null ? _ref90 : `Receipt: ${productName}`,
4430
4496
  text: (designed == null ? void 0 : designed.text) || fallbackText
4431
4497
  }, (designed == null ? void 0 : designed.html) ? {
4432
4498
  html: designed.html
@@ -4460,7 +4526,7 @@ async function findOrderForDispute(paymentIntentId) {
4460
4526
  // SSO.
4461
4527
  const seller = (_this4 = await findUserByUidAcrossPools(sellerUid).catch(()=>null)) == null ? void 0 : _this4.record;
4462
4528
  if (seller == null ? void 0 : seller.email) {
4463
- var _hostSnapshot_get, _ref90;
4529
+ var _hostSnapshot_get, _ref91;
4464
4530
  const siteName = String((_hostSnapshot_get = hostSnapshot.get('displayName')) != null ? _hostSnapshot_get : hostId);
4465
4531
  const fallbackText = `You made a sale on ${siteName}!\n\n${productName} — $${amount}` + (buyerEmail ? `\nBuyer: ${buyerEmail}` : '') + `\nOrder reference: ${object.id}`;
4466
4532
  // Site-owner-designed template when published (AGL-771).
@@ -4474,7 +4540,7 @@ async function findOrderForDispute(paymentIntentId) {
4474
4540
  });
4475
4541
  await sendEmail(_extends({
4476
4542
  to: seller.email,
4477
- subject: (_ref90 = designed == null ? void 0 : designed.subject) != null ? _ref90 : `New order: ${productName}`,
4543
+ subject: (_ref91 = designed == null ? void 0 : designed.subject) != null ? _ref91 : `New order: ${productName}`,
4478
4544
  text: (designed == null ? void 0 : designed.text) || fallbackText
4479
4545
  }, (designed == null ? void 0 : designed.html) ? {
4480
4546
  html: designed.html
@@ -4504,28 +4570,28 @@ async function findOrderForDispute(paymentIntentId) {
4504
4570
  // the refund is written on the order's timeline. Nothing else is moved: a
4505
4571
  // Dashboard refund is staff's act, and they chose its transfer reversal.
4506
4572
  if (type === 'charge.refunded') {
4507
- var _ref91, _ref92;
4573
+ var _ref92, _ref93;
4508
4574
  var _object_payment_intent, _snapshot_ref_parent_parent;
4509
- const paymentIntentId = typeof (object == null ? void 0 : object.payment_intent) === 'string' ? object.payment_intent : String((_ref91 = object == null ? void 0 : (_object_payment_intent = object.payment_intent) == null ? void 0 : _object_payment_intent.id) != null ? _ref91 : '');
4575
+ const paymentIntentId = typeof (object == null ? void 0 : object.payment_intent) === 'string' ? object.payment_intent : String((_ref92 = object == null ? void 0 : (_object_payment_intent = object.payment_intent) == null ? void 0 : _object_payment_intent.id) != null ? _ref92 : '');
4510
4576
  const lookup = paymentIntentId ? await findOrderForDispute(paymentIntentId) : {
4511
4577
  kind: 'not-ours'
4512
4578
  };
4513
4579
  if (lookup.kind !== 'order') return;
4514
4580
  const snapshot = lookup.snapshot;
4515
- const hostId = String((_ref92 = (_snapshot_ref_parent_parent = snapshot.ref.parent.parent) == null ? void 0 : _snapshot_ref_parent_parent.id) != null ? _ref92 : '');
4581
+ const hostId = String((_ref93 = (_snapshot_ref_parent_parent = snapshot.ref.parent.parent) == null ? void 0 : _snapshot_ref_parent_parent.id) != null ? _ref93 : '');
4516
4582
  const external = await recordExternalRefund(snapshot.ref, object);
4517
4583
  if (external && hostId) {
4518
- var _ref93, _ref94, _ref95;
4584
+ var _ref94, _ref95, _ref96;
4519
4585
  var _object_refunds;
4520
4586
  // A Stripe Dashboard refund is a refund to every subscriber too
4521
4587
  // (AGL-3645): accounting books it and the merchant's webhooks hear it,
4522
4588
  // as they do a console refund. Keyed by the charge's refunded total,
4523
4589
  // which the record above only ever advances once per amount.
4524
- const latestRefund = ((_ref93 = object == null ? void 0 : (_object_refunds = object.refunds) == null ? void 0 : _object_refunds.data) != null ? _ref93 : [])[0];
4590
+ const latestRefund = ((_ref94 = object == null ? void 0 : (_object_refunds = object.refunds) == null ? void 0 : _object_refunds.data) != null ? _ref94 : [])[0];
4525
4591
  await raiseOrderEvent(ORDER_REFUNDED_EVENT, {
4526
4592
  hostId,
4527
4593
  orderId: snapshot.id,
4528
- key: `external-refund:${String((_ref94 = object == null ? void 0 : object.id) != null ? _ref94 : paymentIntentId)}:${Number((_ref95 = object == null ? void 0 : object.amount_refunded) != null ? _ref95 : 0)}`,
4594
+ key: `external-refund:${String((_ref95 = object == null ? void 0 : object.id) != null ? _ref95 : paymentIntentId)}:${Number((_ref96 = object == null ? void 0 : object.amount_refunded) != null ? _ref96 : 0)}`,
4529
4595
  extra: {
4530
4596
  refund: {
4531
4597
  id: (latestRefund == null ? void 0 : latestRefund.id) ? String(latestRefund.id) : null,
@@ -4575,16 +4641,16 @@ async function findOrderForDispute(paymentIntentId) {
4575
4641
  // merchant; both report the site so the seller's fraud ledger can name it.
4576
4642
  const risk = paymentRiskEventFrom(type, object);
4577
4643
  if (risk && risk.signal.kind !== 'dispute') {
4578
- var _ref96, _snapshot_data1, _ref97, _ref98;
4644
+ var _ref97, _snapshot_data1, _ref98, _ref99;
4579
4645
  var _snapshot_ref_parent_parent1, _order_totals2;
4580
4646
  const lookup = risk.paymentIntentId ? await findOrderForDispute(risk.paymentIntentId) : {
4581
4647
  kind: 'not-ours'
4582
4648
  };
4583
4649
  if (lookup.kind !== 'order') return;
4584
4650
  const snapshot = lookup.snapshot;
4585
- const hostId = String((_ref96 = (_snapshot_ref_parent_parent1 = snapshot.ref.parent.parent) == null ? void 0 : _snapshot_ref_parent_parent1.id) != null ? _ref96 : '');
4651
+ const hostId = String((_ref97 = (_snapshot_ref_parent_parent1 = snapshot.ref.parent.parent) == null ? void 0 : _snapshot_ref_parent_parent1.id) != null ? _ref97 : '');
4586
4652
  const order = CommerceModel.liftLegacyOrder((_snapshot_data1 = snapshot.data()) != null ? _snapshot_data1 : {});
4587
- const orderCents = Number((_ref97 = (_ref98 = (_order_totals2 = order.totals) == null ? void 0 : _order_totals2.totalCents) != null ? _ref98 : order.amountCents) != null ? _ref97 : 0);
4653
+ const orderCents = Number((_ref98 = (_ref99 = (_order_totals2 = order.totals) == null ? void 0 : _order_totals2.totalCents) != null ? _ref99 : order.amountCents) != null ? _ref98 : 0);
4588
4654
  await recordPaymentRiskOnRecord({
4589
4655
  ref: snapshot.ref,
4590
4656
  signal: risk.signal,
@@ -4647,7 +4713,7 @@ async function findOrderForDispute(paymentIntentId) {
4647
4713
  // finds). AGL-1554 will add its own `closed` branch for the marketplace
4648
4714
  // side; the two coexist because each self-selects by finding its own record.
4649
4715
  if (type === 'charge.dispute.created' || type === 'charge.dispute.closed') {
4650
- var _dispute_payment_intent, _ref99;
4716
+ var _dispute_payment_intent, _ref100;
4651
4717
  var _snapshot_ref_parent_parent2;
4652
4718
  const dispute = object != null ? object : {};
4653
4719
  const paymentIntentId = String((_dispute_payment_intent = dispute.payment_intent) != null ? _dispute_payment_intent : '');
@@ -4673,9 +4739,9 @@ async function findOrderForDispute(paymentIntentId) {
4673
4739
  const claimed = lookup.kind === 'order' || lookup.kind === 'unresolved';
4674
4740
  const snapshot = lookup.kind === 'order' ? lookup.snapshot : null;
4675
4741
  if (snapshot) {
4676
- var _ref100;
4742
+ var _ref101;
4677
4743
  var _snapshot_ref_parent_parent3;
4678
- const hostId = String((_ref100 = (_snapshot_ref_parent_parent3 = snapshot.ref.parent.parent) == null ? void 0 : _snapshot_ref_parent_parent3.id) != null ? _ref100 : '');
4744
+ const hostId = String((_ref101 = (_snapshot_ref_parent_parent3 = snapshot.ref.parent.parent) == null ? void 0 : _snapshot_ref_parent_parent3.id) != null ? _ref101 : '');
4679
4745
  if (type === 'charge.dispute.created') {
4680
4746
  var _snapshot_data2;
4681
4747
  // A chargeback's gift cards are frozen while it is open (AGL-3363).
@@ -4693,7 +4759,7 @@ async function findOrderForDispute(paymentIntentId) {
4693
4759
  }, notifyRiskEvent);
4694
4760
  const { opened, record } = await recordDisputeOpened(snapshot, dispute);
4695
4761
  if (opened && hostId) {
4696
- var _snapshot_data3, _record_evidenceDueByMs, _ref101;
4762
+ var _snapshot_data3, _record_evidenceDueByMs, _ref102;
4697
4763
  // Time-critical — Stripe's evidence window is days, not weeks — so
4698
4764
  // this is awaited rather than fired off with `void`: the handler is
4699
4765
  // serverless and work left running past the response is work the
@@ -4712,16 +4778,16 @@ async function findOrderForDispute(paymentIntentId) {
4712
4778
  },
4713
4779
  amount: `$${(record.amountCents / 100).toFixed(2)}`,
4714
4780
  evidenceDueByMs: (_record_evidenceDueByMs = record.evidenceDueByMs) != null ? _record_evidenceDueByMs : null,
4715
- dedupeKey: `sale:${String((_ref101 = dispute == null ? void 0 : dispute.id) != null ? _ref101 : snapshot.id)}`,
4781
+ dedupeKey: `sale:${String((_ref102 = dispute == null ? void 0 : dispute.id) != null ? _ref102 : snapshot.id)}`,
4716
4782
  staffEvidence: record.reason ? `Reason: ${record.reason.replace(/_/g, ' ')}.` : null
4717
4783
  });
4718
4784
  }
4719
4785
  } else {
4720
- var _ref102, _snapshot_data4, _ref103;
4786
+ var _ref103, _snapshot_data4, _ref104;
4721
4787
  // Lost: the money went back, so the cards it bought are voided. Won
4722
4788
  // (or closed on a warning): the dispute's freeze lifts; a freeze a
4723
4789
  // fraud warning or review put on stays for the merchant (AGL-3363).
4724
- await applyOrderGiftCardRisk(snapshot, String((_ref102 = dispute == null ? void 0 : dispute.status) != null ? _ref102 : '') === 'lost' ? {
4790
+ await applyOrderGiftCardRisk(snapshot, String((_ref103 = dispute == null ? void 0 : dispute.status) != null ? _ref103 : '') === 'lost' ? {
4725
4791
  kind: 'void',
4726
4792
  reason: 'dispute-lost'
4727
4793
  } : {
@@ -4792,7 +4858,7 @@ async function findOrderForDispute(paymentIntentId) {
4792
4858
  // transiently-failed reversal gets its retry — and gated inside on
4793
4859
  // the order's own `reversedTransferCents` marker, so it runs at most
4794
4860
  // once per dispute however many times Stripe delivers.
4795
- if (String((_ref103 = dispute == null ? void 0 : dispute.status) != null ? _ref103 : '') === 'lost') {
4861
+ if (String((_ref104 = dispute == null ? void 0 : dispute.status) != null ? _ref104 : '') === 'lost') {
4796
4862
  const pulledBackCents = await reverseSellerShare(snapshot.ref, dispute);
4797
4863
  // The merchant-experience half of the AGL-1794 decision, and not an
4798
4864
  // optional extra: the reversal takes money out of the connected
@@ -4822,7 +4888,7 @@ async function findOrderForDispute(paymentIntentId) {
4822
4888
  return _extends({
4823
4889
  claimed
4824
4890
  }, snapshot ? {
4825
- hostId: String((_ref99 = (_snapshot_ref_parent_parent2 = snapshot.ref.parent.parent) == null ? void 0 : _snapshot_ref_parent_parent2.id) != null ? _ref99 : '')
4891
+ hostId: String((_ref100 = (_snapshot_ref_parent_parent2 = snapshot.ref.parent.parent) == null ? void 0 : _snapshot_ref_parent_parent2.id) != null ? _ref100 : '')
4826
4892
  } : {});
4827
4893
  }
4828
4894
  };