@vio-live/web-sdk 0.7.0 → 0.9.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.
@@ -1,4 +1,4 @@
1
- import { Vio, __decorateClass, primaryImageUrl, displayPrice, getGlobalCurrency, formatPrice } from './chunk-4ZEN4J7I.js';
1
+ import { Vio, __decorateClass, primaryImageUrl, displayPrice, getGlobalCurrency, formatPrice } from './chunk-SNIF67UB.js';
2
2
  import { LitElement, css, html } from 'lit';
3
3
  import { property, state, query } from 'lit/decorators.js';
4
4
 
@@ -69,6 +69,8 @@ var VioTokens = {
69
69
  sm: "2px",
70
70
  md: "4px",
71
71
  lg: "8px",
72
+ /** Sheet/drawer corners — the largest surface radius in the checkout. */
73
+ xl: "16px",
72
74
  full: "9999px"
73
75
  }
74
76
  };
@@ -117,6 +119,7 @@ var VIO_TOKENS_CSS = `
117
119
  --vio-radius-sm: ${VioTokens.radius.sm};
118
120
  --vio-radius-md: ${VioTokens.radius.md};
119
121
  --vio-radius-lg: ${VioTokens.radius.lg};
122
+ --vio-radius-xl: ${VioTokens.radius.xl};
120
123
  }
121
124
  `;
122
125
  function injectTokens() {
@@ -140,7 +143,15 @@ var THEME_KEY_TO_CSS_VAR = {
140
143
  colorBorder: "--vio-color-border",
141
144
  colorBorderDefault: "--vio-color-border-default",
142
145
  fontSerif: "--vio-font-serif",
143
- fontSans: "--vio-font-sans"
146
+ fontSans: "--vio-font-sans",
147
+ radiusSm: "--vio-radius-sm",
148
+ radiusMd: "--vio-radius-md",
149
+ radiusLg: "--vio-radius-lg",
150
+ radiusXl: "--vio-radius-xl",
151
+ spaceSm: "--vio-space-sm",
152
+ spaceMd: "--vio-space-md",
153
+ spaceLg: "--vio-space-lg",
154
+ spaceXl: "--vio-space-xl"
144
155
  };
145
156
  function applyVioTheme(overrides, target = typeof document !== "undefined" ? document.documentElement : null) {
146
157
  if (!target) return;
@@ -2827,6 +2838,8 @@ var _VioCheckout = class _VioCheckout extends LitElement {
2827
2838
  this.kustomMountedOrderId = null;
2828
2839
  this.qliroMounting = false;
2829
2840
  this.qliroMountedOrderId = null;
2841
+ this.walleyMounting = false;
2842
+ this.walleyMountedOrderId = null;
2830
2843
  this.stripeLoading = false;
2831
2844
  this.vippsLoading = false;
2832
2845
  this.form = {
@@ -2920,7 +2933,7 @@ var _VioCheckout = class _VioCheckout extends LitElement {
2920
2933
  max-height: 88vh;
2921
2934
  max-width: 460px;
2922
2935
  margin: 0 auto;
2923
- border-radius: 16px 16px 0 0;
2936
+ border-radius: var(--vio-radius-xl, 16px) var(--vio-radius-xl, 16px) 0 0;
2924
2937
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.18);
2925
2938
  }
2926
2939
  .modal.as-drawer .handle {
@@ -2934,7 +2947,7 @@ var _VioCheckout = class _VioCheckout extends LitElement {
2934
2947
  width: 40px;
2935
2948
  height: 4px;
2936
2949
  background: var(--vio-color-border, #e5e5e5);
2937
- border-radius: 2px;
2950
+ border-radius: var(--vio-radius-sm, 2px);
2938
2951
  }
2939
2952
 
2940
2953
  /* Express (Apple Pay-style): right-side drawer, like the cart. Slides in
@@ -2971,7 +2984,7 @@ var _VioCheckout = class _VioCheckout extends LitElement {
2971
2984
  max-width: none;
2972
2985
  height: 92vh;
2973
2986
  transform: translateY(100%);
2974
- border-radius: 16px 16px 0 0;
2987
+ border-radius: var(--vio-radius-xl, 16px) var(--vio-radius-xl, 16px) 0 0;
2975
2988
  }
2976
2989
  :host([open]) .modal.as-side { transform: translateY(0); }
2977
2990
  }
@@ -2986,7 +2999,7 @@ var _VioCheckout = class _VioCheckout extends LitElement {
2986
2999
  max-width: 440px;
2987
3000
  height: auto;
2988
3001
  max-height: 88vh;
2989
- border-radius: 16px;
3002
+ border-radius: var(--vio-radius-xl, 16px);
2990
3003
  box-shadow: 0 30px 80px -24px rgba(0, 0, 0, 0.4);
2991
3004
  transform: translate(-50%, -50%) scale(0.96);
2992
3005
  opacity: 0;
@@ -3002,7 +3015,7 @@ var _VioCheckout = class _VioCheckout extends LitElement {
3002
3015
  left: 0;
3003
3016
  width: 100%;
3004
3017
  max-width: none;
3005
- border-radius: 16px 16px 0 0;
3018
+ border-radius: var(--vio-radius-xl, 16px) var(--vio-radius-xl, 16px) 0 0;
3006
3019
  transform: translateY(100%) scale(1);
3007
3020
  opacity: 1;
3008
3021
  }
@@ -3016,7 +3029,7 @@ var _VioCheckout = class _VioCheckout extends LitElement {
3016
3029
  .modal {
3017
3030
  top: auto;
3018
3031
  height: 92vh;
3019
- border-radius: 16px 16px 0 0;
3032
+ border-radius: var(--vio-radius-xl, 16px) var(--vio-radius-xl, 16px) 0 0;
3020
3033
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.08);
3021
3034
  }
3022
3035
  .handle {
@@ -3030,7 +3043,7 @@ var _VioCheckout = class _VioCheckout extends LitElement {
3030
3043
  width: 40px;
3031
3044
  height: 4px;
3032
3045
  background: var(--vio-color-border, #e5e5e5);
3033
- border-radius: 2px;
3046
+ border-radius: var(--vio-radius-sm, 2px);
3034
3047
  }
3035
3048
  }
3036
3049
 
@@ -3186,7 +3199,7 @@ var _VioCheckout = class _VioCheckout extends LitElement {
3186
3199
  flex: 1 1 auto;
3187
3200
  padding: 8px 12px;
3188
3201
  border: 1px solid var(--vio-color-border, #ddd);
3189
- border-radius: 8px;
3202
+ border-radius: var(--vio-radius-lg, 8px);
3190
3203
  background: #fff;
3191
3204
  font-size: 13px;
3192
3205
  cursor: pointer;
@@ -3210,7 +3223,7 @@ var _VioCheckout = class _VioCheckout extends LitElement {
3210
3223
  .ship-opt {
3211
3224
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
3212
3225
  padding: 12px 14px; border: 1px solid var(--vio-color-border, #ddd);
3213
- border-radius: 10px; background: #fff; cursor: pointer; font-family: inherit;
3226
+ border-radius: var(--vio-radius-lg, 8px); background: #fff; cursor: pointer; font-family: inherit;
3214
3227
  text-align: left;
3215
3228
  }
3216
3229
  .ship-opt.active {
@@ -3227,7 +3240,7 @@ var _VioCheckout = class _VioCheckout extends LitElement {
3227
3240
  padding: 12px 16px;
3228
3241
  background: #fdecea;
3229
3242
  border: 1px solid var(--vio-color-accent, #c14a3b);
3230
- border-radius: 8px;
3243
+ border-radius: var(--vio-radius-lg, 8px);
3231
3244
  font-size: 13px;
3232
3245
  color: var(--vio-color-accent, #c14a3b);
3233
3246
  text-align: center;
@@ -3237,7 +3250,7 @@ var _VioCheckout = class _VioCheckout extends LitElement {
3237
3250
  padding: 12px 16px;
3238
3251
  background: #f4f4f2;
3239
3252
  border: 1px solid var(--vio-color-border, #ddd);
3240
- border-radius: 8px;
3253
+ border-radius: var(--vio-radius-lg, 8px);
3241
3254
  font-size: 13px;
3242
3255
  color: var(--vio-color-text, #1a1a1a);
3243
3256
  text-align: center;
@@ -3618,6 +3631,63 @@ var _VioCheckout = class _VioCheckout extends LitElement {
3618
3631
  this.cleanReturnQueryParams(["checkout_id", "payment_processor"]);
3619
3632
  return;
3620
3633
  }
3634
+ if (urlParams.get("payment_processor") === "WALLEY" && checkoutId) {
3635
+ if (!this.checkoutState) {
3636
+ const spIdToUse = sponsorId || [...Vio.cart.getAllCarts().keys()][0] || 0;
3637
+ if (spIdToUse) {
3638
+ try {
3639
+ Vio.checkout.open(spIdToUse);
3640
+ } catch {
3641
+ }
3642
+ }
3643
+ }
3644
+ try {
3645
+ Vio.checkout.selectPaymentMethod("walley");
3646
+ } catch {
3647
+ }
3648
+ this.open = true;
3649
+ this.paymentNotice = "Bekrefter betalingen\u2026";
3650
+ try {
3651
+ const order = await Vio.checkout.getWalleyOrder(
3652
+ checkoutId,
3653
+ this.checkoutState?.sponsorId
3654
+ );
3655
+ this.paymentNotice = null;
3656
+ if (order?.html_snippet) {
3657
+ this.walleyMountedOrderId = order.order_id;
3658
+ await this.updateComplete;
3659
+ const container = this.renderRoot?.querySelector(
3660
+ "#vio-walley-checkout-container"
3661
+ );
3662
+ if (container) {
3663
+ Vio.checkout.renderKustomSnippet(container, order.html_snippet);
3664
+ }
3665
+ if (order.status === "PurchaseCompleted") {
3666
+ this.dispatchEvent(
3667
+ new CustomEvent("vio:payment-success", {
3668
+ detail: { method: "walley", orderId: order.order_id },
3669
+ bubbles: true,
3670
+ composed: true
3671
+ })
3672
+ );
3673
+ const spId = this.checkoutState?.sponsorId;
3674
+ if (spId) {
3675
+ try {
3676
+ Vio.cart.clearSponsorCart(spId);
3677
+ } catch {
3678
+ }
3679
+ }
3680
+ }
3681
+ }
3682
+ } catch (err) {
3683
+ this.paymentNotice = null;
3684
+ if (typeof console !== "undefined") {
3685
+ console.warn("[VioCheckout] Walley confirmation read failed:", err);
3686
+ }
3687
+ }
3688
+ this.cleanReturnQueryParams(["checkout_id", "payment_processor"]);
3689
+ return;
3690
+ }
3621
3691
  if (vioMethod === "klarna" && typeof sessionStorage !== "undefined" && sessionStorage.getItem("vio.klarna.pending.v1")) {
3622
3692
  this.cleanReturnQueryParams(["vio_payment", "vio_method", "vio_sponsor", "checkout_id"]);
3623
3693
  return;
@@ -3714,6 +3784,7 @@ var _VioCheckout = class _VioCheckout extends LitElement {
3714
3784
  void this.mountKlarnaIfNeeded();
3715
3785
  void this.mountKustomIfNeeded();
3716
3786
  void this.mountQliroIfNeeded();
3787
+ void this.mountWalleyIfNeeded();
3717
3788
  }
3718
3789
  close() {
3719
3790
  this.open = false;
@@ -3958,6 +4029,10 @@ var _VioCheckout = class _VioCheckout extends LitElement {
3958
4029
  Vio.checkout.selectPaymentMethod("qliro");
3959
4030
  return;
3960
4031
  }
4032
+ if (method === "walley") {
4033
+ Vio.checkout.selectPaymentMethod("walley");
4034
+ return;
4035
+ }
3961
4036
  if (method === "vipps") {
3962
4037
  const email = String(this.form.email ?? "").trim();
3963
4038
  if (!email || !email.includes("@")) {
@@ -4063,6 +4138,8 @@ var _VioCheckout = class _VioCheckout extends LitElement {
4063
4138
  return "Kustom";
4064
4139
  case "qliro":
4065
4140
  return "Qliro";
4141
+ case "walley":
4142
+ return "Walley";
4066
4143
  case "vipps":
4067
4144
  return "Vipps";
4068
4145
  case "stripe":
@@ -4075,7 +4152,7 @@ var _VioCheckout = class _VioCheckout extends LitElement {
4075
4152
  }
4076
4153
  /** True for methods that complete via a separate sheet/widget, not the CTA. */
4077
4154
  isExpressMethod(method) {
4078
- return method === "apple-pay" || method === "klarna" || method === "kustom" || method === "qliro";
4155
+ return method === "apple-pay" || method === "klarna" || method === "kustom" || method === "qliro" || method === "walley";
4079
4156
  }
4080
4157
  orderTotal() {
4081
4158
  const s = this.checkoutState;
@@ -4233,6 +4310,70 @@ var _VioCheckout = class _VioCheckout extends LitElement {
4233
4310
  </div>
4234
4311
  `;
4235
4312
  }
4313
+ /**
4314
+ * Mount the Walley embedded checkout once it's the chosen method. Unlike
4315
+ * Kustom/Qliro, success is signalled INLINE by Walley's own DOM event
4316
+ * (`walleyCheckoutPurchaseCompleted`) — no redirect round-trip needed, so
4317
+ * we handle it here instead of only in the confirmation-return branch.
4318
+ */
4319
+ async mountWalleyIfNeeded() {
4320
+ if (!this.open || !this.checkoutState) return;
4321
+ if (this.checkoutState.paymentMethod !== "walley") return;
4322
+ if (this.walleyMounting) return;
4323
+ const container = this.renderRoot?.querySelector(
4324
+ "#vio-walley-checkout-container"
4325
+ );
4326
+ if (!container) return;
4327
+ if (this.walleyMountedOrderId && container.childElementCount > 0) return;
4328
+ this.walleyMounting = true;
4329
+ container.innerHTML = "";
4330
+ try {
4331
+ const order = await Vio.checkout.mountWalleyCheckout(
4332
+ container,
4333
+ this.checkoutState.sponsorId,
4334
+ () => {
4335
+ this.dispatchEvent(
4336
+ new CustomEvent("vio:payment-success", {
4337
+ detail: { method: "walley", orderId: order.order_id },
4338
+ bubbles: true,
4339
+ composed: true
4340
+ })
4341
+ );
4342
+ const spId = this.checkoutState?.sponsorId;
4343
+ if (spId) {
4344
+ try {
4345
+ Vio.cart.clearSponsorCart(spId);
4346
+ } catch {
4347
+ }
4348
+ }
4349
+ }
4350
+ );
4351
+ this.walleyMountedOrderId = order.order_id;
4352
+ } catch (err) {
4353
+ if (typeof console !== "undefined") {
4354
+ console.warn("[VioCheckout] Walley mount failed:", err);
4355
+ }
4356
+ this.paymentError = `Kunne ikke laste Walley: ${err instanceof Error ? err.message : String(err)}`;
4357
+ Vio.checkout.selectPaymentMethod("");
4358
+ } finally {
4359
+ this.walleyMounting = false;
4360
+ }
4361
+ }
4362
+ unmountWalley() {
4363
+ this.walleyMountedOrderId = null;
4364
+ const container = this.renderRoot?.querySelector(
4365
+ "#vio-walley-checkout-container"
4366
+ );
4367
+ if (container) container.innerHTML = "";
4368
+ }
4369
+ renderWalleyPanel() {
4370
+ return html`
4371
+ <div class="walley-panel">
4372
+ ${this.walleyMounting ? html`<div style="font-size:13px;opacity:0.7;padding:8px 0;">Laster Walley…</div>` : ""}
4373
+ <div id="vio-walley-checkout-container"></div>
4374
+ </div>
4375
+ `;
4376
+ }
4236
4377
  renderKlarnaPanel() {
4237
4378
  const currency = this.checkoutState?.currency || getGlobalCurrency();
4238
4379
  return html`
@@ -4342,7 +4483,7 @@ var _VioCheckout = class _VioCheckout extends LitElement {
4342
4483
  const method = this.checkoutState?.paymentMethod;
4343
4484
  const showCompleteCta = !!method && !this.isExpressMethod(method);
4344
4485
  const isVipps = method === "vipps";
4345
- const isKustom = method === "kustom" || method === "qliro";
4486
+ const isKustom = method === "kustom" || method === "qliro" || method === "walley";
4346
4487
  return html`
4347
4488
  ${!isVipps && !isKustom ? html`
4348
4489
  <section class="section">
@@ -4474,6 +4615,7 @@ var _VioCheckout = class _VioCheckout extends LitElement {
4474
4615
  this.unmountKlarna();
4475
4616
  this.unmountKustom();
4476
4617
  this.unmountQliro();
4618
+ this.unmountWalley();
4477
4619
  Vio.checkout.selectPaymentMethod("");
4478
4620
  }}
4479
4621
  >
@@ -4484,6 +4626,7 @@ var _VioCheckout = class _VioCheckout extends LitElement {
4484
4626
  ${method === "klarna" ? this.renderKlarnaPanel() : ""}
4485
4627
  ${method === "kustom" ? this.renderKustomPanel() : ""}
4486
4628
  ${method === "qliro" ? this.renderQliroPanel() : ""}
4629
+ ${method === "walley" ? this.renderWalleyPanel() : ""}
4487
4630
  ${method === "stripe" ? html`
4488
4631
  <button
4489
4632
  class="payment-btn primary complete-cta"
@@ -4568,6 +4711,11 @@ var _VioCheckout = class _VioCheckout extends LitElement {
4568
4711
  <span style="font-weight:800;font-size:16px;letter-spacing:-0.01em">Qliro</span>
4569
4712
  </button>
4570
4713
  ` : ""}
4714
+ ${this.methodEnabled("walley") ? html`
4715
+ <button class="payment-btn" @click=${() => this.onPay("walley")}>
4716
+ <span style="font-weight:800;font-size:16px;letter-spacing:-0.01em">Walley</span>
4717
+ </button>
4718
+ ` : ""}
4571
4719
  ${this.methodEnabled("vipps") ? html`
4572
4720
  <button class="payment-btn" @click=${() => this.onPay("vipps")}>
4573
4721
  <span style="color:#ff5b24;font-weight:800;font-size:17px;letter-spacing:-0.02em">vipps</span>
@@ -4686,6 +4834,9 @@ __decorateClass([
4686
4834
  __decorateClass([
4687
4835
  state()
4688
4836
  ], _VioCheckout.prototype, "qliroMounting", 2);
4837
+ __decorateClass([
4838
+ state()
4839
+ ], _VioCheckout.prototype, "walleyMounting", 2);
4689
4840
  __decorateClass([
4690
4841
  state()
4691
4842
  ], _VioCheckout.prototype, "stripeLoading", 2);
@@ -4714,5 +4865,5 @@ function registerVioElements() {
4714
4865
  }
4715
4866
 
4716
4867
  export { VioCart, VioCheckout, VioProduct, VioProductCarousel, VioProductDetail, VioTokens, applyVioTheme, registerVioElements };
4717
- //# sourceMappingURL=chunk-GPMDZSC2.js.map
4718
- //# sourceMappingURL=chunk-GPMDZSC2.js.map
4868
+ //# sourceMappingURL=chunk-OTL6QM3G.js.map
4869
+ //# sourceMappingURL=chunk-OTL6QM3G.js.map