@lydianpay/sdk-web 3.15.5 → 3.16.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/chunks/{browser-CH7eaWyg.js → browser-CvvbM3fl.js} +1 -1
- package/dist/chunks/{connect-multichain-DUlpFu-U.js → connect-multichain-JrYKtq5o.js} +9 -9
- package/dist/chunks/{index-BWDzkEUT.js → index-Bwl_cWLK.js} +1 -1
- package/dist/chunks/{index-B0KsTd4q.js → index-CD8P_mOo.js} +2 -2
- package/dist/chunks/{index-C3_NkCKr.js → index-DAsQ6TuK.js} +1 -1
- package/dist/chunks/{index-DLmUAaTw.js → index-DFLPr81C.js} +3 -3
- package/dist/chunks/{index-Dgq02q9R.js → index-DGLVpgOJ.js} +2 -2
- package/dist/chunks/{index-DwADRT3v.js → index-GdvVEXe8.js} +154 -117
- package/dist/chunks/{mountEngine-Bk-qJ-ZC.js → mountEngine-B9qRQyLg.js} +9407 -9270
- package/dist/lydian.js +1 -1
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/network/gatewayRequestError.d.ts +9 -0
- package/dist/types/network/session/index.d.ts +2 -1
- package/dist/types/types.d.ts +6 -0
- package/dist/types/ui/flowConfig.d.ts +1 -0
- package/dist/types/ui/react/AlertBanner.d.ts +1 -1
- package/dist/types/ui/react/CheckboxField.d.ts +8 -0
- package/dist/types/ui/react/EmailReceiptCard/EmailReceiptCard.d.ts +4 -0
- package/dist/types/ui/react/EmailReceiptCard/EmailReceiptForm.d.ts +7 -0
- package/dist/types/ui/react/EmailReceiptCard/emailReceiptHelpers.d.ts +7 -0
- package/dist/types/ui/react/EmailReceiptCard/useEmailReceiptSender.d.ts +7 -0
- package/dist/types/ui/react/FormField.d.ts +2 -1
- package/dist/types/ui/react/checkoutStore.d.ts +2 -1
- package/package.json +1 -1
|
@@ -1,10 +1,31 @@
|
|
|
1
|
-
const
|
|
1
|
+
const v = ["USD", "TRY", "PHP"];
|
|
2
2
|
function U(e) {
|
|
3
|
-
return typeof e == "string" &&
|
|
3
|
+
return typeof e == "string" && v.includes(e);
|
|
4
4
|
}
|
|
5
|
-
function
|
|
5
|
+
function d(e) {
|
|
6
6
|
return "sessionID" in e && typeof e.sessionID == "string" && e.sessionID.length > 0;
|
|
7
7
|
}
|
|
8
|
+
class O extends Error {
|
|
9
|
+
constructor({
|
|
10
|
+
statusText: t,
|
|
11
|
+
errorCode: a,
|
|
12
|
+
response: n
|
|
13
|
+
}) {
|
|
14
|
+
super(t, { cause: n }), this.name = "GatewayRequestError", this.errorCode = a;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
async function m(e) {
|
|
18
|
+
const t = await e.clone().json().catch(() => null);
|
|
19
|
+
return new O({
|
|
20
|
+
statusText: e.statusText,
|
|
21
|
+
errorCode: F(t),
|
|
22
|
+
response: e
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function F(e) {
|
|
26
|
+
if (!(typeof e != "object" || e === null || !("errorCode" in e)))
|
|
27
|
+
return typeof e.errorCode == "number" ? e.errorCode : void 0;
|
|
28
|
+
}
|
|
8
29
|
class p {
|
|
9
30
|
// Optional: a caller-supplied session has no key and needs none (see Sessions).
|
|
10
31
|
// The key is still required when the SDK creates the session, enforced in
|
|
@@ -23,7 +44,7 @@ class p {
|
|
|
23
44
|
const n = `${this.baseUri}${t}`, o = this.headers({ "Content-Type": "application/json" }), r = Object.assign({}, a, { headers: o }), s = await fetch(n, r);
|
|
24
45
|
if (s.ok)
|
|
25
46
|
return await s.json();
|
|
26
|
-
throw
|
|
47
|
+
throw await m(s);
|
|
27
48
|
}
|
|
28
49
|
// For endpoints that reply text/plain rather than JSON (e.g. PATCH
|
|
29
50
|
// /customer/otp -> "OTP sent"). Sends the same JSON request headers but does
|
|
@@ -32,17 +53,17 @@ class p {
|
|
|
32
53
|
const n = `${this.baseUri}${t}`, o = this.headers({ "Content-Type": "application/json" }), r = Object.assign({}, a, { headers: o }), s = await fetch(n, r);
|
|
33
54
|
if (s.ok)
|
|
34
55
|
return await s.text();
|
|
35
|
-
throw
|
|
56
|
+
throw await m(s);
|
|
36
57
|
}
|
|
37
58
|
async requestWithFormData(t, a) {
|
|
38
59
|
const n = `${this.baseUri}${t}`, o = this.headers(), r = Object.assign({}, a, { headers: o }), s = await fetch(n, r);
|
|
39
60
|
if (s.ok)
|
|
40
61
|
return await s.json();
|
|
41
|
-
throw
|
|
62
|
+
throw await m(s);
|
|
42
63
|
}
|
|
43
64
|
}
|
|
44
65
|
const c = "transaction";
|
|
45
|
-
class
|
|
66
|
+
class W extends p {
|
|
46
67
|
async getCryptoTransaction(t) {
|
|
47
68
|
return await this.request(`/${c}/${t}`);
|
|
48
69
|
}
|
|
@@ -93,7 +114,7 @@ class R extends p {
|
|
|
93
114
|
);
|
|
94
115
|
}
|
|
95
116
|
}
|
|
96
|
-
function
|
|
117
|
+
function $(e, t) {
|
|
97
118
|
t.forEach((a) => {
|
|
98
119
|
Object.getOwnPropertyNames(a.prototype).forEach((n) => {
|
|
99
120
|
const o = Object.getOwnPropertyDescriptor(a.prototype, n);
|
|
@@ -101,40 +122,40 @@ function O(e, t) {
|
|
|
101
122
|
});
|
|
102
123
|
});
|
|
103
124
|
}
|
|
104
|
-
const
|
|
105
|
-
class
|
|
125
|
+
const C = "customer/otp";
|
|
126
|
+
class x extends p {
|
|
106
127
|
// PATCH /customer/otp -> text/plain "OTP sent" (no JSON body).
|
|
107
128
|
async sendCustomerOTP(t) {
|
|
108
|
-
return await this.requestText(`/${
|
|
129
|
+
return await this.requestText(`/${C}`, {
|
|
109
130
|
method: "PATCH",
|
|
110
131
|
body: JSON.stringify(t)
|
|
111
132
|
});
|
|
112
133
|
}
|
|
113
134
|
// PUT /customer/otp -> { customerUUID, kycValidated }.
|
|
114
135
|
async authenticateCustomerOTP(t) {
|
|
115
|
-
return await this.request(`/${
|
|
136
|
+
return await this.request(`/${C}`, {
|
|
116
137
|
method: "PUT",
|
|
117
138
|
body: JSON.stringify(t)
|
|
118
139
|
});
|
|
119
140
|
}
|
|
120
141
|
}
|
|
121
|
-
const
|
|
122
|
-
class
|
|
142
|
+
const l = "session";
|
|
143
|
+
class M extends p {
|
|
123
144
|
async createSession(t) {
|
|
124
|
-
return await this.request(`/${
|
|
145
|
+
return await this.request(`/${l}`, {
|
|
125
146
|
method: "POST",
|
|
126
147
|
body: JSON.stringify(t)
|
|
127
148
|
});
|
|
128
149
|
}
|
|
129
150
|
async getSession(t) {
|
|
130
|
-
return await this.request(`/${
|
|
151
|
+
return await this.request(`/${l}/${t}`);
|
|
131
152
|
}
|
|
132
153
|
// Promotes the session into a transaction. Allowed once per session — except
|
|
133
154
|
// that a KYC-pending (-3) response does not consume the promotion, which is
|
|
134
155
|
// what lets the restore-details flow re-promote with a customerUUID.
|
|
135
156
|
async createSessionTransaction(t, a) {
|
|
136
157
|
return await this.request(
|
|
137
|
-
`/${
|
|
158
|
+
`/${l}/${t}/transaction`,
|
|
138
159
|
{
|
|
139
160
|
method: "POST",
|
|
140
161
|
body: JSON.stringify(a)
|
|
@@ -144,15 +165,21 @@ class W extends p {
|
|
|
144
165
|
// PATCH /session/{id}/cancel replies text/plain (the merchant's cancel URL),
|
|
145
166
|
// not JSON. Cancelling cascades to the linked transaction, if any.
|
|
146
167
|
async cancelSession(t) {
|
|
147
|
-
return await this.requestText(`/${
|
|
168
|
+
return await this.requestText(`/${l}/${t}/cancel`, {
|
|
148
169
|
method: "PATCH"
|
|
149
170
|
});
|
|
150
171
|
}
|
|
172
|
+
async sendReceipt(t, a) {
|
|
173
|
+
await this.request(`/${l}/${t}/receipt`, {
|
|
174
|
+
method: "POST",
|
|
175
|
+
body: JSON.stringify(a)
|
|
176
|
+
});
|
|
177
|
+
}
|
|
151
178
|
}
|
|
152
|
-
class
|
|
179
|
+
class E extends p {
|
|
153
180
|
}
|
|
154
|
-
|
|
155
|
-
const
|
|
181
|
+
$(E, [W, x, M]);
|
|
182
|
+
const Y = E;
|
|
156
183
|
var u = {
|
|
157
184
|
COMPLIANCE_PENDING: -10,
|
|
158
185
|
API_CANCELLED: -9,
|
|
@@ -170,21 +197,21 @@ var u = {
|
|
|
170
197
|
FRAUD: -1,
|
|
171
198
|
PENDING: 0,
|
|
172
199
|
SUCCESS: 1
|
|
173
|
-
},
|
|
200
|
+
}, se = {
|
|
174
201
|
PARTIALLY_PAID: 1,
|
|
175
202
|
OVERPAID: 3
|
|
176
|
-
},
|
|
203
|
+
}, B = {
|
|
177
204
|
PENDING: 0,
|
|
178
205
|
CONFIRMED: 1
|
|
179
|
-
},
|
|
206
|
+
}, h = {
|
|
180
207
|
dev: "https://api.lydian.dev",
|
|
181
208
|
sandbox: "https://api.sandbox.lydian.com",
|
|
182
209
|
prod: "https://api.lydian.com"
|
|
183
210
|
};
|
|
184
|
-
function
|
|
185
|
-
return e.gatewayUrl ? new URL(e.gatewayUrl).origin : e.dev ?
|
|
211
|
+
function G(e) {
|
|
212
|
+
return e.gatewayUrl ? new URL(e.gatewayUrl).origin : e.dev ? h.dev : e.sandbox ? h.sandbox : h.prod;
|
|
186
213
|
}
|
|
187
|
-
function
|
|
214
|
+
function S({
|
|
188
215
|
options: e,
|
|
189
216
|
unsupportedKeys: t,
|
|
190
217
|
entryPoint: a
|
|
@@ -192,14 +219,14 @@ function E({
|
|
|
192
219
|
const n = t.filter((o) => e[o] !== void 0);
|
|
193
220
|
return n.length === 0 ? null : `${n.join(" and ")} ${n.length > 1 ? "are" : "is"} not used by ${a}. Passing it has no effect, so this is almost always a mistake.`;
|
|
194
221
|
}
|
|
195
|
-
function
|
|
222
|
+
function D(e) {
|
|
196
223
|
var t;
|
|
197
224
|
return (t = e.flow) != null && t.walletConnect && !e.walletConnectProjectId ? "walletConnectProjectId is required when flow.walletConnect is on" : null;
|
|
198
225
|
}
|
|
199
|
-
function
|
|
200
|
-
return e.gatewayUrl === void 0 ||
|
|
226
|
+
function N(e) {
|
|
227
|
+
return e.gatewayUrl === void 0 || q(e.gatewayUrl) ? null : `gatewayUrl must be an http(s) origin such as http://localhost:8000, with no path, got ${JSON.stringify(e.gatewayUrl)}`;
|
|
201
228
|
}
|
|
202
|
-
function
|
|
229
|
+
function q(e) {
|
|
203
230
|
let t;
|
|
204
231
|
try {
|
|
205
232
|
t = new URL(e);
|
|
@@ -208,20 +235,20 @@ function Y(e) {
|
|
|
208
235
|
}
|
|
209
236
|
return (t.protocol === "http:" || t.protocol === "https:") && t.pathname === "/" && t.search === "" && t.hash === "";
|
|
210
237
|
}
|
|
211
|
-
function
|
|
212
|
-
return e !== null && !
|
|
238
|
+
function ie(e) {
|
|
239
|
+
return e !== null && !d(e) && !!e.publishableKey;
|
|
213
240
|
}
|
|
214
|
-
function
|
|
215
|
-
return e !== null && !
|
|
241
|
+
function ce(e) {
|
|
242
|
+
return e !== null && !d(e);
|
|
216
243
|
}
|
|
217
|
-
function
|
|
244
|
+
function le({
|
|
218
245
|
options: e,
|
|
219
246
|
session: t,
|
|
220
247
|
settled: a
|
|
221
248
|
}) {
|
|
222
|
-
return !a && t !== null && e !== null &&
|
|
249
|
+
return !a && t !== null && e !== null && d(e);
|
|
223
250
|
}
|
|
224
|
-
function
|
|
251
|
+
function A(e, t, a) {
|
|
225
252
|
try {
|
|
226
253
|
e == null || e(t, a);
|
|
227
254
|
} catch (n) {
|
|
@@ -239,24 +266,24 @@ function y(e) {
|
|
|
239
266
|
}
|
|
240
267
|
return t.protocol === "https:" || t.protocol === "http:" ? e : void 0;
|
|
241
268
|
}
|
|
242
|
-
async function
|
|
269
|
+
async function _({
|
|
243
270
|
api: e,
|
|
244
271
|
options: t,
|
|
245
272
|
emit: a
|
|
246
273
|
}) {
|
|
247
274
|
try {
|
|
248
|
-
const n = await
|
|
249
|
-
a("session.loaded",
|
|
250
|
-
const s = await
|
|
275
|
+
const n = await H({ api: e, options: t }), { session: o, sessionPromoted: r } = await K({ api: e, sessionID: n });
|
|
276
|
+
a("session.loaded", z(o));
|
|
277
|
+
const s = await J({
|
|
251
278
|
api: e,
|
|
252
279
|
transactionID: o.transactionID
|
|
253
280
|
});
|
|
254
281
|
return { ok: !0, session: o, sessionPromoted: r, linkedTransaction: s };
|
|
255
282
|
} catch (n) {
|
|
256
|
-
return { ok: !1, ...await
|
|
283
|
+
return { ok: !1, ...await j(n) };
|
|
257
284
|
}
|
|
258
285
|
}
|
|
259
|
-
async function
|
|
286
|
+
async function j(e) {
|
|
260
287
|
const t = e instanceof Error ? e.cause : void 0;
|
|
261
288
|
if (!(t instanceof Response && t.status === 404))
|
|
262
289
|
return {};
|
|
@@ -273,35 +300,35 @@ async function _(e) {
|
|
|
273
300
|
function P(e) {
|
|
274
301
|
return typeof e == "string" ? y(e) : void 0;
|
|
275
302
|
}
|
|
276
|
-
async function
|
|
303
|
+
async function H({
|
|
277
304
|
api: e,
|
|
278
305
|
options: t
|
|
279
306
|
}) {
|
|
280
|
-
return
|
|
307
|
+
return d(t) ? t.sessionID : (await e.createSession({
|
|
281
308
|
amount: t.transaction.amount,
|
|
282
309
|
amountCurrency: t.transaction.currency,
|
|
283
310
|
descriptor: t.transaction.descriptor,
|
|
284
311
|
referenceNumber: t.transaction.referenceNumber
|
|
285
312
|
})).sessionID;
|
|
286
313
|
}
|
|
287
|
-
async function
|
|
314
|
+
async function K({
|
|
288
315
|
api: e,
|
|
289
316
|
sessionID: t
|
|
290
317
|
}) {
|
|
291
318
|
const a = await e.getSession(t);
|
|
292
|
-
return { session: a, sessionPromoted:
|
|
319
|
+
return { session: a, sessionPromoted: I(a) };
|
|
293
320
|
}
|
|
294
|
-
function
|
|
321
|
+
function z(e) {
|
|
295
322
|
return {
|
|
296
323
|
sessionID: e.sessionID,
|
|
297
324
|
merchantName: e.merchantName,
|
|
298
|
-
alreadyPromoted:
|
|
325
|
+
alreadyPromoted: I(e)
|
|
299
326
|
};
|
|
300
327
|
}
|
|
301
|
-
function
|
|
328
|
+
function I(e) {
|
|
302
329
|
return !!e.transactionID;
|
|
303
330
|
}
|
|
304
|
-
async function
|
|
331
|
+
async function J({
|
|
305
332
|
api: e,
|
|
306
333
|
transactionID: t
|
|
307
334
|
}) {
|
|
@@ -313,7 +340,7 @@ async function K({
|
|
|
313
340
|
return console.error("Failed to resolve the session transaction:", a), null;
|
|
314
341
|
}
|
|
315
342
|
}
|
|
316
|
-
function
|
|
343
|
+
function k({
|
|
317
344
|
message: e,
|
|
318
345
|
reason: t,
|
|
319
346
|
shouldEndCheckout: a,
|
|
@@ -333,7 +360,7 @@ function C({
|
|
|
333
360
|
}
|
|
334
361
|
};
|
|
335
362
|
}
|
|
336
|
-
const
|
|
363
|
+
const Q = {
|
|
337
364
|
"common.cancelTransaction": "Cancel Transaction",
|
|
338
365
|
"common.cancel": "Cancel",
|
|
339
366
|
"common.back": "Back",
|
|
@@ -488,6 +515,15 @@ const j = {
|
|
|
488
515
|
"success.getAppBody": "Want a simpler checkout experience? Try the <strong>Lydian Wallet</strong> next time.",
|
|
489
516
|
"success.downloadFromAppStore": "Download from the App Store",
|
|
490
517
|
"success.downloadFromGooglePlay": "Get it on Google Play",
|
|
518
|
+
"receipt.title": "Email Receipt",
|
|
519
|
+
"receipt.subtitle": "Get a copy of these payment details by email.",
|
|
520
|
+
"receipt.marketingConsent": "I’d like to receive promotional updates, offers, and announcements from Lydian.",
|
|
521
|
+
"receipt.send": "Send Receipt",
|
|
522
|
+
"receipt.sending": "Sending...",
|
|
523
|
+
"receipt.sent": "Your receipt is on its way. Contact support if you need another copy.",
|
|
524
|
+
"receipt.sendFailed": "We couldn't send your receipt. Please try again.",
|
|
525
|
+
"receipt.unavailable": "Email receipts aren't available for this payment.",
|
|
526
|
+
"receipt.alreadySent": "A receipt has already been sent for this payment. Contact support if you need another copy.",
|
|
491
527
|
"failure.title": "We couldn't complete your payment",
|
|
492
528
|
"failure.paymentId": "Payment ID",
|
|
493
529
|
"failure.copyPaymentId": "Copy payment ID",
|
|
@@ -559,34 +595,34 @@ const j = {
|
|
|
559
595
|
"validation.customerDetailsMissing": "Customer details are missing.",
|
|
560
596
|
"validation.invalidOtp": "Please enter a valid 6-digit code.",
|
|
561
597
|
"terms.notice": 'By continuing, you agree to Lydian <a href="https://lydian.com/privacy" target="_blank" rel="noopener noreferrer">Terms and Conditions</a> and understand your data will be processed according to the <a href="https://lydian.com/privacy" target="_blank" rel="noopener noreferrer">Privacy Notice</a>.'
|
|
562
|
-
},
|
|
563
|
-
let
|
|
564
|
-
function
|
|
565
|
-
return
|
|
598
|
+
}, T = { en: Q }, L = "en";
|
|
599
|
+
let R = L;
|
|
600
|
+
function de() {
|
|
601
|
+
return R;
|
|
566
602
|
}
|
|
567
|
-
function
|
|
603
|
+
function w(e, t) {
|
|
568
604
|
var n;
|
|
569
|
-
const a = ((n =
|
|
605
|
+
const a = ((n = T[R]) == null ? void 0 : n[e]) ?? T[L][e] ?? e;
|
|
570
606
|
return t ? a.replace(
|
|
571
607
|
/\{(\w+)\}/g,
|
|
572
608
|
(o, r) => t[r] != null ? String(t[r]) : `{${r}}`
|
|
573
609
|
) : a;
|
|
574
610
|
}
|
|
575
|
-
function
|
|
611
|
+
function Z(e) {
|
|
576
612
|
return e === u.SUCCESS ? "succeeded" : e < u.PENDING && e !== u.KYC_VERIFICATION_PENDING && e !== u.COMPLIANCE_PENDING ? "failed" : "active";
|
|
577
613
|
}
|
|
578
|
-
function
|
|
614
|
+
function X({
|
|
579
615
|
transaction: e,
|
|
580
616
|
session: t
|
|
581
617
|
}) {
|
|
582
618
|
var o, r, s;
|
|
583
|
-
const a =
|
|
619
|
+
const a = Z(e.status);
|
|
584
620
|
if (a === "active")
|
|
585
621
|
return null;
|
|
586
622
|
if (a === "failed")
|
|
587
623
|
return {
|
|
588
624
|
outcome: a,
|
|
589
|
-
message:
|
|
625
|
+
message: w("errors.paymentCouldNotComplete"),
|
|
590
626
|
failure: {
|
|
591
627
|
shouldEndCheckout: !0,
|
|
592
628
|
// Negative (non-KYC) status — cancelled / fraud / timeout.
|
|
@@ -596,7 +632,7 @@ function J({
|
|
|
596
632
|
}
|
|
597
633
|
};
|
|
598
634
|
const n = (o = e.payments) == null ? void 0 : o.find(
|
|
599
|
-
(i) => i.status ===
|
|
635
|
+
(i) => i.status === B.CONFIRMED
|
|
600
636
|
);
|
|
601
637
|
return {
|
|
602
638
|
outcome: a,
|
|
@@ -616,13 +652,13 @@ function J({
|
|
|
616
652
|
}
|
|
617
653
|
};
|
|
618
654
|
}
|
|
619
|
-
function
|
|
655
|
+
function V() {
|
|
620
656
|
let e = null;
|
|
621
657
|
return {
|
|
622
658
|
setOptions: (t) => {
|
|
623
659
|
e = t;
|
|
624
660
|
},
|
|
625
|
-
emit: (t, a) =>
|
|
661
|
+
emit: (t, a) => A(e == null ? void 0 : e.onEvent, t, a),
|
|
626
662
|
paymentFailed: (t, a) => {
|
|
627
663
|
var n;
|
|
628
664
|
return (n = e == null ? void 0 : e.paymentFailedListener) == null ? void 0 : n.call(e, t, a);
|
|
@@ -637,7 +673,7 @@ function Q() {
|
|
|
637
673
|
}
|
|
638
674
|
};
|
|
639
675
|
}
|
|
640
|
-
class
|
|
676
|
+
class ee extends HTMLElement {
|
|
641
677
|
constructor() {
|
|
642
678
|
super(), this.engine = null, this.engineLoadPromise = null, this.isTornDown = !1, this.shadow = this.attachShadow({ mode: "open" });
|
|
643
679
|
}
|
|
@@ -647,7 +683,7 @@ class Z extends HTMLElement {
|
|
|
647
683
|
this.isTornDown = !1;
|
|
648
684
|
}
|
|
649
685
|
async initialize(t) {
|
|
650
|
-
const a =
|
|
686
|
+
const a = te(t), n = ae({ api: a, options: t }), o = await this.loadEngine(t, n);
|
|
651
687
|
!o || this.isTornDown || (this.engine = o, await o.initialize(t, { api: a, sessionLoad: n }));
|
|
652
688
|
}
|
|
653
689
|
async loadEngine(t, a) {
|
|
@@ -675,7 +711,7 @@ class Z extends HTMLElement {
|
|
|
675
711
|
// Not started in the constructor: a page can carry the tag and never check out.
|
|
676
712
|
// Overlapping initialize() calls share one download.
|
|
677
713
|
getOrLoadEngine() {
|
|
678
|
-
return this.engineLoadPromise ?? (this.engineLoadPromise = import("./mountEngine-
|
|
714
|
+
return this.engineLoadPromise ?? (this.engineLoadPromise = import("./mountEngine-B9qRQyLg.js").then((t) => t.m).then((t) => {
|
|
679
715
|
const a = t.mountCheckoutEngine({
|
|
680
716
|
host: this,
|
|
681
717
|
shadowRoot: this.shadow
|
|
@@ -708,9 +744,9 @@ class Z extends HTMLElement {
|
|
|
708
744
|
const n = await a;
|
|
709
745
|
if (this.isDismissedByHost)
|
|
710
746
|
return;
|
|
711
|
-
const o =
|
|
747
|
+
const o = V();
|
|
712
748
|
o.setOptions(t);
|
|
713
|
-
const r = n.ok && n.linkedTransaction ?
|
|
749
|
+
const r = n.ok && n.linkedTransaction ? X({
|
|
714
750
|
transaction: n.linkedTransaction,
|
|
715
751
|
session: n.session
|
|
716
752
|
}) : null;
|
|
@@ -731,16 +767,16 @@ class Z extends HTMLElement {
|
|
|
731
767
|
return;
|
|
732
768
|
}
|
|
733
769
|
if (!n.ok && n.failureURL) {
|
|
734
|
-
const
|
|
735
|
-
message:
|
|
770
|
+
const g = w("errors.unableToCreateSession"), b = k({
|
|
771
|
+
message: g,
|
|
736
772
|
reason: "sessionExpired",
|
|
737
773
|
shouldEndCheckout: !0,
|
|
738
774
|
session: { failureURL: n.failureURL }
|
|
739
775
|
});
|
|
740
|
-
o.emit("payment.failed",
|
|
776
|
+
o.emit("payment.failed", b.event), o.paymentFailed(g, b.failure);
|
|
741
777
|
return;
|
|
742
778
|
}
|
|
743
|
-
const s =
|
|
779
|
+
const s = w("errors.checkoutUnavailable"), i = k({
|
|
744
780
|
message: s,
|
|
745
781
|
reason: "error",
|
|
746
782
|
shouldEndCheckout: !0,
|
|
@@ -754,88 +790,89 @@ class Z extends HTMLElement {
|
|
|
754
790
|
t == null || t.teardown(), t == null || t.unmount(), this.engine = null, this.engineLoadPromise = null;
|
|
755
791
|
}
|
|
756
792
|
}
|
|
757
|
-
function
|
|
758
|
-
return new
|
|
759
|
-
|
|
760
|
-
|
|
793
|
+
function te(e) {
|
|
794
|
+
return new Y(
|
|
795
|
+
G(e),
|
|
796
|
+
d(e) ? void 0 : e.publishableKey
|
|
761
797
|
);
|
|
762
798
|
}
|
|
763
|
-
function
|
|
799
|
+
function ae({
|
|
764
800
|
api: e,
|
|
765
801
|
options: t
|
|
766
802
|
}) {
|
|
767
|
-
return
|
|
803
|
+
return _({
|
|
768
804
|
api: e,
|
|
769
805
|
options: t,
|
|
770
|
-
emit: (a, n) =>
|
|
806
|
+
emit: (a, n) => A(t.onEvent, a, n)
|
|
771
807
|
});
|
|
772
808
|
}
|
|
773
|
-
customElements.get("lydian-checkout") || customElements.define("lydian-checkout",
|
|
774
|
-
function
|
|
809
|
+
customElements.get("lydian-checkout") || customElements.define("lydian-checkout", ee);
|
|
810
|
+
function f() {
|
|
775
811
|
return document.querySelector("lydian-checkout");
|
|
776
812
|
}
|
|
777
|
-
async function
|
|
813
|
+
async function ne(e) {
|
|
778
814
|
if (!e.publishableKey || !e.transaction.amount || !e.transaction.currency)
|
|
779
815
|
throw new Error("SDK initialization requires publishableKey and a transaction");
|
|
780
|
-
const t =
|
|
816
|
+
const t = D(e);
|
|
781
817
|
if (t)
|
|
782
818
|
throw new Error(t);
|
|
783
|
-
const a =
|
|
819
|
+
const a = N(e);
|
|
784
820
|
if (a)
|
|
785
821
|
throw new Error(a);
|
|
786
822
|
if (!U(e.transaction.currency))
|
|
787
|
-
throw new Error("Invalid value for currency, valid values are: " +
|
|
788
|
-
const n =
|
|
823
|
+
throw new Error("Invalid value for currency, valid values are: " + v.join(", "));
|
|
824
|
+
const n = S({
|
|
789
825
|
options: e,
|
|
790
826
|
unsupportedKeys: ["sessionID"],
|
|
791
827
|
entryPoint: "init"
|
|
792
828
|
});
|
|
793
829
|
if (n)
|
|
794
830
|
throw new Error(n);
|
|
795
|
-
await
|
|
831
|
+
await f().initialize(e);
|
|
796
832
|
}
|
|
797
|
-
async function
|
|
833
|
+
async function oe(e) {
|
|
798
834
|
if (!e.sessionID)
|
|
799
835
|
throw new Error("initExistingSession requires a sessionID");
|
|
800
|
-
const t =
|
|
836
|
+
const t = D(e);
|
|
801
837
|
if (t)
|
|
802
838
|
throw new Error(t);
|
|
803
|
-
const a =
|
|
839
|
+
const a = N(e);
|
|
804
840
|
if (a)
|
|
805
841
|
throw new Error(a);
|
|
806
|
-
const n =
|
|
842
|
+
const n = S({
|
|
807
843
|
options: e,
|
|
808
844
|
unsupportedKeys: ["publishableKey", "transaction"],
|
|
809
845
|
entryPoint: "initExistingSession"
|
|
810
846
|
});
|
|
811
847
|
if (n)
|
|
812
848
|
throw new Error(n);
|
|
813
|
-
await
|
|
849
|
+
await f().initialize(e);
|
|
814
850
|
}
|
|
815
|
-
async function
|
|
816
|
-
await
|
|
851
|
+
async function re(e) {
|
|
852
|
+
await f().updateTransaction(e);
|
|
817
853
|
}
|
|
818
|
-
window.Lydian = { init:
|
|
854
|
+
window.Lydian = { init: ne, initExistingSession: oe, updateTransaction: re };
|
|
819
855
|
export {
|
|
820
|
-
|
|
856
|
+
O as G,
|
|
857
|
+
se as P,
|
|
821
858
|
u as T,
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
859
|
+
B as a,
|
|
860
|
+
ce as b,
|
|
861
|
+
v as c,
|
|
862
|
+
K as d,
|
|
863
|
+
z as e,
|
|
864
|
+
J as f,
|
|
865
|
+
de as g,
|
|
866
|
+
d as h,
|
|
830
867
|
U as i,
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
868
|
+
Z as j,
|
|
869
|
+
X as k,
|
|
870
|
+
I as l,
|
|
871
|
+
le as m,
|
|
872
|
+
k as n,
|
|
873
|
+
ie as o,
|
|
874
|
+
V as p,
|
|
875
|
+
H as r,
|
|
839
876
|
y as s,
|
|
840
|
-
|
|
877
|
+
w as t
|
|
841
878
|
};
|