@alma/in-page 2.11.0 → 2.12.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/README.md +30 -0
- package/dist/index.es.js +450 -438
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +148 -148
- package/dist/index.umd.js.map +1 -1
- package/dist/src/Embedded/eligibility.d.ts +1 -0
- package/dist/src/Embedded/fallback.d.ts +1 -1
- package/dist/src/Modal/modal.d.ts +2 -1
- package/dist/src/messages/listener.d.ts +1 -1
- package/dist/src/mount.d.ts +1 -1
- package/dist/src/store.d.ts +2 -4
- package/dist/src/types.d.ts +1 -0
- package/dist/src/unmount.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
const
|
|
1
|
+
var Q = Object.defineProperty;
|
|
2
|
+
var ee = (e, t, n) => t in e ? Q(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var z = (e, t, n) => ee(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
const te = (e = "LIVE", t) => {
|
|
5
5
|
let n = null, a = null;
|
|
6
6
|
return {
|
|
7
|
-
|
|
7
|
+
setPaymentModal: (s) => {
|
|
8
8
|
n = s;
|
|
9
9
|
},
|
|
10
|
-
|
|
10
|
+
getPaymentModal: () => n,
|
|
11
11
|
getEnvironment: () => e,
|
|
12
12
|
getCheckoutUrl: () => t,
|
|
13
13
|
setTranslations: (s) => {
|
|
@@ -15,18 +15,167 @@ const ee = (e = "LIVE", t) => {
|
|
|
15
15
|
},
|
|
16
16
|
getTranslations: () => a
|
|
17
17
|
};
|
|
18
|
-
},
|
|
18
|
+
}, i = "alma-in-page-modal", G = {
|
|
19
|
+
embedded: "/in-page/embedded/",
|
|
20
|
+
modal: "/in-page/modal/"
|
|
21
|
+
}, P = {
|
|
22
|
+
orange: "#FA5022",
|
|
23
|
+
backdrop: "#6C6C6C",
|
|
24
|
+
white: "#FEFEFE"
|
|
25
|
+
}, ne = `
|
|
26
|
+
#${i}-element {
|
|
27
|
+
position: fixed;
|
|
28
|
+
z-index: 10337;
|
|
29
|
+
top: 0;
|
|
30
|
+
left: 0;
|
|
31
|
+
bottom: 0;
|
|
32
|
+
right: 0;
|
|
33
|
+
display: flex;
|
|
34
|
+
align-items: center;
|
|
35
|
+
justify-content: center;
|
|
36
|
+
z-index: 9999;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
#${i}-background {
|
|
40
|
+
background: ${P.backdrop};
|
|
41
|
+
position: absolute;
|
|
42
|
+
width: 100vw;
|
|
43
|
+
height: 100vh;
|
|
44
|
+
opacity: 0.8;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
#${i}-body {
|
|
48
|
+
background: ${P.white};
|
|
49
|
+
width: 100%;
|
|
50
|
+
max-width: 700px;
|
|
51
|
+
height: calc(100% - 32px);
|
|
52
|
+
bottom: 0;
|
|
53
|
+
position: absolute;
|
|
54
|
+
border-radius: 0;
|
|
55
|
+
box-shadow: 0px 0px 12px 4px rgba(41, 15, 8, 0.04);
|
|
56
|
+
border-radius: 20px 20px 0 0;
|
|
57
|
+
overflow: hidden;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
#${i}-close {
|
|
61
|
+
position: absolute;
|
|
62
|
+
right: 0;
|
|
63
|
+
top: 0;
|
|
64
|
+
cursor: pointer;
|
|
65
|
+
width: 72px;
|
|
66
|
+
height: 72px;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
#${i}-close:hover, #${i}-close:focus-visible {
|
|
70
|
+
border-radius: 50%;
|
|
71
|
+
outline: 1px solid ${P.orange};
|
|
72
|
+
outline-offset: -16px;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
#${i}-logo {
|
|
76
|
+
position: absolute;
|
|
77
|
+
left: 24px;
|
|
78
|
+
top: 16px;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
#${i}-iframe {
|
|
82
|
+
width: 100%;
|
|
83
|
+
height: 100%;
|
|
84
|
+
border: 0;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.alma-fixed-body {
|
|
88
|
+
position: fixed;
|
|
89
|
+
width: 100%;
|
|
90
|
+
overflow: auto;
|
|
91
|
+
height: 100%;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.${i}-slideIn {
|
|
95
|
+
animation: ${i}-slideIn 300ms ease-out;
|
|
96
|
+
animation-iteration-count: 1;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.${i}-fadeIn {
|
|
100
|
+
animation: ${i}-fadeIn 300ms;
|
|
101
|
+
animation-iteration-count: 1;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.${i}-slideOut {
|
|
105
|
+
animation: ${i}-slideOut 300ms ease-in;
|
|
106
|
+
animation-iteration-count: 1;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.${i}-fadeOut {
|
|
110
|
+
animation: ${i}-fadeOut 300ms;
|
|
111
|
+
animation-iteration-count: 1;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
@media (min-width: 600px) {
|
|
115
|
+
#${i}-body {
|
|
116
|
+
width: 80%;
|
|
117
|
+
height: 80%;
|
|
118
|
+
max-height: 700px;
|
|
119
|
+
bottom: initial;
|
|
120
|
+
border-radius: 20px;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
@keyframes ${i}-slideIn {
|
|
125
|
+
from {
|
|
126
|
+
transform: translateY(300px);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
to {
|
|
130
|
+
transform: translateY(0px);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
@keyframes ${i}-fadeIn {
|
|
135
|
+
from {
|
|
136
|
+
opacity: 0;
|
|
137
|
+
visibility: hidden;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
to {
|
|
141
|
+
opacity: 1;
|
|
142
|
+
visibility: visible;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
@keyframes ${i}-slideOut {
|
|
147
|
+
from {
|
|
148
|
+
transform: translateY(0px);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
to {
|
|
152
|
+
transform: translateY(300px);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
@keyframes ${i}-fadeOut {
|
|
157
|
+
from {
|
|
158
|
+
opacity: 1;
|
|
159
|
+
visibility: visible;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
to {
|
|
163
|
+
opacity: 0;
|
|
164
|
+
visibility: hidden;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
`, ae = "data:image/svg+xml,%3csvg%20width='72'%20height='72'%20viewBox='0%200%2072%2072'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20filter='url(%23filter0_d_12596_6540)'%3e%3ccircle%20cx='36'%20cy='36'%20r='20'%20fill='white'/%3e%3c/g%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M29.4697%2029.4697C29.7626%2029.1768%2030.2374%2029.1768%2030.5303%2029.4697L36%2034.9393L41.4697%2029.4697C41.7626%2029.1768%2042.2374%2029.1768%2042.5303%2029.4697C42.8232%2029.7626%2042.8232%2030.2374%2042.5303%2030.5303L37.0607%2036L42.5303%2041.4697C42.8232%2041.7626%2042.8232%2042.2374%2042.5303%2042.5303C42.2374%2042.8232%2041.7626%2042.8232%2041.4697%2042.5303L36%2037.0607L30.5303%2042.5303C30.2374%2042.8232%2029.7626%2042.8232%2029.4697%2042.5303C29.1768%2042.2374%2029.1768%2041.7626%2029.4697%2041.4697L34.9393%2036L29.4697%2030.5303C29.1768%2030.2374%2029.1768%2029.7626%2029.4697%2029.4697Z'%20fill='%231A1A1A'/%3e%3cdefs%3e%3cfilter%20id='filter0_d_12596_6540'%20x='0'%20y='0'%20width='72'%20height='72'%20filterUnits='userSpaceOnUse'%20color-interpolation-filters='sRGB'%3e%3cfeFlood%20flood-opacity='0'%20result='BackgroundImageFix'/%3e%3cfeColorMatrix%20in='SourceAlpha'%20type='matrix'%20values='0%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%20127%200'%20result='hardAlpha'/%3e%3cfeMorphology%20radius='4'%20operator='dilate'%20in='SourceAlpha'%20result='effect1_dropShadow_12596_6540'/%3e%3cfeOffset/%3e%3cfeGaussianBlur%20stdDeviation='6'/%3e%3cfeComposite%20in2='hardAlpha'%20operator='out'/%3e%3cfeColorMatrix%20type='matrix'%20values='0%200%200%200%200.160784%200%200%200%200%200.0588235%200%200%200%200%200.0313726%200%200%200%200.04%200'/%3e%3cfeBlend%20mode='normal'%20in2='BackgroundImageFix'%20result='effect1_dropShadow_12596_6540'/%3e%3cfeBlend%20mode='normal'%20in='SourceGraphic'%20in2='effect1_dropShadow_12596_6540'%20result='shape'/%3e%3c/filter%3e%3c/defs%3e%3c/svg%3e", oe = "v2.12.0", re = (e) => {
|
|
19
168
|
const t = document.getElementById(e.replace("#", ""));
|
|
20
169
|
if (t)
|
|
21
170
|
return t;
|
|
22
|
-
|
|
171
|
+
H();
|
|
23
172
|
};
|
|
24
|
-
function
|
|
173
|
+
function H() {
|
|
25
174
|
throw new Error(
|
|
26
175
|
"Element not found, please add an id selector for the iframe"
|
|
27
176
|
);
|
|
28
177
|
}
|
|
29
|
-
function
|
|
178
|
+
function L(e, t) {
|
|
30
179
|
if (t)
|
|
31
180
|
return t;
|
|
32
181
|
switch (e) {
|
|
@@ -45,7 +194,7 @@ function B(e, t) {
|
|
|
45
194
|
return "https://checkout.getalma.eu";
|
|
46
195
|
}
|
|
47
196
|
}
|
|
48
|
-
function
|
|
197
|
+
function Y(e) {
|
|
49
198
|
switch (e) {
|
|
50
199
|
case "LOCAL":
|
|
51
200
|
return "http://localhost:1337";
|
|
@@ -62,28 +211,28 @@ function G(e) {
|
|
|
62
211
|
return "https://api.getalma.eu";
|
|
63
212
|
}
|
|
64
213
|
}
|
|
65
|
-
function
|
|
214
|
+
function S(e, t) {
|
|
66
215
|
const n = `[Alma InPage] ${e}`;
|
|
67
216
|
return console.error(n), t !== "PROD" && t !== "LIVE" && alert(n), n;
|
|
68
217
|
}
|
|
69
|
-
function
|
|
70
|
-
const n =
|
|
218
|
+
function se(e, t) {
|
|
219
|
+
const n = Y(t);
|
|
71
220
|
return fetch(`${n}/v1/checkout/payments/${e}/return-urls`, {
|
|
72
221
|
headers: {
|
|
73
|
-
"X-Alma-Agent": `Alma Checkout - InPage/${
|
|
222
|
+
"X-Alma-Agent": `Alma Checkout - InPage/${_()}`
|
|
74
223
|
}
|
|
75
224
|
}).then((a) => a.json()).then((a) => {
|
|
76
225
|
if (a.error_code) {
|
|
77
226
|
let o = "";
|
|
78
227
|
a.error_code === "not_found" && (o = `
|
|
79
228
|
|
|
80
|
-
Please check that payment "${e}" has been created on the ${t} environment (${n}).`),
|
|
229
|
+
Please check that payment "${e}" has been created on the ${t} environment (${n}).`), S(
|
|
81
230
|
`Error: ${a.error_code}
|
|
82
231
|
|
|
83
232
|
${a.message}${o}`,
|
|
84
233
|
t
|
|
85
234
|
);
|
|
86
|
-
} else a.origin && a.origin !== "online_in_page" &&
|
|
235
|
+
} else a.origin && a.origin !== "online_in_page" && S(
|
|
87
236
|
`Your payment does not have the proper origin for an in-page payment, you should use "online_in_page".
|
|
88
237
|
|
|
89
238
|
Please, check the documentation:
|
|
@@ -93,56 +242,120 @@ https://docs.almapay.com/docs/integration-in-page`,
|
|
|
93
242
|
return { success: a.return_url, failure: a.failure_return_url };
|
|
94
243
|
}).catch((a) => (console.error("[Alma InPage] Failed to fetch payment return URLs:", a), { success: void 0, failure: void 0 }));
|
|
95
244
|
}
|
|
96
|
-
function
|
|
97
|
-
return
|
|
245
|
+
function ie(e, t, n, a) {
|
|
246
|
+
return L(t, a) + "/" + e + n;
|
|
98
247
|
}
|
|
99
|
-
function
|
|
100
|
-
const e =
|
|
248
|
+
function _() {
|
|
249
|
+
const e = oe.match(/\d+\.\d+\.\d+/);
|
|
101
250
|
return e ? e[0] : "2.0.0";
|
|
102
251
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
252
|
+
let B = 0, C = null;
|
|
253
|
+
function le(e, t, n, a, o) {
|
|
254
|
+
C = n, document.getElementById(`${i}-wrapper`) && E(!1), B = window.scrollY, document.body.classList.add("alma-fixed-body"), document.body.scroll(0, B);
|
|
255
|
+
const l = ce(), m = ue(), p = me(), r = pe(), f = X(a), s = fe(e, t, o);
|
|
256
|
+
return document.body.appendChild(l), l.appendChild(m), m.appendChild(p), m.appendChild(r), r.appendChild(f), r.appendChild(s), l.classList.add(`${i}-fadeIn`), r.classList.add(`${i}-slideIn`), s.focus(), s;
|
|
257
|
+
}
|
|
258
|
+
function de(e) {
|
|
259
|
+
C = e;
|
|
260
|
+
const t = document.getElementById(`${i}-close`);
|
|
261
|
+
t && (t.title = e.closeModalButtonHover);
|
|
262
|
+
}
|
|
263
|
+
function E(e = !0, t) {
|
|
264
|
+
const n = document.getElementById(`${i}-wrapper`);
|
|
265
|
+
if (n && (!e || confirm(
|
|
266
|
+
(C == null ? void 0 : C.closeModalMessage) ?? "Are you sure you want to leave the payment page?"
|
|
267
|
+
))) {
|
|
268
|
+
const a = document.getElementById(
|
|
269
|
+
`${i}-wrapper`
|
|
270
|
+
), o = document.getElementById(`${i}-body`);
|
|
271
|
+
a == null || a.classList.add(`${i}-fadeOut`), o == null || o.classList.add(`${i}-slideOut`), window.setTimeout(() => {
|
|
272
|
+
document.body.classList.remove("alma-fixed-body"), document.body.scroll(0, B), n.remove(), t && t();
|
|
273
|
+
}, 300);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
function ce() {
|
|
277
|
+
const e = document.createElement("style");
|
|
278
|
+
e.innerHTML = ne;
|
|
279
|
+
const t = document.createElement("div");
|
|
280
|
+
return t.id = `${i}-wrapper`, t.role = "dialog", t.ariaModal = "true", t.appendChild(e), t;
|
|
281
|
+
}
|
|
282
|
+
function ue() {
|
|
283
|
+
const e = document.createElement("div");
|
|
284
|
+
return e.id = `${i}-element`, e;
|
|
285
|
+
}
|
|
286
|
+
function me() {
|
|
287
|
+
const e = document.createElement("div");
|
|
288
|
+
return e.id = `${i}-background`, e;
|
|
289
|
+
}
|
|
290
|
+
function pe() {
|
|
291
|
+
const e = document.createElement("div");
|
|
292
|
+
return e.id = `${i}-body`, e;
|
|
293
|
+
}
|
|
294
|
+
function fe(e, t, n) {
|
|
295
|
+
const a = new URL(
|
|
296
|
+
ie(e, t, G.modal, n)
|
|
297
|
+
);
|
|
298
|
+
a.searchParams.append("inPageVersion", _());
|
|
299
|
+
const o = document.createElement("iframe");
|
|
300
|
+
return o.id = `${i}-iframe`, o.setAttribute(
|
|
301
|
+
"allow",
|
|
302
|
+
"camera *; microphone *; geolocation *; clipboard-read *; clipboard-write *; gyroscope *; accelerometer *; magnetometer *; ch-ua-platform-version *; ch-ua-model *; ch-ua-full-version *; payment"
|
|
303
|
+
), o.src = a.toString(), o.title = "Alma", o;
|
|
304
|
+
}
|
|
305
|
+
function X(e) {
|
|
306
|
+
const t = document.createElement("img");
|
|
307
|
+
return t.id = `${i}-close`, t.title = (C == null ? void 0 : C.closeModalButtonHover) || "Close the alma modal (you'll lose your data)", t.onclick = () => E(!0, e), t.onkeyup = (n) => {
|
|
308
|
+
n.key === "Enter" && E(!1, e);
|
|
309
|
+
}, t.src = ae, t.tabIndex = 0, t;
|
|
310
|
+
}
|
|
311
|
+
function he() {
|
|
312
|
+
const e = document.getElementById(`${i}-close`);
|
|
313
|
+
e == null || e.remove();
|
|
314
|
+
}
|
|
315
|
+
function ge(e, t, n, a) {
|
|
316
|
+
const o = [], l = (r) => {
|
|
317
|
+
var f;
|
|
318
|
+
if (r.origin !== L(e, t) || r.data.from !== "checkout" || !r.source || r.source !== ((f = n()) == null ? void 0 : f.contentWindow))
|
|
106
319
|
return !1;
|
|
107
|
-
|
|
108
|
-
(
|
|
109
|
-
).forEach((
|
|
110
|
-
|
|
111
|
-
}) : (
|
|
320
|
+
r.data.type === "in_page_status" ? o.filter(
|
|
321
|
+
(s) => s && s.eventName === r.data.payload
|
|
322
|
+
).forEach((s) => {
|
|
323
|
+
s && s.callback();
|
|
324
|
+
}) : r.data.type === "locale" ? typeof r.data.payload == "string" && a(r.data.payload) : (
|
|
112
325
|
// Sent by the iframe fallback, see Embedded/fallback.ts
|
|
113
|
-
|
|
326
|
+
r.data.type !== "embedded_height" && r.data.type !== "translations" && console.warn("Unknown message type:", r.data.type)
|
|
114
327
|
);
|
|
115
328
|
};
|
|
116
|
-
window.addEventListener("message",
|
|
117
|
-
function
|
|
118
|
-
window.removeEventListener("message",
|
|
329
|
+
window.addEventListener("message", l, !1);
|
|
330
|
+
function m() {
|
|
331
|
+
window.removeEventListener("message", l, !1);
|
|
119
332
|
}
|
|
120
|
-
function
|
|
121
|
-
const
|
|
122
|
-
(
|
|
333
|
+
function p(r, f, s) {
|
|
334
|
+
const g = o.findIndex(
|
|
335
|
+
(b) => b && b.eventName === r && b.callerName === f
|
|
123
336
|
);
|
|
124
|
-
|
|
337
|
+
g !== -1 && (o[g] = null), o.push({ eventName: r, callerName: f, callback: s });
|
|
125
338
|
}
|
|
126
339
|
return {
|
|
127
|
-
onInPageStatusChanged:
|
|
128
|
-
unsubscribe:
|
|
340
|
+
onInPageStatusChanged: p,
|
|
341
|
+
unsubscribe: m
|
|
129
342
|
};
|
|
130
343
|
}
|
|
131
|
-
class
|
|
344
|
+
class J extends Error {
|
|
132
345
|
constructor() {
|
|
133
346
|
super(...arguments);
|
|
134
|
-
|
|
347
|
+
z(this, "name", "BlockedRequestError");
|
|
135
348
|
}
|
|
136
349
|
}
|
|
137
|
-
async function
|
|
350
|
+
async function ye(e, t) {
|
|
138
351
|
const n = await fetch(
|
|
139
|
-
`${
|
|
352
|
+
`${Y(t)}/v2/payments/eligibility`,
|
|
140
353
|
{
|
|
141
354
|
method: "POST",
|
|
142
355
|
headers: {
|
|
143
356
|
Authorization: `Alma-Merchant-Auth ${e.merchantId}`,
|
|
144
357
|
"Content-Type": "application/json",
|
|
145
|
-
"X-Alma-Agent": `Alma Checkout - InPage/${
|
|
358
|
+
"X-Alma-Agent": `Alma Checkout - InPage/${_()}`
|
|
146
359
|
},
|
|
147
360
|
body: JSON.stringify({
|
|
148
361
|
purchase_amount: e.amountInCents,
|
|
@@ -154,11 +367,12 @@ async function re(e, t) {
|
|
|
154
367
|
}
|
|
155
368
|
],
|
|
156
369
|
capture_method: e.captureMethod,
|
|
157
|
-
locale: e.locale
|
|
370
|
+
locale: e.locale,
|
|
371
|
+
...e.billingCountry && { billing_address: { country: e.billingCountry } }
|
|
158
372
|
})
|
|
159
373
|
}
|
|
160
374
|
).catch((o) => {
|
|
161
|
-
throw new
|
|
375
|
+
throw new J(String(o));
|
|
162
376
|
});
|
|
163
377
|
if (!n.ok)
|
|
164
378
|
throw new Error(`Eligibility request failed with status ${n.status}`);
|
|
@@ -166,57 +380,7 @@ async function re(e, t) {
|
|
|
166
380
|
(o) => o.eligible && o.deferred_days === e.deferredDays && o.deferred_months === e.deferredMonths
|
|
167
381
|
) ?? null;
|
|
168
382
|
}
|
|
169
|
-
const
|
|
170
|
-
embedded: "/in-page/embedded/",
|
|
171
|
-
modal: "/in-page/modal/"
|
|
172
|
-
};
|
|
173
|
-
function se(e, t) {
|
|
174
|
-
if (!e.isConnected) return;
|
|
175
|
-
const {
|
|
176
|
-
environment: n,
|
|
177
|
-
merchantId: a,
|
|
178
|
-
selector: o,
|
|
179
|
-
amountInCents: l,
|
|
180
|
-
installmentsCount: i,
|
|
181
|
-
deferredDays: c,
|
|
182
|
-
deferredMonths: d,
|
|
183
|
-
locale: f,
|
|
184
|
-
captureMethod: s,
|
|
185
|
-
style: v,
|
|
186
|
-
onIntegratedPayButtonClicked: g,
|
|
187
|
-
checkoutUrl: w
|
|
188
|
-
} = t, u = new URL(
|
|
189
|
-
B(n ?? "PROD", w) + Y.embedded
|
|
190
|
-
);
|
|
191
|
-
u.searchParams.append("merchantId", a), u.searchParams.append("amountInCents", l.toString()), u.searchParams.append("installmentsCount", i.toString()), c && u.searchParams.append("deferredDays", c.toString()), d && u.searchParams.append("deferredMonths", d.toString()), u.searchParams.append("locale", f ?? "FR"), u.searchParams.append("captureMethod", s ?? "automatic"), u.searchParams.append("domElement", o), u.searchParams.append("style", JSON.stringify(v || null)), u.searchParams.append("inPageVersion", k()), g && u.searchParams.append("showPayButton", "true"), u.searchParams.append("fallback", "true");
|
|
192
|
-
const p = document.createElement("iframe");
|
|
193
|
-
p.src = u.toString(), p.id = `alma-embedded-iframe-${o}`, p.style.width = "100%", p.style.height = "150px", p.style.transition = "height 0.5s", p.style.border = "none", p.style.display = e.style.display === "none" ? "none" : "block", p.setAttribute("allow", "payment"), e.replaceWith(p), window.addEventListener("message", function b(h) {
|
|
194
|
-
if (!p.isConnected) {
|
|
195
|
-
window.removeEventListener("message", b);
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
|
-
h.origin !== u.origin || h.source !== p.contentWindow || (h.data.type === "embedded_height" ? p.style.height = `${Math.ceil(h.data.payload)}px` : h.data.type === "in_page_status" && h.data.payload === "ready_for_payment" && (g == null || g()));
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
const X = "Alma Inter", ie = "https://cdn.almapay.com/fonts/Inter/InterVariable-latin.woff2", le = 300;
|
|
202
|
-
let _ = null;
|
|
203
|
-
function de() {
|
|
204
|
-
if (_ || typeof FontFace > "u" || !document.fonts) return;
|
|
205
|
-
const e = new FontFace(X, `url(${ie}) format("woff2")`, {
|
|
206
|
-
weight: "400 700",
|
|
207
|
-
display: "swap"
|
|
208
|
-
});
|
|
209
|
-
document.fonts.add(e), _ = e.load().catch((t) => {
|
|
210
|
-
console.error("[Alma InPage] Failed to load the font:", t);
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
function ce() {
|
|
214
|
-
return Promise.race([
|
|
215
|
-
_,
|
|
216
|
-
new Promise((e) => setTimeout(e, le))
|
|
217
|
-
]);
|
|
218
|
-
}
|
|
219
|
-
const J = {
|
|
383
|
+
const Z = {
|
|
220
384
|
fr: {
|
|
221
385
|
modal: {
|
|
222
386
|
closeModalMessage: "Voulez-vous vraiment quitter la page de paiement ?",
|
|
@@ -330,19 +494,66 @@ const J = {
|
|
|
330
494
|
}
|
|
331
495
|
}
|
|
332
496
|
};
|
|
333
|
-
function
|
|
334
|
-
return Object.keys(
|
|
497
|
+
function W(e) {
|
|
498
|
+
return Object.keys(Z).includes(e);
|
|
335
499
|
}
|
|
336
|
-
function
|
|
337
|
-
const t = String(e ?? "
|
|
338
|
-
if (
|
|
339
|
-
const n = navigator.language.split("-")[0];
|
|
340
|
-
return
|
|
500
|
+
function I(e) {
|
|
501
|
+
const t = String(e ?? "").toLowerCase();
|
|
502
|
+
if (W(t)) return t;
|
|
503
|
+
const n = navigator.language.split("-")[0].toLowerCase();
|
|
504
|
+
return W(n) ? n : "en";
|
|
341
505
|
}
|
|
342
|
-
function
|
|
343
|
-
return
|
|
506
|
+
function M(e) {
|
|
507
|
+
return Z[I(e)];
|
|
344
508
|
}
|
|
345
|
-
|
|
509
|
+
function be(e, t) {
|
|
510
|
+
if (!e.isConnected) return;
|
|
511
|
+
const {
|
|
512
|
+
environment: n,
|
|
513
|
+
merchantId: a,
|
|
514
|
+
selector: o,
|
|
515
|
+
amountInCents: l,
|
|
516
|
+
installmentsCount: m,
|
|
517
|
+
deferredDays: p,
|
|
518
|
+
deferredMonths: r,
|
|
519
|
+
locale: f,
|
|
520
|
+
captureMethod: s,
|
|
521
|
+
billingCountry: g,
|
|
522
|
+
style: b,
|
|
523
|
+
onIntegratedPayButtonClicked: y,
|
|
524
|
+
checkoutUrl: v
|
|
525
|
+
} = t, d = new URL(
|
|
526
|
+
L(n ?? "PROD", v) + G.embedded
|
|
527
|
+
);
|
|
528
|
+
d.searchParams.append("merchantId", a), d.searchParams.append("amountInCents", l.toString()), d.searchParams.append("installmentsCount", m.toString()), p && d.searchParams.append("deferredDays", p.toString()), r && d.searchParams.append("deferredMonths", r.toString()), d.searchParams.append("locale", I(f).toUpperCase()), d.searchParams.append("captureMethod", s ?? "automatic"), g !== void 0 && d.searchParams.append("billingCountry", g), d.searchParams.append("domElement", o), d.searchParams.append("style", JSON.stringify(b || null)), d.searchParams.append("inPageVersion", _()), y && d.searchParams.append("showPayButton", "true"), d.searchParams.append("fallback", "true");
|
|
529
|
+
const c = document.createElement("iframe");
|
|
530
|
+
return c.src = d.toString(), c.id = `alma-embedded-iframe-${o}`, c.style.width = "100%", c.style.height = "150px", c.style.transition = "height 0.5s", c.style.border = "none", c.style.display = e.style.display === "none" ? "none" : "block", c.setAttribute("allow", "payment"), e.replaceWith(c), window.addEventListener("message", function w(h) {
|
|
531
|
+
if (!c.isConnected) {
|
|
532
|
+
window.removeEventListener("message", w);
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
h.origin !== d.origin || h.source !== c.contentWindow || (h.data.type === "embedded_height" ? c.style.height = `${Math.ceil(h.data.payload)}px` : h.data.type === "in_page_status" && h.data.payload === "ready_for_payment" && (y == null || y()));
|
|
536
|
+
}), c;
|
|
537
|
+
}
|
|
538
|
+
const K = "Alma Inter", we = "https://cdn.almapay.com/fonts/Inter/InterVariable-latin.woff2", ve = 300;
|
|
539
|
+
let F = null;
|
|
540
|
+
function Ce() {
|
|
541
|
+
if (F || typeof FontFace > "u" || !document.fonts) return;
|
|
542
|
+
const e = new FontFace(K, `url(${we}) format("woff2")`, {
|
|
543
|
+
weight: "400 700",
|
|
544
|
+
display: "swap"
|
|
545
|
+
});
|
|
546
|
+
document.fonts.add(e), F = e.load().catch((t) => {
|
|
547
|
+
console.error("[Alma InPage] Failed to load the font:", t);
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
function $e() {
|
|
551
|
+
return Promise.race([
|
|
552
|
+
F,
|
|
553
|
+
new Promise((e) => setTimeout(e, ve))
|
|
554
|
+
]);
|
|
555
|
+
}
|
|
556
|
+
const N = `
|
|
346
557
|
/* The merchant's rules matching the host win over :host, unless :host is !important */
|
|
347
558
|
:host {
|
|
348
559
|
padding: 0 !important;
|
|
@@ -363,7 +574,7 @@ const U = `
|
|
|
363
574
|
flex-direction: column;
|
|
364
575
|
gap: 10px;
|
|
365
576
|
margin: 8px 16px;
|
|
366
|
-
font-family: "${
|
|
577
|
+
font-family: "${K}", sans-serif;
|
|
367
578
|
font-size: 14px;
|
|
368
579
|
line-height: 19px;
|
|
369
580
|
letter-spacing: -0.6px;
|
|
@@ -487,32 +698,32 @@ const U = `
|
|
|
487
698
|
}
|
|
488
699
|
}
|
|
489
700
|
`;
|
|
490
|
-
function
|
|
701
|
+
function u(e, t, n) {
|
|
491
702
|
const a = document.createElement(e);
|
|
492
703
|
return t && (a.className = t), n !== void 0 && (a.textContent = n), a;
|
|
493
704
|
}
|
|
494
|
-
function
|
|
495
|
-
const n =
|
|
705
|
+
function k(e, t) {
|
|
706
|
+
const n = u("span", "skeleton");
|
|
496
707
|
n.style.width = `${e}px`;
|
|
497
|
-
const a =
|
|
708
|
+
const a = u("span", t);
|
|
498
709
|
return a.append(n), a;
|
|
499
710
|
}
|
|
500
|
-
function
|
|
711
|
+
function T(e, t) {
|
|
501
712
|
t && typeof t == "object" && Object.assign(e.style, t);
|
|
502
713
|
}
|
|
503
|
-
function
|
|
504
|
-
const t =
|
|
505
|
-
return
|
|
506
|
-
}
|
|
507
|
-
let I = null;
|
|
508
|
-
function O(e, t) {
|
|
509
|
-
"adoptedStyleSheets" in e && "replaceSync" in CSSStyleSheet.prototype ? (I || (I = new CSSStyleSheet(), I.replaceSync(U)), e.adoptedStyleSheets = [I], e.replaceChildren(t)) : e.replaceChildren(m("style", void 0, U), t);
|
|
714
|
+
function O(e) {
|
|
715
|
+
const t = u("div", "container fadeIn");
|
|
716
|
+
return T(t, e.containerStyle), t;
|
|
510
717
|
}
|
|
718
|
+
let A = null;
|
|
511
719
|
function D(e, t) {
|
|
720
|
+
"adoptedStyleSheets" in e && "replaceSync" in CSSStyleSheet.prototype ? (A || (A = new CSSStyleSheet(), A.replaceSync(N)), e.adoptedStyleSheets = [A], e.replaceChildren(t)) : e.replaceChildren(u("style", void 0, N), t);
|
|
721
|
+
}
|
|
722
|
+
function R(e, t) {
|
|
512
723
|
var o;
|
|
513
724
|
const n = e.host.clientWidth;
|
|
514
725
|
(o = e.querySelector(".button")) == null || o.classList.toggle("fitContent", n >= 769);
|
|
515
|
-
const a = new Intl.DateTimeFormat(
|
|
726
|
+
const a = new Intl.DateTimeFormat(I(t), {
|
|
516
727
|
day: "numeric",
|
|
517
728
|
month: n > 400 ? "long" : "short"
|
|
518
729
|
}).format;
|
|
@@ -520,392 +731,193 @@ function D(e, t) {
|
|
|
520
731
|
l.textContent = a(Number(l.dataset.dueDate));
|
|
521
732
|
});
|
|
522
733
|
}
|
|
523
|
-
function
|
|
734
|
+
function q(e) {
|
|
524
735
|
return e > 4;
|
|
525
736
|
}
|
|
526
|
-
function
|
|
527
|
-
const n =
|
|
528
|
-
n.classList.add("delayed"),
|
|
529
|
-
const a =
|
|
530
|
-
if (t.isDeferredCapture && n.append(
|
|
531
|
-
const o =
|
|
532
|
-
for (let
|
|
533
|
-
const f =
|
|
534
|
-
f.append(
|
|
737
|
+
function xe(e, t) {
|
|
738
|
+
const n = O(t);
|
|
739
|
+
n.classList.add("delayed"), D(e, n);
|
|
740
|
+
const a = M(t.locale).embedded;
|
|
741
|
+
if (t.isDeferredCapture && n.append(u("div", "bold", a.deferredCaptureExplanation)), !q(t.installmentsCount)) {
|
|
742
|
+
const o = u("div", "installments");
|
|
743
|
+
for (let r = 0; r < t.installmentsCount; r++) {
|
|
744
|
+
const f = u("div", "installment");
|
|
745
|
+
f.append(k(90, "label"), k(60)), o.append(f);
|
|
535
746
|
}
|
|
536
|
-
const l =
|
|
537
|
-
|
|
747
|
+
const l = u("div", "total"), m = u("div", "totalAmount"), p = u("div", "bold");
|
|
748
|
+
p.append(k(60)), m.append(p, u("div", "fees", " ")), l.append(k(40), m), o.append(l), n.append(o);
|
|
538
749
|
}
|
|
539
750
|
if (t.onPayButtonClicked) {
|
|
540
|
-
const o =
|
|
541
|
-
o.disabled = !0,
|
|
751
|
+
const o = u("button", "button skeletonButton", " ");
|
|
752
|
+
o.disabled = !0, T(o, t.buttonStyle), n.append(o);
|
|
542
753
|
}
|
|
543
|
-
|
|
754
|
+
R(e, t.locale);
|
|
544
755
|
}
|
|
545
|
-
function
|
|
546
|
-
const a =
|
|
756
|
+
function Ee(e, t, n) {
|
|
757
|
+
const a = O(n), o = I(n.locale), l = M(n.locale).embedded, m = (s) => new Intl.NumberFormat(o, {
|
|
547
758
|
style: "currency",
|
|
548
759
|
currency: "EUR"
|
|
549
|
-
}).format(s / 100),
|
|
760
|
+
}).format(s / 100), p = (s) => new Intl.NumberFormat(o, {
|
|
550
761
|
style: "percent",
|
|
551
762
|
minimumFractionDigits: 2,
|
|
552
763
|
maximumFractionDigits: 2
|
|
553
764
|
}).format(s / 1e4);
|
|
554
|
-
n.isDeferredCapture && a.append(
|
|
555
|
-
const
|
|
556
|
-
if (!
|
|
557
|
-
const s =
|
|
558
|
-
s.dataset.testid = "installments", t.payment_plan.forEach((
|
|
559
|
-
const
|
|
560
|
-
|
|
561
|
-
const
|
|
562
|
-
n.isDeferredCapture ?
|
|
563
|
-
|
|
564
|
-
|
|
765
|
+
n.isDeferredCapture && a.append(u("div", "bold", l.deferredCaptureExplanation));
|
|
766
|
+
const r = t.customer_fee + t.customer_interest, f = t.purchase_amount + r;
|
|
767
|
+
if (!q(n.installmentsCount)) {
|
|
768
|
+
const s = u("div", "installments");
|
|
769
|
+
s.dataset.testid = "installments", t.payment_plan.forEach((c, w) => {
|
|
770
|
+
const h = u("div", "installment");
|
|
771
|
+
h.dataset.testid = `installment-${w}`;
|
|
772
|
+
const $ = u("span", "label");
|
|
773
|
+
n.isDeferredCapture ? $.textContent = w === 0 ? l.deferredFirstInstallment : l.deferredMonth(w) : ($.classList.add("date"), $.dataset.dueDate = String(c.due_date * 1e3)), h.append(
|
|
774
|
+
$,
|
|
775
|
+
u(
|
|
565
776
|
"span",
|
|
566
777
|
void 0,
|
|
567
|
-
|
|
568
|
-
|
|
778
|
+
m(
|
|
779
|
+
c.purchase_amount + c.customer_fee + c.customer_interest
|
|
569
780
|
)
|
|
570
781
|
)
|
|
571
|
-
), s.append(
|
|
782
|
+
), s.append(h);
|
|
572
783
|
});
|
|
573
|
-
const
|
|
574
|
-
|
|
575
|
-
const
|
|
576
|
-
|
|
784
|
+
const g = u("div", "total"), b = u("div", "fees"), y = m(r), v = typeof t.annual_interest_rate == "number" ? p(t.annual_interest_rate) : null;
|
|
785
|
+
b.textContent = `${l.customerFees} ${v === null ? y : l.feesWithTaeg(y, v)}`;
|
|
786
|
+
const d = u("div", "totalAmount");
|
|
787
|
+
d.append(u("div", "bold", m(f)), b), g.append(u("span", "bold", l.total), d), s.append(g), a.append(s);
|
|
577
788
|
}
|
|
578
789
|
if (n.onPayButtonClicked) {
|
|
579
|
-
const s =
|
|
790
|
+
const s = u(
|
|
580
791
|
"button",
|
|
581
792
|
"button",
|
|
582
|
-
l.payButton(
|
|
793
|
+
l.payButton(m(f))
|
|
583
794
|
);
|
|
584
|
-
s.type = "button",
|
|
585
|
-
var
|
|
586
|
-
return (
|
|
795
|
+
s.type = "button", T(s, n.buttonStyle), s.onclick = () => {
|
|
796
|
+
var g;
|
|
797
|
+
return (g = n.onPayButtonClicked) == null ? void 0 : g.call(n);
|
|
587
798
|
}, a.append(s);
|
|
588
799
|
}
|
|
589
|
-
|
|
800
|
+
D(e, a), R(e, n.locale);
|
|
590
801
|
}
|
|
591
|
-
function
|
|
592
|
-
const n =
|
|
593
|
-
n.classList.add("error"), n.textContent =
|
|
802
|
+
function j(e, t) {
|
|
803
|
+
const n = O(t);
|
|
804
|
+
n.classList.add("error"), n.textContent = M(t.locale).embedded.noPlanError, D(e, n);
|
|
594
805
|
}
|
|
595
|
-
function
|
|
596
|
-
var
|
|
806
|
+
function Me(e) {
|
|
807
|
+
var U;
|
|
597
808
|
const {
|
|
598
809
|
environment: t,
|
|
599
810
|
merchantId: n,
|
|
600
811
|
selector: a,
|
|
601
812
|
amountInCents: o,
|
|
602
813
|
installmentsCount: l,
|
|
603
|
-
deferredDays:
|
|
604
|
-
deferredMonths:
|
|
605
|
-
locale:
|
|
814
|
+
deferredDays: m,
|
|
815
|
+
deferredMonths: p,
|
|
816
|
+
locale: r,
|
|
606
817
|
captureMethod: f,
|
|
607
818
|
style: s,
|
|
608
|
-
|
|
819
|
+
billingCountry: g,
|
|
820
|
+
onIntegratedPayButtonClicked: b
|
|
609
821
|
} = e;
|
|
610
|
-
if (!a)
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
const
|
|
615
|
-
|
|
616
|
-
const
|
|
617
|
-
|
|
618
|
-
|
|
822
|
+
if (!a) {
|
|
823
|
+
H();
|
|
824
|
+
return;
|
|
825
|
+
}
|
|
826
|
+
const y = (x) => parseInt(String(x), 10), v = y(l), d = document.createElement("div");
|
|
827
|
+
d.id = `alma-embedded-${a.replace("#", "")}`, d.style.width = "100%", d.style.display = v > 4 && !b ? "none" : "flow-root";
|
|
828
|
+
const c = d.attachShadow({ mode: "open" });
|
|
829
|
+
(U = re(a)) == null || U.replaceChildren(d);
|
|
830
|
+
let w = d;
|
|
831
|
+
const h = {
|
|
832
|
+
locale: r,
|
|
833
|
+
installmentsCount: v,
|
|
619
834
|
isDeferredCapture: f === "manual",
|
|
620
|
-
onPayButtonClicked:
|
|
835
|
+
onPayButtonClicked: b,
|
|
621
836
|
containerStyle: s == null ? void 0 : s.embedded,
|
|
622
837
|
buttonStyle: s == null ? void 0 : s.embeddedButton
|
|
623
838
|
};
|
|
624
|
-
|
|
625
|
-
const
|
|
626
|
-
|
|
839
|
+
Ce(), xe(c, h);
|
|
840
|
+
const $ = new ResizeObserver(() => {
|
|
841
|
+
d.isConnected ? R(c, r) : $.disconnect();
|
|
627
842
|
});
|
|
628
|
-
return
|
|
843
|
+
return $.observe(d), ye(
|
|
629
844
|
{
|
|
630
845
|
merchantId: n,
|
|
631
|
-
amountInCents:
|
|
632
|
-
installmentsCount:
|
|
633
|
-
deferredDays:
|
|
634
|
-
deferredMonths:
|
|
846
|
+
amountInCents: y(o),
|
|
847
|
+
installmentsCount: v,
|
|
848
|
+
deferredDays: y(m) || 0,
|
|
849
|
+
deferredMonths: y(p) || 0,
|
|
635
850
|
captureMethod: f ?? "automatic",
|
|
636
|
-
locale:
|
|
851
|
+
locale: I(r).toUpperCase(),
|
|
852
|
+
billingCountry: g
|
|
637
853
|
},
|
|
638
854
|
t ?? "PROD"
|
|
639
|
-
).then(async (
|
|
640
|
-
await
|
|
641
|
-
}).catch((
|
|
642
|
-
console.error("[Alma InPage] Failed to display the payment plan:",
|
|
643
|
-
}),
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
backdrop: "#6C6C6C",
|
|
648
|
-
white: "#FEFEFE"
|
|
649
|
-
}, fe = `
|
|
650
|
-
#${r}-element {
|
|
651
|
-
position: fixed;
|
|
652
|
-
z-index: 10337;
|
|
653
|
-
top: 0;
|
|
654
|
-
left: 0;
|
|
655
|
-
bottom: 0;
|
|
656
|
-
right: 0;
|
|
657
|
-
display: flex;
|
|
658
|
-
align-items: center;
|
|
659
|
-
justify-content: center;
|
|
660
|
-
z-index: 9999;
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
#${r}-background {
|
|
664
|
-
background: ${A.backdrop};
|
|
665
|
-
position: absolute;
|
|
666
|
-
width: 100vw;
|
|
667
|
-
height: 100vh;
|
|
668
|
-
opacity: 0.8;
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
#${r}-body {
|
|
672
|
-
background: ${A.white};
|
|
673
|
-
width: 100%;
|
|
674
|
-
max-width: 700px;
|
|
675
|
-
height: calc(100% - 32px);
|
|
676
|
-
bottom: 0;
|
|
677
|
-
position: absolute;
|
|
678
|
-
border-radius: 0;
|
|
679
|
-
box-shadow: 0px 0px 12px 4px rgba(41, 15, 8, 0.04);
|
|
680
|
-
border-radius: 20px 20px 0 0;
|
|
681
|
-
overflow: hidden;
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
#${r}-close {
|
|
685
|
-
position: absolute;
|
|
686
|
-
right: 0;
|
|
687
|
-
top: 0;
|
|
688
|
-
cursor: pointer;
|
|
689
|
-
width: 72px;
|
|
690
|
-
height: 72px;
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
#${r}-close:hover, #${r}-close:focus-visible {
|
|
694
|
-
border-radius: 50%;
|
|
695
|
-
outline: 1px solid ${A.orange};
|
|
696
|
-
outline-offset: -16px;
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
#${r}-logo {
|
|
700
|
-
position: absolute;
|
|
701
|
-
left: 24px;
|
|
702
|
-
top: 16px;
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
#${r}-iframe {
|
|
706
|
-
width: 100%;
|
|
707
|
-
height: 100%;
|
|
708
|
-
border: 0;
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
.alma-fixed-body {
|
|
712
|
-
position: fixed;
|
|
713
|
-
width: 100%;
|
|
714
|
-
overflow: auto;
|
|
715
|
-
height: 100%;
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
.${r}-slideIn {
|
|
719
|
-
animation: ${r}-slideIn 300ms ease-out;
|
|
720
|
-
animation-iteration-count: 1;
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
.${r}-fadeIn {
|
|
724
|
-
animation: ${r}-fadeIn 300ms;
|
|
725
|
-
animation-iteration-count: 1;
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
.${r}-slideOut {
|
|
729
|
-
animation: ${r}-slideOut 300ms ease-in;
|
|
730
|
-
animation-iteration-count: 1;
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
.${r}-fadeOut {
|
|
734
|
-
animation: ${r}-fadeOut 300ms;
|
|
735
|
-
animation-iteration-count: 1;
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
@media (min-width: 600px) {
|
|
739
|
-
#${r}-body {
|
|
740
|
-
width: 80%;
|
|
741
|
-
height: 80%;
|
|
742
|
-
max-height: 700px;
|
|
743
|
-
bottom: initial;
|
|
744
|
-
border-radius: 20px;
|
|
745
|
-
}
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
@keyframes ${r}-slideIn {
|
|
749
|
-
from {
|
|
750
|
-
transform: translateY(300px);
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
to {
|
|
754
|
-
transform: translateY(0px);
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
|
|
758
|
-
@keyframes ${r}-fadeIn {
|
|
759
|
-
from {
|
|
760
|
-
opacity: 0;
|
|
761
|
-
visibility: hidden;
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
to {
|
|
765
|
-
opacity: 1;
|
|
766
|
-
visibility: visible;
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
|
|
770
|
-
@keyframes ${r}-slideOut {
|
|
771
|
-
from {
|
|
772
|
-
transform: translateY(0px);
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
to {
|
|
776
|
-
transform: translateY(300px);
|
|
777
|
-
}
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
@keyframes ${r}-fadeOut {
|
|
781
|
-
from {
|
|
782
|
-
opacity: 1;
|
|
783
|
-
visibility: visible;
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
to {
|
|
787
|
-
opacity: 0;
|
|
788
|
-
visibility: hidden;
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
|
-
`, he = "data:image/svg+xml,%3csvg%20width='72'%20height='72'%20viewBox='0%200%2072%2072'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20filter='url(%23filter0_d_12596_6540)'%3e%3ccircle%20cx='36'%20cy='36'%20r='20'%20fill='white'/%3e%3c/g%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M29.4697%2029.4697C29.7626%2029.1768%2030.2374%2029.1768%2030.5303%2029.4697L36%2034.9393L41.4697%2029.4697C41.7626%2029.1768%2042.2374%2029.1768%2042.5303%2029.4697C42.8232%2029.7626%2042.8232%2030.2374%2042.5303%2030.5303L37.0607%2036L42.5303%2041.4697C42.8232%2041.7626%2042.8232%2042.2374%2042.5303%2042.5303C42.2374%2042.8232%2041.7626%2042.8232%2041.4697%2042.5303L36%2037.0607L30.5303%2042.5303C30.2374%2042.8232%2029.7626%2042.8232%2029.4697%2042.5303C29.1768%2042.2374%2029.1768%2041.7626%2029.4697%2041.4697L34.9393%2036L29.4697%2030.5303C29.1768%2030.2374%2029.1768%2029.7626%2029.4697%2029.4697Z'%20fill='%231A1A1A'/%3e%3cdefs%3e%3cfilter%20id='filter0_d_12596_6540'%20x='0'%20y='0'%20width='72'%20height='72'%20filterUnits='userSpaceOnUse'%20color-interpolation-filters='sRGB'%3e%3cfeFlood%20flood-opacity='0'%20result='BackgroundImageFix'/%3e%3cfeColorMatrix%20in='SourceAlpha'%20type='matrix'%20values='0%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%20127%200'%20result='hardAlpha'/%3e%3cfeMorphology%20radius='4'%20operator='dilate'%20in='SourceAlpha'%20result='effect1_dropShadow_12596_6540'/%3e%3cfeOffset/%3e%3cfeGaussianBlur%20stdDeviation='6'/%3e%3cfeComposite%20in2='hardAlpha'%20operator='out'/%3e%3cfeColorMatrix%20type='matrix'%20values='0%200%200%200%200.160784%200%200%200%200%200.0588235%200%200%200%200%200.0313726%200%200%200%200.04%200'/%3e%3cfeBlend%20mode='normal'%20in2='BackgroundImageFix'%20result='effect1_dropShadow_12596_6540'/%3e%3cfeBlend%20mode='normal'%20in='SourceGraphic'%20in2='effect1_dropShadow_12596_6540'%20result='shape'/%3e%3c/filter%3e%3c/defs%3e%3c/svg%3e";
|
|
792
|
-
let P = 0, E = null;
|
|
793
|
-
function ge(e, t, n, a, o) {
|
|
794
|
-
E = n, document.getElementById(`${r}-wrapper`) && x(!1), P = window.scrollY, document.body.classList.add("alma-fixed-body"), document.body.scroll(0, P);
|
|
795
|
-
const l = ye(), i = be(), c = ve(), d = we(), f = q(a), s = Ee(e, t, o);
|
|
796
|
-
document.body.appendChild(l), l.appendChild(i), i.appendChild(c), i.appendChild(d), d.appendChild(f), d.appendChild(s), l.classList.add(`${r}-fadeIn`), d.classList.add(`${r}-slideIn`), s.focus();
|
|
797
|
-
}
|
|
798
|
-
function x(e = !0, t) {
|
|
799
|
-
const n = document.getElementById(`${r}-wrapper`);
|
|
800
|
-
if (n && (!e || confirm(
|
|
801
|
-
(E == null ? void 0 : E.closeModalMessage) ?? "Are you sure you want to leave the payment page?"
|
|
802
|
-
))) {
|
|
803
|
-
const a = document.getElementById(
|
|
804
|
-
`${r}-wrapper`
|
|
805
|
-
), o = document.getElementById(`${r}-body`);
|
|
806
|
-
a == null || a.classList.add(`${r}-fadeOut`), o == null || o.classList.add(`${r}-slideOut`), window.setTimeout(() => {
|
|
807
|
-
document.body.classList.remove("alma-fixed-body"), document.body.scroll(0, P), n.remove(), t && t();
|
|
808
|
-
}, 300);
|
|
809
|
-
}
|
|
810
|
-
}
|
|
811
|
-
function ye() {
|
|
812
|
-
const e = document.createElement("style");
|
|
813
|
-
e.innerHTML = fe;
|
|
814
|
-
const t = document.createElement("div");
|
|
815
|
-
return t.id = `${r}-wrapper`, t.role = "dialog", t.ariaModal = "true", t.appendChild(e), t;
|
|
816
|
-
}
|
|
817
|
-
function be() {
|
|
818
|
-
const e = document.createElement("div");
|
|
819
|
-
return e.id = `${r}-element`, e;
|
|
820
|
-
}
|
|
821
|
-
function ve() {
|
|
822
|
-
const e = document.createElement("div");
|
|
823
|
-
return e.id = `${r}-background`, e;
|
|
824
|
-
}
|
|
825
|
-
function we() {
|
|
826
|
-
const e = document.createElement("div");
|
|
827
|
-
return e.id = `${r}-body`, e;
|
|
828
|
-
}
|
|
829
|
-
function Ee(e, t, n) {
|
|
830
|
-
const a = new URL(
|
|
831
|
-
ae(e, t, Y.modal, n)
|
|
832
|
-
);
|
|
833
|
-
a.searchParams.append("inPageVersion", k());
|
|
834
|
-
const o = document.createElement("iframe");
|
|
835
|
-
return o.id = `${r}-iframe`, o.setAttribute(
|
|
836
|
-
"allow",
|
|
837
|
-
"camera *; microphone *; geolocation *; clipboard-read *; clipboard-write *; gyroscope *; accelerometer *; magnetometer *; ch-ua-platform-version *; ch-ua-model *; ch-ua-full-version *; payment"
|
|
838
|
-
), o.src = a.toString(), o.title = "Alma", o;
|
|
839
|
-
}
|
|
840
|
-
function q(e) {
|
|
841
|
-
const t = document.createElement("img");
|
|
842
|
-
return t.id = `${r}-close`, t.title = (E == null ? void 0 : E.closeModalButtonHover) || "Close the alma modal (you'll lose your data)", t.onclick = () => x(!0, e), t.onkeyup = (n) => {
|
|
843
|
-
n.key === "Enter" && x(!1, e);
|
|
844
|
-
}, t.src = he, t.tabIndex = 0, t;
|
|
845
|
-
}
|
|
846
|
-
function $e() {
|
|
847
|
-
const e = document.getElementById(`${r}-close`);
|
|
848
|
-
e == null || e.remove();
|
|
849
|
-
}
|
|
850
|
-
function xe(e, t, n) {
|
|
851
|
-
const { paymentId: a, onPaymentRejected: o, onPaymentSucceeded: l, onUserCloseModal: i } = e;
|
|
855
|
+
).then(async (x) => {
|
|
856
|
+
await $e(), x ? Ee(c, x, h) : j(c, h);
|
|
857
|
+
}).catch((x) => {
|
|
858
|
+
console.error("[Alma InPage] Failed to display the payment plan:", x), x instanceof J ? w = be(d, e) ?? w : j(c, h);
|
|
859
|
+
}), () => w.remove();
|
|
860
|
+
}
|
|
861
|
+
function Ie(e, t, n) {
|
|
862
|
+
const { paymentId: a, onPaymentRejected: o, onPaymentSucceeded: l, onUserCloseModal: m } = e;
|
|
852
863
|
if (typeof a != "string" || a.trim() === "") {
|
|
853
|
-
const
|
|
864
|
+
const r = S(
|
|
854
865
|
`startPayment() requires a non-empty "paymentId" (received: ${JSON.stringify(
|
|
855
866
|
a
|
|
856
867
|
)}). Make sure the payment has been created and its id retrieved before calling startPayment().`,
|
|
857
868
|
t.getEnvironment()
|
|
858
869
|
);
|
|
859
|
-
throw new Error(
|
|
870
|
+
throw new Error(r);
|
|
860
871
|
}
|
|
861
|
-
const
|
|
872
|
+
const p = {
|
|
862
873
|
success: null,
|
|
863
874
|
failure: null
|
|
864
875
|
};
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
}),
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
876
|
+
se(a, t.getEnvironment()).then((r) => {
|
|
877
|
+
p.success = r.success, p.failure = r.failure;
|
|
878
|
+
}), t.setPaymentModal(
|
|
879
|
+
le(
|
|
880
|
+
a,
|
|
881
|
+
t.getEnvironment(),
|
|
882
|
+
t.getTranslations(),
|
|
883
|
+
m,
|
|
884
|
+
t.getCheckoutUrl()
|
|
885
|
+
)
|
|
873
886
|
), n(
|
|
874
887
|
"3ds_started",
|
|
875
888
|
"start-payment",
|
|
876
|
-
|
|
889
|
+
he
|
|
877
890
|
), n("3ds_failed", "start-payment", () => {
|
|
878
|
-
const
|
|
879
|
-
|
|
891
|
+
const r = document.getElementById(`${i}-body`);
|
|
892
|
+
r && r.appendChild(X(m));
|
|
880
893
|
}), n("trigger_success_callback", "start-payment", () => {
|
|
881
|
-
|
|
894
|
+
V(l, p.success);
|
|
882
895
|
}), n("trigger_reject_callback", "start-payment", () => {
|
|
883
|
-
|
|
896
|
+
V(o, p.failure);
|
|
884
897
|
});
|
|
885
898
|
}
|
|
886
|
-
function
|
|
887
|
-
|
|
899
|
+
function V(e, t) {
|
|
900
|
+
E(!1), e ? e() : t && window.location.assign(t);
|
|
888
901
|
}
|
|
889
|
-
function
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
return;
|
|
893
|
-
const a = j(n);
|
|
894
|
-
e.setEmbeddedSelector(null), a && a.firstChild && a.removeChild(a.firstChild);
|
|
902
|
+
function ke(e, t, n) {
|
|
903
|
+
var a;
|
|
904
|
+
(a = e.getPaymentModal()) != null && a.isConnected && E(!1), t(), n == null || n();
|
|
895
905
|
}
|
|
896
|
-
function
|
|
897
|
-
const t =
|
|
898
|
-
t.setTranslations(
|
|
899
|
-
const { onInPageStatusChanged: n, unsubscribe: a } =
|
|
906
|
+
function _e(e) {
|
|
907
|
+
const t = te(e.environment, e.checkoutUrl);
|
|
908
|
+
t.setTranslations(M(e.locale).modal);
|
|
909
|
+
const { onInPageStatusChanged: n, unsubscribe: a } = ge(
|
|
900
910
|
t.getEnvironment(),
|
|
901
|
-
e.checkoutUrl
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
911
|
+
e.checkoutUrl,
|
|
912
|
+
t.getPaymentModal,
|
|
913
|
+
(l) => de(M(l).modal)
|
|
914
|
+
), o = Me(e);
|
|
915
|
+
return {
|
|
916
|
+
startPayment: (l) => Ie(l, t, n),
|
|
917
|
+
unmount: () => ke(t, a, o)
|
|
906
918
|
};
|
|
907
919
|
}
|
|
908
920
|
export {
|
|
909
|
-
|
|
921
|
+
_e as initialize
|
|
910
922
|
};
|
|
911
923
|
//# sourceMappingURL=index.es.js.map
|