@alma/in-page 2.10.0 → 2.11.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/index.es.js +181 -181
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +9 -9
- package/dist/index.umd.js.map +1 -1
- package/dist/src/Embedded/eligibility.d.ts +2 -0
- package/dist/src/translations.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var R = (e, t, n) =>
|
|
1
|
+
var K = Object.defineProperty;
|
|
2
|
+
var Q = (e, t, n) => t in e ? K(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var R = (e, t, n) => Q(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
4
|
const ee = (e = "LIVE", t) => {
|
|
5
5
|
let n = null, a = null;
|
|
6
6
|
return {
|
|
7
|
-
setEmbeddedSelector: (
|
|
8
|
-
n =
|
|
7
|
+
setEmbeddedSelector: (s) => {
|
|
8
|
+
n = s;
|
|
9
9
|
},
|
|
10
10
|
getEmbeddedSelector: () => n,
|
|
11
11
|
getEnvironment: () => e,
|
|
12
12
|
getCheckoutUrl: () => t,
|
|
13
|
-
setTranslations: (
|
|
14
|
-
a =
|
|
13
|
+
setTranslations: (s) => {
|
|
14
|
+
a = s;
|
|
15
15
|
},
|
|
16
16
|
getTranslations: () => a
|
|
17
17
|
};
|
|
18
|
-
}, te = "v2.
|
|
18
|
+
}, te = "v2.11.0", j = (e) => {
|
|
19
19
|
const t = document.getElementById(e.replace("#", ""));
|
|
20
20
|
if (t)
|
|
21
21
|
return t;
|
|
22
|
-
|
|
22
|
+
V();
|
|
23
23
|
};
|
|
24
|
-
function
|
|
24
|
+
function V() {
|
|
25
25
|
throw new Error(
|
|
26
26
|
"Element not found, please add an id selector for the iframe"
|
|
27
27
|
);
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function B(e, t) {
|
|
30
30
|
if (t)
|
|
31
31
|
return t;
|
|
32
32
|
switch (e) {
|
|
@@ -45,7 +45,7 @@ function _(e, t) {
|
|
|
45
45
|
return "https://checkout.getalma.eu";
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
function
|
|
48
|
+
function G(e) {
|
|
49
49
|
switch (e) {
|
|
50
50
|
case "LOCAL":
|
|
51
51
|
return "http://localhost:1337";
|
|
@@ -67,10 +67,10 @@ function M(e, t) {
|
|
|
67
67
|
return console.error(n), t !== "PROD" && t !== "LIVE" && alert(n), n;
|
|
68
68
|
}
|
|
69
69
|
function ne(e, t) {
|
|
70
|
-
const n =
|
|
70
|
+
const n = G(t);
|
|
71
71
|
return fetch(`${n}/v1/checkout/payments/${e}/return-urls`, {
|
|
72
72
|
headers: {
|
|
73
|
-
"X-Alma-Agent": `Alma Checkout - InPage/${
|
|
73
|
+
"X-Alma-Agent": `Alma Checkout - InPage/${k()}`
|
|
74
74
|
}
|
|
75
75
|
}).then((a) => a.json()).then((a) => {
|
|
76
76
|
if (a.error_code) {
|
|
@@ -94,41 +94,41 @@ https://docs.almapay.com/docs/integration-in-page`,
|
|
|
94
94
|
}).catch((a) => (console.error("[Alma InPage] Failed to fetch payment return URLs:", a), { success: void 0, failure: void 0 }));
|
|
95
95
|
}
|
|
96
96
|
function ae(e, t, n, a) {
|
|
97
|
-
return
|
|
97
|
+
return B(t, a) + "/" + e + n;
|
|
98
98
|
}
|
|
99
|
-
function
|
|
99
|
+
function k() {
|
|
100
100
|
const e = te.match(/\d+\.\d+\.\d+/);
|
|
101
101
|
return e ? e[0] : "2.0.0";
|
|
102
102
|
}
|
|
103
103
|
function oe(e, t) {
|
|
104
|
-
const n = [], a = (
|
|
105
|
-
if (
|
|
104
|
+
const n = [], a = (i) => {
|
|
105
|
+
if (i.origin !== B(e, t) || i.data.from !== "checkout")
|
|
106
106
|
return !1;
|
|
107
|
-
|
|
108
|
-
(
|
|
109
|
-
).forEach((
|
|
110
|
-
|
|
107
|
+
i.data.type === "in_page_status" ? n.filter(
|
|
108
|
+
(c) => c && c.eventName === i.data.payload
|
|
109
|
+
).forEach((c) => {
|
|
110
|
+
c && c.callback();
|
|
111
111
|
}) : (
|
|
112
112
|
// Sent by the iframe fallback, see Embedded/fallback.ts
|
|
113
|
-
|
|
113
|
+
i.data.type !== "embedded_height" && i.data.type !== "translations" && console.warn("Unknown message type:", i.data.type)
|
|
114
114
|
);
|
|
115
115
|
};
|
|
116
116
|
window.addEventListener("message", a, !1);
|
|
117
117
|
function o() {
|
|
118
118
|
window.removeEventListener("message", a, !1);
|
|
119
119
|
}
|
|
120
|
-
function i
|
|
121
|
-
const
|
|
122
|
-
(
|
|
120
|
+
function l(i, c, d) {
|
|
121
|
+
const f = n.findIndex(
|
|
122
|
+
(s) => s && s.eventName === i && s.callerName === c
|
|
123
123
|
);
|
|
124
|
-
|
|
124
|
+
f !== -1 && (n[f] = null), n.push({ eventName: i, callerName: c, callback: d });
|
|
125
125
|
}
|
|
126
126
|
return {
|
|
127
|
-
onInPageStatusChanged:
|
|
127
|
+
onInPageStatusChanged: l,
|
|
128
128
|
unsubscribe: o
|
|
129
129
|
};
|
|
130
130
|
}
|
|
131
|
-
class
|
|
131
|
+
class H extends Error {
|
|
132
132
|
constructor() {
|
|
133
133
|
super(...arguments);
|
|
134
134
|
R(this, "name", "BlockedRequestError");
|
|
@@ -136,13 +136,13 @@ class W extends Error {
|
|
|
136
136
|
}
|
|
137
137
|
async function re(e, t) {
|
|
138
138
|
const n = await fetch(
|
|
139
|
-
`${
|
|
139
|
+
`${G(t)}/v2/payments/eligibility`,
|
|
140
140
|
{
|
|
141
141
|
method: "POST",
|
|
142
142
|
headers: {
|
|
143
143
|
Authorization: `Alma-Merchant-Auth ${e.merchantId}`,
|
|
144
144
|
"Content-Type": "application/json",
|
|
145
|
-
"X-Alma-Agent": `Alma Checkout - InPage/${
|
|
145
|
+
"X-Alma-Agent": `Alma Checkout - InPage/${k()}`
|
|
146
146
|
},
|
|
147
147
|
body: JSON.stringify({
|
|
148
148
|
purchase_amount: e.amountInCents,
|
|
@@ -158,7 +158,7 @@ async function re(e, t) {
|
|
|
158
158
|
})
|
|
159
159
|
}
|
|
160
160
|
).catch((o) => {
|
|
161
|
-
throw new
|
|
161
|
+
throw new H(String(o));
|
|
162
162
|
});
|
|
163
163
|
if (!n.ok)
|
|
164
164
|
throw new Error(`Eligibility request failed with status ${n.status}`);
|
|
@@ -176,47 +176,47 @@ function se(e, t) {
|
|
|
176
176
|
environment: n,
|
|
177
177
|
merchantId: a,
|
|
178
178
|
selector: o,
|
|
179
|
-
amountInCents:
|
|
180
|
-
installmentsCount:
|
|
181
|
-
deferredDays:
|
|
179
|
+
amountInCents: l,
|
|
180
|
+
installmentsCount: i,
|
|
181
|
+
deferredDays: c,
|
|
182
182
|
deferredMonths: d,
|
|
183
|
-
locale:
|
|
184
|
-
captureMethod:
|
|
183
|
+
locale: f,
|
|
184
|
+
captureMethod: s,
|
|
185
185
|
style: v,
|
|
186
186
|
onIntegratedPayButtonClicked: g,
|
|
187
|
-
checkoutUrl:
|
|
188
|
-
} = t,
|
|
189
|
-
|
|
187
|
+
checkoutUrl: w
|
|
188
|
+
} = t, u = new URL(
|
|
189
|
+
B(n ?? "PROD", w) + Y.embedded
|
|
190
190
|
);
|
|
191
|
-
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
if (!
|
|
195
|
-
window.removeEventListener("message",
|
|
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
196
|
return;
|
|
197
197
|
}
|
|
198
|
-
|
|
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
199
|
});
|
|
200
200
|
}
|
|
201
201
|
const X = "Alma Inter", ie = "https://cdn.almapay.com/fonts/Inter/InterVariable-latin.woff2", le = 300;
|
|
202
|
-
let
|
|
202
|
+
let _ = null;
|
|
203
203
|
function de() {
|
|
204
|
-
if (
|
|
204
|
+
if (_ || typeof FontFace > "u" || !document.fonts) return;
|
|
205
205
|
const e = new FontFace(X, `url(${ie}) format("woff2")`, {
|
|
206
206
|
weight: "400 700",
|
|
207
207
|
display: "swap"
|
|
208
208
|
});
|
|
209
|
-
document.fonts.add(e),
|
|
209
|
+
document.fonts.add(e), _ = e.load().catch((t) => {
|
|
210
210
|
console.error("[Alma InPage] Failed to load the font:", t);
|
|
211
211
|
});
|
|
212
212
|
}
|
|
213
213
|
function ce() {
|
|
214
214
|
return Promise.race([
|
|
215
|
-
|
|
215
|
+
_,
|
|
216
216
|
new Promise((e) => setTimeout(e, le))
|
|
217
217
|
]);
|
|
218
218
|
}
|
|
219
|
-
const
|
|
219
|
+
const J = {
|
|
220
220
|
fr: {
|
|
221
221
|
modal: {
|
|
222
222
|
closeModalMessage: "Voulez-vous vraiment quitter la page de paiement ?",
|
|
@@ -224,8 +224,8 @@ const Z = {
|
|
|
224
224
|
},
|
|
225
225
|
embedded: {
|
|
226
226
|
total: "Total",
|
|
227
|
-
|
|
228
|
-
|
|
227
|
+
customerFees: "Dont frais",
|
|
228
|
+
feesWithTaeg: (e, t) => `${e} (TAEG ${t})`,
|
|
229
229
|
payButton: (e) => `Payer ${e}`,
|
|
230
230
|
noPlanError: "Une erreur est survenue, aucun échéancier n'est disponible, merci de réessayer.",
|
|
231
231
|
deferredCaptureExplanation: "Vos prélèvements commenceront lorsque nous aurons validé votre commande.",
|
|
@@ -240,8 +240,8 @@ const Z = {
|
|
|
240
240
|
},
|
|
241
241
|
embedded: {
|
|
242
242
|
total: "Total",
|
|
243
|
-
|
|
244
|
-
|
|
243
|
+
customerFees: "Including fees",
|
|
244
|
+
feesWithTaeg: (e, t) => `${e} (APR ${t})`,
|
|
245
245
|
payButton: (e) => `Pay ${e}`,
|
|
246
246
|
noPlanError: "An error has occurred, no payment schedule is available, please try again.",
|
|
247
247
|
deferredCaptureExplanation: "Your direct debits will start as soon as we have validated your order.",
|
|
@@ -256,8 +256,8 @@ const Z = {
|
|
|
256
256
|
},
|
|
257
257
|
embedded: {
|
|
258
258
|
total: "Gesamtbetrag",
|
|
259
|
-
|
|
260
|
-
|
|
259
|
+
customerFees: "Davon Kosten",
|
|
260
|
+
feesWithTaeg: (e, t) => `${e} (effektiver Jahreszins ${t})`,
|
|
261
261
|
payButton: (e) => `${e} zahlen`,
|
|
262
262
|
noPlanError: "Es ist ein Fehler aufgetreten, es ist kein Zahlungsplan verfügbar. Bitte versuchen Sie es erneut.",
|
|
263
263
|
deferredCaptureExplanation: "Ihre Abbuchungen beginnen, sobald wir Ihre Bestellung freigegeben haben.",
|
|
@@ -272,8 +272,8 @@ const Z = {
|
|
|
272
272
|
},
|
|
273
273
|
embedded: {
|
|
274
274
|
total: "Totale",
|
|
275
|
-
|
|
276
|
-
|
|
275
|
+
customerFees: "Di cui commissioni",
|
|
276
|
+
feesWithTaeg: (e, t) => `${e} (TAEG ${t})`,
|
|
277
277
|
payButton: (e) => `Paga ${e}`,
|
|
278
278
|
noPlanError: "Si è verificato un errore, non è disponibile nessun piano di pagamento, riprovare.",
|
|
279
279
|
deferredCaptureExplanation: "Gli addebiti diretti inizieranno non appena avremo convalidato l'ordine.",
|
|
@@ -288,8 +288,8 @@ const Z = {
|
|
|
288
288
|
},
|
|
289
289
|
embedded: {
|
|
290
290
|
total: "Total",
|
|
291
|
-
|
|
292
|
-
|
|
291
|
+
customerFees: "De los cuales, los costes administrativos",
|
|
292
|
+
feesWithTaeg: (e, t) => `${e} (TAE ${t})`,
|
|
293
293
|
payButton: (e) => `Pagar ${e}`,
|
|
294
294
|
noPlanError: "Se ha producido un error, inténtelo de nuevo.",
|
|
295
295
|
deferredCaptureExplanation: "La domiciliación bancaria se iniciará en cuanto hayamos validado tu pedido.",
|
|
@@ -304,8 +304,8 @@ const Z = {
|
|
|
304
304
|
},
|
|
305
305
|
embedded: {
|
|
306
306
|
total: "Totaal",
|
|
307
|
-
|
|
308
|
-
|
|
307
|
+
customerFees: "Waarvan kosten",
|
|
308
|
+
feesWithTaeg: (e, t) => `${e} (JKP ${t})`,
|
|
309
309
|
payButton: (e) => `Betaal ${e}`,
|
|
310
310
|
noPlanError: "Er is een fout opgetreden, er is geen betaalschema beschikbaar, probeer het opnieuw.",
|
|
311
311
|
deferredCaptureExplanation: "Uw automatische incasso's beginnen zodra we uw bestelling hebben gevalideerd.",
|
|
@@ -320,8 +320,8 @@ const Z = {
|
|
|
320
320
|
},
|
|
321
321
|
embedded: {
|
|
322
322
|
total: "Total",
|
|
323
|
-
|
|
324
|
-
|
|
323
|
+
customerFees: "Incluindo encargos",
|
|
324
|
+
feesWithTaeg: (e, t) => `${e} (TAEG ${t})`,
|
|
325
325
|
payButton: (e) => `Pagar ${e}`,
|
|
326
326
|
noPlanError: "Ocorreu um erro, não existe nenhum plano de pagamento disponível, tente novamente.",
|
|
327
327
|
deferredCaptureExplanation: "Os seus débitos diretos começarão assim que tivermos validado a sua encomenda.",
|
|
@@ -331,16 +331,16 @@ const Z = {
|
|
|
331
331
|
}
|
|
332
332
|
};
|
|
333
333
|
function z(e) {
|
|
334
|
-
return Object.keys(
|
|
334
|
+
return Object.keys(J).includes(e);
|
|
335
335
|
}
|
|
336
|
-
function
|
|
336
|
+
function F(e) {
|
|
337
337
|
const t = String(e ?? "FR").toLowerCase();
|
|
338
338
|
if (z(t)) return t;
|
|
339
339
|
const n = navigator.language.split("-")[0];
|
|
340
340
|
return z(n) ? n : "en";
|
|
341
341
|
}
|
|
342
|
-
function
|
|
343
|
-
return
|
|
342
|
+
function S(e) {
|
|
343
|
+
return J[F(e)];
|
|
344
344
|
}
|
|
345
345
|
const U = `
|
|
346
346
|
/* The merchant's rules matching the host win over :host, unless :host is !important */
|
|
@@ -487,162 +487,162 @@ const U = `
|
|
|
487
487
|
}
|
|
488
488
|
}
|
|
489
489
|
`;
|
|
490
|
-
function
|
|
490
|
+
function m(e, t, n) {
|
|
491
491
|
const a = document.createElement(e);
|
|
492
492
|
return t && (a.className = t), n !== void 0 && (a.textContent = n), a;
|
|
493
493
|
}
|
|
494
494
|
function C(e, t) {
|
|
495
|
-
const n =
|
|
495
|
+
const n = m("span", "skeleton");
|
|
496
496
|
n.style.width = `${e}px`;
|
|
497
|
-
const a =
|
|
497
|
+
const a = m("span", t);
|
|
498
498
|
return a.append(n), a;
|
|
499
499
|
}
|
|
500
500
|
function L(e, t) {
|
|
501
501
|
t && typeof t == "object" && Object.assign(e.style, t);
|
|
502
502
|
}
|
|
503
|
-
function
|
|
504
|
-
const t =
|
|
503
|
+
function T(e) {
|
|
504
|
+
const t = m("div", "container fadeIn");
|
|
505
505
|
return L(t, e.containerStyle), t;
|
|
506
506
|
}
|
|
507
|
-
let
|
|
507
|
+
let I = null;
|
|
508
508
|
function O(e, t) {
|
|
509
|
-
"adoptedStyleSheets" in e && "replaceSync" in CSSStyleSheet.prototype ? (
|
|
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);
|
|
510
510
|
}
|
|
511
511
|
function D(e, t) {
|
|
512
512
|
var o;
|
|
513
513
|
const n = e.host.clientWidth;
|
|
514
514
|
(o = e.querySelector(".button")) == null || o.classList.toggle("fitContent", n >= 769);
|
|
515
|
-
const a = new Intl.DateTimeFormat(
|
|
515
|
+
const a = new Intl.DateTimeFormat(F(t), {
|
|
516
516
|
day: "numeric",
|
|
517
517
|
month: n > 400 ? "long" : "short"
|
|
518
518
|
}).format;
|
|
519
|
-
e.querySelectorAll(".date").forEach((
|
|
520
|
-
|
|
519
|
+
e.querySelectorAll(".date").forEach((l) => {
|
|
520
|
+
l.textContent = a(Number(l.dataset.dueDate));
|
|
521
521
|
});
|
|
522
522
|
}
|
|
523
|
-
function
|
|
523
|
+
function Z(e) {
|
|
524
524
|
return e > 4;
|
|
525
525
|
}
|
|
526
526
|
function ue(e, t) {
|
|
527
|
-
const n =
|
|
527
|
+
const n = T(t);
|
|
528
528
|
n.classList.add("delayed"), O(e, n);
|
|
529
|
-
const a =
|
|
530
|
-
if (t.isDeferredCapture && n.append(
|
|
531
|
-
const o =
|
|
529
|
+
const a = S(t.locale).embedded;
|
|
530
|
+
if (t.isDeferredCapture && n.append(m("div", "bold", a.deferredCaptureExplanation)), !Z(t.installmentsCount)) {
|
|
531
|
+
const o = m("div", "installments");
|
|
532
532
|
for (let d = 0; d < t.installmentsCount; d++) {
|
|
533
|
-
const
|
|
534
|
-
|
|
533
|
+
const f = m("div", "installment");
|
|
534
|
+
f.append(C(90, "label"), C(60)), o.append(f);
|
|
535
535
|
}
|
|
536
|
-
const
|
|
537
|
-
|
|
536
|
+
const l = m("div", "total"), i = m("div", "totalAmount"), c = m("div", "bold");
|
|
537
|
+
c.append(C(60)), i.append(c, m("div", "fees", " ")), l.append(C(40), i), o.append(l), n.append(o);
|
|
538
538
|
}
|
|
539
539
|
if (t.onPayButtonClicked) {
|
|
540
|
-
const o =
|
|
540
|
+
const o = m("button", "button skeletonButton", " ");
|
|
541
541
|
o.disabled = !0, L(o, t.buttonStyle), n.append(o);
|
|
542
542
|
}
|
|
543
543
|
D(e, t.locale);
|
|
544
544
|
}
|
|
545
545
|
function me(e, t, n) {
|
|
546
|
-
const a =
|
|
546
|
+
const a = T(n), o = F(n.locale), l = S(n.locale).embedded, i = (s) => new Intl.NumberFormat(o, {
|
|
547
547
|
style: "currency",
|
|
548
548
|
currency: "EUR"
|
|
549
|
-
}).format(
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
549
|
+
}).format(s / 100), c = (s) => new Intl.NumberFormat(o, {
|
|
550
|
+
style: "percent",
|
|
551
|
+
minimumFractionDigits: 2,
|
|
552
|
+
maximumFractionDigits: 2
|
|
553
|
+
}).format(s / 1e4);
|
|
554
|
+
n.isDeferredCapture && a.append(m("div", "bold", l.deferredCaptureExplanation));
|
|
555
|
+
const d = t.customer_fee + t.customer_interest, f = t.purchase_amount + d;
|
|
556
|
+
if (!Z(n.installmentsCount)) {
|
|
557
|
+
const s = m("div", "installments");
|
|
558
|
+
s.dataset.testid = "installments", t.payment_plan.forEach((b, h) => {
|
|
559
|
+
const $ = m("div", "installment");
|
|
560
|
+
$.dataset.testid = `installment-${h}`;
|
|
561
|
+
const y = m("span", "label");
|
|
562
|
+
n.isDeferredCapture ? y.textContent = h === 0 ? l.deferredFirstInstallment : l.deferredMonth(h) : (y.classList.add("date"), y.dataset.dueDate = String(b.due_date * 1e3)), $.append(
|
|
559
563
|
y,
|
|
560
|
-
|
|
564
|
+
m(
|
|
561
565
|
"span",
|
|
562
566
|
void 0,
|
|
563
|
-
|
|
564
|
-
|
|
567
|
+
i(
|
|
568
|
+
b.purchase_amount + b.customer_fee + b.customer_interest
|
|
565
569
|
)
|
|
566
570
|
)
|
|
567
|
-
),
|
|
571
|
+
), s.append($);
|
|
568
572
|
});
|
|
569
|
-
const
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
} else
|
|
574
|
-
v.textContent = i.fees(s(l));
|
|
575
|
-
const g = p("div", "totalAmount");
|
|
576
|
-
g.append(p("div", "bold", s(d)), v), m.append(p("span", "bold", i.total), g), u.append(m), a.append(u);
|
|
573
|
+
const v = m("div", "total"), g = m("div", "fees"), w = i(d), u = typeof t.annual_interest_rate == "number" ? c(t.annual_interest_rate) : null;
|
|
574
|
+
g.textContent = `${l.customerFees} ${u === null ? w : l.feesWithTaeg(w, u)}`;
|
|
575
|
+
const p = m("div", "totalAmount");
|
|
576
|
+
p.append(m("div", "bold", i(f)), g), v.append(m("span", "bold", l.total), p), s.append(v), a.append(s);
|
|
577
577
|
}
|
|
578
578
|
if (n.onPayButtonClicked) {
|
|
579
|
-
const
|
|
579
|
+
const s = m(
|
|
580
580
|
"button",
|
|
581
581
|
"button",
|
|
582
|
-
|
|
582
|
+
l.payButton(i(f))
|
|
583
583
|
);
|
|
584
|
-
|
|
585
|
-
var
|
|
586
|
-
return (
|
|
587
|
-
}, a.append(
|
|
584
|
+
s.type = "button", L(s, n.buttonStyle), s.onclick = () => {
|
|
585
|
+
var v;
|
|
586
|
+
return (v = n.onPayButtonClicked) == null ? void 0 : v.call(n);
|
|
587
|
+
}, a.append(s);
|
|
588
588
|
}
|
|
589
589
|
O(e, a), D(e, n.locale);
|
|
590
590
|
}
|
|
591
|
-
function
|
|
592
|
-
const n =
|
|
593
|
-
n.classList.add("error"), n.textContent =
|
|
591
|
+
function W(e, t) {
|
|
592
|
+
const n = T(t);
|
|
593
|
+
n.classList.add("error"), n.textContent = S(t.locale).embedded.noPlanError, O(e, n);
|
|
594
594
|
}
|
|
595
595
|
function pe(e) {
|
|
596
|
-
var
|
|
596
|
+
var $;
|
|
597
597
|
const {
|
|
598
598
|
environment: t,
|
|
599
599
|
merchantId: n,
|
|
600
600
|
selector: a,
|
|
601
601
|
amountInCents: o,
|
|
602
|
-
installmentsCount:
|
|
603
|
-
deferredDays:
|
|
604
|
-
deferredMonths:
|
|
602
|
+
installmentsCount: l,
|
|
603
|
+
deferredDays: i,
|
|
604
|
+
deferredMonths: c,
|
|
605
605
|
locale: d,
|
|
606
|
-
captureMethod:
|
|
607
|
-
style:
|
|
606
|
+
captureMethod: f,
|
|
607
|
+
style: s,
|
|
608
608
|
onIntegratedPayButtonClicked: v
|
|
609
609
|
} = e;
|
|
610
610
|
if (!a)
|
|
611
|
-
return
|
|
612
|
-
const g = (
|
|
613
|
-
|
|
614
|
-
const
|
|
615
|
-
(
|
|
616
|
-
const
|
|
611
|
+
return V(), !1;
|
|
612
|
+
const g = (y) => parseInt(String(y), 10), w = g(l), u = document.createElement("div");
|
|
613
|
+
u.id = `alma-embedded-${a.replace("#", "")}`, u.style.width = "100%", u.style.display = w > 4 && !v ? "none" : "flow-root";
|
|
614
|
+
const p = u.attachShadow({ mode: "open" });
|
|
615
|
+
($ = j(a)) == null || $.replaceChildren(u);
|
|
616
|
+
const b = {
|
|
617
617
|
locale: d,
|
|
618
|
-
installmentsCount:
|
|
619
|
-
isDeferredCapture:
|
|
618
|
+
installmentsCount: w,
|
|
619
|
+
isDeferredCapture: f === "manual",
|
|
620
620
|
onPayButtonClicked: v,
|
|
621
|
-
containerStyle:
|
|
622
|
-
buttonStyle:
|
|
621
|
+
containerStyle: s == null ? void 0 : s.embedded,
|
|
622
|
+
buttonStyle: s == null ? void 0 : s.embeddedButton
|
|
623
623
|
};
|
|
624
|
-
de(), ue(
|
|
625
|
-
const
|
|
626
|
-
|
|
624
|
+
de(), ue(p, b);
|
|
625
|
+
const h = new ResizeObserver(() => {
|
|
626
|
+
u.isConnected ? D(p, d) : h.disconnect();
|
|
627
627
|
});
|
|
628
|
-
return
|
|
628
|
+
return h.observe(u), re(
|
|
629
629
|
{
|
|
630
630
|
merchantId: n,
|
|
631
631
|
amountInCents: g(o),
|
|
632
|
-
installmentsCount:
|
|
633
|
-
deferredDays: g(
|
|
634
|
-
deferredMonths: g(
|
|
635
|
-
captureMethod:
|
|
632
|
+
installmentsCount: w,
|
|
633
|
+
deferredDays: g(i) || 0,
|
|
634
|
+
deferredMonths: g(c) || 0,
|
|
635
|
+
captureMethod: f ?? "automatic",
|
|
636
636
|
locale: d ?? "FR"
|
|
637
637
|
},
|
|
638
638
|
t ?? "PROD"
|
|
639
|
-
).then(async (
|
|
640
|
-
await ce(),
|
|
641
|
-
}).catch((
|
|
642
|
-
console.error("[Alma InPage] Failed to display the payment plan:",
|
|
639
|
+
).then(async (y) => {
|
|
640
|
+
await ce(), y ? me(p, y, b) : W(p, b);
|
|
641
|
+
}).catch((y) => {
|
|
642
|
+
console.error("[Alma InPage] Failed to display the payment plan:", y), y instanceof H ? se(u, e) : W(p, b);
|
|
643
643
|
}), !0;
|
|
644
644
|
}
|
|
645
|
-
const
|
|
645
|
+
const A = {
|
|
646
646
|
orange: "#FA5022",
|
|
647
647
|
backdrop: "#6C6C6C",
|
|
648
648
|
white: "#FEFEFE"
|
|
@@ -661,7 +661,7 @@ const S = {
|
|
|
661
661
|
}
|
|
662
662
|
|
|
663
663
|
#${r}-background {
|
|
664
|
-
background: ${
|
|
664
|
+
background: ${A.backdrop};
|
|
665
665
|
position: absolute;
|
|
666
666
|
width: 100vw;
|
|
667
667
|
height: 100vh;
|
|
@@ -669,7 +669,7 @@ const S = {
|
|
|
669
669
|
}
|
|
670
670
|
|
|
671
671
|
#${r}-body {
|
|
672
|
-
background: ${
|
|
672
|
+
background: ${A.white};
|
|
673
673
|
width: 100%;
|
|
674
674
|
max-width: 700px;
|
|
675
675
|
height: calc(100% - 32px);
|
|
@@ -692,7 +692,7 @@ const S = {
|
|
|
692
692
|
|
|
693
693
|
#${r}-close:hover, #${r}-close:focus-visible {
|
|
694
694
|
border-radius: 50%;
|
|
695
|
-
outline: 1px solid ${
|
|
695
|
+
outline: 1px solid ${A.orange};
|
|
696
696
|
outline-offset: -16px;
|
|
697
697
|
}
|
|
698
698
|
|
|
@@ -789,16 +789,16 @@ const S = {
|
|
|
789
789
|
}
|
|
790
790
|
}
|
|
791
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,
|
|
792
|
+
let P = 0, E = null;
|
|
793
793
|
function ge(e, t, n, a, o) {
|
|
794
|
-
|
|
795
|
-
const
|
|
796
|
-
document.body.appendChild(
|
|
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
797
|
}
|
|
798
|
-
function
|
|
798
|
+
function x(e = !0, t) {
|
|
799
799
|
const n = document.getElementById(`${r}-wrapper`);
|
|
800
800
|
if (n && (!e || confirm(
|
|
801
|
-
(
|
|
801
|
+
(E == null ? void 0 : E.closeModalMessage) ?? "Are you sure you want to leave the payment page?"
|
|
802
802
|
))) {
|
|
803
803
|
const a = document.getElementById(
|
|
804
804
|
`${r}-wrapper`
|
|
@@ -826,29 +826,29 @@ function we() {
|
|
|
826
826
|
const e = document.createElement("div");
|
|
827
827
|
return e.id = `${r}-body`, e;
|
|
828
828
|
}
|
|
829
|
-
function
|
|
829
|
+
function Ee(e, t, n) {
|
|
830
830
|
const a = new URL(
|
|
831
831
|
ae(e, t, Y.modal, n)
|
|
832
832
|
);
|
|
833
|
-
a.searchParams.append("inPageVersion",
|
|
833
|
+
a.searchParams.append("inPageVersion", k());
|
|
834
834
|
const o = document.createElement("iframe");
|
|
835
835
|
return o.id = `${r}-iframe`, o.setAttribute(
|
|
836
836
|
"allow",
|
|
837
837
|
"camera *; microphone *; geolocation *; clipboard-read *; clipboard-write *; gyroscope *; accelerometer *; magnetometer *; ch-ua-platform-version *; ch-ua-model *; ch-ua-full-version *; payment"
|
|
838
838
|
), o.src = a.toString(), o.title = "Alma", o;
|
|
839
839
|
}
|
|
840
|
-
function
|
|
840
|
+
function q(e) {
|
|
841
841
|
const t = document.createElement("img");
|
|
842
|
-
return t.id = `${r}-close`, t.title = (
|
|
843
|
-
n.key === "Enter" &&
|
|
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
844
|
}, t.src = he, t.tabIndex = 0, t;
|
|
845
845
|
}
|
|
846
|
-
function
|
|
846
|
+
function $e() {
|
|
847
847
|
const e = document.getElementById(`${r}-close`);
|
|
848
848
|
e == null || e.remove();
|
|
849
849
|
}
|
|
850
|
-
function
|
|
851
|
-
const { paymentId: a, onPaymentRejected: o, onPaymentSucceeded:
|
|
850
|
+
function xe(e, t, n) {
|
|
851
|
+
const { paymentId: a, onPaymentRejected: o, onPaymentSucceeded: l, onUserCloseModal: i } = e;
|
|
852
852
|
if (typeof a != "string" || a.trim() === "") {
|
|
853
853
|
const d = M(
|
|
854
854
|
`startPayment() requires a non-empty "paymentId" (received: ${JSON.stringify(
|
|
@@ -858,51 +858,51 @@ function Ce(e, t, n) {
|
|
|
858
858
|
);
|
|
859
859
|
throw new Error(d);
|
|
860
860
|
}
|
|
861
|
-
const
|
|
861
|
+
const c = {
|
|
862
862
|
success: null,
|
|
863
863
|
failure: null
|
|
864
864
|
};
|
|
865
865
|
ne(a, t.getEnvironment()).then((d) => {
|
|
866
|
-
|
|
866
|
+
c.success = d.success, c.failure = d.failure;
|
|
867
867
|
}), ge(
|
|
868
868
|
a,
|
|
869
869
|
t.getEnvironment(),
|
|
870
870
|
t.getTranslations(),
|
|
871
|
-
|
|
871
|
+
i,
|
|
872
872
|
t.getCheckoutUrl()
|
|
873
873
|
), n(
|
|
874
874
|
"3ds_started",
|
|
875
875
|
"start-payment",
|
|
876
|
-
|
|
876
|
+
$e
|
|
877
877
|
), n("3ds_failed", "start-payment", () => {
|
|
878
878
|
const d = document.getElementById(`${r}-body`);
|
|
879
|
-
d && d.appendChild(
|
|
879
|
+
d && d.appendChild(q(i));
|
|
880
880
|
}), n("trigger_success_callback", "start-payment", () => {
|
|
881
|
-
N(
|
|
881
|
+
N(l, c.success);
|
|
882
882
|
}), n("trigger_reject_callback", "start-payment", () => {
|
|
883
|
-
N(o,
|
|
883
|
+
N(o, c.failure);
|
|
884
884
|
});
|
|
885
885
|
}
|
|
886
886
|
function N(e, t) {
|
|
887
|
-
|
|
887
|
+
x(!1), e ? e() : t && window.location.assign(t);
|
|
888
888
|
}
|
|
889
|
-
function
|
|
889
|
+
function Ce(e, t) {
|
|
890
890
|
const n = e.getEmbeddedSelector();
|
|
891
|
-
if (
|
|
891
|
+
if (x(!1), t(), !n)
|
|
892
892
|
return;
|
|
893
|
-
const a =
|
|
893
|
+
const a = j(n);
|
|
894
894
|
e.setEmbeddedSelector(null), a && a.firstChild && a.removeChild(a.firstChild);
|
|
895
895
|
}
|
|
896
896
|
function ke(e) {
|
|
897
897
|
const t = ee(e.environment, e.checkoutUrl);
|
|
898
|
-
t.setTranslations(
|
|
898
|
+
t.setTranslations(S(e.locale).modal);
|
|
899
899
|
const { onInPageStatusChanged: n, unsubscribe: a } = oe(
|
|
900
900
|
t.getEnvironment(),
|
|
901
901
|
e.checkoutUrl
|
|
902
902
|
);
|
|
903
903
|
return pe(e) && t.setEmbeddedSelector(e.selector), {
|
|
904
|
-
startPayment: (
|
|
905
|
-
unmount: () =>
|
|
904
|
+
startPayment: (l) => xe(l, t, n),
|
|
905
|
+
unmount: () => Ce(t, a)
|
|
906
906
|
};
|
|
907
907
|
}
|
|
908
908
|
export {
|