choco-one-click-payment 1.1.32 → 1.1.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +129 -116
- package/dist/index.js +6 -6
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -172,24 +172,24 @@ for (let e = 0; e < 256; ++e)
|
|
|
172
172
|
function It(e, t = 0) {
|
|
173
173
|
return H[e[t + 0]] + H[e[t + 1]] + H[e[t + 2]] + H[e[t + 3]] + "-" + H[e[t + 4]] + H[e[t + 5]] + "-" + H[e[t + 6]] + H[e[t + 7]] + "-" + H[e[t + 8]] + H[e[t + 9]] + "-" + H[e[t + 10]] + H[e[t + 11]] + H[e[t + 12]] + H[e[t + 13]] + H[e[t + 14]] + H[e[t + 15]];
|
|
174
174
|
}
|
|
175
|
-
const Qt = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto),
|
|
175
|
+
const Qt = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), We = {
|
|
176
176
|
randomUUID: Qt
|
|
177
177
|
};
|
|
178
178
|
function Be(e, t, o) {
|
|
179
|
-
if (
|
|
180
|
-
return
|
|
179
|
+
if (We.randomUUID && !e)
|
|
180
|
+
return We.randomUUID();
|
|
181
181
|
e = e || {};
|
|
182
182
|
const i = e.random || (e.rng || Bt)();
|
|
183
183
|
return i[6] = i[6] & 15 | 64, i[8] = i[8] & 63 | 128, It(i);
|
|
184
184
|
}
|
|
185
|
-
const
|
|
185
|
+
const Ve = "choco_device_id";
|
|
186
186
|
function V(e, t = "ru", o = "KZT") {
|
|
187
187
|
const i = Number(e), s = t === "ru" ? "ru-RU" : "en-US";
|
|
188
188
|
return `${i.toLocaleString(s)} ${bt[o]}`;
|
|
189
189
|
}
|
|
190
190
|
function rt() {
|
|
191
|
-
let e = localStorage.getItem(
|
|
192
|
-
return e || (e = Be(), localStorage.setItem(
|
|
191
|
+
let e = localStorage.getItem(Ve);
|
|
192
|
+
return e || (e = Be(), localStorage.setItem(Ve, e)), e;
|
|
193
193
|
}
|
|
194
194
|
function Ce() {
|
|
195
195
|
if (typeof window > "u") return !1;
|
|
@@ -201,7 +201,7 @@ function ot() {
|
|
|
201
201
|
const e = navigator.userAgent || "", t = e.indexOf("OS");
|
|
202
202
|
return (e.indexOf("iPhone") > -1 || e.indexOf("iPad") > -1) && t > -1 ? Number(e.substring(t + 3, t + 6).replace("_", ".")) : 0;
|
|
203
203
|
}
|
|
204
|
-
function
|
|
204
|
+
function Xe() {
|
|
205
205
|
var u;
|
|
206
206
|
if (typeof navigator > "u") return "unknown";
|
|
207
207
|
const e = (navigator.userAgent || navigator.vendor || "").toLowerCase(), t = (navigator.platform || "").toLowerCase(), o = (((u = navigator.userAgentData) == null ? void 0 : u.platform) || "").toLowerCase(), i = `${e} ${t} ${o}`;
|
|
@@ -210,7 +210,7 @@ function De() {
|
|
|
210
210
|
function ye() {
|
|
211
211
|
if (typeof navigator > "u") return !1;
|
|
212
212
|
const e = navigator.userAgentData;
|
|
213
|
-
return e != null && e.platform && ["iOS", "iPadOS"].includes(e.platform) ||
|
|
213
|
+
return e != null && e.platform && ["iOS", "iPadOS"].includes(e.platform) || Xe() === "ios" ? !0 : (navigator.userAgent || "").includes("Macintosh") && typeof document < "u" && "ontouchend" in document;
|
|
214
214
|
}
|
|
215
215
|
function me(e) {
|
|
216
216
|
if (typeof sessionStorage > "u") return !1;
|
|
@@ -220,9 +220,9 @@ function me(e) {
|
|
|
220
220
|
function St(e) {
|
|
221
221
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
222
222
|
}
|
|
223
|
-
var fe = { exports: {} }, Pt = fe.exports,
|
|
223
|
+
var fe = { exports: {} }, Pt = fe.exports, Ye;
|
|
224
224
|
function kt() {
|
|
225
|
-
return
|
|
225
|
+
return Ye || (Ye = 1, (function(e, t) {
|
|
226
226
|
(function(i, s) {
|
|
227
227
|
e.exports = s();
|
|
228
228
|
})(Pt, function() {
|
|
@@ -1474,46 +1474,46 @@ function kt() {
|
|
|
1474
1474
|
var ke = D.data.channels[W];
|
|
1475
1475
|
ke.channel && (le[ke.channel] = ke.token);
|
|
1476
1476
|
}
|
|
1477
|
-
var
|
|
1478
|
-
n._isBatching || (n.startBatching(),
|
|
1479
|
-
for (var
|
|
1480
|
-
if (c.hasOwnProperty(
|
|
1477
|
+
var xe = !1;
|
|
1478
|
+
n._isBatching || (n.startBatching(), xe = !0);
|
|
1479
|
+
for (var Fe in c)
|
|
1480
|
+
if (c.hasOwnProperty(Fe)) {
|
|
1481
1481
|
var yt = (function() {
|
|
1482
|
-
var z = c[
|
|
1483
|
-
if (
|
|
1482
|
+
var z = c[Fe], Je = le[z];
|
|
1483
|
+
if (Je) {
|
|
1484
1484
|
var oe = {
|
|
1485
1485
|
method: n._methodType.SUBSCRIBE,
|
|
1486
1486
|
params: {
|
|
1487
1487
|
channel: z,
|
|
1488
|
-
token:
|
|
1488
|
+
token: Je
|
|
1489
1489
|
}
|
|
1490
|
-
},
|
|
1491
|
-
if (
|
|
1490
|
+
}, qe = n._getSub(z);
|
|
1491
|
+
if (qe === null)
|
|
1492
1492
|
return "continue";
|
|
1493
|
-
var
|
|
1494
|
-
if (
|
|
1493
|
+
var je = qe._needRecover();
|
|
1494
|
+
if (je === !0) {
|
|
1495
1495
|
oe.params.recover = !0;
|
|
1496
1496
|
var we = n._getLastSeq(z), _e = n._getLastGen(z);
|
|
1497
1497
|
if (we || _e)
|
|
1498
1498
|
we && (oe.params.seq = we), _e && (oe.params.gen = _e);
|
|
1499
1499
|
else {
|
|
1500
|
-
var
|
|
1501
|
-
|
|
1500
|
+
var ze = n._getLastOffset(z);
|
|
1501
|
+
ze && (oe.params.offset = ze);
|
|
1502
1502
|
}
|
|
1503
|
-
var
|
|
1504
|
-
|
|
1503
|
+
var Ke = n._getLastEpoch(z);
|
|
1504
|
+
Ke && (oe.params.epoch = Ke);
|
|
1505
1505
|
}
|
|
1506
|
-
n._call(oe).then(function(
|
|
1507
|
-
n._subscribeResponse(z,
|
|
1508
|
-
}, function(
|
|
1509
|
-
n._subscribeError(z,
|
|
1506
|
+
n._call(oe).then(function($) {
|
|
1507
|
+
n._subscribeResponse(z, je, n._decoder.decodeCommandResult(n._methodType.SUBSCRIBE, $.result)), $.next && $.next();
|
|
1508
|
+
}, function($) {
|
|
1509
|
+
n._subscribeError(z, $.error), $.next && $.next();
|
|
1510
1510
|
});
|
|
1511
1511
|
} else
|
|
1512
1512
|
return n._subscribeError(z, n._createErrorObject("permission denied", 103)), "continue";
|
|
1513
1513
|
})();
|
|
1514
1514
|
if (yt === "continue") continue;
|
|
1515
1515
|
}
|
|
1516
|
-
|
|
1516
|
+
xe && n.stopBatching();
|
|
1517
1517
|
}
|
|
1518
1518
|
};
|
|
1519
1519
|
if (this._config.onPrivateSubscribe !== null)
|
|
@@ -2239,7 +2239,7 @@ function kt() {
|
|
|
2239
2239
|
var wt = kt();
|
|
2240
2240
|
const _t = /* @__PURE__ */ St(wt);
|
|
2241
2241
|
let he = null;
|
|
2242
|
-
function
|
|
2242
|
+
function Ge(e, t) {
|
|
2243
2243
|
if (!(e != null && e.client_url) || !(e != null && e.token) || !(e != null && e.channel))
|
|
2244
2244
|
return console.error("[Centrifuge] Invalid socket_connections"), null;
|
|
2245
2245
|
const { client_url: o, token: i, channel: s } = e;
|
|
@@ -2279,7 +2279,7 @@ function Tt(e) {
|
|
|
2279
2279
|
function ge(e) {
|
|
2280
2280
|
return /^4[0-9]/.test(e) ? "visa" : /^5[1-5]/.test(e) || /^2[2-7]/.test(e) ? "mastercard" : "card";
|
|
2281
2281
|
}
|
|
2282
|
-
const
|
|
2282
|
+
const ee = {
|
|
2283
2283
|
iconType: "kaspi_pay",
|
|
2284
2284
|
label: "Kaspi.kz",
|
|
2285
2285
|
type: "kaspi_pay"
|
|
@@ -2295,7 +2295,7 @@ const $ = {
|
|
|
2295
2295
|
function K(e) {
|
|
2296
2296
|
return e === "enabled" || e === !0;
|
|
2297
2297
|
}
|
|
2298
|
-
function
|
|
2298
|
+
function Ze(e) {
|
|
2299
2299
|
if (!e) return null;
|
|
2300
2300
|
let t = String(e).trim().toLowerCase();
|
|
2301
2301
|
return t.startsWith("payment_method_") && (t = t.replace("payment_method_", "")), t === "kaspi" ? "kaspi_pay" : t === "apple" ? "apple_pay" : t === "google" ? "google_pay" : t === "newcard" ? "new_card" : t === "card" ? "card" : ["kaspi_pay", "apple_pay", "google_pay", "new_card"].includes(t) ? t : null;
|
|
@@ -2305,18 +2305,18 @@ function Lt(e) {
|
|
|
2305
2305
|
const t = e, o = ((u = t == null ? void 0 : t.context) == null ? void 0 : u.last_payment_method) ?? (t == null ? void 0 : t.last_payment_method) ?? ((a = t == null ? void 0 : t.attributes) == null ? void 0 : a.last_payment_method);
|
|
2306
2306
|
if (!o) return null;
|
|
2307
2307
|
if (typeof o == "string")
|
|
2308
|
-
return { type:
|
|
2308
|
+
return { type: Ze(o), cardId: null };
|
|
2309
2309
|
if (typeof o != "object") return null;
|
|
2310
2310
|
const i = o.type ?? o.payment_method ?? o.method, s = o.card_id ?? o.cardId ?? o.id ?? ((l = o.card) == null ? void 0 : l.id) ?? null;
|
|
2311
2311
|
return {
|
|
2312
|
-
type:
|
|
2312
|
+
type: Ze(i),
|
|
2313
2313
|
cardId: s != null ? String(s) : null
|
|
2314
2314
|
};
|
|
2315
2315
|
}
|
|
2316
2316
|
function Rt(e, t, o = {}) {
|
|
2317
2317
|
var k, b, w, L;
|
|
2318
|
-
const i = [], s = (k = e == null ? void 0 : e.kaspi) == null ? void 0 : k.data, u = ((b = e == null ? void 0 : e.cards_v2) == null ? void 0 : b.data) || [], a = ((L = (w = e == null ? void 0 : e.payment_methods) == null ? void 0 : w.data) == null ? void 0 : L.attributes) || {}, l = K(a.payment_method_kaspi), f = K(a.payment_method_card), C = typeof window < "u" && window.self === window.top, _ =
|
|
2319
|
-
return s != null && s.isKaspiOnly && l && !P ? [
|
|
2318
|
+
const i = [], s = (k = e == null ? void 0 : e.kaspi) == null ? void 0 : k.data, u = ((b = e == null ? void 0 : e.cards_v2) == null ? void 0 : b.data) || [], a = ((L = (w = e == null ? void 0 : e.payment_methods) == null ? void 0 : w.data) == null ? void 0 : L.attributes) || {}, l = K(a.payment_method_kaspi), f = K(a.payment_method_card), C = typeof window < "u" && window.self === window.top, _ = Xe() === "ios", E = !!(o != null && o.onlyKaspiAvailable), P = !!(o != null && o.disableKaspi);
|
|
2319
|
+
return s != null && s.isKaspiOnly && l && !P ? [ee] : E ? s != null && s.isAvailable && l && !P ? [ee] : [] : (K(a.payment_method_apple_pay) && !me("apple_pay") && (Ce() && C || ye() || _ || ot() === 16) && i.push(st), s != null && s.isAvailable && l && !P && i.push(ee), f && u.filter((O) => !O.isExpired).forEach((O) => {
|
|
2320
2320
|
i.push({
|
|
2321
2321
|
iconType: ge(O.attributes.mask),
|
|
2322
2322
|
type: "card",
|
|
@@ -2331,14 +2331,14 @@ function Rt(e, t, o = {}) {
|
|
|
2331
2331
|
label: t ? t("newCard") : "Оплата новой картой"
|
|
2332
2332
|
}), i);
|
|
2333
2333
|
}
|
|
2334
|
-
function
|
|
2334
|
+
function Re(e, t = {}) {
|
|
2335
2335
|
var B, k, b, w;
|
|
2336
|
-
const o = (B = e == null ? void 0 : e.kaspi) == null ? void 0 : B.data, i = ((k = e == null ? void 0 : e.cards_v2) == null ? void 0 : k.data) || [], s = ((w = (b = e == null ? void 0 : e.payment_methods) == null ? void 0 : b.data) == null ? void 0 : w.attributes) || {}, u = K(s.payment_method_kaspi), a = K(s.payment_method_card), l = !!(t != null && t.disableKaspi), f = typeof window < "u" && window.self === window.top, S =
|
|
2336
|
+
const o = (B = e == null ? void 0 : e.kaspi) == null ? void 0 : B.data, i = ((k = e == null ? void 0 : e.cards_v2) == null ? void 0 : k.data) || [], s = ((w = (b = e == null ? void 0 : e.payment_methods) == null ? void 0 : b.data) == null ? void 0 : w.attributes) || {}, u = K(s.payment_method_kaspi), a = K(s.payment_method_card), l = !!(t != null && t.disableKaspi), f = typeof window < "u" && window.self === window.top, S = Xe() === "ios", _ = K(s.payment_method_apple_pay) && !me("apple_pay") && (Ce() && f || ye() || S || ot() === 16), E = K(s.payment_method_google_pay) && !me("google_pay") && !(t != null && t.disableGooglePay) && !Ce() && !ye();
|
|
2337
2337
|
if (o != null && o.isKaspiOnly && u && !l || t != null && t.onlyKaspiAvailable && (o != null && o.isAvailable) && u && !l)
|
|
2338
|
-
return
|
|
2338
|
+
return ee;
|
|
2339
2339
|
const P = Lt(e);
|
|
2340
2340
|
if ((P == null ? void 0 : P.type) === "kaspi_pay" && (o != null && o.isAvailable) && u && !l)
|
|
2341
|
-
return
|
|
2341
|
+
return ee;
|
|
2342
2342
|
if ((P == null ? void 0 : P.type) === "apple_pay" && _) return st;
|
|
2343
2343
|
if ((P == null ? void 0 : P.type) === "google_pay" && E) return it;
|
|
2344
2344
|
if ((P == null ? void 0 : P.type) === "new_card" && K(s.payment_method_new_card))
|
|
@@ -2368,7 +2368,7 @@ function Le(e, t = {}) {
|
|
|
2368
2368
|
cardType: L.type
|
|
2369
2369
|
};
|
|
2370
2370
|
}
|
|
2371
|
-
if (o != null && o.isAvailable && u && !l) return
|
|
2371
|
+
if (o != null && o.isAvailable && u && !l) return ee;
|
|
2372
2372
|
const T = a ? i.find((L) => !L.isExpired) : null;
|
|
2373
2373
|
return T ? {
|
|
2374
2374
|
iconType: ge(T.attributes.mask),
|
|
@@ -2386,7 +2386,7 @@ function at(e) {
|
|
|
2386
2386
|
return null;
|
|
2387
2387
|
}
|
|
2388
2388
|
}
|
|
2389
|
-
function
|
|
2389
|
+
function Oe(e, t) {
|
|
2390
2390
|
if (!(typeof localStorage > "u"))
|
|
2391
2391
|
try {
|
|
2392
2392
|
localStorage.setItem(e, t);
|
|
@@ -2409,7 +2409,7 @@ async function Ot(e, t) {
|
|
|
2409
2409
|
return `HTTP ${e.status}: ${e.statusText}`;
|
|
2410
2410
|
}
|
|
2411
2411
|
}
|
|
2412
|
-
async function
|
|
2412
|
+
async function Z(e, t) {
|
|
2413
2413
|
const o = await Ot(e, t);
|
|
2414
2414
|
throw Object.assign(new Error(o), { status: e.status });
|
|
2415
2415
|
}
|
|
@@ -2449,7 +2449,7 @@ async function Se(e, t, o, i, s) {
|
|
|
2449
2449
|
},
|
|
2450
2450
|
body: JSON.stringify(i)
|
|
2451
2451
|
});
|
|
2452
|
-
return u.ok || await
|
|
2452
|
+
return u.ok || await Z(u, s), u.json();
|
|
2453
2453
|
}
|
|
2454
2454
|
async function Mt(e, t, o) {
|
|
2455
2455
|
var l, f, C, S;
|
|
@@ -2466,7 +2466,7 @@ async function Mt(e, t, o) {
|
|
|
2466
2466
|
track_id: o
|
|
2467
2467
|
})
|
|
2468
2468
|
});
|
|
2469
|
-
i.ok || await
|
|
2469
|
+
i.ok || await Z(i, "Не удалось авторизоваться через track_id");
|
|
2470
2470
|
const s = await i.json(), u = (s == null ? void 0 : s.access_token) ?? ((f = (l = s == null ? void 0 : s.data) == null ? void 0 : l.attributes) == null ? void 0 : f.access_token), a = (s == null ? void 0 : s.refresh_token) ?? ((S = (C = s == null ? void 0 : s.data) == null ? void 0 : C.attributes) == null ? void 0 : S.refresh_token) ?? null;
|
|
2471
2471
|
if (!u) throw new Error("В ответе отсутствует access_token");
|
|
2472
2472
|
return { access_token: u, refresh_token: a };
|
|
@@ -2482,12 +2482,12 @@ async function Nt(e, t, o) {
|
|
|
2482
2482
|
refresh_token: o
|
|
2483
2483
|
})
|
|
2484
2484
|
});
|
|
2485
|
-
i.ok || await
|
|
2485
|
+
i.ok || await Z(i, "Не удалось обновить токен по refresh_token");
|
|
2486
2486
|
const s = await i.json(), u = (s == null ? void 0 : s.access_token) ?? ((f = (l = s == null ? void 0 : s.data) == null ? void 0 : l.attributes) == null ? void 0 : f.access_token), a = (s == null ? void 0 : s.refresh_token) ?? ((S = (C = s == null ? void 0 : s.data) == null ? void 0 : C.attributes) == null ? void 0 : S.refresh_token) ?? null;
|
|
2487
2487
|
if (!u) throw new Error("В ответе отсутствует access_token");
|
|
2488
2488
|
return { access_token: u, refresh_token: a };
|
|
2489
2489
|
}
|
|
2490
|
-
async function
|
|
2490
|
+
async function Me(e, t) {
|
|
2491
2491
|
const o = await fetch(`${e}/orders/v1/checkout/context`, {
|
|
2492
2492
|
method: "POST",
|
|
2493
2493
|
headers: {
|
|
@@ -2504,7 +2504,7 @@ async function Oe(e, t) {
|
|
|
2504
2504
|
}
|
|
2505
2505
|
})
|
|
2506
2506
|
});
|
|
2507
|
-
return o.ok || await
|
|
2507
|
+
return o.ok || await Z(o, "Ошибка получения контекста оплаты"), o.json();
|
|
2508
2508
|
}
|
|
2509
2509
|
async function Dt(e, t, o) {
|
|
2510
2510
|
const i = await fetch(`${e}/payment-gateway/v1/cards/${o}`, {
|
|
@@ -2514,7 +2514,7 @@ async function Dt(e, t, o) {
|
|
|
2514
2514
|
Authorization: `Bearer ${t.accessToken}`
|
|
2515
2515
|
}
|
|
2516
2516
|
});
|
|
2517
|
-
return i.ok || await
|
|
2517
|
+
return i.ok || await Z(i, "Не удалось удалить карту"), i.json().catch(() => ({}));
|
|
2518
2518
|
}
|
|
2519
2519
|
async function Xt(e, t, o) {
|
|
2520
2520
|
const i = await fetch(
|
|
@@ -2527,7 +2527,7 @@ async function Xt(e, t, o) {
|
|
|
2527
2527
|
}
|
|
2528
2528
|
}
|
|
2529
2529
|
);
|
|
2530
|
-
return i.ok || await
|
|
2530
|
+
return i.ok || await Z(i, "Не удалось отметить карту как основную"), i.json().catch(() => ({}));
|
|
2531
2531
|
}
|
|
2532
2532
|
async function Ut(e, t, o) {
|
|
2533
2533
|
const i = await fetch(`${e}/orders/v1/orders/${o}/status`, {
|
|
@@ -2545,7 +2545,7 @@ async function Ut(e, t, o) {
|
|
|
2545
2545
|
const s = await i.json(), u = (s == null ? void 0 : s.data) ?? s;
|
|
2546
2546
|
return { data: { status: u == null ? void 0 : u.status, payload: (u == null ? void 0 : u.payload) ?? {} } };
|
|
2547
2547
|
}
|
|
2548
|
-
async function
|
|
2548
|
+
async function $e(e, t, o, i, s = {}) {
|
|
2549
2549
|
const { checkoutAmount: u, checkoutPaymentMethod: a, useBalanceFlag: l, voucher: f } = Ie(
|
|
2550
2550
|
t,
|
|
2551
2551
|
{
|
|
@@ -2587,7 +2587,7 @@ async function xt(e, t) {
|
|
|
2587
2587
|
}
|
|
2588
2588
|
}
|
|
2589
2589
|
);
|
|
2590
|
-
return o.ok || await
|
|
2590
|
+
return o.ok || await Z(o, "Ошибка получения купонов"), o.json();
|
|
2591
2591
|
}
|
|
2592
2592
|
async function Ft(e, t, o) {
|
|
2593
2593
|
const i = window.location.hostname, s = await fetch(`${e}/payment-gateway/v1/apple/session`, {
|
|
@@ -2599,7 +2599,7 @@ async function Ft(e, t, o) {
|
|
|
2599
2599
|
},
|
|
2600
2600
|
body: JSON.stringify({ validationUrl: o, domainName: i })
|
|
2601
2601
|
});
|
|
2602
|
-
return s.ok || await
|
|
2602
|
+
return s.ok || await Z(s, "Ошибка получения Apple Pay сессии"), s.json();
|
|
2603
2603
|
}
|
|
2604
2604
|
async function Jt(e, t, o, i, s = {}) {
|
|
2605
2605
|
const { checkoutAmount: u, checkoutPaymentMethod: a, useBalanceFlag: l, voucher: f } = Ie(
|
|
@@ -2671,10 +2671,10 @@ function qt(e) {
|
|
|
2671
2671
|
bonuses: s
|
|
2672
2672
|
};
|
|
2673
2673
|
}
|
|
2674
|
-
function
|
|
2675
|
-
|
|
2674
|
+
function Ne(e, t) {
|
|
2675
|
+
Oe("webPayToken", e), t && Oe("webPayRefreshToken", t);
|
|
2676
2676
|
}
|
|
2677
|
-
function
|
|
2677
|
+
function et() {
|
|
2678
2678
|
be("webPayToken"), be("webPayRefreshToken");
|
|
2679
2679
|
}
|
|
2680
2680
|
async function jt(e) {
|
|
@@ -2686,7 +2686,7 @@ async function jt(e) {
|
|
|
2686
2686
|
e.config.clientId,
|
|
2687
2687
|
t
|
|
2688
2688
|
);
|
|
2689
|
-
|
|
2689
|
+
Ne(i.access_token, i.refresh_token), e.accessToken = i.access_token;
|
|
2690
2690
|
return;
|
|
2691
2691
|
} catch {
|
|
2692
2692
|
be("webPayRefreshToken");
|
|
@@ -2700,7 +2700,7 @@ async function jt(e) {
|
|
|
2700
2700
|
e.config.clientId,
|
|
2701
2701
|
e.config.trackId
|
|
2702
2702
|
);
|
|
2703
|
-
|
|
2703
|
+
Ne(o.access_token, o.refresh_token), e.accessToken = o.access_token;
|
|
2704
2704
|
}
|
|
2705
2705
|
const zt = `<svg width="17" height="16" viewBox="0 0 17 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2706
2706
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M8.89711 8.50443C10.4185 8.72365 10.6242 9.56386 10.7471 10.3459L10.7816 10.5699L10.8557 11.0301C11.0006 11.9088 11.303 13.7327 11.303 14.6845C11.303 14.9224 11.2806 15.105 11.2396 15.2053C11.1713 15.3599 10.9724 15.5082 10.6978 15.6319C10.0332 15.7846 9.33863 15.8671 8.62315 15.8671C8.54739 15.8671 8.47285 15.8637 8.39805 15.8616C8.10889 15.785 7.89156 15.657 7.77649 15.4821C7.42905 14.9542 7.40812 13.7781 7.40116 12.4037L7.40037 12.2443L7.39755 11.8324C7.38623 10.3774 7.37651 9.1229 7.94288 8.67272C8.16223 8.49957 8.47392 8.44225 8.89711 8.50443ZM5.58009 11.6722C5.90978 11.6548 6.12181 13.1684 6.16441 14.3162C6.19427 15.1152 6.10438 15.4439 5.96084 15.5619C5.79833 15.5113 5.63864 15.4565 5.48128 15.397C5.3763 15.219 5.29607 14.9389 5.2451 14.5721C5.08947 13.4193 5.22466 11.6925 5.58009 11.6722ZM13.8455 13.934C13.825 14.0391 13.796 14.1204 13.7602 14.1889C13.4783 14.4 13.1821 14.5938 12.872 14.7682C12.7733 14.7837 12.6856 14.7729 12.6427 14.7053C12.2318 14.0314 12.0775 11.9173 12.4752 11.7333C12.9936 11.4995 13.9224 13.5685 13.8455 13.934ZM8.50042 0C13.1296 0 16.8941 3.42166 16.9979 7.67934L17 7.82651V7.89454C16.9915 9.81778 16.2332 11.5773 14.9839 12.9392C14.9386 12.918 14.8559 12.8486 14.7062 12.6395C14.5512 12.4293 13.2148 10.5096 13.2148 8.30946C13.2148 7.87768 13.8816 7.20318 14.4717 6.61114C14.9128 6.16562 15.3306 5.74539 15.4845 5.4151C15.6804 4.98892 15.5433 4.69134 15.3265 4.59047C15.1302 4.50082 14.8355 4.56621 14.6287 4.90904C14.2893 5.46389 14.1805 5.56758 13.6855 5.93882C13.1984 6.30986 12.424 6.68338 12.424 6.19988C12.424 5.93882 12.8553 5.34757 13.0684 4.93314C13.286 4.51408 13.0515 4.21072 12.6022 4.21072C11.7198 4.21072 11.1341 5.2598 11.1341 5.62326C11.1341 5.98642 11.3229 6.03813 11.3229 6.46104C11.3229 6.88713 10.3548 7.4398 9.44281 7.4398C8.56481 7.4398 8.05566 7.27394 7.8447 6.80665L7.81777 6.74105L7.75678 6.57266C7.54046 5.98255 7.38528 5.55458 7.11514 5.10733C6.9717 4.87081 6.75038 4.70684 6.55897 4.56257C6.30881 4.38121 6.17902 4.21421 6.15193 4.08967C6.12696 3.96611 6.11352 3.73326 6.54117 3.19648C6.96793 2.66277 7.02775 2.25958 6.81418 2.05153C6.73678 1.97752 6.60482 1.93011 6.43535 1.93011C6.13562 1.93011 5.71912 2.07834 5.2899 2.48551C4.62267 3.12364 5.00146 3.72951 5.00146 3.99548C5.00146 4.26127 4.87922 4.41162 4.47882 4.77323C4.07547 5.13644 3.93627 5.44783 3.89014 6.69935C3.87247 7.3442 3.75079 7.71539 3.64156 8.04453C3.54718 8.33302 3.46038 8.60425 3.45569 8.99611C3.44822 9.43038 3.52566 9.71023 3.61604 10.0331C3.70477 10.3316 3.79902 10.6736 3.8594 11.2456C3.95544 12.1312 3.92205 12.8792 3.74744 13.6437L3.70084 13.8353L3.68995 13.8903C3.65419 14.0247 3.61168 14.1879 3.55423 14.249C1.4029 12.8228 0 10.4936 0 7.86072C0 3.51974 3.80561 0 8.50042 0Z" fill="#F14635"/>
|
|
@@ -2771,7 +2771,7 @@ function $t(e) {
|
|
|
2771
2771
|
const t = e == null ? void 0 : e.toLowerCase();
|
|
2772
2772
|
return t && Zt[t] || "";
|
|
2773
2773
|
}
|
|
2774
|
-
const
|
|
2774
|
+
const Ue = `<svg width="22" height="22" viewBox="0 0 22 22" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2775
2775
|
<path d="M19.7045 10.7313C15.0567 10.7313 11.2687 6.94328 11.2687 2.26866C11.2687 2.10746 11.1612 2 11 2C10.8388 2 10.7313 2.10746 10.7313 2.26866C10.7313 6.94328 6.94328 10.7313 2.26866 10.7313C2.10746 10.7313 2 10.8388 2 11C2 11.1612 2.10746 11.2687 2.26866 11.2687C6.94328 11.2687 10.7313 15.0567 10.7313 19.7313C10.7313 19.8925 10.8388 20 11 20C11.1612 20 11.2687 19.8925 11.2687 19.7313C11.2687 15.0567 15.0567 11.2687 19.7313 11.2687C19.8925 11.2687 20 11.1612 20 11C20 10.8388 19.8657 10.7313 19.7045 10.7313Z" fill="#2F2F2F"/>
|
|
2776
2776
|
</svg>
|
|
2777
2777
|
`, en = '<svg class="choco-widget-method-item-trash" width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M4.16663 5.83317H15.8333" stroke="#CC3434" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><path d="M15 5.8335V15.0002C15 15.921 14.2542 16.6668 13.3333 16.6668H6.66667C5.74583 16.6668 5 15.921 5 15.0002V5.8335" stroke="#CC3434" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><path d="M12.5 3.12516H7.5" stroke="#CC3434" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><path d="M8.33329 9.1665V13.3332" stroke="#CC3434" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><path d="M11.6667 9.1665V13.3332" stroke="#CC3434" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>', tn = '<svg class="choco-widget-method-item-check" width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M13.3333 4.3335L5.99996 11.6668L2.66663 8.3335" stroke="#242424" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>';
|
|
@@ -2828,7 +2828,7 @@ function nn(e, t, o, i) {
|
|
|
2828
2828
|
</div>
|
|
2829
2829
|
<div class="choco-widget-balance-label-wrapper">
|
|
2830
2830
|
<div class="choco-widget-balance-icon">
|
|
2831
|
-
${
|
|
2831
|
+
${Ue}
|
|
2832
2832
|
</div>
|
|
2833
2833
|
<div class="choco-widget-balance-amount">${s ? V(e.amount, "ru", i) : 0}</div>
|
|
2834
2834
|
<label class="choco-widget-toggle">
|
|
@@ -2852,7 +2852,7 @@ function rn(e, t, o, i) {
|
|
|
2852
2852
|
<div class="choco-widget-balance-label-wrapper">
|
|
2853
2853
|
${f ? `
|
|
2854
2854
|
<div class="choco-widget-balance-icon">
|
|
2855
|
-
${
|
|
2855
|
+
${Ue}
|
|
2856
2856
|
</div>
|
|
2857
2857
|
<div class="choco-widget-balance-amount">${f}</div>
|
|
2858
2858
|
` : ""}
|
|
@@ -2875,7 +2875,7 @@ function on(e, t, o, i, s, u, a, l) {
|
|
|
2875
2875
|
</div>
|
|
2876
2876
|
<div class="choco-widget-balance-label-wrapper">
|
|
2877
2877
|
<div class="choco-widget-balance-icon">
|
|
2878
|
-
${
|
|
2878
|
+
${Ue}
|
|
2879
2879
|
</div>
|
|
2880
2880
|
<div class="choco-widget-balance-amount">${e}</div>
|
|
2881
2881
|
<label class="choco-widget-toggle">
|
|
@@ -3203,7 +3203,7 @@ function dt(e) {
|
|
|
3203
3203
|
);
|
|
3204
3204
|
w && (w.innerHTML = ""), L && (L.innerHTML = "");
|
|
3205
3205
|
}
|
|
3206
|
-
pe(e),
|
|
3206
|
+
pe(e), Y(e);
|
|
3207
3207
|
}
|
|
3208
3208
|
async function fn(e) {
|
|
3209
3209
|
var a, l, f, C, S;
|
|
@@ -3234,7 +3234,7 @@ async function fn(e) {
|
|
|
3234
3234
|
});
|
|
3235
3235
|
u.classList.add("choco-widget-google-pay-button"), u.style.setProperty("width", "100%", "important"), u.style.setProperty("height", "52px", "important"), u.style.setProperty("min-height", "52px", "important"), u.style.setProperty("border-radius", "12px", "important"), u.style.setProperty("font-size", "16px", "important"), u.style.setProperty("font-weight", "bold", "important"), u.querySelectorAll("*").forEach((_) => {
|
|
3236
3236
|
_.style.setProperty("border-radius", "12px", "important"), _.style.setProperty("font-weight", "bold", "important"), _.style.setProperty("font-size", "16px", "important");
|
|
3237
|
-
}), t.appendChild(u),
|
|
3237
|
+
}), t.appendChild(u), Y(e);
|
|
3238
3238
|
}
|
|
3239
3239
|
function gn(e) {
|
|
3240
3240
|
var u, a;
|
|
@@ -3261,10 +3261,10 @@ function gn(e) {
|
|
|
3261
3261
|
</defs>
|
|
3262
3262
|
</svg>
|
|
3263
3263
|
</span>
|
|
3264
|
-
`, o.appendChild(i), o.appendChild(s), t.appendChild(o),
|
|
3264
|
+
`, o.appendChild(i), o.appendChild(s), t.appendChild(o), Y(e);
|
|
3265
3265
|
}
|
|
3266
3266
|
function ne(e) {
|
|
3267
|
-
e.loading = !0,
|
|
3267
|
+
e.loading = !0, Y(e);
|
|
3268
3268
|
}
|
|
3269
3269
|
function j(e) {
|
|
3270
3270
|
var _, E, P, T, B, k, b, w;
|
|
@@ -3280,7 +3280,7 @@ function j(e) {
|
|
|
3280
3280
|
), C = e._isInteractionBlocked(), S = e.paymentMethodDisabled || C;
|
|
3281
3281
|
t && (t.disabled = S), o && (o.disabled = C, o.classList.remove("choco-widget-pay-button--loading")), i && (i.disabled = C), s && (s.disabled = C), u == null || u.classList.toggle("choco-widget-wallet-blocked", C), u == null || u.setAttribute("aria-disabled", String(C)), a == null || a.classList.toggle("choco-widget-wallet-blocked", C), a == null || a.setAttribute("aria-disabled", String(C)), l == null || l.classList.toggle("choco-widget-wallet-blocked", C), l == null || l.setAttribute("aria-disabled", String(C)), f == null || f.classList.remove("disabled");
|
|
3282
3282
|
}
|
|
3283
|
-
function
|
|
3283
|
+
function Y(e) {
|
|
3284
3284
|
var _, E, P, T, B, k, b, w;
|
|
3285
3285
|
const t = (_ = e.container) == null ? void 0 : _.querySelector(".choco-widget-payment-method"), o = (E = e.container) == null ? void 0 : E.querySelector(".choco-widget-pay-button"), i = (P = e.container) == null ? void 0 : P.querySelector(
|
|
3286
3286
|
".choco-widget-google-pay-button-slot button"
|
|
@@ -3299,7 +3299,7 @@ function ht(e) {
|
|
|
3299
3299
|
const t = (o = e.container) == null ? void 0 : o.querySelector('[data-sheet="payment"]');
|
|
3300
3300
|
t && (t.classList.add("choco-widget-payment-sheet--open"), e.isPaymentSheetOpen = !0, ue(e));
|
|
3301
3301
|
}
|
|
3302
|
-
function
|
|
3302
|
+
function G(e) {
|
|
3303
3303
|
var o;
|
|
3304
3304
|
const t = (o = e.container) == null ? void 0 : o.querySelector('[data-sheet="payment"]');
|
|
3305
3305
|
if (t) {
|
|
@@ -3315,7 +3315,7 @@ function ue(e) {
|
|
|
3315
3315
|
const o = t.querySelector(".choco-widget-sheet-title"), i = t.querySelector('[data-action="close-sheet"]'), s = t.querySelector('[data-action="edit-sheet"]'), u = t.querySelector('[data-action="previous-sheet"]'), l = e.getAvailablePaymentMethods().some((C) => C.type === "card");
|
|
3316
3316
|
e.isPaymentSheetEditMode ? (t.classList.add("choco-widget-payment-sheet--edit"), o && (o.textContent = e.t("editCards")), i && (i.style.display = "none"), s && (s.style.display = "none"), u && (u.style.display = "")) : (t.classList.remove("choco-widget-payment-sheet--edit"), t.classList.toggle("choco-widget-payment-sheet--no-cards", !l), o && (o.textContent = e.t("paymentMethods")), i && (i.style.display = ""), s && (s.style.display = l ? "" : "none"), u && (u.style.display = "none"));
|
|
3317
3317
|
}
|
|
3318
|
-
function
|
|
3318
|
+
function Te(e) {
|
|
3319
3319
|
if (!e.addCardActionUrl || !e.container) return;
|
|
3320
3320
|
const t = e.container.querySelector('[data-sheet="add-card"]'), o = e.container.querySelector(
|
|
3321
3321
|
"#choco-widget-add-card-iframe"
|
|
@@ -3349,11 +3349,11 @@ function yn(e, t) {
|
|
|
3349
3349
|
}
|
|
3350
3350
|
function ve(e) {
|
|
3351
3351
|
var o;
|
|
3352
|
-
e._pendingDeleteMethod = null,
|
|
3352
|
+
e._pendingDeleteMethod = null, De(e, !1);
|
|
3353
3353
|
const t = (o = e.container) == null ? void 0 : o.querySelector('[data-sheet="payment"]');
|
|
3354
3354
|
t == null || t.classList.remove("choco-widget-payment-sheet--delete-confirm"), ue(e);
|
|
3355
3355
|
}
|
|
3356
|
-
function
|
|
3356
|
+
function De(e, t) {
|
|
3357
3357
|
var u, a, l;
|
|
3358
3358
|
const o = (u = e.container) == null ? void 0 : u.querySelector(
|
|
3359
3359
|
".choco-widget-sheet-delete-confirm-actions"
|
|
@@ -3369,10 +3369,10 @@ async function mn(e, t) {
|
|
|
3369
3369
|
const o = t == null ? void 0 : t.cardId;
|
|
3370
3370
|
if (!(!o || (t == null ? void 0 : t.type) !== "card"))
|
|
3371
3371
|
try {
|
|
3372
|
-
await Dt(e.apiUrl, e._getApiConfig(), o), e.checkoutContext = await
|
|
3372
|
+
await Dt(e.apiUrl, e._getApiConfig(), o), e.checkoutContext = await Me(
|
|
3373
3373
|
e.apiUrl,
|
|
3374
3374
|
e._getApiConfig()
|
|
3375
|
-
), ((i = e.selectedPaymentMethod) == null ? void 0 : i.type) === "card" && ((s = e.selectedPaymentMethod) == null ? void 0 : s.cardId) === o && (e.selectedPaymentMethod =
|
|
3375
|
+
), ((i = e.selectedPaymentMethod) == null ? void 0 : i.type) === "card" && ((s = e.selectedPaymentMethod) == null ? void 0 : s.cardId) === o && (e.selectedPaymentMethod = Re(
|
|
3376
3376
|
e.checkoutContext.data,
|
|
3377
3377
|
e._getKaspiOptions()
|
|
3378
3378
|
), e._emitPaymentMethodSelected(), lt(e)), Ae(e), e.config.onSuccess({ message: e.t("cardDeleted") }), e.config.onCardDeleted && e.config.onCardDeleted({ cardId: o });
|
|
@@ -3385,12 +3385,12 @@ async function mn(e, t) {
|
|
|
3385
3385
|
function ft(e, t) {
|
|
3386
3386
|
if (!e._isInteractionBlocked()) {
|
|
3387
3387
|
if (e.selectedPaymentMethod = t, e._emitPaymentMethodSelected(), t.type === "new_card") {
|
|
3388
|
-
e._emitUserEvent("one_click_pay_method_resolved", { payment_method: t.type }),
|
|
3388
|
+
e._emitUserEvent("one_click_pay_method_resolved", { payment_method: t.type }), G(e), e.handlePayment();
|
|
3389
3389
|
return;
|
|
3390
3390
|
}
|
|
3391
3391
|
e._emitUserEvent("one_click_pay_method_resolved", {
|
|
3392
3392
|
payment_method: e._getPaymentMethodForUserEvent()
|
|
3393
|
-
}), Ae(e),
|
|
3393
|
+
}), Ae(e), G(e), lt(e);
|
|
3394
3394
|
}
|
|
3395
3395
|
}
|
|
3396
3396
|
function tt(e, t) {
|
|
@@ -3402,10 +3402,10 @@ function tt(e, t) {
|
|
|
3402
3402
|
}
|
|
3403
3403
|
switch (o) {
|
|
3404
3404
|
case "order.paid":
|
|
3405
|
-
e._orderStatusResolved = !0,
|
|
3405
|
+
e._orderStatusResolved = !0, te(e), pt(e, t);
|
|
3406
3406
|
break;
|
|
3407
3407
|
case "order.failed":
|
|
3408
|
-
e._orderStatusResolved = !0,
|
|
3408
|
+
e._orderStatusResolved = !0, te(e), Ct(e, t);
|
|
3409
3409
|
break;
|
|
3410
3410
|
case "order.action_required":
|
|
3411
3411
|
bn(e, t);
|
|
@@ -3414,17 +3414,17 @@ function tt(e, t) {
|
|
|
3414
3414
|
console.warn("Unknown event type:", o);
|
|
3415
3415
|
}
|
|
3416
3416
|
}
|
|
3417
|
-
function
|
|
3417
|
+
function te(e) {
|
|
3418
3418
|
e._orderStatusPollingId && (clearInterval(e._orderStatusPollingId), e._orderStatusPollingId = null);
|
|
3419
3419
|
}
|
|
3420
3420
|
function ce(e, t) {
|
|
3421
|
-
|
|
3421
|
+
te(e), e._orderStatusResolved = !1;
|
|
3422
3422
|
const o = 6e3, i = 5;
|
|
3423
3423
|
let s = 0;
|
|
3424
3424
|
const u = async () => {
|
|
3425
3425
|
if (!e._orderStatusResolved) {
|
|
3426
3426
|
if (s >= i) {
|
|
3427
|
-
|
|
3427
|
+
te(e), j(e), e.config.onError({
|
|
3428
3428
|
attributes: { message: e.t("errorNoServerResponseRetry") }
|
|
3429
3429
|
});
|
|
3430
3430
|
return;
|
|
@@ -3437,13 +3437,13 @@ function ce(e, t) {
|
|
|
3437
3437
|
String(t)
|
|
3438
3438
|
), l = a == null ? void 0 : a.status, f = (a == null ? void 0 : a.payload) || {};
|
|
3439
3439
|
if (l === "success") {
|
|
3440
|
-
e._orderStatusResolved = !0,
|
|
3440
|
+
e._orderStatusResolved = !0, te(e), pt(e, {
|
|
3441
3441
|
id: String(f.id || t),
|
|
3442
3442
|
attributes: { amount: f.amount, paid_at: f.paid_at || "" }
|
|
3443
3443
|
});
|
|
3444
3444
|
return;
|
|
3445
3445
|
}
|
|
3446
|
-
l === "fail" && (e._orderStatusResolved = !0,
|
|
3446
|
+
l === "fail" && (e._orderStatusResolved = !0, te(e), Ct(e, {
|
|
3447
3447
|
id: String(f.id || t),
|
|
3448
3448
|
attributes: { message: f.message || e.t("paymentError") }
|
|
3449
3449
|
}));
|
|
@@ -3454,14 +3454,14 @@ function ce(e, t) {
|
|
|
3454
3454
|
};
|
|
3455
3455
|
e._orderStatusPollingId = setInterval(u, o), u();
|
|
3456
3456
|
}
|
|
3457
|
-
function
|
|
3457
|
+
function He() {
|
|
3458
3458
|
return typeof document > "u" ? !1 : document.hidden || document.visibilityState === "hidden";
|
|
3459
3459
|
}
|
|
3460
3460
|
function gt(e, t) {
|
|
3461
3461
|
j(e), e.config.onSuccess(t);
|
|
3462
3462
|
}
|
|
3463
|
-
function
|
|
3464
|
-
if (!e._pendingSuccessPayload ||
|
|
3463
|
+
function Le(e) {
|
|
3464
|
+
if (!e._pendingSuccessPayload || He()) return;
|
|
3465
3465
|
const t = e._pendingSuccessPayload;
|
|
3466
3466
|
e._pendingSuccessPayload = null, gt(e, t);
|
|
3467
3467
|
}
|
|
@@ -3469,7 +3469,7 @@ function pt(e, t) {
|
|
|
3469
3469
|
var s, u;
|
|
3470
3470
|
e.isAddCardViewOpen && ae(e);
|
|
3471
3471
|
const o = t.attributes || ((s = t.data) == null ? void 0 : s.attributes) || {}, i = { id: t.id || ((u = t.data) == null ? void 0 : u.id), attributes: o };
|
|
3472
|
-
if (
|
|
3472
|
+
if (He()) {
|
|
3473
3473
|
e._pendingSuccessPayload = i;
|
|
3474
3474
|
return;
|
|
3475
3475
|
}
|
|
@@ -3518,7 +3518,7 @@ async function En(e) {
|
|
|
3518
3518
|
if (e._isBalanceFullyCoveringAmount()) {
|
|
3519
3519
|
ne(e);
|
|
3520
3520
|
try {
|
|
3521
|
-
const a = await
|
|
3521
|
+
const a = await $e(
|
|
3522
3522
|
e.apiUrl,
|
|
3523
3523
|
e._getApiConfig(),
|
|
3524
3524
|
e.deviceId,
|
|
@@ -3548,7 +3548,7 @@ async function En(e) {
|
|
|
3548
3548
|
}
|
|
3549
3549
|
ne(e);
|
|
3550
3550
|
try {
|
|
3551
|
-
const a = await
|
|
3551
|
+
const a = await $e(
|
|
3552
3552
|
e.apiUrl,
|
|
3553
3553
|
e._getApiConfig(),
|
|
3554
3554
|
e.deviceId,
|
|
@@ -3791,7 +3791,7 @@ function Sn(e) {
|
|
|
3791
3791
|
var a, l, f, C, S, _, E, P, T, B, k;
|
|
3792
3792
|
const t = e.container;
|
|
3793
3793
|
(a = t.querySelector('[data-action="pay"]')) == null || a.addEventListener("click", () => e.handlePayment()), (l = t.querySelector('[data-action="change-method"]')) == null || l.addEventListener("click", () => ht(e)), t.querySelectorAll('[data-action="close"]').forEach((b) => b.addEventListener("click", () => e.close())), (f = t.querySelector('[data-action="close-sheet"]')) == null || f.addEventListener("click", () => {
|
|
3794
|
-
e._pendingDeleteMethod ? ve(e) :
|
|
3794
|
+
e._pendingDeleteMethod ? ve(e) : G(e);
|
|
3795
3795
|
}), (C = t.querySelector('[data-action="edit-sheet"]')) == null || C.addEventListener("click", () => {
|
|
3796
3796
|
e.isPaymentSheetEditMode = !0, Ae(e), ue(e);
|
|
3797
3797
|
}), (S = t.querySelector('[data-action="previous-sheet"]')) == null || S.addEventListener("click", () => {
|
|
@@ -3799,7 +3799,7 @@ function Sn(e) {
|
|
|
3799
3799
|
}), (_ = t.querySelector('[data-action="close-add-card"]')) == null || _.addEventListener("click", () => ae(e)), (E = t.querySelector('[data-action="confirm-delete-cancel"]')) == null || E.addEventListener("click", () => ve(e)), (P = t.querySelector('[data-action="confirm-delete-submit"]')) == null || P.addEventListener("click", () => {
|
|
3800
3800
|
if (e._pendingDeleteMethod) {
|
|
3801
3801
|
const b = e._pendingDeleteMethod;
|
|
3802
|
-
|
|
3802
|
+
De(e, !0), mn(e, b).then(() => G(e)).finally(() => De(e, !1));
|
|
3803
3803
|
}
|
|
3804
3804
|
}), t.querySelectorAll(".choco-widget-method-item").forEach((b) => {
|
|
3805
3805
|
b.addEventListener("click", (w) => {
|
|
@@ -3811,7 +3811,7 @@ function Sn(e) {
|
|
|
3811
3811
|
});
|
|
3812
3812
|
const o = t.querySelector('[data-sheet="payment"]');
|
|
3813
3813
|
o && (o.addEventListener("click", (b) => {
|
|
3814
|
-
b.target === o &&
|
|
3814
|
+
b.target === o && G(e);
|
|
3815
3815
|
}), kn(e, o));
|
|
3816
3816
|
const i = t.querySelector('[data-action="toggle-balance"]');
|
|
3817
3817
|
i && ((T = i.querySelector("input[type='checkbox']")) == null || T.addEventListener("change", (b) => {
|
|
@@ -3828,7 +3828,7 @@ function Sn(e) {
|
|
|
3828
3828
|
}
|
|
3829
3829
|
function Pn(e, t) {
|
|
3830
3830
|
var o, i;
|
|
3831
|
-
e.isOpen && (t.key === "Escape" && (t.preventDefault(), e._pendingDeleteMethod ? ve(e) : e.isAddCardViewOpen ? ae(e) : e.isPaymentSheetOpen ?
|
|
3831
|
+
e.isOpen && (t.key === "Escape" && (t.preventDefault(), e._pendingDeleteMethod ? ve(e) : e.isAddCardViewOpen ? ae(e) : e.isPaymentSheetOpen ? G(e) : e.close()), t.key === "Enter" && ((i = (o = t.target) == null ? void 0 : o.dataset) == null ? void 0 : i.action) === "pay" && (t.preventDefault(), e.handlePayment()));
|
|
3832
3832
|
}
|
|
3833
3833
|
function kn(e, t) {
|
|
3834
3834
|
const o = t.querySelector('[data-action="sheet-drag-handle"]'), i = t.querySelector(".choco-widget-sheet-content");
|
|
@@ -3845,7 +3845,7 @@ function kn(e, t) {
|
|
|
3845
3845
|
if (i.classList.remove("choco-widget-sheet-content--dragging"), S >= s) {
|
|
3846
3846
|
i.style.transform = "translateY(100%)";
|
|
3847
3847
|
const _ = () => {
|
|
3848
|
-
i.removeEventListener("transitionend", _), i.style.transform = "",
|
|
3848
|
+
i.removeEventListener("transitionend", _), i.style.transform = "", G(e);
|
|
3849
3849
|
};
|
|
3850
3850
|
i.addEventListener("transitionend", _);
|
|
3851
3851
|
} else
|
|
@@ -3861,13 +3861,13 @@ class ie {
|
|
|
3861
3861
|
return at(t);
|
|
3862
3862
|
}
|
|
3863
3863
|
static _setAuthStorageValue(t, o) {
|
|
3864
|
-
|
|
3864
|
+
Oe(t, o);
|
|
3865
3865
|
}
|
|
3866
3866
|
static _removeAuthStorageValue(t) {
|
|
3867
3867
|
be(t);
|
|
3868
3868
|
}
|
|
3869
3869
|
static async logout() {
|
|
3870
|
-
|
|
3870
|
+
et();
|
|
3871
3871
|
}
|
|
3872
3872
|
// ─── Конструктор ──────────────────────────────────────────────────────────────
|
|
3873
3873
|
constructor(t) {
|
|
@@ -3968,7 +3968,7 @@ class ie {
|
|
|
3968
3968
|
pe(this);
|
|
3969
3969
|
}
|
|
3970
3970
|
_showAddCardView() {
|
|
3971
|
-
|
|
3971
|
+
Te(this);
|
|
3972
3972
|
}
|
|
3973
3973
|
_closeAddCardView() {
|
|
3974
3974
|
ae(this);
|
|
@@ -3986,10 +3986,10 @@ class ie {
|
|
|
3986
3986
|
}
|
|
3987
3987
|
// ─── Хранение токенов ────────────────────────────────────────────────────────
|
|
3988
3988
|
_saveTokensToStorage(t, o) {
|
|
3989
|
-
|
|
3989
|
+
Ne(t, o);
|
|
3990
3990
|
}
|
|
3991
3991
|
_clearAuthStorage() {
|
|
3992
|
-
|
|
3992
|
+
et();
|
|
3993
3993
|
}
|
|
3994
3994
|
_getAuthStorageValue(t) {
|
|
3995
3995
|
return ie._getAuthStorageValue(t);
|
|
@@ -4030,13 +4030,13 @@ class ie {
|
|
|
4030
4030
|
this._lifecycleListenersAttached && (document.removeEventListener("visibilitychange", this._boundVisibilityChange), window.removeEventListener("focus", this._boundWindowFocus), window.removeEventListener("pageshow", this._boundPageShow), this._lifecycleListenersAttached = !1);
|
|
4031
4031
|
}
|
|
4032
4032
|
_onVisibilityChange() {
|
|
4033
|
-
|
|
4033
|
+
He() || Le(this);
|
|
4034
4034
|
}
|
|
4035
4035
|
_onWindowFocus() {
|
|
4036
|
-
|
|
4036
|
+
Le(this);
|
|
4037
4037
|
}
|
|
4038
4038
|
_onPageShow() {
|
|
4039
|
-
|
|
4039
|
+
Le(this);
|
|
4040
4040
|
}
|
|
4041
4041
|
// ─── Авторизация (приватная) ──────────────────────────────────────────────────
|
|
4042
4042
|
async _obtainTokenByRefreshOrTrackId() {
|
|
@@ -4044,13 +4044,13 @@ class ie {
|
|
|
4044
4044
|
}
|
|
4045
4045
|
async _fetchCheckoutContextWithRetry() {
|
|
4046
4046
|
try {
|
|
4047
|
-
this.checkoutContext = await
|
|
4047
|
+
this.checkoutContext = await Me(
|
|
4048
4048
|
this.apiUrl,
|
|
4049
4049
|
this._getApiConfig()
|
|
4050
4050
|
);
|
|
4051
4051
|
} catch (t) {
|
|
4052
4052
|
if (t.status === 401)
|
|
4053
|
-
this._removeAuthStorageValue("webPayToken"), await this._obtainTokenByRefreshOrTrackId(), this.checkoutContext = await
|
|
4053
|
+
this._removeAuthStorageValue("webPayToken"), await this._obtainTokenByRefreshOrTrackId(), this.checkoutContext = await Me(
|
|
4054
4054
|
this.apiUrl,
|
|
4055
4055
|
this._getApiConfig()
|
|
4056
4056
|
);
|
|
@@ -4061,7 +4061,7 @@ class ie {
|
|
|
4061
4061
|
async _fetchCoupons() {
|
|
4062
4062
|
try {
|
|
4063
4063
|
const t = await xt(this.apiUrl, this._getApiConfig()), i = (Array.isArray(t) ? t : Array.isArray(t == null ? void 0 : t.data) ? t.data : []).filter((s) => s.is_available && Number(s.reward_amount) > 0).sort((s, u) => s.sort_weight - u.sort_weight);
|
|
4064
|
-
this.selectedCoupon = i.length > 0 ? i[0] : null, this.useCoupon =
|
|
4064
|
+
this.selectedCoupon = i.length > 0 ? i[0] : null, this.useCoupon = !1;
|
|
4065
4065
|
} catch {
|
|
4066
4066
|
this.selectedCoupon = null, this.useCoupon = !1;
|
|
4067
4067
|
}
|
|
@@ -4089,11 +4089,11 @@ class ie {
|
|
|
4089
4089
|
return this.config.onError({ attributes: { message: u.message } }), !1;
|
|
4090
4090
|
}
|
|
4091
4091
|
await this._fetchCoupons();
|
|
4092
|
-
const i =
|
|
4092
|
+
const i = Ge(
|
|
4093
4093
|
(o = (t = this.checkoutContext) == null ? void 0 : t.data) == null ? void 0 : o.socket_connections,
|
|
4094
4094
|
(s) => tt(this, s)
|
|
4095
4095
|
);
|
|
4096
|
-
return i && (this.centrifuge = i.centrifuge), this.selectedPaymentMethod =
|
|
4096
|
+
return i && (this.centrifuge = i.centrifuge), this.selectedPaymentMethod = Re(
|
|
4097
4097
|
this.checkoutContext.data,
|
|
4098
4098
|
this._getKaspiOptions()
|
|
4099
4099
|
), this._emitPaymentMethodSelected(), this._render(), !0;
|
|
@@ -4106,7 +4106,7 @@ class ie {
|
|
|
4106
4106
|
}
|
|
4107
4107
|
destroy() {
|
|
4108
4108
|
const t = document.getElementById("choco-one-click-widget");
|
|
4109
|
-
t && (t.style.display = "none"), this._clearNewCardActionTimeout(),
|
|
4109
|
+
t && (t.style.display = "none"), this._clearNewCardActionTimeout(), te(this), this._pendingSuccessPayload = null, this._detachLifecycleListeners(), this.isAddCardViewOpen && ae(this), this.centrifuge && (this.centrifuge.disconnect(), this.centrifuge = null), document.removeEventListener("keydown", this._boundKeyDown), this.container && (this.container.classList.remove("choco-one-click-widget--visible"), setTimeout(() => {
|
|
4110
4110
|
var o;
|
|
4111
4111
|
(o = this.container) == null || o.remove(), this.container = null;
|
|
4112
4112
|
}, 300)), this.isOpen = !1, this.isPaymentSheetOpen = !1, this.isAddCardViewOpen = !1, this.selectedPaymentMethod = null;
|
|
@@ -4149,12 +4149,25 @@ class ie {
|
|
|
4149
4149
|
ht(this);
|
|
4150
4150
|
}
|
|
4151
4151
|
closePaymentSheet() {
|
|
4152
|
-
|
|
4152
|
+
G(this);
|
|
4153
4153
|
}
|
|
4154
4154
|
async updateAmount(t) {
|
|
4155
|
+
var o, i;
|
|
4155
4156
|
if (typeof t != "number" || !Number.isFinite(t) || t < 0)
|
|
4156
4157
|
throw new Error("amount must be a non-negative number");
|
|
4157
|
-
this.config.amount = t,
|
|
4158
|
+
if (this.config.amount = t, this.accessToken && this.isOpen) {
|
|
4159
|
+
const s = this.selectedCoupon;
|
|
4160
|
+
if (await this._fetchCoupons(), (s == null ? void 0 : s.voucher_id) !== ((o = this.selectedCoupon) == null ? void 0 : o.voucher_id)) {
|
|
4161
|
+
const a = this.isPaymentSheetOpen, l = this.isAddCardViewOpen;
|
|
4162
|
+
if (this._render(), Y(this), a) {
|
|
4163
|
+
const f = (i = this.container) == null ? void 0 : i.querySelector('[data-sheet="payment"]');
|
|
4164
|
+
f && (f.classList.add("choco-widget-payment-sheet--open"), this.isPaymentSheetOpen = !0);
|
|
4165
|
+
}
|
|
4166
|
+
l && Te(this);
|
|
4167
|
+
return;
|
|
4168
|
+
}
|
|
4169
|
+
}
|
|
4170
|
+
pe(this);
|
|
4158
4171
|
}
|
|
4159
4172
|
async updateAvailableBonus(t) {
|
|
4160
4173
|
if (typeof t != "number" || !Number.isFinite(t) || t < 0)
|
|
@@ -4166,17 +4179,17 @@ class ie {
|
|
|
4166
4179
|
throw new Error(`Unsupported locale: ${t}`);
|
|
4167
4180
|
if (this.config.locale = t, !this.container) return;
|
|
4168
4181
|
const o = this.isPaymentSheetOpen, i = this.isAddCardViewOpen;
|
|
4169
|
-
if (this._render(),
|
|
4182
|
+
if (this._render(), Y(this), o) {
|
|
4170
4183
|
const s = this.container.querySelector('[data-sheet="payment"]');
|
|
4171
4184
|
s && (s.classList.add("choco-widget-payment-sheet--open"), this.isPaymentSheetOpen = !0);
|
|
4172
4185
|
}
|
|
4173
|
-
i &&
|
|
4186
|
+
i && Te(this);
|
|
4174
4187
|
}
|
|
4175
4188
|
async setLoading(t) {
|
|
4176
|
-
this.loading = !!t,
|
|
4189
|
+
this.loading = !!t, Y(this);
|
|
4177
4190
|
}
|
|
4178
4191
|
async setDisabled(t) {
|
|
4179
|
-
this.disabled = !!t,
|
|
4192
|
+
this.disabled = !!t, Y(this);
|
|
4180
4193
|
}
|
|
4181
4194
|
async setPreorderId(t) {
|
|
4182
4195
|
this.config.preorderId = t;
|
|
@@ -4200,11 +4213,11 @@ class ie {
|
|
|
4200
4213
|
return this.config.onError({ attributes: { message: a.message } }), !1;
|
|
4201
4214
|
}
|
|
4202
4215
|
await this._fetchCoupons(), this.centrifuge && (this.centrifuge.disconnect(), this.centrifuge = null);
|
|
4203
|
-
const s =
|
|
4216
|
+
const s = Ge(
|
|
4204
4217
|
(i = (o = this.checkoutContext) == null ? void 0 : o.data) == null ? void 0 : i.socket_connections,
|
|
4205
4218
|
(u) => tt(this, u)
|
|
4206
4219
|
);
|
|
4207
|
-
return s && (this.centrifuge = s.centrifuge), this.selectedPaymentMethod =
|
|
4220
|
+
return s && (this.centrifuge = s.centrifuge), this.selectedPaymentMethod = Re(
|
|
4208
4221
|
this.checkoutContext.data,
|
|
4209
4222
|
this._getKaspiOptions()
|
|
4210
4223
|
), this._emitPaymentMethodSelected(), this.paymentMethodDisabled = !1, this._render(), !0;
|