@alma/in-page 2.9.0 → 2.10.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 +633 -204
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +152 -8
- package/dist/index.umd.js.map +1 -1
- package/dist/src/Embedded/eligibility.d.ts +31 -0
- package/dist/src/Embedded/fallback.d.ts +7 -0
- package/dist/src/Embedded/font.d.ts +10 -0
- package/dist/src/Embedded/render.d.ts +22 -0
- package/dist/src/Embedded/style.d.ts +1 -0
- package/dist/src/helpers.d.ts +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/messages/listener.d.ts +2 -2
- package/dist/src/store.d.ts +1 -5
- package/dist/src/translations.d.ts +19 -0
- package/dist/src/types.d.ts +3 -7
- package/dist/src/unmount.d.ts +1 -1
- package/package.json +1 -1
- package/dist/src/messages/send.d.ts +0 -5
package/dist/index.es.js
CHANGED
|
@@ -1,43 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
var Q = Object.defineProperty;
|
|
2
|
+
var K = (e, t, n) => t in e ? Q(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var R = (e, t, n) => K(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
const ee = (e = "LIVE", t) => {
|
|
5
|
+
let n = null, a = null;
|
|
3
6
|
return {
|
|
4
|
-
setEmbeddedSelector: (
|
|
5
|
-
|
|
7
|
+
setEmbeddedSelector: (m) => {
|
|
8
|
+
n = m;
|
|
6
9
|
},
|
|
7
|
-
getEmbeddedSelector: () =>
|
|
8
|
-
setIsCheckoutLoaded: (p) => {
|
|
9
|
-
n = p;
|
|
10
|
-
},
|
|
11
|
-
getIsCheckoutLoaded: () => n,
|
|
10
|
+
getEmbeddedSelector: () => n,
|
|
12
11
|
getEnvironment: () => e,
|
|
13
12
|
getCheckoutUrl: () => t,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
},
|
|
17
|
-
getAndResetMessagesToSendLater: () => {
|
|
18
|
-
const p = Array.from(o);
|
|
19
|
-
return o = /* @__PURE__ */ new Set(), p;
|
|
13
|
+
setTranslations: (m) => {
|
|
14
|
+
a = m;
|
|
20
15
|
},
|
|
21
|
-
|
|
22
|
-
i = p;
|
|
23
|
-
},
|
|
24
|
-
getTranslations: () => i
|
|
16
|
+
getTranslations: () => a
|
|
25
17
|
};
|
|
26
|
-
},
|
|
27
|
-
embedded: "/in-page/embedded/",
|
|
28
|
-
modal: "/in-page/modal/"
|
|
29
|
-
}, P = "v2.9.0", $ = (e) => {
|
|
18
|
+
}, te = "v2.10.0", V = (e) => {
|
|
30
19
|
const t = document.getElementById(e.replace("#", ""));
|
|
31
20
|
if (t)
|
|
32
21
|
return t;
|
|
33
|
-
|
|
22
|
+
G();
|
|
34
23
|
};
|
|
35
|
-
function
|
|
24
|
+
function G() {
|
|
36
25
|
throw new Error(
|
|
37
26
|
"Element not found, please add an id selector for the iframe"
|
|
38
27
|
);
|
|
39
28
|
}
|
|
40
|
-
function
|
|
29
|
+
function _(e, t) {
|
|
41
30
|
if (t)
|
|
42
31
|
return t;
|
|
43
32
|
switch (e) {
|
|
@@ -56,7 +45,7 @@ function b(e, t) {
|
|
|
56
45
|
return "https://checkout.getalma.eu";
|
|
57
46
|
}
|
|
58
47
|
}
|
|
59
|
-
function
|
|
48
|
+
function H(e) {
|
|
60
49
|
switch (e) {
|
|
61
50
|
case "LOCAL":
|
|
62
51
|
return "http://localhost:1337";
|
|
@@ -73,143 +62,591 @@ function A(e) {
|
|
|
73
62
|
return "https://api.getalma.eu";
|
|
74
63
|
}
|
|
75
64
|
}
|
|
76
|
-
function
|
|
77
|
-
const
|
|
78
|
-
return console.error(
|
|
65
|
+
function M(e, t) {
|
|
66
|
+
const n = `[Alma InPage] ${e}`;
|
|
67
|
+
return console.error(n), t !== "PROD" && t !== "LIVE" && alert(n), n;
|
|
79
68
|
}
|
|
80
|
-
function
|
|
81
|
-
const
|
|
82
|
-
return fetch(`${
|
|
69
|
+
function ne(e, t) {
|
|
70
|
+
const n = H(t);
|
|
71
|
+
return fetch(`${n}/v1/checkout/payments/${e}/return-urls`, {
|
|
83
72
|
headers: {
|
|
84
|
-
"X-Alma-Agent": `Alma Checkout - InPage/${
|
|
73
|
+
"X-Alma-Agent": `Alma Checkout - InPage/${I()}`
|
|
85
74
|
}
|
|
86
|
-
}).then((
|
|
87
|
-
if (
|
|
75
|
+
}).then((a) => a.json()).then((a) => {
|
|
76
|
+
if (a.error_code) {
|
|
88
77
|
let o = "";
|
|
89
|
-
|
|
78
|
+
a.error_code === "not_found" && (o = `
|
|
90
79
|
|
|
91
|
-
Please check that payment "${e}" has been created on the ${t} environment (${
|
|
92
|
-
`Error: ${
|
|
80
|
+
Please check that payment "${e}" has been created on the ${t} environment (${n}).`), M(
|
|
81
|
+
`Error: ${a.error_code}
|
|
93
82
|
|
|
94
|
-
${
|
|
83
|
+
${a.message}${o}`,
|
|
95
84
|
t
|
|
96
85
|
);
|
|
97
|
-
} else
|
|
86
|
+
} else a.origin && a.origin !== "online_in_page" && M(
|
|
98
87
|
`Your payment does not have the proper origin for an in-page payment, you should use "online_in_page".
|
|
99
88
|
|
|
100
89
|
Please, check the documentation:
|
|
101
90
|
https://docs.almapay.com/docs/integration-in-page`,
|
|
102
91
|
t
|
|
103
92
|
);
|
|
104
|
-
return { success:
|
|
105
|
-
}).catch((
|
|
93
|
+
return { success: a.return_url, failure: a.failure_return_url };
|
|
94
|
+
}).catch((a) => (console.error("[Alma InPage] Failed to fetch payment return URLs:", a), { success: void 0, failure: void 0 }));
|
|
106
95
|
}
|
|
107
|
-
function
|
|
108
|
-
return
|
|
96
|
+
function ae(e, t, n, a) {
|
|
97
|
+
return _(t, a) + "/" + e + n;
|
|
109
98
|
}
|
|
110
|
-
function
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
function C() {
|
|
114
|
-
const e = P.match(/\d+\.\d+\.\d+/);
|
|
99
|
+
function I() {
|
|
100
|
+
const e = te.match(/\d+\.\d+\.\d+/);
|
|
115
101
|
return e ? e[0] : "2.0.0";
|
|
116
102
|
}
|
|
117
|
-
function
|
|
118
|
-
const
|
|
119
|
-
if (s.origin !==
|
|
103
|
+
function oe(e, t) {
|
|
104
|
+
const n = [], a = (s) => {
|
|
105
|
+
if (s.origin !== _(e, t) || s.data.from !== "checkout")
|
|
120
106
|
return !1;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
if (t !== f)
|
|
130
|
-
return;
|
|
131
|
-
const c = document.getElementById(
|
|
132
|
-
`alma-embedded-iframe-${t}`
|
|
133
|
-
);
|
|
134
|
-
c && (c.style.height = `${Math.ceil(l)}px`);
|
|
135
|
-
} else s.data.type === "translations" ? a(l) : console.warn("Unknown message type:", s.data.type);
|
|
107
|
+
s.data.type === "in_page_status" ? n.filter(
|
|
108
|
+
(l) => l && l.eventName === s.data.payload
|
|
109
|
+
).forEach((l) => {
|
|
110
|
+
l && l.callback();
|
|
111
|
+
}) : (
|
|
112
|
+
// Sent by the iframe fallback, see Embedded/fallback.ts
|
|
113
|
+
s.data.type !== "embedded_height" && s.data.type !== "translations" && console.warn("Unknown message type:", s.data.type)
|
|
114
|
+
);
|
|
136
115
|
};
|
|
137
|
-
window.addEventListener("message",
|
|
138
|
-
function
|
|
139
|
-
window.removeEventListener("message",
|
|
116
|
+
window.addEventListener("message", a, !1);
|
|
117
|
+
function o() {
|
|
118
|
+
window.removeEventListener("message", a, !1);
|
|
140
119
|
}
|
|
141
|
-
function
|
|
142
|
-
const
|
|
143
|
-
(
|
|
120
|
+
function i(s, l, d) {
|
|
121
|
+
const u = n.findIndex(
|
|
122
|
+
(m) => m && m.eventName === s && m.callerName === l
|
|
144
123
|
);
|
|
145
|
-
|
|
124
|
+
u !== -1 && (n[u] = null), n.push({ eventName: s, callerName: l, callback: d });
|
|
146
125
|
}
|
|
147
126
|
return {
|
|
148
|
-
onInPageStatusChanged:
|
|
149
|
-
unsubscribe:
|
|
127
|
+
onInPageStatusChanged: i,
|
|
128
|
+
unsubscribe: o
|
|
150
129
|
};
|
|
151
130
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
const n =
|
|
160
|
-
|
|
161
|
-
|
|
131
|
+
class W extends Error {
|
|
132
|
+
constructor() {
|
|
133
|
+
super(...arguments);
|
|
134
|
+
R(this, "name", "BlockedRequestError");
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
async function re(e, t) {
|
|
138
|
+
const n = await fetch(
|
|
139
|
+
`${H(t)}/v2/payments/eligibility`,
|
|
140
|
+
{
|
|
141
|
+
method: "POST",
|
|
142
|
+
headers: {
|
|
143
|
+
Authorization: `Alma-Merchant-Auth ${e.merchantId}`,
|
|
144
|
+
"Content-Type": "application/json",
|
|
145
|
+
"X-Alma-Agent": `Alma Checkout - InPage/${I()}`
|
|
146
|
+
},
|
|
147
|
+
body: JSON.stringify({
|
|
148
|
+
purchase_amount: e.amountInCents,
|
|
149
|
+
queries: [
|
|
150
|
+
{
|
|
151
|
+
installments_count: e.installmentsCount,
|
|
152
|
+
deferred_days: e.deferredDays,
|
|
153
|
+
deferred_months: e.deferredMonths
|
|
154
|
+
}
|
|
155
|
+
],
|
|
156
|
+
capture_method: e.captureMethod,
|
|
157
|
+
locale: e.locale
|
|
158
|
+
})
|
|
159
|
+
}
|
|
160
|
+
).catch((o) => {
|
|
161
|
+
throw new W(String(o));
|
|
162
|
+
});
|
|
163
|
+
if (!n.ok)
|
|
164
|
+
throw new Error(`Eligibility request failed with status ${n.status}`);
|
|
165
|
+
return (await n.json()).find(
|
|
166
|
+
(o) => o.eligible && o.deferred_days === e.deferredDays && o.deferred_months === e.deferredMonths
|
|
167
|
+
) ?? null;
|
|
168
|
+
}
|
|
169
|
+
const r = "alma-in-page-modal", Y = {
|
|
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: i,
|
|
180
|
+
installmentsCount: s,
|
|
181
|
+
deferredDays: l,
|
|
182
|
+
deferredMonths: d,
|
|
183
|
+
locale: u,
|
|
184
|
+
captureMethod: m,
|
|
185
|
+
style: v,
|
|
186
|
+
onIntegratedPayButtonClicked: g,
|
|
187
|
+
checkoutUrl: h
|
|
188
|
+
} = t, c = new URL(
|
|
189
|
+
_(n ?? "PROD", h) + Y.embedded
|
|
162
190
|
);
|
|
163
|
-
|
|
191
|
+
c.searchParams.append("merchantId", a), c.searchParams.append("amountInCents", i.toString()), c.searchParams.append("installmentsCount", s.toString()), l && c.searchParams.append("deferredDays", l.toString()), d && c.searchParams.append("deferredMonths", d.toString()), c.searchParams.append("locale", u ?? "FR"), c.searchParams.append("captureMethod", m ?? "automatic"), c.searchParams.append("domElement", o), c.searchParams.append("style", JSON.stringify(v || null)), c.searchParams.append("inPageVersion", I()), g && c.searchParams.append("showPayButton", "true"), c.searchParams.append("fallback", "true");
|
|
192
|
+
const f = document.createElement("iframe");
|
|
193
|
+
f.src = c.toString(), f.id = `alma-embedded-iframe-${o}`, f.style.width = "100%", f.style.height = "150px", f.style.transition = "height 0.5s", f.style.border = "none", f.style.display = e.style.display === "none" ? "none" : "block", f.setAttribute("allow", "payment"), e.replaceWith(f), window.addEventListener("message", function y(b) {
|
|
194
|
+
if (!f.isConnected) {
|
|
195
|
+
window.removeEventListener("message", y);
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
b.origin !== c.origin || b.source !== f.contentWindow || (b.data.type === "embedded_height" ? f.style.height = `${Math.ceil(b.data.payload)}px` : b.data.type === "in_page_status" && b.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 A = null;
|
|
203
|
+
function de() {
|
|
204
|
+
if (A || 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), A = 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
|
+
A,
|
|
216
|
+
new Promise((e) => setTimeout(e, le))
|
|
217
|
+
]);
|
|
218
|
+
}
|
|
219
|
+
const Z = {
|
|
220
|
+
fr: {
|
|
221
|
+
modal: {
|
|
222
|
+
closeModalMessage: "Voulez-vous vraiment quitter la page de paiement ?",
|
|
223
|
+
closeModalButtonHover: "Abandonner le paiement avec Alma"
|
|
224
|
+
},
|
|
225
|
+
embedded: {
|
|
226
|
+
total: "Total",
|
|
227
|
+
fees: (e) => `Dont ${e} de frais à payer aujourd'hui.`,
|
|
228
|
+
offeredFees: "Les frais de paiement sont offerts",
|
|
229
|
+
payButton: (e) => `Payer ${e}`,
|
|
230
|
+
noPlanError: "Une erreur est survenue, aucun échéancier n'est disponible, merci de réessayer.",
|
|
231
|
+
deferredCaptureExplanation: "Vos prélèvements commenceront lorsque nous aurons validé votre commande.",
|
|
232
|
+
deferredFirstInstallment: "Au traitement de la commande",
|
|
233
|
+
deferredMonth: (e) => `${e} mois après`
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
en: {
|
|
237
|
+
modal: {
|
|
238
|
+
closeModalMessage: "Do you really want to leave the checkout page?",
|
|
239
|
+
closeModalButtonHover: "Cancel the payment with Alma"
|
|
240
|
+
},
|
|
241
|
+
embedded: {
|
|
242
|
+
total: "Total",
|
|
243
|
+
fees: (e) => `Including ${e} of fees to be paid today.`,
|
|
244
|
+
offeredFees: "Payment fees are free",
|
|
245
|
+
payButton: (e) => `Pay ${e}`,
|
|
246
|
+
noPlanError: "An error has occurred, no payment schedule is available, please try again.",
|
|
247
|
+
deferredCaptureExplanation: "Your direct debits will start as soon as we have validated your order.",
|
|
248
|
+
deferredFirstInstallment: "When processing the order",
|
|
249
|
+
deferredMonth: (e) => `${e} month after`
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
de: {
|
|
253
|
+
modal: {
|
|
254
|
+
closeModalMessage: "Möchten Sie die Zahlungsseite wirklich verlassen?",
|
|
255
|
+
closeModalButtonHover: "Zahlung mit Alma abbrechen"
|
|
256
|
+
},
|
|
257
|
+
embedded: {
|
|
258
|
+
total: "Gesamtbetrag",
|
|
259
|
+
fees: (e) => `Davon ${e} Gebühren, die heute bezahlt werden müssen.`,
|
|
260
|
+
offeredFees: "Die Zahlungsgebühren sind erlassen",
|
|
261
|
+
payButton: (e) => `${e} zahlen`,
|
|
262
|
+
noPlanError: "Es ist ein Fehler aufgetreten, es ist kein Zahlungsplan verfügbar. Bitte versuchen Sie es erneut.",
|
|
263
|
+
deferredCaptureExplanation: "Ihre Abbuchungen beginnen, sobald wir Ihre Bestellung freigegeben haben.",
|
|
264
|
+
deferredFirstInstallment: "Bei der Bearbeitung der Bestellung",
|
|
265
|
+
deferredMonth: (e) => e === 1 ? `${e} Monat später` : `${e} Monate später`
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
it: {
|
|
269
|
+
modal: {
|
|
270
|
+
closeModalMessage: "Vuoi davvero lasciare la pagina di pagamento?",
|
|
271
|
+
closeModalButtonHover: "Annullare il pagamento con Alma"
|
|
272
|
+
},
|
|
273
|
+
embedded: {
|
|
274
|
+
total: "Totale",
|
|
275
|
+
fees: (e) => `Inclusa la commissione di ${e} per il pagamento rateale.`,
|
|
276
|
+
offeredFees: "Nessuna commissione di pagamento",
|
|
277
|
+
payButton: (e) => `Paga ${e}`,
|
|
278
|
+
noPlanError: "Si è verificato un errore, non è disponibile nessun piano di pagamento, riprovare.",
|
|
279
|
+
deferredCaptureExplanation: "Gli addebiti diretti inizieranno non appena avremo convalidato l'ordine.",
|
|
280
|
+
deferredFirstInstallment: "Elaborazione dell'ordine",
|
|
281
|
+
deferredMonth: (e) => e === 1 ? `${e} mese dopo` : `${e} mesi dopo`
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
es: {
|
|
285
|
+
modal: {
|
|
286
|
+
closeModalMessage: "¿De verdad quieres salir de la página de pago?",
|
|
287
|
+
closeModalButtonHover: "Cancelar el pago con Alma"
|
|
288
|
+
},
|
|
289
|
+
embedded: {
|
|
290
|
+
total: "Total",
|
|
291
|
+
fees: (e) => `De los cuales ${e} son gastos administrativos.`,
|
|
292
|
+
offeredFees: "Las comisiones de pago son gratuitas",
|
|
293
|
+
payButton: (e) => `Pagar ${e}`,
|
|
294
|
+
noPlanError: "Se ha producido un error, inténtelo de nuevo.",
|
|
295
|
+
deferredCaptureExplanation: "La domiciliación bancaria se iniciará en cuanto hayamos validado tu pedido.",
|
|
296
|
+
deferredFirstInstallment: "Al procesarse el pedido",
|
|
297
|
+
deferredMonth: (e) => e === 1 ? `${e} mes después` : `${e} meses después`
|
|
298
|
+
}
|
|
299
|
+
},
|
|
300
|
+
nl: {
|
|
301
|
+
modal: {
|
|
302
|
+
closeModalMessage: "Weet je zeker dat je de betaalpagina wilt verlaten?",
|
|
303
|
+
closeModalButtonHover: "Annuleer betaling met Alma"
|
|
304
|
+
},
|
|
305
|
+
embedded: {
|
|
306
|
+
total: "Totaal",
|
|
307
|
+
fees: (e) => `Waarvan ${e} kosten die vandaag moeten worden betaald.`,
|
|
308
|
+
offeredFees: "Geen extra kosten",
|
|
309
|
+
payButton: (e) => `Betaal ${e}`,
|
|
310
|
+
noPlanError: "Er is een fout opgetreden, er is geen betaalschema beschikbaar, probeer het opnieuw.",
|
|
311
|
+
deferredCaptureExplanation: "Uw automatische incasso's beginnen zodra we uw bestelling hebben gevalideerd.",
|
|
312
|
+
deferredFirstInstallment: "Op het moment dat de bestelling wordt verwerkt",
|
|
313
|
+
deferredMonth: (e) => `${e} maand na`
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
pt: {
|
|
317
|
+
modal: {
|
|
318
|
+
closeModalMessage: "Quer mesmo sair da página de pagamento?",
|
|
319
|
+
closeModalButtonHover: "Cancelar o pagamento com a Alma"
|
|
320
|
+
},
|
|
321
|
+
embedded: {
|
|
322
|
+
total: "Total",
|
|
323
|
+
fees: (e) => `Do qual ${e} deve ser pago hoje.`,
|
|
324
|
+
offeredFees: "As despesas de pagamento são gratuitas",
|
|
325
|
+
payButton: (e) => `Pagar ${e}`,
|
|
326
|
+
noPlanError: "Ocorreu um erro, não existe nenhum plano de pagamento disponível, tente novamente.",
|
|
327
|
+
deferredCaptureExplanation: "Os seus débitos diretos começarão assim que tivermos validado a sua encomenda.",
|
|
328
|
+
deferredFirstInstallment: "Processamento de encomendas",
|
|
329
|
+
deferredMonth: (e) => e === 1 ? `${e} mês seguinte` : `${e} meses seguintes`
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
function z(e) {
|
|
334
|
+
return Object.keys(Z).includes(e);
|
|
335
|
+
}
|
|
336
|
+
function B(e) {
|
|
337
|
+
const t = String(e ?? "FR").toLowerCase();
|
|
338
|
+
if (z(t)) return t;
|
|
339
|
+
const n = navigator.language.split("-")[0];
|
|
340
|
+
return z(n) ? n : "en";
|
|
341
|
+
}
|
|
342
|
+
function k(e) {
|
|
343
|
+
return Z[B(e)];
|
|
344
|
+
}
|
|
345
|
+
const U = `
|
|
346
|
+
/* The merchant's rules matching the host win over :host, unless :host is !important */
|
|
347
|
+
:host {
|
|
348
|
+
padding: 0 !important;
|
|
349
|
+
border: none !important;
|
|
350
|
+
background-color: #fefefe !important;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
.container {
|
|
354
|
+
/* Resets what is inherited from the merchant's page, except what hides the payment plan */
|
|
355
|
+
all: initial;
|
|
356
|
+
visibility: inherit;
|
|
357
|
+
pointer-events: inherit;
|
|
358
|
+
direction: ltr;
|
|
359
|
+
color: #130a07;
|
|
360
|
+
-webkit-font-smoothing: antialiased;
|
|
361
|
+
-moz-osx-font-smoothing: grayscale;
|
|
362
|
+
display: flex;
|
|
363
|
+
flex-direction: column;
|
|
364
|
+
gap: 10px;
|
|
365
|
+
margin: 8px 16px;
|
|
366
|
+
font-family: "${X}", sans-serif;
|
|
367
|
+
font-size: 14px;
|
|
368
|
+
line-height: 19px;
|
|
369
|
+
letter-spacing: -0.6px;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
.fadeIn {
|
|
373
|
+
animation: fadeIn 0.4s ease-out backwards;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/* A fast response never shows the skeleton, which would only flash */
|
|
377
|
+
.delayed {
|
|
378
|
+
animation-delay: 0.2s;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
@keyframes fadeIn {
|
|
382
|
+
from {
|
|
383
|
+
opacity: 0;
|
|
384
|
+
}
|
|
385
|
+
to {
|
|
386
|
+
opacity: 1;
|
|
387
|
+
}
|
|
164
388
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
389
|
+
|
|
390
|
+
.bold {
|
|
391
|
+
font-weight: 700;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
.installments {
|
|
395
|
+
display: flex;
|
|
396
|
+
flex-direction: column;
|
|
397
|
+
gap: 2px;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
.installment,
|
|
401
|
+
.total {
|
|
402
|
+
display: flex;
|
|
403
|
+
justify-content: space-between;
|
|
404
|
+
gap: 8px;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
.total {
|
|
408
|
+
align-items: center;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
.label {
|
|
412
|
+
font-size: 16px;
|
|
413
|
+
line-height: 135%;
|
|
414
|
+
letter-spacing: normal;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
.date {
|
|
418
|
+
text-transform: capitalize;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
.totalAmount {
|
|
422
|
+
text-align: right;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
.error {
|
|
426
|
+
margin-block: 16px;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
.fees {
|
|
430
|
+
margin-top: 4px;
|
|
431
|
+
font-size: 12px;
|
|
432
|
+
line-height: 16px;
|
|
433
|
+
opacity: 0.5;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
.skeleton {
|
|
437
|
+
display: inline-block;
|
|
438
|
+
height: 12px;
|
|
439
|
+
vertical-align: middle;
|
|
440
|
+
border-radius: 6px;
|
|
441
|
+
background-color: currentColor;
|
|
442
|
+
opacity: 0.1;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
.button {
|
|
446
|
+
font: inherit;
|
|
447
|
+
font-size: 16px;
|
|
448
|
+
line-height: 22px;
|
|
449
|
+
font-weight: 700;
|
|
450
|
+
color: #fff;
|
|
451
|
+
background-color: #130a07;
|
|
452
|
+
border: 3px solid transparent;
|
|
453
|
+
border-radius: 100px;
|
|
454
|
+
box-sizing: border-box;
|
|
455
|
+
height: 50px;
|
|
456
|
+
padding: 0 24px;
|
|
457
|
+
cursor: pointer;
|
|
458
|
+
transition: all 0.2s ease;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
.fitContent {
|
|
462
|
+
width: -moz-fit-content;
|
|
463
|
+
width: fit-content;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
.button:hover:not(:disabled) {
|
|
467
|
+
background-color: #3e1509;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
.button:focus-visible {
|
|
471
|
+
outline: 3px solid #53d9e8;
|
|
472
|
+
outline-offset: -3px;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
.skeletonButton {
|
|
476
|
+
opacity: 0.1;
|
|
477
|
+
cursor: default;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
.skeletonButton.fitContent {
|
|
481
|
+
width: 160px;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
@media (prefers-reduced-motion: reduce) {
|
|
485
|
+
.fadeIn {
|
|
486
|
+
animation: none;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
`;
|
|
490
|
+
function p(e, t, n) {
|
|
491
|
+
const a = document.createElement(e);
|
|
492
|
+
return t && (a.className = t), n !== void 0 && (a.textContent = n), a;
|
|
493
|
+
}
|
|
494
|
+
function C(e, t) {
|
|
495
|
+
const n = p("span", "skeleton");
|
|
496
|
+
n.style.width = `${e}px`;
|
|
497
|
+
const a = p("span", t);
|
|
498
|
+
return a.append(n), a;
|
|
499
|
+
}
|
|
500
|
+
function L(e, t) {
|
|
501
|
+
t && typeof t == "object" && Object.assign(e.style, t);
|
|
502
|
+
}
|
|
503
|
+
function F(e) {
|
|
504
|
+
const t = p("div", "container fadeIn");
|
|
505
|
+
return L(t, e.containerStyle), t;
|
|
506
|
+
}
|
|
507
|
+
let $ = null;
|
|
508
|
+
function O(e, t) {
|
|
509
|
+
"adoptedStyleSheets" in e && "replaceSync" in CSSStyleSheet.prototype ? ($ || ($ = new CSSStyleSheet(), $.replaceSync(U)), e.adoptedStyleSheets = [$], e.replaceChildren(t)) : e.replaceChildren(p("style", void 0, U), t);
|
|
510
|
+
}
|
|
511
|
+
function D(e, t) {
|
|
512
|
+
var o;
|
|
513
|
+
const n = e.host.clientWidth;
|
|
514
|
+
(o = e.querySelector(".button")) == null || o.classList.toggle("fitContent", n >= 769);
|
|
515
|
+
const a = new Intl.DateTimeFormat(B(t), {
|
|
516
|
+
day: "numeric",
|
|
517
|
+
month: n > 400 ? "long" : "short"
|
|
518
|
+
}).format;
|
|
519
|
+
e.querySelectorAll(".date").forEach((i) => {
|
|
520
|
+
i.textContent = a(Number(i.dataset.dueDate));
|
|
168
521
|
});
|
|
169
522
|
}
|
|
170
|
-
function
|
|
523
|
+
function q(e) {
|
|
524
|
+
return e > 4;
|
|
525
|
+
}
|
|
526
|
+
function ue(e, t) {
|
|
527
|
+
const n = F(t);
|
|
528
|
+
n.classList.add("delayed"), O(e, n);
|
|
529
|
+
const a = k(t.locale).embedded;
|
|
530
|
+
if (t.isDeferredCapture && n.append(p("div", "bold", a.deferredCaptureExplanation)), !q(t.installmentsCount)) {
|
|
531
|
+
const o = p("div", "installments");
|
|
532
|
+
for (let d = 0; d < t.installmentsCount; d++) {
|
|
533
|
+
const u = p("div", "installment");
|
|
534
|
+
u.append(C(90, "label"), C(60)), o.append(u);
|
|
535
|
+
}
|
|
536
|
+
const i = p("div", "total"), s = p("div", "totalAmount"), l = p("div", "bold");
|
|
537
|
+
l.append(C(60)), s.append(l, p("div", "fees", " ")), i.append(C(40), s), o.append(i), n.append(o);
|
|
538
|
+
}
|
|
539
|
+
if (t.onPayButtonClicked) {
|
|
540
|
+
const o = p("button", "button skeletonButton", " ");
|
|
541
|
+
o.disabled = !0, L(o, t.buttonStyle), n.append(o);
|
|
542
|
+
}
|
|
543
|
+
D(e, t.locale);
|
|
544
|
+
}
|
|
545
|
+
function me(e, t, n) {
|
|
546
|
+
const a = F(n), o = B(n.locale), i = k(n.locale).embedded, s = (u) => new Intl.NumberFormat(o, {
|
|
547
|
+
style: "currency",
|
|
548
|
+
currency: "EUR"
|
|
549
|
+
}).format(u / 100);
|
|
550
|
+
n.isDeferredCapture && a.append(p("div", "bold", i.deferredCaptureExplanation));
|
|
551
|
+
const l = t.customer_fee + t.customer_interest, d = t.purchase_amount + l;
|
|
552
|
+
if (!q(n.installmentsCount)) {
|
|
553
|
+
const u = p("div", "installments");
|
|
554
|
+
u.dataset.testid = "installments", t.payment_plan.forEach((h, c) => {
|
|
555
|
+
const f = p("div", "installment");
|
|
556
|
+
f.dataset.testid = `installment-${c}`;
|
|
557
|
+
const y = p("span", "label");
|
|
558
|
+
n.isDeferredCapture ? y.textContent = c === 0 ? i.deferredFirstInstallment : i.deferredMonth(c) : (y.classList.add("date"), y.dataset.dueDate = String(h.due_date * 1e3)), f.append(
|
|
559
|
+
y,
|
|
560
|
+
p(
|
|
561
|
+
"span",
|
|
562
|
+
void 0,
|
|
563
|
+
s(
|
|
564
|
+
h.purchase_amount + h.customer_fee + h.customer_interest
|
|
565
|
+
)
|
|
566
|
+
)
|
|
567
|
+
), u.append(f);
|
|
568
|
+
});
|
|
569
|
+
const m = p("div", "total"), v = p("div", "fees");
|
|
570
|
+
if (l === 0) {
|
|
571
|
+
const h = p("span", void 0, "🎁");
|
|
572
|
+
h.setAttribute("aria-hidden", "true"), v.append(`${i.offeredFees} `, h);
|
|
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);
|
|
577
|
+
}
|
|
578
|
+
if (n.onPayButtonClicked) {
|
|
579
|
+
const u = p(
|
|
580
|
+
"button",
|
|
581
|
+
"button",
|
|
582
|
+
i.payButton(s(d))
|
|
583
|
+
);
|
|
584
|
+
u.type = "button", L(u, n.buttonStyle), u.onclick = () => {
|
|
585
|
+
var m;
|
|
586
|
+
return (m = n.onPayButtonClicked) == null ? void 0 : m.call(n);
|
|
587
|
+
}, a.append(u);
|
|
588
|
+
}
|
|
589
|
+
O(e, a), D(e, n.locale);
|
|
590
|
+
}
|
|
591
|
+
function j(e, t) {
|
|
592
|
+
const n = F(t);
|
|
593
|
+
n.classList.add("error"), n.textContent = k(t.locale).embedded.noPlanError, O(e, n);
|
|
594
|
+
}
|
|
595
|
+
function pe(e) {
|
|
596
|
+
var T;
|
|
171
597
|
const {
|
|
172
598
|
environment: t,
|
|
173
|
-
merchantId:
|
|
174
|
-
selector:
|
|
599
|
+
merchantId: n,
|
|
600
|
+
selector: a,
|
|
175
601
|
amountInCents: o,
|
|
176
602
|
installmentsCount: i,
|
|
177
|
-
deferredDays:
|
|
178
|
-
deferredMonths:
|
|
179
|
-
locale:
|
|
180
|
-
captureMethod:
|
|
181
|
-
style:
|
|
182
|
-
onIntegratedPayButtonClicked:
|
|
183
|
-
checkoutUrl: g
|
|
603
|
+
deferredDays: s,
|
|
604
|
+
deferredMonths: l,
|
|
605
|
+
locale: d,
|
|
606
|
+
captureMethod: u,
|
|
607
|
+
style: m,
|
|
608
|
+
onIntegratedPayButtonClicked: v
|
|
184
609
|
} = e;
|
|
185
|
-
if (!
|
|
186
|
-
return
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
)
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
610
|
+
if (!a)
|
|
611
|
+
return G(), !1;
|
|
612
|
+
const g = (w) => parseInt(String(w), 10), h = g(i), c = document.createElement("div");
|
|
613
|
+
c.id = `alma-embedded-${a.replace("#", "")}`, c.style.width = "100%", c.style.display = h > 4 && !v ? "none" : "flow-root";
|
|
614
|
+
const f = c.attachShadow({ mode: "open" });
|
|
615
|
+
(T = V(a)) == null || T.replaceChildren(c);
|
|
616
|
+
const y = {
|
|
617
|
+
locale: d,
|
|
618
|
+
installmentsCount: h,
|
|
619
|
+
isDeferredCapture: u === "manual",
|
|
620
|
+
onPayButtonClicked: v,
|
|
621
|
+
containerStyle: m == null ? void 0 : m.embedded,
|
|
622
|
+
buttonStyle: m == null ? void 0 : m.embeddedButton
|
|
623
|
+
};
|
|
624
|
+
de(), ue(f, y);
|
|
625
|
+
const b = new ResizeObserver(() => {
|
|
626
|
+
c.isConnected ? D(f, d) : b.disconnect();
|
|
627
|
+
});
|
|
628
|
+
return b.observe(c), re(
|
|
629
|
+
{
|
|
630
|
+
merchantId: n,
|
|
631
|
+
amountInCents: g(o),
|
|
632
|
+
installmentsCount: h,
|
|
633
|
+
deferredDays: g(s) || 0,
|
|
634
|
+
deferredMonths: g(l) || 0,
|
|
635
|
+
captureMethod: u ?? "automatic",
|
|
636
|
+
locale: d ?? "FR"
|
|
637
|
+
},
|
|
638
|
+
t ?? "PROD"
|
|
639
|
+
).then(async (w) => {
|
|
640
|
+
await ce(), w ? me(f, w, y) : j(f, y);
|
|
641
|
+
}).catch((w) => {
|
|
642
|
+
console.error("[Alma InPage] Failed to display the payment plan:", w), w instanceof W ? se(c, e) : j(f, y);
|
|
198
643
|
}), !0;
|
|
199
644
|
}
|
|
200
|
-
|
|
201
|
-
selector: e,
|
|
202
|
-
url: t,
|
|
203
|
-
shouldBeHidden: a
|
|
204
|
-
}) {
|
|
205
|
-
const n = $(e), o = document.createElement("iframe");
|
|
206
|
-
o.src = t, o.id = `alma-embedded-iframe-${e}`, o.style.width = "100%", o.style.height = "150px", o.style.transition = "height 0.5s", o.style.border = "none", o.style.display = a ? "none" : "block", o.setAttribute("allow", "payment"), n == null || n.replaceChildren(o);
|
|
207
|
-
}
|
|
208
|
-
const E = {
|
|
645
|
+
const S = {
|
|
209
646
|
orange: "#FA5022",
|
|
210
647
|
backdrop: "#6C6C6C",
|
|
211
648
|
white: "#FEFEFE"
|
|
212
|
-
},
|
|
649
|
+
}, fe = `
|
|
213
650
|
#${r}-element {
|
|
214
651
|
position: fixed;
|
|
215
652
|
z-index: 10337;
|
|
@@ -224,7 +661,7 @@ const E = {
|
|
|
224
661
|
}
|
|
225
662
|
|
|
226
663
|
#${r}-background {
|
|
227
|
-
background: ${
|
|
664
|
+
background: ${S.backdrop};
|
|
228
665
|
position: absolute;
|
|
229
666
|
width: 100vw;
|
|
230
667
|
height: 100vh;
|
|
@@ -232,7 +669,7 @@ const E = {
|
|
|
232
669
|
}
|
|
233
670
|
|
|
234
671
|
#${r}-body {
|
|
235
|
-
background: ${
|
|
672
|
+
background: ${S.white};
|
|
236
673
|
width: 100%;
|
|
237
674
|
max-width: 700px;
|
|
238
675
|
height: calc(100% - 32px);
|
|
@@ -255,7 +692,7 @@ const E = {
|
|
|
255
692
|
|
|
256
693
|
#${r}-close:hover, #${r}-close:focus-visible {
|
|
257
694
|
border-radius: 50%;
|
|
258
|
-
outline: 1px solid ${
|
|
695
|
+
outline: 1px solid ${S.orange};
|
|
259
696
|
outline-offset: -16px;
|
|
260
697
|
}
|
|
261
698
|
|
|
@@ -351,132 +788,124 @@ const E = {
|
|
|
351
788
|
visibility: hidden;
|
|
352
789
|
}
|
|
353
790
|
}
|
|
354
|
-
`,
|
|
355
|
-
let
|
|
356
|
-
function
|
|
357
|
-
|
|
358
|
-
const i =
|
|
359
|
-
document.body.appendChild(i), i.appendChild(
|
|
360
|
-
}
|
|
361
|
-
function
|
|
362
|
-
const
|
|
363
|
-
if (
|
|
364
|
-
(
|
|
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, x = null;
|
|
793
|
+
function ge(e, t, n, a, o) {
|
|
794
|
+
x = n, document.getElementById(`${r}-wrapper`) && E(!1), P = window.scrollY, document.body.classList.add("alma-fixed-body"), document.body.scroll(0, P);
|
|
795
|
+
const i = ye(), s = be(), l = ve(), d = we(), u = J(a), m = xe(e, t, o);
|
|
796
|
+
document.body.appendChild(i), i.appendChild(s), s.appendChild(l), s.appendChild(d), d.appendChild(u), d.appendChild(m), i.classList.add(`${r}-fadeIn`), d.classList.add(`${r}-slideIn`), m.focus();
|
|
797
|
+
}
|
|
798
|
+
function E(e = !0, t) {
|
|
799
|
+
const n = document.getElementById(`${r}-wrapper`);
|
|
800
|
+
if (n && (!e || confirm(
|
|
801
|
+
(x == null ? void 0 : x.closeModalMessage) ?? "Are you sure you want to leave the payment page?"
|
|
365
802
|
))) {
|
|
366
|
-
const
|
|
803
|
+
const a = document.getElementById(
|
|
367
804
|
`${r}-wrapper`
|
|
368
805
|
), o = document.getElementById(`${r}-body`);
|
|
369
|
-
|
|
370
|
-
document.body.classList.remove("alma-fixed-body"), document.body.scroll(0,
|
|
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();
|
|
371
808
|
}, 300);
|
|
372
809
|
}
|
|
373
810
|
}
|
|
374
|
-
function
|
|
811
|
+
function ye() {
|
|
375
812
|
const e = document.createElement("style");
|
|
376
|
-
e.innerHTML =
|
|
813
|
+
e.innerHTML = fe;
|
|
377
814
|
const t = document.createElement("div");
|
|
378
815
|
return t.id = `${r}-wrapper`, t.role = "dialog", t.ariaModal = "true", t.appendChild(e), t;
|
|
379
816
|
}
|
|
380
|
-
function
|
|
817
|
+
function be() {
|
|
381
818
|
const e = document.createElement("div");
|
|
382
819
|
return e.id = `${r}-element`, e;
|
|
383
820
|
}
|
|
384
|
-
function
|
|
821
|
+
function ve() {
|
|
385
822
|
const e = document.createElement("div");
|
|
386
823
|
return e.id = `${r}-background`, e;
|
|
387
824
|
}
|
|
388
|
-
function
|
|
825
|
+
function we() {
|
|
389
826
|
const e = document.createElement("div");
|
|
390
827
|
return e.id = `${r}-body`, e;
|
|
391
828
|
}
|
|
392
|
-
function
|
|
393
|
-
const
|
|
394
|
-
|
|
829
|
+
function xe(e, t, n) {
|
|
830
|
+
const a = new URL(
|
|
831
|
+
ae(e, t, Y.modal, n)
|
|
395
832
|
);
|
|
396
|
-
|
|
833
|
+
a.searchParams.append("inPageVersion", I());
|
|
397
834
|
const o = document.createElement("iframe");
|
|
398
835
|
return o.id = `${r}-iframe`, o.setAttribute(
|
|
399
836
|
"allow",
|
|
400
|
-
"camera *;
|
|
401
|
-
), o.src =
|
|
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;
|
|
402
839
|
}
|
|
403
|
-
function
|
|
840
|
+
function J(e) {
|
|
404
841
|
const t = document.createElement("img");
|
|
405
|
-
return t.id = `${r}-close`, t.title = (
|
|
406
|
-
|
|
407
|
-
}, t.src =
|
|
842
|
+
return t.id = `${r}-close`, t.title = (x == null ? void 0 : x.closeModalButtonHover) || "Close the alma modal (you'll lose your data)", t.onclick = () => E(!0, e), t.onkeyup = (n) => {
|
|
843
|
+
n.key === "Enter" && E(!1, e);
|
|
844
|
+
}, t.src = he, t.tabIndex = 0, t;
|
|
408
845
|
}
|
|
409
|
-
function
|
|
846
|
+
function Ee() {
|
|
410
847
|
const e = document.getElementById(`${r}-close`);
|
|
411
848
|
e == null || e.remove();
|
|
412
849
|
}
|
|
413
|
-
function
|
|
414
|
-
const { paymentId:
|
|
415
|
-
if (typeof
|
|
416
|
-
const
|
|
850
|
+
function Ce(e, t, n) {
|
|
851
|
+
const { paymentId: a, onPaymentRejected: o, onPaymentSucceeded: i, onUserCloseModal: s } = e;
|
|
852
|
+
if (typeof a != "string" || a.trim() === "") {
|
|
853
|
+
const d = M(
|
|
417
854
|
`startPayment() requires a non-empty "paymentId" (received: ${JSON.stringify(
|
|
418
|
-
|
|
855
|
+
a
|
|
419
856
|
)}). Make sure the payment has been created and its id retrieved before calling startPayment().`,
|
|
420
857
|
t.getEnvironment()
|
|
421
858
|
);
|
|
422
|
-
throw new Error(
|
|
859
|
+
throw new Error(d);
|
|
423
860
|
}
|
|
424
|
-
|
|
425
|
-
const m = {
|
|
861
|
+
const l = {
|
|
426
862
|
success: null,
|
|
427
863
|
failure: null
|
|
428
864
|
};
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
}),
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
);
|
|
439
|
-
}), a(
|
|
865
|
+
ne(a, t.getEnvironment()).then((d) => {
|
|
866
|
+
l.success = d.success, l.failure = d.failure;
|
|
867
|
+
}), ge(
|
|
868
|
+
a,
|
|
869
|
+
t.getEnvironment(),
|
|
870
|
+
t.getTranslations(),
|
|
871
|
+
s,
|
|
872
|
+
t.getCheckoutUrl()
|
|
873
|
+
), n(
|
|
440
874
|
"3ds_started",
|
|
441
875
|
"start-payment",
|
|
442
|
-
|
|
443
|
-
),
|
|
444
|
-
const
|
|
445
|
-
|
|
446
|
-
}),
|
|
447
|
-
|
|
448
|
-
}),
|
|
449
|
-
|
|
876
|
+
Ee
|
|
877
|
+
), n("3ds_failed", "start-payment", () => {
|
|
878
|
+
const d = document.getElementById(`${r}-body`);
|
|
879
|
+
d && d.appendChild(J(s));
|
|
880
|
+
}), n("trigger_success_callback", "start-payment", () => {
|
|
881
|
+
N(i, l.success);
|
|
882
|
+
}), n("trigger_reject_callback", "start-payment", () => {
|
|
883
|
+
N(o, l.failure);
|
|
450
884
|
});
|
|
451
885
|
}
|
|
452
|
-
function
|
|
453
|
-
|
|
886
|
+
function N(e, t) {
|
|
887
|
+
E(!1), e ? e() : t && window.location.assign(t);
|
|
454
888
|
}
|
|
455
|
-
function
|
|
456
|
-
const
|
|
457
|
-
if (
|
|
889
|
+
function $e(e, t) {
|
|
890
|
+
const n = e.getEmbeddedSelector();
|
|
891
|
+
if (E(!1), t(), !n)
|
|
458
892
|
return;
|
|
459
|
-
const
|
|
460
|
-
e.setEmbeddedSelector(null),
|
|
893
|
+
const a = V(n);
|
|
894
|
+
e.setEmbeddedSelector(null), a && a.firstChild && a.removeChild(a.firstChild);
|
|
461
895
|
}
|
|
462
|
-
function
|
|
463
|
-
const t =
|
|
896
|
+
function ke(e) {
|
|
897
|
+
const t = ee(e.environment, e.checkoutUrl);
|
|
898
|
+
t.setTranslations(k(e.locale).modal);
|
|
899
|
+
const { onInPageStatusChanged: n, unsubscribe: a } = oe(
|
|
464
900
|
t.getEnvironment(),
|
|
465
|
-
e.selector,
|
|
466
|
-
t.setTranslations,
|
|
467
901
|
e.checkoutUrl
|
|
468
902
|
);
|
|
469
|
-
return
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
var i;
|
|
473
|
-
(i = e.onIntegratedPayButtonClicked) == null || i.call(e);
|
|
474
|
-
}), D(e) && t.setEmbeddedSelector(e.selector), {
|
|
475
|
-
startPayment: (i) => W(i, t, a),
|
|
476
|
-
unmount: () => q(t, n)
|
|
903
|
+
return pe(e) && t.setEmbeddedSelector(e.selector), {
|
|
904
|
+
startPayment: (i) => Ce(i, t, n),
|
|
905
|
+
unmount: () => $e(t, a)
|
|
477
906
|
};
|
|
478
907
|
}
|
|
479
908
|
export {
|
|
480
|
-
|
|
909
|
+
ke as initialize
|
|
481
910
|
};
|
|
482
911
|
//# sourceMappingURL=index.es.js.map
|