@lydianpay/sdk-web 3.18.5 → 3.18.7
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-CVOwvGr5.js → browser-B7Rxf-Bu.js} +1 -1
- package/dist/chunks/{connect-multichain-_NxUAIzm.js → connect-multichain-DmSOZ6si.js} +9 -9
- package/dist/chunks/{dist-CFzvrfDT.js → dist-BgxCOd2O.js} +3 -3
- package/dist/chunks/{dist-Bfwrp0r9.js → dist-CXSFu8-J.js} +2 -2
- package/dist/chunks/{index-R4WX4ogg.js → index-BhTaLNkR.js} +2 -2
- package/dist/chunks/{index-CoiVOJK6.js → index-BmB5ME03.js} +1 -1
- package/dist/chunks/{index-Ul_-S-KR.js → index-CpjSM5Xu.js} +1 -1
- package/dist/chunks/{index-BHvqWN2h.js → index-CqjYiCV9.js} +123 -110
- package/dist/chunks/{mountEngine-B7wlou0O.js → mountEngine-CG_6rKvA.js} +12178 -11984
- package/dist/lydian.js +1 -1
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/network/customer/index.d.ts +2 -1
- package/dist/types/types.d.ts +15 -0
- package/dist/types/ui/checkoutCallbacks.d.ts +6 -2
- package/dist/types/ui/kycFlow.d.ts +10 -3
- package/dist/types/ui/kycValidation.d.ts +1 -0
- package/dist/types/ui/kycVerificationRequest.d.ts +2 -4
- package/dist/types/ui/react/FormField.d.ts +2 -1
- package/dist/types/ui/react/KycFields.d.ts +2 -0
- package/dist/types/ui/react/RestoreDetailsEntry.d.ts +2 -0
- package/dist/types/ui/react/checkoutActions.d.ts +6 -1
- package/dist/types/ui/react/checkoutStore.d.ts +11 -5
- package/dist/types/ui/restoredCustomer.d.ts +21 -0
- package/dist/types/ui/savedCustomer.d.ts +13 -0
- package/dist/types/ui/sessionBootstrap.d.ts +5 -9
- package/dist/types/ui/sessionHelpers.d.ts +4 -4
- package/dist/types/utils/guards.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const E = ["USD", "TRY", "PHP"];
|
|
2
|
-
function
|
|
2
|
+
function O(e) {
|
|
3
3
|
return typeof e == "string" && E.includes(e);
|
|
4
4
|
}
|
|
5
5
|
function u(e) {
|
|
6
6
|
return "sessionID" in e && typeof e.sessionID == "string" && e.sessionID.length > 0;
|
|
7
7
|
}
|
|
8
|
-
class
|
|
8
|
+
class U extends Error {
|
|
9
9
|
constructor({
|
|
10
10
|
statusText: t,
|
|
11
11
|
errorCode: a,
|
|
@@ -16,7 +16,7 @@ class O extends Error {
|
|
|
16
16
|
}
|
|
17
17
|
async function m(e) {
|
|
18
18
|
const t = await e.clone().json().catch(() => null);
|
|
19
|
-
return new
|
|
19
|
+
return new U({
|
|
20
20
|
statusText: e.statusText,
|
|
21
21
|
errorCode: F(t),
|
|
22
22
|
response: e
|
|
@@ -62,7 +62,7 @@ class y {
|
|
|
62
62
|
throw await m(s);
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
const
|
|
65
|
+
const l = "transaction", W = [
|
|
66
66
|
"firstName",
|
|
67
67
|
"lastName",
|
|
68
68
|
"email",
|
|
@@ -82,11 +82,11 @@ const c = "transaction", W = [
|
|
|
82
82
|
];
|
|
83
83
|
class $ extends y {
|
|
84
84
|
async getCryptoTransaction(t) {
|
|
85
|
-
return await this.request(`/${
|
|
85
|
+
return await this.request(`/${l}/${t}`);
|
|
86
86
|
}
|
|
87
87
|
async createPaymentRequest(t, a) {
|
|
88
88
|
return await this.request(
|
|
89
|
-
`/${
|
|
89
|
+
`/${l}/${t}/payment`,
|
|
90
90
|
{
|
|
91
91
|
method: "POST",
|
|
92
92
|
body: JSON.stringify(a)
|
|
@@ -95,7 +95,7 @@ class $ extends y {
|
|
|
95
95
|
}
|
|
96
96
|
async buildTransfer(t, a, n) {
|
|
97
97
|
return await this.request(
|
|
98
|
-
`/${
|
|
98
|
+
`/${l}/${t}/payment/${a}/transfer`,
|
|
99
99
|
{
|
|
100
100
|
method: "POST",
|
|
101
101
|
body: JSON.stringify(n)
|
|
@@ -104,7 +104,7 @@ class $ extends y {
|
|
|
104
104
|
}
|
|
105
105
|
async broadcastTransfer(t, a, n) {
|
|
106
106
|
return await this.request(
|
|
107
|
-
`/${
|
|
107
|
+
`/${l}/${t}/payment/${a}/transfer/broadcast`,
|
|
108
108
|
{
|
|
109
109
|
method: "POST",
|
|
110
110
|
body: JSON.stringify(n)
|
|
@@ -113,7 +113,7 @@ class $ extends y {
|
|
|
113
113
|
}
|
|
114
114
|
async cancelCryptoTransaction(t, a) {
|
|
115
115
|
return await this.request(
|
|
116
|
-
`/${
|
|
116
|
+
`/${l}/${t}/cancel`,
|
|
117
117
|
{
|
|
118
118
|
method: "PATCH",
|
|
119
119
|
body: JSON.stringify(a)
|
|
@@ -128,7 +128,7 @@ class $ extends y {
|
|
|
128
128
|
}), n.append("storeKYC", a.storeKYC ? "true" : "false"), a.customerUUID && n.append("customerUUID", a.customerUUID), a.walletAddress && n.append("walletAddress", a.walletAddress), a.documentType && n.append("documentType", a.documentType), a.documentFiles.forEach(
|
|
129
129
|
(o, r) => n.append("documentFiles", o, `${r + 1}-${o.name}`)
|
|
130
130
|
), await this.requestWithFormData(
|
|
131
|
-
`/${
|
|
131
|
+
`/${l}/${t}/verification`,
|
|
132
132
|
{
|
|
133
133
|
method: "POST",
|
|
134
134
|
body: n
|
|
@@ -136,7 +136,7 @@ class $ extends y {
|
|
|
136
136
|
);
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
|
-
function
|
|
139
|
+
function M(e, t) {
|
|
140
140
|
t.forEach((a) => {
|
|
141
141
|
Object.getOwnPropertyNames(a.prototype).forEach((n) => {
|
|
142
142
|
const o = Object.getOwnPropertyDescriptor(a.prototype, n);
|
|
@@ -144,49 +144,57 @@ function Y(e, t) {
|
|
|
144
144
|
});
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
|
-
const
|
|
148
|
-
class
|
|
147
|
+
const f = "customer";
|
|
148
|
+
class Y extends y {
|
|
149
149
|
// PATCH /customer/otp -> text/plain "OTP sent" (no JSON body).
|
|
150
150
|
async sendCustomerOTP(t) {
|
|
151
|
-
return await this.requestText(`/${
|
|
151
|
+
return await this.requestText(`/${f}/otp`, {
|
|
152
152
|
method: "PATCH",
|
|
153
153
|
body: JSON.stringify(t)
|
|
154
154
|
});
|
|
155
155
|
}
|
|
156
156
|
// PUT /customer/otp -> { customerUUID, kycValidated }.
|
|
157
157
|
async authenticateCustomerOTP(t) {
|
|
158
|
-
return await this.request(`/${
|
|
158
|
+
return await this.request(`/${f}/otp`, {
|
|
159
|
+
method: "PUT",
|
|
160
|
+
body: JSON.stringify(t)
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
// PUT /customer/pii -> the stored record, masked. Verifies the same code as
|
|
164
|
+
// PUT /customer/otp; a code serves both until it expires.
|
|
165
|
+
async getCustomerPII(t) {
|
|
166
|
+
return await this.request(`/${f}/pii`, {
|
|
159
167
|
method: "PUT",
|
|
160
168
|
body: JSON.stringify(t)
|
|
161
169
|
});
|
|
162
170
|
}
|
|
163
171
|
}
|
|
164
|
-
const
|
|
172
|
+
const x = "places", B = { "X-User": "lydian" };
|
|
165
173
|
class _ extends y {
|
|
166
174
|
async getCountries(t) {
|
|
167
|
-
return await this.request(`/${
|
|
168
|
-
headers:
|
|
175
|
+
return await this.request(`/${x}/countries`, {
|
|
176
|
+
headers: B,
|
|
169
177
|
signal: t
|
|
170
178
|
});
|
|
171
179
|
}
|
|
172
180
|
}
|
|
173
|
-
const
|
|
181
|
+
const d = "session";
|
|
174
182
|
class q extends y {
|
|
175
183
|
async createSession(t) {
|
|
176
|
-
return await this.request(`/${
|
|
184
|
+
return await this.request(`/${d}`, {
|
|
177
185
|
method: "POST",
|
|
178
186
|
body: JSON.stringify(t)
|
|
179
187
|
});
|
|
180
188
|
}
|
|
181
189
|
async getSession(t) {
|
|
182
|
-
return await this.request(`/${
|
|
190
|
+
return await this.request(`/${d}/${t}`);
|
|
183
191
|
}
|
|
184
192
|
// Promotes the session into a transaction. Allowed once per session — except
|
|
185
193
|
// that a KYC-pending (-3) response does not consume the promotion, which is
|
|
186
194
|
// what lets the restore-details flow re-promote with a customerUUID.
|
|
187
195
|
async createSessionTransaction(t, a) {
|
|
188
196
|
return await this.request(
|
|
189
|
-
`/${
|
|
197
|
+
`/${d}/${t}/transaction`,
|
|
190
198
|
{
|
|
191
199
|
method: "POST",
|
|
192
200
|
body: JSON.stringify(a)
|
|
@@ -196,22 +204,22 @@ class q extends y {
|
|
|
196
204
|
// PATCH /session/{id}/cancel replies text/plain (the merchant's cancel URL),
|
|
197
205
|
// not JSON. Cancelling cascades to the linked transaction, if any.
|
|
198
206
|
async cancelSession(t) {
|
|
199
|
-
return await this.requestText(`/${
|
|
207
|
+
return await this.requestText(`/${d}/${t}/cancel`, {
|
|
200
208
|
method: "PATCH"
|
|
201
209
|
});
|
|
202
210
|
}
|
|
203
211
|
async sendReceipt(t, a) {
|
|
204
|
-
await this.request(`/${
|
|
212
|
+
await this.request(`/${d}/${t}/receipt`, {
|
|
205
213
|
method: "POST",
|
|
206
214
|
body: JSON.stringify(a)
|
|
207
215
|
});
|
|
208
216
|
}
|
|
209
217
|
}
|
|
210
|
-
class
|
|
218
|
+
class S extends y {
|
|
211
219
|
}
|
|
212
|
-
|
|
213
|
-
const G =
|
|
214
|
-
var
|
|
220
|
+
M(S, [$, Y, _, q]);
|
|
221
|
+
const G = S;
|
|
222
|
+
var c = {
|
|
215
223
|
COMPLIANCE_PENDING: -10,
|
|
216
224
|
API_CANCELLED: -9,
|
|
217
225
|
PAYMENT_TIMEOUT: -8,
|
|
@@ -228,10 +236,10 @@ var d = {
|
|
|
228
236
|
FRAUD: -1,
|
|
229
237
|
PENDING: 0,
|
|
230
238
|
SUCCESS: 1
|
|
231
|
-
},
|
|
239
|
+
}, H = {
|
|
232
240
|
PARTIALLY_PAID: 1,
|
|
233
241
|
OVERPAID: 3
|
|
234
|
-
},
|
|
242
|
+
}, K = {
|
|
235
243
|
PENDING: 0,
|
|
236
244
|
CONFIRMED: 1
|
|
237
245
|
}, w = {
|
|
@@ -239,10 +247,10 @@ var d = {
|
|
|
239
247
|
sandbox: "https://api.sandbox.lydian.com",
|
|
240
248
|
prod: "https://api.lydian.com"
|
|
241
249
|
};
|
|
242
|
-
function
|
|
250
|
+
function j(e) {
|
|
243
251
|
return e.gatewayUrl ? new URL(e.gatewayUrl).origin : e.dev ? w.dev : e.sandbox ? w.sandbox : w.prod;
|
|
244
252
|
}
|
|
245
|
-
function
|
|
253
|
+
function v({
|
|
246
254
|
options: e,
|
|
247
255
|
unsupportedKeys: t,
|
|
248
256
|
entryPoint: a
|
|
@@ -266,20 +274,20 @@ function z(e) {
|
|
|
266
274
|
}
|
|
267
275
|
return (t.protocol === "http:" || t.protocol === "https:") && t.pathname === "/" && t.search === "" && t.hash === "";
|
|
268
276
|
}
|
|
269
|
-
function
|
|
277
|
+
function ye(e) {
|
|
270
278
|
return e !== null && !u(e) && !!e.publishableKey;
|
|
271
279
|
}
|
|
272
|
-
function
|
|
280
|
+
function pe(e) {
|
|
273
281
|
return e !== null && !u(e);
|
|
274
282
|
}
|
|
275
|
-
function
|
|
283
|
+
function he({
|
|
276
284
|
options: e,
|
|
277
285
|
session: t,
|
|
278
286
|
settled: a
|
|
279
287
|
}) {
|
|
280
288
|
return !a && t !== null && e !== null && u(e);
|
|
281
289
|
}
|
|
282
|
-
function
|
|
290
|
+
function I(e, t, a) {
|
|
283
291
|
try {
|
|
284
292
|
e == null || e(t, a);
|
|
285
293
|
} catch (n) {
|
|
@@ -297,24 +305,28 @@ function p(e) {
|
|
|
297
305
|
}
|
|
298
306
|
return t.protocol === "https:" || t.protocol === "http:" ? e : void 0;
|
|
299
307
|
}
|
|
300
|
-
|
|
308
|
+
const J = [
|
|
309
|
+
c.KYC_VERIFICATION_PENDING,
|
|
310
|
+
c.COMPLIANCE_PENDING
|
|
311
|
+
];
|
|
312
|
+
async function Q({
|
|
301
313
|
api: e,
|
|
302
314
|
options: t,
|
|
303
315
|
emit: a
|
|
304
316
|
}) {
|
|
305
317
|
try {
|
|
306
|
-
const n = await
|
|
318
|
+
const n = await V({ api: e, options: t }), o = await e.getSession(n);
|
|
307
319
|
a("session.loaded", Z(o));
|
|
308
|
-
const
|
|
320
|
+
const r = await te({
|
|
309
321
|
api: e,
|
|
310
322
|
transactionID: o.transactionID
|
|
311
|
-
});
|
|
312
|
-
return { ok: !0, session: o, sessionPromoted:
|
|
323
|
+
}), s = ee({ session: o, linkedTransaction: r });
|
|
324
|
+
return { ok: !0, session: o, sessionPromoted: s, linkedTransaction: r };
|
|
313
325
|
} catch (n) {
|
|
314
|
-
return { ok: !1, ...await
|
|
326
|
+
return { ok: !1, ...await X(n) };
|
|
315
327
|
}
|
|
316
328
|
}
|
|
317
|
-
async function
|
|
329
|
+
async function X(e) {
|
|
318
330
|
const t = e instanceof Error ? e.cause : void 0;
|
|
319
331
|
if (!(t instanceof Response && t.status === 404))
|
|
320
332
|
return {};
|
|
@@ -331,7 +343,7 @@ async function Q(e) {
|
|
|
331
343
|
function C(e) {
|
|
332
344
|
return typeof e == "string" ? p(e) : void 0;
|
|
333
345
|
}
|
|
334
|
-
async function
|
|
346
|
+
async function V({
|
|
335
347
|
api: e,
|
|
336
348
|
options: t
|
|
337
349
|
}) {
|
|
@@ -342,24 +354,23 @@ async function X({
|
|
|
342
354
|
referenceNumber: t.transaction.referenceNumber
|
|
343
355
|
})).sessionID;
|
|
344
356
|
}
|
|
345
|
-
async function V({
|
|
346
|
-
api: e,
|
|
347
|
-
sessionID: t
|
|
348
|
-
}) {
|
|
349
|
-
const a = await e.getSession(t);
|
|
350
|
-
return { session: a, sessionPromoted: I(a) };
|
|
351
|
-
}
|
|
352
357
|
function Z(e) {
|
|
353
358
|
return {
|
|
354
359
|
sessionID: e.sessionID,
|
|
355
360
|
merchantName: e.merchantName,
|
|
356
|
-
alreadyPromoted:
|
|
361
|
+
alreadyPromoted: N(e)
|
|
357
362
|
};
|
|
358
363
|
}
|
|
359
|
-
function
|
|
364
|
+
function N(e) {
|
|
360
365
|
return !!e.transactionID;
|
|
361
366
|
}
|
|
362
|
-
|
|
367
|
+
function ee({
|
|
368
|
+
session: e,
|
|
369
|
+
linkedTransaction: t
|
|
370
|
+
}) {
|
|
371
|
+
return N(e) ? t ? !J.includes(t.status) : !0 : !1;
|
|
372
|
+
}
|
|
373
|
+
async function te({
|
|
363
374
|
api: e,
|
|
364
375
|
transactionID: t
|
|
365
376
|
}) {
|
|
@@ -391,7 +402,7 @@ function P({
|
|
|
391
402
|
}
|
|
392
403
|
};
|
|
393
404
|
}
|
|
394
|
-
const
|
|
405
|
+
const ae = {
|
|
395
406
|
"common.cancelTransaction": "Cancel Transaction",
|
|
396
407
|
"common.cancel": "Cancel",
|
|
397
408
|
"common.back": "Back",
|
|
@@ -500,6 +511,7 @@ const te = {
|
|
|
500
511
|
"kyc.fileHint": "PNG, JPG or PDF, up to 10 MB",
|
|
501
512
|
"kyc.saveInfo": "Securely save this info for next time",
|
|
502
513
|
"kyc.saveInfoDescription": "Next time, skip this step by entering the one-time code sent to your email.",
|
|
514
|
+
"kyc.onFileHint": "Details we have on file are shown masked. Select a field to replace it.",
|
|
503
515
|
"scan.exactAmountNotice": "Make sure you send the exact amount on the correct network to complete your payment smoothly.",
|
|
504
516
|
"scan.scanWithWallet": "Scan the QR code with your preferred wallet",
|
|
505
517
|
"scan.payOnWallet": "Pay on {wallet}",
|
|
@@ -583,6 +595,7 @@ const te = {
|
|
|
583
595
|
"restore.sendCode": "Send code",
|
|
584
596
|
"restore.verifyCode": "Verify code",
|
|
585
597
|
"restore.autoFillHeading": "Auto-fill info below",
|
|
598
|
+
"restore.autoFillAs": "Auto-fill with {email}",
|
|
586
599
|
"restore.otpPrompt": "Please enter the 6-digit code sent to",
|
|
587
600
|
"restore.notYou": "Not you?",
|
|
588
601
|
"restore.didntGetCode": "Didn't get the code?",
|
|
@@ -638,32 +651,32 @@ const te = {
|
|
|
638
651
|
"validation.customerDetailsMissing": "Customer details are missing.",
|
|
639
652
|
"validation.invalidOtp": "Please enter a valid 6-digit code.",
|
|
640
653
|
"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>.'
|
|
641
|
-
}, T = { en:
|
|
642
|
-
let
|
|
643
|
-
function
|
|
644
|
-
return
|
|
654
|
+
}, T = { en: ae }, R = "en";
|
|
655
|
+
let L = R;
|
|
656
|
+
function me() {
|
|
657
|
+
return L;
|
|
645
658
|
}
|
|
646
659
|
function h(e, t) {
|
|
647
660
|
var n;
|
|
648
|
-
const a = ((n = T[
|
|
661
|
+
const a = ((n = T[L]) == null ? void 0 : n[e]) ?? T[R][e] ?? e;
|
|
649
662
|
return t ? a.replace(
|
|
650
663
|
/\{(\w+)\}/g,
|
|
651
664
|
(o, r) => t[r] != null ? String(t[r]) : `{${r}}`
|
|
652
665
|
) : a;
|
|
653
666
|
}
|
|
654
|
-
function
|
|
655
|
-
return e ===
|
|
667
|
+
function ne(e) {
|
|
668
|
+
return e === c.SUCCESS ? "succeeded" : e < c.PENDING && e !== c.KYC_VERIFICATION_PENDING && e !== c.COMPLIANCE_PENDING ? "failed" : "active";
|
|
656
669
|
}
|
|
657
|
-
function
|
|
670
|
+
function oe({
|
|
658
671
|
transaction: e,
|
|
659
672
|
session: t
|
|
660
673
|
}) {
|
|
661
674
|
var o, r, s;
|
|
662
|
-
const a =
|
|
675
|
+
const a = ne(e.status);
|
|
663
676
|
if (a === "active")
|
|
664
677
|
return null;
|
|
665
678
|
if (a === "failed") {
|
|
666
|
-
const i = e.status ===
|
|
679
|
+
const i = e.status === c.PAYMENT_TIMEOUT && e.paymentStatus === H.PARTIALLY_PAID;
|
|
667
680
|
return {
|
|
668
681
|
outcome: a,
|
|
669
682
|
message: h(i ? "errors.paymentShortRefundRequested" : "errors.paymentCouldNotComplete"),
|
|
@@ -677,7 +690,7 @@ function ne({
|
|
|
677
690
|
};
|
|
678
691
|
}
|
|
679
692
|
const n = (o = e.payments) == null ? void 0 : o.find(
|
|
680
|
-
(i) => i.status ===
|
|
693
|
+
(i) => i.status === K.CONFIRMED
|
|
681
694
|
);
|
|
682
695
|
return {
|
|
683
696
|
outcome: a,
|
|
@@ -697,13 +710,13 @@ function ne({
|
|
|
697
710
|
}
|
|
698
711
|
};
|
|
699
712
|
}
|
|
700
|
-
function
|
|
713
|
+
function re() {
|
|
701
714
|
let e = null;
|
|
702
715
|
return {
|
|
703
716
|
setOptions: (t) => {
|
|
704
717
|
e = t;
|
|
705
718
|
},
|
|
706
|
-
emit: (t, a) =>
|
|
719
|
+
emit: (t, a) => I(e == null ? void 0 : e.onEvent, t, a),
|
|
707
720
|
paymentFailed: (t, a) => {
|
|
708
721
|
var n;
|
|
709
722
|
return (n = e == null ? void 0 : e.paymentFailedListener) == null ? void 0 : n.call(e, t, a);
|
|
@@ -718,7 +731,7 @@ function oe() {
|
|
|
718
731
|
}
|
|
719
732
|
};
|
|
720
733
|
}
|
|
721
|
-
class
|
|
734
|
+
class se extends HTMLElement {
|
|
722
735
|
constructor() {
|
|
723
736
|
super(), this.engine = null, this.engineLoadPromise = null, this.isTornDown = !1, this.shadow = this.attachShadow({ mode: "open" });
|
|
724
737
|
}
|
|
@@ -728,7 +741,7 @@ class re extends HTMLElement {
|
|
|
728
741
|
this.isTornDown = !1;
|
|
729
742
|
}
|
|
730
743
|
async initialize(t) {
|
|
731
|
-
const a =
|
|
744
|
+
const a = ie(t), n = ce({ api: a, options: t }), o = await this.loadEngine(t, n);
|
|
732
745
|
!o || this.isTornDown || (this.engine = o, await o.initialize(t, { api: a, sessionLoad: n }));
|
|
733
746
|
}
|
|
734
747
|
async loadEngine(t, a) {
|
|
@@ -756,7 +769,7 @@ class re extends HTMLElement {
|
|
|
756
769
|
// Not started in the constructor: a page can carry the tag and never check out.
|
|
757
770
|
// Overlapping initialize() calls share one download.
|
|
758
771
|
getOrLoadEngine() {
|
|
759
|
-
return this.engineLoadPromise ?? (this.engineLoadPromise = import("./mountEngine-
|
|
772
|
+
return this.engineLoadPromise ?? (this.engineLoadPromise = import("./mountEngine-CG_6rKvA.js").then((t) => t.m).then((t) => {
|
|
760
773
|
const a = t.mountCheckoutEngine({
|
|
761
774
|
host: this,
|
|
762
775
|
shadowRoot: this.shadow
|
|
@@ -789,9 +802,9 @@ class re extends HTMLElement {
|
|
|
789
802
|
const n = await a;
|
|
790
803
|
if (this.isDismissedByHost)
|
|
791
804
|
return;
|
|
792
|
-
const o =
|
|
805
|
+
const o = re();
|
|
793
806
|
o.setOptions(t);
|
|
794
|
-
const r = n.ok && n.linkedTransaction ?
|
|
807
|
+
const r = n.ok && n.linkedTransaction ? oe({
|
|
795
808
|
transaction: n.linkedTransaction,
|
|
796
809
|
session: n.session
|
|
797
810
|
}) : null;
|
|
@@ -812,13 +825,13 @@ class re extends HTMLElement {
|
|
|
812
825
|
return;
|
|
813
826
|
}
|
|
814
827
|
if (!n.ok && n.failureURL) {
|
|
815
|
-
const
|
|
816
|
-
message:
|
|
828
|
+
const b = h("errors.unableToCreateSession"), k = P({
|
|
829
|
+
message: b,
|
|
817
830
|
reason: "sessionExpired",
|
|
818
831
|
shouldEndCheckout: !0,
|
|
819
832
|
session: { failureURL: n.failureURL }
|
|
820
833
|
});
|
|
821
|
-
o.emit("payment.failed",
|
|
834
|
+
o.emit("payment.failed", k.event), o.paymentFailed(b, k.failure);
|
|
822
835
|
return;
|
|
823
836
|
}
|
|
824
837
|
const s = h("errors.checkoutUnavailable"), i = P({
|
|
@@ -835,27 +848,27 @@ class re extends HTMLElement {
|
|
|
835
848
|
t == null || t.teardown(), t == null || t.unmount(), this.engine = null, this.engineLoadPromise = null;
|
|
836
849
|
}
|
|
837
850
|
}
|
|
838
|
-
function
|
|
851
|
+
function ie(e) {
|
|
839
852
|
return new G(
|
|
840
|
-
|
|
853
|
+
j(e),
|
|
841
854
|
u(e) ? void 0 : e.publishableKey
|
|
842
855
|
);
|
|
843
856
|
}
|
|
844
|
-
function
|
|
857
|
+
function ce({
|
|
845
858
|
api: e,
|
|
846
859
|
options: t
|
|
847
860
|
}) {
|
|
848
|
-
return
|
|
861
|
+
return Q({
|
|
849
862
|
api: e,
|
|
850
863
|
options: t,
|
|
851
|
-
emit: (a, n) =>
|
|
864
|
+
emit: (a, n) => I(t.onEvent, a, n)
|
|
852
865
|
});
|
|
853
866
|
}
|
|
854
|
-
customElements.get("lydian-checkout") || customElements.define("lydian-checkout",
|
|
855
|
-
function
|
|
867
|
+
customElements.get("lydian-checkout") || customElements.define("lydian-checkout", se);
|
|
868
|
+
function g() {
|
|
856
869
|
return document.querySelector("lydian-checkout");
|
|
857
870
|
}
|
|
858
|
-
async function
|
|
871
|
+
async function le(e) {
|
|
859
872
|
if (!e.publishableKey || !e.transaction.amount || !e.transaction.currency)
|
|
860
873
|
throw new Error("SDK initialization requires publishableKey and a transaction");
|
|
861
874
|
const t = D(e);
|
|
@@ -864,18 +877,18 @@ async function ce(e) {
|
|
|
864
877
|
const a = A(e);
|
|
865
878
|
if (a)
|
|
866
879
|
throw new Error(a);
|
|
867
|
-
if (!
|
|
880
|
+
if (!O(e.transaction.currency))
|
|
868
881
|
throw new Error("Invalid value for currency, valid values are: " + E.join(", "));
|
|
869
|
-
const n =
|
|
882
|
+
const n = v({
|
|
870
883
|
options: e,
|
|
871
884
|
unsupportedKeys: ["sessionID"],
|
|
872
885
|
entryPoint: "init"
|
|
873
886
|
});
|
|
874
887
|
if (n)
|
|
875
888
|
throw new Error(n);
|
|
876
|
-
await
|
|
889
|
+
await g().initialize(e);
|
|
877
890
|
}
|
|
878
|
-
async function
|
|
891
|
+
async function de(e) {
|
|
879
892
|
if (!e.sessionID)
|
|
880
893
|
throw new Error("initExistingSession requires a sessionID");
|
|
881
894
|
const t = D(e);
|
|
@@ -884,40 +897,40 @@ async function le(e) {
|
|
|
884
897
|
const a = A(e);
|
|
885
898
|
if (a)
|
|
886
899
|
throw new Error(a);
|
|
887
|
-
const n =
|
|
900
|
+
const n = v({
|
|
888
901
|
options: e,
|
|
889
902
|
unsupportedKeys: ["publishableKey", "transaction"],
|
|
890
903
|
entryPoint: "initExistingSession"
|
|
891
904
|
});
|
|
892
905
|
if (n)
|
|
893
906
|
throw new Error(n);
|
|
894
|
-
await
|
|
907
|
+
await g().initialize(e);
|
|
895
908
|
}
|
|
896
|
-
async function
|
|
897
|
-
await
|
|
909
|
+
async function ue(e) {
|
|
910
|
+
await g().updateTransaction(e);
|
|
898
911
|
}
|
|
899
|
-
window.Lydian = { init:
|
|
912
|
+
window.Lydian = { init: le, initExistingSession: de, updateTransaction: ue };
|
|
900
913
|
export {
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
914
|
+
U as G,
|
|
915
|
+
H as P,
|
|
916
|
+
c as T,
|
|
917
|
+
K as a,
|
|
918
|
+
pe as b,
|
|
906
919
|
E as c,
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
920
|
+
Z as d,
|
|
921
|
+
ee as e,
|
|
922
|
+
te as f,
|
|
923
|
+
me as g,
|
|
911
924
|
u as h,
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
925
|
+
O as i,
|
|
926
|
+
ne as j,
|
|
927
|
+
oe as k,
|
|
928
|
+
N as l,
|
|
929
|
+
he as m,
|
|
917
930
|
P as n,
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
931
|
+
ye as o,
|
|
932
|
+
re as p,
|
|
933
|
+
V as r,
|
|
921
934
|
p as s,
|
|
922
935
|
h as t
|
|
923
936
|
};
|