@vio-live/web-sdk 0.37.0 → 0.37.1

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/CHANGELOG.md CHANGED
@@ -14,6 +14,23 @@ How to keep this file: see [CONTRIBUTING → Changelog](CONTRIBUTING.md#changelo
14
14
  The details of each feature live in the [README](README.md); this file says *what*
15
15
  and *when*, and links there.
16
16
 
17
+ ## Unreleased
18
+
19
+ ## 0.37.1 — 2026-10-30
20
+
21
+ ### Fixed
22
+ - **Kustom: the return confirms the order again on a page with two brands' carts** — the return read
23
+ the order with the platform key when its own cart was already closed, and said «Vi kunne ikke
24
+ bekrefte betalingen» for a paid order. It now reads with the returning checkout's sponsor and
25
+ channel, as Qliro and Walley do; Kustom, Qliro, Walley and Adyen reopen on that sponsor
26
+ ([#123](https://github.com/vio-live/vio-web-sdk/pull/123)).
27
+ - **Vipps: coming back from a cancelled payment no longer leaves «Henter betalingsmåter…» for good** —
28
+ on a page that mounts the checkout before it calls `Vio.init()` (Vev), the return found no cart
29
+ (each connection keeps its own), so nothing asked for the payment methods. The checkout now reopens
30
+ on the cart once `Vio.init()` lands (up to 10 s) and lists the methods; a paid return also clears the
31
+ connection's cart. With no checkout at all, the payment step says «Handlekurven er tom.» instead of
32
+ loading.
33
+
17
34
  ## 0.37.0 — 2026-10-29
18
35
 
19
36
  > **Deploy the collector `89f2766` (vio-analytics#38) before using this version:** an older collector rejects
@@ -1,4 +1,4 @@
1
- import { Vio, __decorateClass, primaryImageUrl, displayPrice, resolveDetailLayout, toCampaignId, getGlobalCurrency, layoutOriginOf, copyAppliedLayout, onGlobalDetailLayoutChange, layoutSignature, ensureVippsButton, formatPrice, currentGlobalDescriptionLabel, shippingDescriptionOf, lineOrigins, buyerRefOf, nexiReturnPaymentId, readNexiPending, kustomReturnOutcome, KUSTOM_RETURN_QUERY_KEYS, storageGet, ADYEN_RETURN_METHOD, adyenReturnParams, ADYEN_RETURN_QUERY_KEYS, adyenReturnOutcome, getGlobalCountryCode, isValidPhone, gatewayHasBuyerRef, rememberedCheckoutSponsor, checkoutSponsorOf, AdyenOriginError, normalizeSlotId, autoSlotDisplayName, autoSlotId, sponsorIdentityFrom, Configuration, normalizeScope, campaignCandidates, ctaText } from './chunk-KVI56NGO.js';
1
+ import { Vio, __decorateClass, primaryImageUrl, displayPrice, resolveDetailLayout, toCampaignId, getGlobalCurrency, layoutOriginOf, copyAppliedLayout, onGlobalDetailLayoutChange, layoutSignature, ensureVippsButton, formatPrice, currentGlobalDescriptionLabel, shippingDescriptionOf, lineOrigins, buyerRefOf, nexiReturnPaymentId, readNexiPending, kustomReturnOutcome, KUSTOM_RETURN_QUERY_KEYS, storageGet, ADYEN_RETURN_METHOD, adyenReturnParams, ADYEN_RETURN_QUERY_KEYS, adyenReturnOutcome, getGlobalCountryCode, isValidPhone, gatewayHasBuyerRef, Configuration, rememberedCheckoutSponsor, checkoutSponsorOf, AdyenOriginError, normalizeSlotId, autoSlotDisplayName, autoSlotId, sponsorIdentityFrom, normalizeScope, campaignCandidates, ctaText } from './chunk-GUXBD7KR.js';
2
2
  import { LitElement, css, html, nothing } from 'lit';
3
3
  import { property, state, query } from 'lit/decorators.js';
4
4
 
@@ -7205,7 +7205,7 @@ var _VioCheckout = class _VioCheckout extends LitElement {
7205
7205
  this.returningFrom = "kustom";
7206
7206
  this.setOrderSponsor(sponsorId, kustomReturn.checkoutId);
7207
7207
  if (!this.checkoutState) {
7208
- const spIdToUse = sponsorId || [...Vio.cart.getAllCarts().keys()][0] || 0;
7208
+ const spIdToUse = this.returnSponsorOf(sponsorId, kustomReturn.checkoutId);
7209
7209
  if (spIdToUse) {
7210
7210
  try {
7211
7211
  Vio.checkout.open(spIdToUse);
@@ -7223,7 +7223,8 @@ var _VioCheckout = class _VioCheckout extends LitElement {
7223
7223
  try {
7224
7224
  const order = await Vio.checkout.getKustomOrder(
7225
7225
  kustomOrderId,
7226
- this.checkoutState?.sponsorId
7226
+ this.checkoutState?.sponsorId,
7227
+ kustomReturn.checkoutId
7227
7228
  );
7228
7229
  this.verifyingReturn = null;
7229
7230
  if (order?.status === "checkout_complete" && order.html_snippet) {
@@ -7249,7 +7250,7 @@ var _VioCheckout = class _VioCheckout extends LitElement {
7249
7250
  this.returningFrom = "qliro";
7250
7251
  this.setOrderSponsor(sponsorId, checkoutId);
7251
7252
  if (!this.checkoutState) {
7252
- const spIdToUse = sponsorId || [...Vio.cart.getAllCarts().keys()][0] || 0;
7253
+ const spIdToUse = this.returnSponsorOf(sponsorId, checkoutId);
7253
7254
  if (spIdToUse) {
7254
7255
  try {
7255
7256
  Vio.checkout.open(spIdToUse);
@@ -7304,7 +7305,7 @@ var _VioCheckout = class _VioCheckout extends LitElement {
7304
7305
  this.returningFrom = "walley";
7305
7306
  this.setOrderSponsor(sponsorId, checkoutId);
7306
7307
  if (!this.checkoutState) {
7307
- const spIdToUse = sponsorId || [...Vio.cart.getAllCarts().keys()][0] || 0;
7308
+ const spIdToUse = this.returnSponsorOf(sponsorId, checkoutId);
7308
7309
  if (spIdToUse) {
7309
7310
  try {
7310
7311
  Vio.checkout.open(spIdToUse);
@@ -7363,7 +7364,7 @@ var _VioCheckout = class _VioCheckout extends LitElement {
7363
7364
  this.adyenSettled = true;
7364
7365
  this.autoSelectAttempted = true;
7365
7366
  if (!this.checkoutState) {
7366
- const spIdToUse = sponsorId || [...Vio.cart.getAllCarts().keys()][0] || 0;
7367
+ const spIdToUse = this.returnSponsorOf(sponsorId, checkoutId);
7367
7368
  if (spIdToUse) {
7368
7369
  try {
7369
7370
  Vio.checkout.open(spIdToUse);
@@ -7407,7 +7408,7 @@ var _VioCheckout = class _VioCheckout extends LitElement {
7407
7408
  }
7408
7409
  if (vioMethod === "vipps" && checkoutId) {
7409
7410
  if (!this.checkoutState) {
7410
- const spIdToUse = sponsorId || [...Vio.cart.getAllCarts().keys()][0] || 0;
7411
+ const spIdToUse = this.returnSponsorOf(sponsorId, checkoutId);
7411
7412
  if (spIdToUse) {
7412
7413
  try {
7413
7414
  Vio.checkout.open(spIdToUse);
@@ -7416,10 +7417,12 @@ var _VioCheckout = class _VioCheckout extends LitElement {
7416
7417
  }
7417
7418
  }
7418
7419
  }
7420
+ const reopening = this.checkoutState ? null : this.reopenOnceInitialized(sponsorId, checkoutId, "vipps");
7419
7421
  this.setOrderSponsor(sponsorId, checkoutId);
7420
7422
  this.open = true;
7421
7423
  this.verifyingReturn = "Bekrefter betalingen med Vipps\u2026";
7422
7424
  const { outcome, sawStatus } = await this.pollVippsStatus(checkoutId, sponsorId);
7425
+ if (reopening) await reopening;
7423
7426
  this.verifyingReturn = null;
7424
7427
  this.applyReturnOutcome(outcome, sawStatus, vioMethod, sponsorId, checkoutId);
7425
7428
  this.cleanReturnQueryParams(["vio_payment", "vio_method", "vio_sponsor", "checkout_id"]);
@@ -8339,14 +8342,55 @@ var _VioCheckout = class _VioCheckout extends LitElement {
8339
8342
  </div>
8340
8343
  `;
8341
8344
  }
8345
+ static {
8346
+ /**
8347
+ * Remember whose order this is and how it is named right now, before the
8348
+ * cart that names it is cleared. Whose: the sponsor this tab remembered for
8349
+ * the checkout when it was created (exact for that checkout id), else the
8350
+ * one given (the return URL's `vio_sponsor`, the state it was paid in),
8351
+ * else the open state's — a return without `vio_sponsor` (Qliro, Walley)
8352
+ * re-opens the state with whichever cart comes first, which is a guess.
8353
+ */
8354
+ /**
8355
+ * The sponsor to reopen the checkout with on a provider's return: the one
8356
+ * the URL names, else the one this tab remembered for that checkout (a
8357
+ * return URL need not name it — Kustom's never does), else the first cart.
8358
+ * The first cart alone is a guess: with two brands' carts on the page it is
8359
+ * the wrong one, and with the cart already completed by the order there is
8360
+ * none — every read after it then goes out with the wrong key.
8361
+ */
8362
+ /** How long a return waits for `Vio.init()` to reopen the checkout on its cart. */
8363
+ this.RETURN_INIT_WAIT_MS = 1e4;
8364
+ }
8342
8365
  /**
8343
- * Remember whose order this is and how it is named right now, before the
8344
- * cart that names it is cleared. Whose: the sponsor this tab remembered for
8345
- * the checkout when it was created (exact for that checkout id), else the
8346
- * one given (the return URL's `vio_sponsor`, the state it was paid in),
8347
- * else the open state's — a return without `vio_sponsor` (Qliro, Walley)
8348
- * re-opens the state with whichever cart comes first, which is a guess.
8366
+ * Reopen the checkout of a provider's return once `Vio.init()` is there.
8367
+ * A page may mount the checkout before it calls `Vio.init()` — Vev does:
8368
+ * the overlay renders with the page, the key comes from its config block a
8369
+ * moment later — and then the checkout reads the return first. Each
8370
+ * connection keeps its own carts (0.33), so before the init the cart is not
8371
+ * there: `open()` throws, the checkout has no state, and nothing asks for
8372
+ * the payment methods. A Vipps payment cancelled on Alan's Vev page
8373
+ * (2026-10-29) came back to «Betalingen ble avbrutt…» over a
8374
+ * «Henter betalingsmåter…» that never ended, with no cart to pay again.
8375
+ * Never throws; does nothing when a state is already there.
8349
8376
  */
8377
+ async reopenOnceInitialized(sponsorId, checkoutId, method) {
8378
+ try {
8379
+ if (!Configuration.isInitialized && !await Configuration.whenReady(_VioCheckout.RETURN_INIT_WAIT_MS)) return;
8380
+ if (this.checkoutState) return;
8381
+ const spId = this.returnSponsorOf(sponsorId, checkoutId);
8382
+ if (!spId) return;
8383
+ Vio.checkout.open(spId);
8384
+ Vio.checkout.selectPaymentMethod(method);
8385
+ } catch {
8386
+ }
8387
+ }
8388
+ returnSponsorOf(sponsorId, checkoutId) {
8389
+ if (sponsorId > 0) return sponsorId;
8390
+ const remembered = rememberedCheckoutSponsor(checkoutId || void 0)?.sponsorId;
8391
+ if (remembered) return remembered;
8392
+ return [...Vio.cart.getAllCarts().keys()][0] || 0;
8393
+ }
8350
8394
  setOrderSponsor(sponsorId, checkoutId) {
8351
8395
  try {
8352
8396
  const checkout = checkoutId || void 0;
@@ -9627,7 +9671,14 @@ var _VioCheckout = class _VioCheckout extends LitElement {
9627
9671
  Vennligst velg en fraktmetode for å fullføre betalingen
9628
9672
  </div>
9629
9673
  ` : ""}
9630
- ` : !this.paymentMethodsResolved ? html`
9674
+ ` : !this.checkoutState ? (
9675
+ // Nothing to ask the methods for (loadAvailablePaymentMethods
9676
+ // needs a checkout): the spinner would never end.
9677
+ html`
9678
+ <h3 class="section-heading">Velg betalingsmåte</h3>
9679
+ <p class="payment-loading">${EMPTY_CART_MESSAGE2}</p>
9680
+ `
9681
+ ) : !this.paymentMethodsResolved ? html`
9631
9682
  <h3 class="section-heading">Velg betalingsmåte</h3>
9632
9683
  <div class="payment-loading">
9633
9684
  <span class="payment-spinner" aria-hidden="true"></span>
@@ -9928,5 +9979,5 @@ function registerVioElements() {
9928
9979
  }
9929
9980
 
9930
9981
  export { VioCart, VioCheckout, VioProduct, VioProductCarousel, VioProductDetail, VioTokens, applyVioTheme, registerVioElements };
9931
- //# sourceMappingURL=chunk-LDA7RI43.js.map
9932
- //# sourceMappingURL=chunk-LDA7RI43.js.map
9982
+ //# sourceMappingURL=chunk-2OHYZI3P.js.map
9983
+ //# sourceMappingURL=chunk-2OHYZI3P.js.map