@vio-live/web-sdk 0.5.1 → 0.7.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.
- package/dist/{chunk-7Q4MJ5NQ.js → chunk-4ZEN4J7I.js} +230 -10
- package/dist/chunk-4ZEN4J7I.js.map +1 -0
- package/dist/{chunk-LRXVUOEG.js → chunk-GPMDZSC2.js} +246 -6
- package/dist/{chunk-LRXVUOEG.js.map → chunk-GPMDZSC2.js.map} +1 -1
- package/dist/core/index.d.ts +207 -100
- package/dist/core/index.js +1 -1
- package/dist/index.js +1 -1
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +3 -3
- package/dist/{tokens-TIH4RkPl.d.ts → tokens-CCZuuTN6.d.ts} +12 -0
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-7Q4MJ5NQ.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Vio, __decorateClass, primaryImageUrl, displayPrice, getGlobalCurrency, formatPrice } from './chunk-
|
|
1
|
+
import { Vio, __decorateClass, primaryImageUrl, displayPrice, getGlobalCurrency, formatPrice } from './chunk-4ZEN4J7I.js';
|
|
2
2
|
import { LitElement, css, html } from 'lit';
|
|
3
3
|
import { property, state, query } from 'lit/decorators.js';
|
|
4
4
|
|
|
@@ -2823,6 +2823,10 @@ var _VioCheckout = class _VioCheckout extends LitElement {
|
|
|
2823
2823
|
this.selectedShipping = "";
|
|
2824
2824
|
this.availableShippingsList = [];
|
|
2825
2825
|
this.availableMethods = null;
|
|
2826
|
+
this.kustomMounting = false;
|
|
2827
|
+
this.kustomMountedOrderId = null;
|
|
2828
|
+
this.qliroMounting = false;
|
|
2829
|
+
this.qliroMountedOrderId = null;
|
|
2826
2830
|
this.stripeLoading = false;
|
|
2827
2831
|
this.vippsLoading = false;
|
|
2828
2832
|
this.form = {
|
|
@@ -3499,6 +3503,121 @@ var _VioCheckout = class _VioCheckout extends LitElement {
|
|
|
3499
3503
|
const sponsorId = Number(urlParams.get("vio_sponsor") || 0);
|
|
3500
3504
|
const checkoutId = urlParams.get("checkout_id") || "";
|
|
3501
3505
|
if (!vioPayment && !checkoutId) return;
|
|
3506
|
+
const kustomOrderId = urlParams.get("order_id") || "";
|
|
3507
|
+
if (urlParams.get("payment_processor") === "KUSTOM" && kustomOrderId) {
|
|
3508
|
+
if (!this.checkoutState) {
|
|
3509
|
+
const spIdToUse = sponsorId || [...Vio.cart.getAllCarts().keys()][0] || 0;
|
|
3510
|
+
if (spIdToUse) {
|
|
3511
|
+
try {
|
|
3512
|
+
Vio.checkout.open(spIdToUse);
|
|
3513
|
+
} catch {
|
|
3514
|
+
}
|
|
3515
|
+
}
|
|
3516
|
+
}
|
|
3517
|
+
try {
|
|
3518
|
+
Vio.checkout.selectPaymentMethod("kustom");
|
|
3519
|
+
} catch {
|
|
3520
|
+
}
|
|
3521
|
+
this.open = true;
|
|
3522
|
+
this.paymentNotice = "Bekrefter betalingen\u2026";
|
|
3523
|
+
try {
|
|
3524
|
+
const order = await Vio.checkout.getKustomOrder(
|
|
3525
|
+
kustomOrderId,
|
|
3526
|
+
this.checkoutState?.sponsorId
|
|
3527
|
+
);
|
|
3528
|
+
this.paymentNotice = null;
|
|
3529
|
+
if (order?.html_snippet) {
|
|
3530
|
+
this.kustomMountedOrderId = order.order_id;
|
|
3531
|
+
await this.updateComplete;
|
|
3532
|
+
const container = this.renderRoot?.querySelector(
|
|
3533
|
+
"#vio-kustom-checkout-container"
|
|
3534
|
+
);
|
|
3535
|
+
if (container) {
|
|
3536
|
+
Vio.checkout.renderKustomSnippet(container, order.html_snippet);
|
|
3537
|
+
}
|
|
3538
|
+
if (order.status === "checkout_complete") {
|
|
3539
|
+
this.dispatchEvent(
|
|
3540
|
+
new CustomEvent("vio:payment-success", {
|
|
3541
|
+
detail: { method: "kustom", orderId: order.order_id },
|
|
3542
|
+
bubbles: true,
|
|
3543
|
+
composed: true
|
|
3544
|
+
})
|
|
3545
|
+
);
|
|
3546
|
+
const spId = this.checkoutState?.sponsorId;
|
|
3547
|
+
if (spId) {
|
|
3548
|
+
try {
|
|
3549
|
+
Vio.cart.clearSponsorCart(spId);
|
|
3550
|
+
} catch {
|
|
3551
|
+
}
|
|
3552
|
+
}
|
|
3553
|
+
}
|
|
3554
|
+
}
|
|
3555
|
+
} catch (err) {
|
|
3556
|
+
this.paymentNotice = null;
|
|
3557
|
+
if (typeof console !== "undefined") {
|
|
3558
|
+
console.warn("[VioCheckout] Kustom confirmation read failed:", err);
|
|
3559
|
+
}
|
|
3560
|
+
}
|
|
3561
|
+
this.cleanReturnQueryParams(["order_id", "payment_processor"]);
|
|
3562
|
+
return;
|
|
3563
|
+
}
|
|
3564
|
+
if (urlParams.get("payment_processor") === "QLIRO" && checkoutId) {
|
|
3565
|
+
if (!this.checkoutState) {
|
|
3566
|
+
const spIdToUse = sponsorId || [...Vio.cart.getAllCarts().keys()][0] || 0;
|
|
3567
|
+
if (spIdToUse) {
|
|
3568
|
+
try {
|
|
3569
|
+
Vio.checkout.open(spIdToUse);
|
|
3570
|
+
} catch {
|
|
3571
|
+
}
|
|
3572
|
+
}
|
|
3573
|
+
}
|
|
3574
|
+
try {
|
|
3575
|
+
Vio.checkout.selectPaymentMethod("qliro");
|
|
3576
|
+
} catch {
|
|
3577
|
+
}
|
|
3578
|
+
this.open = true;
|
|
3579
|
+
this.paymentNotice = "Bekrefter betalingen\u2026";
|
|
3580
|
+
try {
|
|
3581
|
+
const order = await Vio.checkout.getQliroOrder(
|
|
3582
|
+
checkoutId,
|
|
3583
|
+
this.checkoutState?.sponsorId
|
|
3584
|
+
);
|
|
3585
|
+
this.paymentNotice = null;
|
|
3586
|
+
if (order?.html_snippet) {
|
|
3587
|
+
this.qliroMountedOrderId = order.order_id;
|
|
3588
|
+
await this.updateComplete;
|
|
3589
|
+
const container = this.renderRoot?.querySelector(
|
|
3590
|
+
"#vio-qliro-checkout-container"
|
|
3591
|
+
);
|
|
3592
|
+
if (container) {
|
|
3593
|
+
Vio.checkout.renderKustomSnippet(container, order.html_snippet);
|
|
3594
|
+
}
|
|
3595
|
+
if (order.status === "Completed") {
|
|
3596
|
+
this.dispatchEvent(
|
|
3597
|
+
new CustomEvent("vio:payment-success", {
|
|
3598
|
+
detail: { method: "qliro", orderId: order.order_id },
|
|
3599
|
+
bubbles: true,
|
|
3600
|
+
composed: true
|
|
3601
|
+
})
|
|
3602
|
+
);
|
|
3603
|
+
const spId = this.checkoutState?.sponsorId;
|
|
3604
|
+
if (spId) {
|
|
3605
|
+
try {
|
|
3606
|
+
Vio.cart.clearSponsorCart(spId);
|
|
3607
|
+
} catch {
|
|
3608
|
+
}
|
|
3609
|
+
}
|
|
3610
|
+
}
|
|
3611
|
+
}
|
|
3612
|
+
} catch (err) {
|
|
3613
|
+
this.paymentNotice = null;
|
|
3614
|
+
if (typeof console !== "undefined") {
|
|
3615
|
+
console.warn("[VioCheckout] Qliro confirmation read failed:", err);
|
|
3616
|
+
}
|
|
3617
|
+
}
|
|
3618
|
+
this.cleanReturnQueryParams(["checkout_id", "payment_processor"]);
|
|
3619
|
+
return;
|
|
3620
|
+
}
|
|
3502
3621
|
if (vioMethod === "klarna" && typeof sessionStorage !== "undefined" && sessionStorage.getItem("vio.klarna.pending.v1")) {
|
|
3503
3622
|
this.cleanReturnQueryParams(["vio_payment", "vio_method", "vio_sponsor", "checkout_id"]);
|
|
3504
3623
|
return;
|
|
@@ -3593,6 +3712,8 @@ var _VioCheckout = class _VioCheckout extends LitElement {
|
|
|
3593
3712
|
void this.loadAvailableShippings();
|
|
3594
3713
|
}
|
|
3595
3714
|
void this.mountKlarnaIfNeeded();
|
|
3715
|
+
void this.mountKustomIfNeeded();
|
|
3716
|
+
void this.mountQliroIfNeeded();
|
|
3596
3717
|
}
|
|
3597
3718
|
close() {
|
|
3598
3719
|
this.open = false;
|
|
@@ -3829,6 +3950,14 @@ var _VioCheckout = class _VioCheckout extends LitElement {
|
|
|
3829
3950
|
void this.onApplePay();
|
|
3830
3951
|
return;
|
|
3831
3952
|
}
|
|
3953
|
+
if (method === "kustom") {
|
|
3954
|
+
Vio.checkout.selectPaymentMethod("kustom");
|
|
3955
|
+
return;
|
|
3956
|
+
}
|
|
3957
|
+
if (method === "qliro") {
|
|
3958
|
+
Vio.checkout.selectPaymentMethod("qliro");
|
|
3959
|
+
return;
|
|
3960
|
+
}
|
|
3832
3961
|
if (method === "vipps") {
|
|
3833
3962
|
const email = String(this.form.email ?? "").trim();
|
|
3834
3963
|
if (!email || !email.includes("@")) {
|
|
@@ -3930,6 +4059,10 @@ var _VioCheckout = class _VioCheckout extends LitElement {
|
|
|
3930
4059
|
return "Apple Pay";
|
|
3931
4060
|
case "klarna":
|
|
3932
4061
|
return "Klarna";
|
|
4062
|
+
case "kustom":
|
|
4063
|
+
return "Kustom";
|
|
4064
|
+
case "qliro":
|
|
4065
|
+
return "Qliro";
|
|
3933
4066
|
case "vipps":
|
|
3934
4067
|
return "Vipps";
|
|
3935
4068
|
case "stripe":
|
|
@@ -3942,7 +4075,7 @@ var _VioCheckout = class _VioCheckout extends LitElement {
|
|
|
3942
4075
|
}
|
|
3943
4076
|
/** True for methods that complete via a separate sheet/widget, not the CTA. */
|
|
3944
4077
|
isExpressMethod(method) {
|
|
3945
|
-
return method === "apple-pay" || method === "klarna";
|
|
4078
|
+
return method === "apple-pay" || method === "klarna" || method === "kustom" || method === "qliro";
|
|
3946
4079
|
}
|
|
3947
4080
|
orderTotal() {
|
|
3948
4081
|
const s = this.checkoutState;
|
|
@@ -4014,6 +4147,92 @@ var _VioCheckout = class _VioCheckout extends LitElement {
|
|
|
4014
4147
|
`;
|
|
4015
4148
|
}
|
|
4016
4149
|
/** Klarna Payments widget panel: shipping + category chips + widget + pay button. */
|
|
4150
|
+
/** Mount the Kustom embedded checkout once it's the chosen method. */
|
|
4151
|
+
async mountKustomIfNeeded() {
|
|
4152
|
+
if (!this.open || !this.checkoutState) return;
|
|
4153
|
+
if (this.checkoutState.paymentMethod !== "kustom") return;
|
|
4154
|
+
if (this.kustomMounting) return;
|
|
4155
|
+
const container = this.renderRoot?.querySelector(
|
|
4156
|
+
"#vio-kustom-checkout-container"
|
|
4157
|
+
);
|
|
4158
|
+
if (!container) return;
|
|
4159
|
+
if (this.kustomMountedOrderId && container.childElementCount > 0) return;
|
|
4160
|
+
this.kustomMounting = true;
|
|
4161
|
+
container.innerHTML = "";
|
|
4162
|
+
try {
|
|
4163
|
+
const order = await Vio.checkout.mountKustomCheckout(
|
|
4164
|
+
container,
|
|
4165
|
+
this.checkoutState.sponsorId
|
|
4166
|
+
);
|
|
4167
|
+
this.kustomMountedOrderId = order.order_id;
|
|
4168
|
+
} catch (err) {
|
|
4169
|
+
if (typeof console !== "undefined") {
|
|
4170
|
+
console.warn("[VioCheckout] Kustom mount failed:", err);
|
|
4171
|
+
}
|
|
4172
|
+
this.paymentError = `Kunne ikke laste Kustom: ${err instanceof Error ? err.message : String(err)}`;
|
|
4173
|
+
Vio.checkout.selectPaymentMethod("");
|
|
4174
|
+
} finally {
|
|
4175
|
+
this.kustomMounting = false;
|
|
4176
|
+
}
|
|
4177
|
+
}
|
|
4178
|
+
unmountKustom() {
|
|
4179
|
+
this.kustomMountedOrderId = null;
|
|
4180
|
+
const container = this.renderRoot?.querySelector(
|
|
4181
|
+
"#vio-kustom-checkout-container"
|
|
4182
|
+
);
|
|
4183
|
+
if (container) container.innerHTML = "";
|
|
4184
|
+
}
|
|
4185
|
+
renderKustomPanel() {
|
|
4186
|
+
return html`
|
|
4187
|
+
<div class="kustom-panel">
|
|
4188
|
+
${this.kustomMounting ? html`<div style="font-size:13px;opacity:0.7;padding:8px 0;">Laster Kustom…</div>` : ""}
|
|
4189
|
+
<div id="vio-kustom-checkout-container"></div>
|
|
4190
|
+
</div>
|
|
4191
|
+
`;
|
|
4192
|
+
}
|
|
4193
|
+
/** Mount the Qliro embedded checkout once it's the chosen method. */
|
|
4194
|
+
async mountQliroIfNeeded() {
|
|
4195
|
+
if (!this.open || !this.checkoutState) return;
|
|
4196
|
+
if (this.checkoutState.paymentMethod !== "qliro") return;
|
|
4197
|
+
if (this.qliroMounting) return;
|
|
4198
|
+
const container = this.renderRoot?.querySelector(
|
|
4199
|
+
"#vio-qliro-checkout-container"
|
|
4200
|
+
);
|
|
4201
|
+
if (!container) return;
|
|
4202
|
+
if (this.qliroMountedOrderId && container.childElementCount > 0) return;
|
|
4203
|
+
this.qliroMounting = true;
|
|
4204
|
+
container.innerHTML = "";
|
|
4205
|
+
try {
|
|
4206
|
+
const order = await Vio.checkout.mountQliroCheckout(
|
|
4207
|
+
container,
|
|
4208
|
+
this.checkoutState.sponsorId
|
|
4209
|
+
);
|
|
4210
|
+
this.qliroMountedOrderId = order.order_id;
|
|
4211
|
+
} catch (err) {
|
|
4212
|
+
if (typeof console !== "undefined") {
|
|
4213
|
+
console.warn("[VioCheckout] Qliro mount failed:", err);
|
|
4214
|
+
}
|
|
4215
|
+
this.paymentError = `Kunne ikke laste Qliro: ${err instanceof Error ? err.message : String(err)}`;
|
|
4216
|
+
Vio.checkout.selectPaymentMethod("");
|
|
4217
|
+
} finally {
|
|
4218
|
+
this.qliroMounting = false;
|
|
4219
|
+
}
|
|
4220
|
+
}
|
|
4221
|
+
unmountQliro() {
|
|
4222
|
+
this.qliroMountedOrderId = null;
|
|
4223
|
+
const container = this.renderRoot?.querySelector(
|
|
4224
|
+
"#vio-qliro-checkout-container"
|
|
4225
|
+
);
|
|
4226
|
+
if (container) container.innerHTML = "";
|
|
4227
|
+
}
|
|
4228
|
+
renderQliroPanel() {
|
|
4229
|
+
return html`
|
|
4230
|
+
<div class="qliro-panel">
|
|
4231
|
+
${this.qliroMounting ? html`<div style="font-size:13px;opacity:0.7;padding:8px 0;">Laster Qliro…</div>` : ""}
|
|
4232
|
+
<div id="vio-qliro-checkout-container"></div>
|
|
4233
|
+
</div>
|
|
4234
|
+
`;
|
|
4235
|
+
}
|
|
4017
4236
|
renderKlarnaPanel() {
|
|
4018
4237
|
const currency = this.checkoutState?.currency || getGlobalCurrency();
|
|
4019
4238
|
return html`
|
|
@@ -4123,8 +4342,9 @@ var _VioCheckout = class _VioCheckout extends LitElement {
|
|
|
4123
4342
|
const method = this.checkoutState?.paymentMethod;
|
|
4124
4343
|
const showCompleteCta = !!method && !this.isExpressMethod(method);
|
|
4125
4344
|
const isVipps = method === "vipps";
|
|
4345
|
+
const isKustom = method === "kustom" || method === "qliro";
|
|
4126
4346
|
return html`
|
|
4127
|
-
${!isVipps ? html`
|
|
4347
|
+
${!isVipps && !isKustom ? html`
|
|
4128
4348
|
<section class="section">
|
|
4129
4349
|
<div class="section-label">Steg 1</div>
|
|
4130
4350
|
<h3 class="section-heading">Leveringsadresse</h3>
|
|
@@ -4241,7 +4461,7 @@ var _VioCheckout = class _VioCheckout extends LitElement {
|
|
|
4241
4461
|
` : ""}
|
|
4242
4462
|
|
|
4243
4463
|
<section class="section">
|
|
4244
|
-
<div class="section-label">${isVipps ? "Betaling" : "Steg 2"}</div>
|
|
4464
|
+
<div class="section-label">${isVipps || isKustom ? "Betaling" : "Steg 2"}</div>
|
|
4245
4465
|
${method ? html`
|
|
4246
4466
|
<div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px;">
|
|
4247
4467
|
<h3 class="section-heading" style="margin:0;">
|
|
@@ -4252,6 +4472,8 @@ var _VioCheckout = class _VioCheckout extends LitElement {
|
|
|
4252
4472
|
style="background:none; border:none; color:var(--vio-color-accent, #c14a3b); text-decoration:underline; font-size:13px; cursor:pointer;"
|
|
4253
4473
|
@click=${() => {
|
|
4254
4474
|
this.unmountKlarna();
|
|
4475
|
+
this.unmountKustom();
|
|
4476
|
+
this.unmountQliro();
|
|
4255
4477
|
Vio.checkout.selectPaymentMethod("");
|
|
4256
4478
|
}}
|
|
4257
4479
|
>
|
|
@@ -4260,6 +4482,8 @@ var _VioCheckout = class _VioCheckout extends LitElement {
|
|
|
4260
4482
|
</div>
|
|
4261
4483
|
|
|
4262
4484
|
${method === "klarna" ? this.renderKlarnaPanel() : ""}
|
|
4485
|
+
${method === "kustom" ? this.renderKustomPanel() : ""}
|
|
4486
|
+
${method === "qliro" ? this.renderQliroPanel() : ""}
|
|
4263
4487
|
${method === "stripe" ? html`
|
|
4264
4488
|
<button
|
|
4265
4489
|
class="payment-btn primary complete-cta"
|
|
@@ -4334,6 +4558,16 @@ var _VioCheckout = class _VioCheckout extends LitElement {
|
|
|
4334
4558
|
Klarna
|
|
4335
4559
|
</button>
|
|
4336
4560
|
` : ""}
|
|
4561
|
+
${this.methodEnabled("kustom") ? html`
|
|
4562
|
+
<button class="payment-btn" @click=${() => this.onPay("kustom")}>
|
|
4563
|
+
<span style="font-weight:800;font-size:16px;letter-spacing:-0.01em">Kustom</span>
|
|
4564
|
+
</button>
|
|
4565
|
+
` : ""}
|
|
4566
|
+
${this.methodEnabled("qliro") ? html`
|
|
4567
|
+
<button class="payment-btn" @click=${() => this.onPay("qliro")}>
|
|
4568
|
+
<span style="font-weight:800;font-size:16px;letter-spacing:-0.01em">Qliro</span>
|
|
4569
|
+
</button>
|
|
4570
|
+
` : ""}
|
|
4337
4571
|
${this.methodEnabled("vipps") ? html`
|
|
4338
4572
|
<button class="payment-btn" @click=${() => this.onPay("vipps")}>
|
|
4339
4573
|
<span style="color:#ff5b24;font-weight:800;font-size:17px;letter-spacing:-0.02em">vipps</span>
|
|
@@ -4446,6 +4680,12 @@ __decorateClass([
|
|
|
4446
4680
|
__decorateClass([
|
|
4447
4681
|
state()
|
|
4448
4682
|
], _VioCheckout.prototype, "availableMethods", 2);
|
|
4683
|
+
__decorateClass([
|
|
4684
|
+
state()
|
|
4685
|
+
], _VioCheckout.prototype, "kustomMounting", 2);
|
|
4686
|
+
__decorateClass([
|
|
4687
|
+
state()
|
|
4688
|
+
], _VioCheckout.prototype, "qliroMounting", 2);
|
|
4449
4689
|
__decorateClass([
|
|
4450
4690
|
state()
|
|
4451
4691
|
], _VioCheckout.prototype, "stripeLoading", 2);
|
|
@@ -4474,5 +4714,5 @@ function registerVioElements() {
|
|
|
4474
4714
|
}
|
|
4475
4715
|
|
|
4476
4716
|
export { VioCart, VioCheckout, VioProduct, VioProductCarousel, VioProductDetail, VioTokens, applyVioTheme, registerVioElements };
|
|
4477
|
-
//# sourceMappingURL=chunk-
|
|
4478
|
-
//# sourceMappingURL=chunk-
|
|
4717
|
+
//# sourceMappingURL=chunk-GPMDZSC2.js.map
|
|
4718
|
+
//# sourceMappingURL=chunk-GPMDZSC2.js.map
|