@lydianpay/sdk-web 3.19.4 → 3.19.5

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.
@@ -1,68 +1,82 @@
1
1
  const E = ["USD", "TRY", "PHP"];
2
- function U(e) {
3
- return typeof e == "string" && E.includes(e);
2
+ function U(t) {
3
+ return typeof t == "string" && E.includes(t);
4
4
  }
5
- function u(e) {
6
- return "sessionID" in e && typeof e.sessionID == "string" && e.sessionID.length > 0;
5
+ function u(t) {
6
+ return "sessionID" in t && typeof t.sessionID == "string" && t.sessionID.length > 0;
7
7
  }
8
8
  class O extends Error {
9
9
  constructor({
10
- statusText: t,
10
+ statusText: e,
11
11
  errorCode: a,
12
12
  response: n
13
13
  }) {
14
- super(t, { cause: n }), this.name = "GatewayRequestError", this.errorCode = a;
14
+ super(e, { cause: n }), this.name = "GatewayRequestError", this.errorCode = a;
15
15
  }
16
16
  }
17
- async function w(e) {
18
- const t = await e.clone().json().catch(() => null);
17
+ async function F(t) {
18
+ const e = await t.clone().json().catch(() => null);
19
19
  return new O({
20
- statusText: e.statusText,
21
- errorCode: F(t),
22
- response: e
20
+ statusText: t.statusText,
21
+ errorCode: W(e),
22
+ response: t
23
23
  });
24
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;
25
+ function W(t) {
26
+ if (!(typeof t != "object" || t === null || !("errorCode" in t)))
27
+ return typeof t.errorCode == "number" ? t.errorCode : void 0;
28
28
  }
29
+ const k = { "Content-Type": "application/json" };
29
30
  class y {
30
31
  // Optional: a caller-supplied session has no key and needs none (see Sessions).
31
32
  // The key is still required when the SDK creates the session, enforced in
32
33
  // index.ts where that is known.
33
- constructor(t, a) {
34
- if (this.baseUri = t, this.publishableKey = a, !this.baseUri)
34
+ constructor(e, a) {
35
+ if (this.baseUri = e, this.publishableKey = a, !this.baseUri)
35
36
  throw new Error("baseUri is required");
36
37
  }
37
38
  // Omitted rather than blank when there is no key: the gateway checks the pk_
38
39
  // prefix first, so an empty header is a 400 where an absent one is anonymous.
39
- headers(t) {
40
- const a = { ...t };
40
+ headers(e) {
41
+ const a = { ...e };
41
42
  return this.publishableKey && (a["X-Publishable-Key"] = this.publishableKey), a;
42
43
  }
43
- async request(t, a) {
44
- const n = `${this.baseUri}${t}`, o = this.headers({ "Content-Type": "application/json", ...a == null ? void 0 : a.headers }), r = Object.assign({}, a, { headers: o }), s = await fetch(n, r);
45
- if (s.ok)
46
- return await s.json();
47
- throw await w(s);
44
+ async send({
45
+ endpoint: e,
46
+ options: a,
47
+ requestHeaders: n
48
+ }) {
49
+ const o = await fetch(`${this.baseUri}${e}`, {
50
+ ...a,
51
+ headers: this.headers(n)
52
+ });
53
+ if (o.ok)
54
+ return o;
55
+ throw await F(o);
56
+ }
57
+ async request(e, a) {
58
+ return await (await this.send({
59
+ endpoint: e,
60
+ options: a,
61
+ requestHeaders: { ...k, ...a == null ? void 0 : a.headers }
62
+ })).json();
48
63
  }
49
64
  // For endpoints that reply text/plain rather than JSON (e.g. PATCH
50
65
  // /customer/otp -> "OTP sent"). Sends the same JSON request headers but does
51
66
  // not call response.json(), which would throw on a non-JSON body.
52
- async requestText(t, a) {
53
- const n = `${this.baseUri}${t}`, o = this.headers({ "Content-Type": "application/json" }), r = Object.assign({}, a, { headers: o }), s = await fetch(n, r);
54
- if (s.ok)
55
- return await s.text();
56
- throw await w(s);
67
+ async requestText(e, a) {
68
+ return await (await this.send({
69
+ endpoint: e,
70
+ options: a,
71
+ requestHeaders: k
72
+ })).text();
57
73
  }
58
- async requestWithFormData(t, a) {
59
- const n = `${this.baseUri}${t}`, o = this.headers(), r = Object.assign({}, a, { headers: o }), s = await fetch(n, r);
60
- if (s.ok)
61
- return await s.json();
62
- throw await w(s);
74
+ // No Content-Type: the browser sets the multipart boundary.
75
+ async requestWithFormData(e, a) {
76
+ return await (await this.send({ endpoint: e, options: a })).json();
63
77
  }
64
78
  }
65
- const l = "transaction", W = [
79
+ const c = "transaction", _ = [
66
80
  "firstName",
67
81
  "lastName",
68
82
  "email",
@@ -81,55 +95,55 @@ const l = "transaction", W = [
81
95
  "nationalIDNumber",
82
96
  "customerIDNumber"
83
97
  ];
84
- class $ extends y {
85
- async getCryptoTransaction(t) {
86
- return await this.request(`/${l}/${t}`);
98
+ class M extends y {
99
+ async getCryptoTransaction(e) {
100
+ return await this.request(`/${c}/${e}`);
87
101
  }
88
- async createPaymentRequest(t, a) {
102
+ async createPaymentRequest(e, a) {
89
103
  return await this.request(
90
- `/${l}/${t}/payment`,
104
+ `/${c}/${e}/payment`,
91
105
  {
92
106
  method: "POST",
93
107
  body: JSON.stringify(a)
94
108
  }
95
109
  );
96
110
  }
97
- async buildTransfer(t, a, n) {
111
+ async buildTransfer(e, a, n) {
98
112
  return await this.request(
99
- `/${l}/${t}/payment/${a}/transfer`,
113
+ `/${c}/${e}/payment/${a}/transfer`,
100
114
  {
101
115
  method: "POST",
102
116
  body: JSON.stringify(n)
103
117
  }
104
118
  );
105
119
  }
106
- async broadcastTransfer(t, a, n) {
120
+ async broadcastTransfer(e, a, n) {
107
121
  return await this.request(
108
- `/${l}/${t}/payment/${a}/transfer/broadcast`,
122
+ `/${c}/${e}/payment/${a}/transfer/broadcast`,
109
123
  {
110
124
  method: "POST",
111
125
  body: JSON.stringify(n)
112
126
  }
113
127
  );
114
128
  }
115
- async cancelCryptoTransaction(t, a) {
129
+ async cancelCryptoTransaction(e, a) {
116
130
  return await this.request(
117
- `/${l}/${t}/cancel`,
131
+ `/${c}/${e}/cancel`,
118
132
  {
119
133
  method: "PATCH",
120
134
  body: JSON.stringify(a)
121
135
  }
122
136
  );
123
137
  }
124
- async kycVerification(t, a) {
138
+ async kycVerification(e, a) {
125
139
  const n = new FormData();
126
- return n.append("asset", a.asset), n.append("network", a.network), W.forEach((o) => {
140
+ return n.append("asset", a.asset), n.append("network", a.network), _.forEach((o) => {
127
141
  const r = a[o];
128
142
  r && n.append(o, r);
129
143
  }), 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(
130
144
  (o, r) => n.append("documentFiles", o, `${r + 1}-${o.name}`)
131
145
  ), await this.requestWithFormData(
132
- `/${l}/${t}/verification`,
146
+ `/${c}/${e}/verification`,
133
147
  {
134
148
  method: "POST",
135
149
  body: n
@@ -137,71 +151,72 @@ class $ extends y {
137
151
  );
138
152
  }
139
153
  }
140
- function M(e, t) {
141
- t.forEach((a) => {
154
+ function Y(t, e) {
155
+ e.forEach((a) => {
142
156
  Object.getOwnPropertyNames(a.prototype).forEach((n) => {
143
157
  const o = Object.getOwnPropertyDescriptor(a.prototype, n);
144
- o && Object.defineProperty(e.prototype, n, o);
158
+ o && Object.defineProperty(t.prototype, n, o);
145
159
  });
146
160
  });
147
161
  }
148
162
  const h = "customer";
149
- class Y extends y {
163
+ class B extends y {
150
164
  // PATCH /customer/otp -> text/plain "OTP sent" (no JSON body).
151
- async sendCustomerOTP(t) {
165
+ async sendCustomerOTP(e) {
152
166
  return await this.requestText(`/${h}/otp`, {
153
167
  method: "PATCH",
154
- body: JSON.stringify(t)
168
+ body: JSON.stringify(e)
155
169
  });
156
170
  }
157
171
  // PUT /customer/otp -> { customerUUID, kycValidated }.
158
- async authenticateCustomerOTP(t) {
172
+ async authenticateCustomerOTP(e) {
159
173
  return await this.request(`/${h}/otp`, {
160
174
  method: "PUT",
161
- body: JSON.stringify(t)
175
+ body: JSON.stringify(e)
162
176
  });
163
177
  }
164
- // PUT /customer/pii -> the stored record, masked. Verifies the same code as
165
- // PUT /customer/otp; a code serves both until it expires.
166
- async getCustomerPII(t) {
178
+ // PUT /customer/pii -> the stored record, masked unless the merchant shows it
179
+ // as stored. Verifies the same code as PUT /customer/otp; a code serves both
180
+ // until it expires.
181
+ async getCustomerPII(e) {
167
182
  return await this.request(`/${h}/pii`, {
168
183
  method: "PUT",
169
- body: JSON.stringify(t)
184
+ body: JSON.stringify(e)
170
185
  });
171
186
  }
172
- async updateCustomerPII(t) {
187
+ async updateCustomerPII(e) {
173
188
  return await this.request(`/${h}/pii`, {
174
189
  method: "PATCH",
175
- body: JSON.stringify(t)
190
+ body: JSON.stringify(e)
176
191
  });
177
192
  }
178
193
  }
179
- const _ = "places", x = { "X-User": "lydian" };
180
- class B extends y {
181
- async getCountries(t) {
182
- return await this.request(`/${_}/countries`, {
194
+ const $ = "places", x = { "X-User": "lydian" };
195
+ class q extends y {
196
+ async getCountries(e) {
197
+ return await this.request(`/${$}/countries`, {
183
198
  headers: x,
184
- signal: t
199
+ signal: e
185
200
  });
186
201
  }
187
202
  }
188
203
  const d = "session";
189
- class q extends y {
190
- async createSession(t) {
204
+ class G extends y {
205
+ async createSession(e) {
191
206
  return await this.request(`/${d}`, {
192
207
  method: "POST",
193
- body: JSON.stringify(t)
208
+ body: JSON.stringify(e)
194
209
  });
195
210
  }
196
- async getSession(t) {
197
- return await this.request(`/${d}/${t}`);
211
+ async getSession(e) {
212
+ return await this.request(`/${d}/${e}`);
198
213
  }
199
214
  // Promotes the session into a transaction. Allowed once per session — except
200
215
  // that a KYC-pending (3) response does not consume the promotion, which is
201
216
  // what lets the restore-details flow re-promote with a customerUUID.
202
- async createSessionTransaction(t, a) {
217
+ async createSessionTransaction(e, a) {
203
218
  return await this.request(
204
- `/${d}/${t}/transaction`,
219
+ `/${d}/${e}/transaction`,
205
220
  {
206
221
  method: "POST",
207
222
  body: JSON.stringify(a)
@@ -210,13 +225,13 @@ class q extends y {
210
225
  }
211
226
  // PATCH /session/{id}/cancel replies text/plain (the merchant's cancel URL),
212
227
  // not JSON. Cancelling cascades to the linked transaction, if any.
213
- async cancelSession(t) {
214
- return await this.requestText(`/${d}/${t}/cancel`, {
228
+ async cancelSession(e) {
229
+ return await this.requestText(`/${d}/${e}/cancel`, {
215
230
  method: "PATCH"
216
231
  });
217
232
  }
218
- async sendReceipt(t, a) {
219
- await this.request(`/${d}/${t}/receipt`, {
233
+ async sendReceipt(e, a) {
234
+ await this.request(`/${d}/${e}/receipt`, {
220
235
  method: "POST",
221
236
  body: JSON.stringify(a)
222
237
  });
@@ -224,9 +239,9 @@ class q extends y {
224
239
  }
225
240
  class D extends y {
226
241
  }
227
- M(D, [$, Y, B, q]);
228
- const G = D;
229
- var i = {
242
+ Y(D, [M, B, q, G]);
243
+ const H = D;
244
+ var s = {
230
245
  SINGLE_PAYMENT_REQUIRED: -11,
231
246
  API_CANCELLED: -9,
232
247
  PAYMENT_TIMEOUT: -8,
@@ -244,164 +259,164 @@ var i = {
244
259
  // one promotion — the OTP restore flow re-promotes the same session.
245
260
  KYC_VERIFICATION_PENDING: 3,
246
261
  COMPLIANCE_PENDING: 10
247
- }, H = {
262
+ }, K = {
248
263
  PARTIALLY_PAID: 1,
249
264
  OVERPAID: 3
250
- }, j = {
265
+ }, z = {
251
266
  PENDING: 0,
252
267
  CONFIRMED: 1
253
- }, g = {
268
+ }, w = {
254
269
  dev: "https://api.lydian.dev",
255
270
  sandbox: "https://api.sandbox.lydian.com",
256
271
  prod: "https://api.lydian.com"
257
272
  };
258
- function K(e) {
259
- return e.gatewayUrl ? new URL(e.gatewayUrl).origin : e.dev ? g.dev : e.sandbox ? g.sandbox : g.prod;
273
+ function j(t) {
274
+ return t.gatewayUrl ? new URL(t.gatewayUrl).origin : t.dev ? w.dev : t.sandbox ? w.sandbox : w.prod;
260
275
  }
261
276
  function S({
262
- options: e,
263
- unsupportedKeys: t,
277
+ options: t,
278
+ unsupportedKeys: e,
264
279
  entryPoint: a
265
280
  }) {
266
- const n = t.filter((o) => e[o] !== void 0);
281
+ const n = e.filter((o) => t[o] !== void 0);
267
282
  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.`;
268
283
  }
269
- function A(e) {
270
- var t;
271
- return (t = e.flow) != null && t.walletConnect && !e.walletConnectProjectId ? "walletConnectProjectId is required when flow.walletConnect is on" : null;
284
+ function A(t) {
285
+ var e;
286
+ return (e = t.flow) != null && e.walletConnect && !t.walletConnectProjectId ? "walletConnectProjectId is required when flow.walletConnect is on" : null;
272
287
  }
273
- function v(e) {
274
- return e.gatewayUrl === void 0 || z(e.gatewayUrl) ? null : `gatewayUrl must be an http(s) origin such as http://localhost:8000, with no path, got ${JSON.stringify(e.gatewayUrl)}`;
288
+ function v(t) {
289
+ return t.gatewayUrl === void 0 || J(t.gatewayUrl) ? null : `gatewayUrl must be an http(s) origin such as http://localhost:8000, with no path, got ${JSON.stringify(t.gatewayUrl)}`;
275
290
  }
276
- function z(e) {
277
- let t;
291
+ function J(t) {
292
+ let e;
278
293
  try {
279
- t = new URL(e);
294
+ e = new URL(t);
280
295
  } catch {
281
296
  return !1;
282
297
  }
283
- return (t.protocol === "http:" || t.protocol === "https:") && t.pathname === "/" && t.search === "" && t.hash === "";
298
+ return (e.protocol === "http:" || e.protocol === "https:") && e.pathname === "/" && e.search === "" && e.hash === "";
284
299
  }
285
- function pe(e) {
286
- return e !== null && !u(e) && !!e.publishableKey;
300
+ function he(t) {
301
+ return t !== null && !u(t) && !!t.publishableKey;
287
302
  }
288
- function he(e) {
289
- return e !== null && !u(e);
303
+ function me(t) {
304
+ return t !== null && !u(t);
290
305
  }
291
- function me({
292
- options: e,
293
- session: t,
306
+ function fe({
307
+ options: t,
308
+ session: e,
294
309
  settled: a
295
310
  }) {
296
- return !a && t !== null && e !== null && u(e);
311
+ return !a && e !== null && t !== null && u(t);
297
312
  }
298
- function I(e, t, a) {
313
+ function I(t, e, a) {
299
314
  try {
300
- e == null || e(t, a);
315
+ t == null || t(e, a);
301
316
  } catch (n) {
302
- console.error(`onEvent("${t}") threw:`, n);
317
+ console.error(`onEvent("${e}") threw:`, n);
303
318
  }
304
319
  }
305
- function m(e) {
306
- if (!e)
320
+ function m(t) {
321
+ if (!t)
307
322
  return;
308
- let t;
323
+ let e;
309
324
  try {
310
- t = new URL(e);
325
+ e = new URL(t);
311
326
  } catch {
312
327
  return;
313
328
  }
314
- return t.protocol === "https:" || t.protocol === "http:" ? e : void 0;
329
+ return e.protocol === "https:" || e.protocol === "http:" ? t : void 0;
315
330
  }
316
- const J = [
317
- i.KYC_VERIFICATION_PENDING,
318
- i.COMPLIANCE_PENDING
331
+ const Q = [
332
+ s.KYC_VERIFICATION_PENDING,
333
+ s.COMPLIANCE_PENDING
319
334
  ];
320
- async function Q({
321
- api: e,
322
- options: t,
335
+ async function X({
336
+ api: t,
337
+ options: e,
323
338
  emit: a
324
339
  }) {
325
340
  try {
326
- const n = await V({ api: e, options: t }), o = await e.getSession(n);
327
- a("session.loaded", Z(o));
328
- const r = await te({
329
- api: e,
341
+ const n = await Z({ api: t, options: e }), o = await t.getSession(n);
342
+ a("session.loaded", ee(o));
343
+ const r = await ae({
344
+ api: t,
330
345
  transactionID: o.transactionID
331
- }), s = ee({ session: o, linkedTransaction: r });
332
- return { ok: !0, session: o, sessionPromoted: s, linkedTransaction: r };
346
+ }), i = te({ session: o, linkedTransaction: r });
347
+ return { ok: !0, session: o, sessionPromoted: i, linkedTransaction: r };
333
348
  } catch (n) {
334
- return { ok: !1, ...await X(n) };
349
+ return { ok: !1, ...await V(n) };
335
350
  }
336
351
  }
337
- async function X(e) {
338
- const t = e instanceof Error ? e.cause : void 0;
339
- if (!(t instanceof Response && t.status === 404))
352
+ async function V(t) {
353
+ const e = t instanceof Error ? t.cause : void 0;
354
+ if (!(e instanceof Response && e.status === 404))
340
355
  return {};
341
356
  try {
342
- const n = await t.json();
357
+ const n = await e.json();
343
358
  return {
344
- failureURL: k(n == null ? void 0 : n.failureURL),
345
- cancelURL: k(n == null ? void 0 : n.cancelURL)
359
+ failureURL: P(n == null ? void 0 : n.failureURL),
360
+ cancelURL: P(n == null ? void 0 : n.cancelURL)
346
361
  };
347
362
  } catch {
348
363
  return {};
349
364
  }
350
365
  }
351
- function k(e) {
352
- return typeof e == "string" ? m(e) : void 0;
366
+ function P(t) {
367
+ return typeof t == "string" ? m(t) : void 0;
353
368
  }
354
- async function V({
355
- api: e,
356
- options: t
369
+ async function Z({
370
+ api: t,
371
+ options: e
357
372
  }) {
358
- return u(t) ? t.sessionID : (await e.createSession({
359
- amount: t.transaction.amount,
360
- amountCurrency: t.transaction.currency,
361
- descriptor: t.transaction.descriptor,
362
- referenceNumber: t.transaction.referenceNumber
373
+ return u(e) ? e.sessionID : (await t.createSession({
374
+ amount: e.transaction.amount,
375
+ amountCurrency: e.transaction.currency,
376
+ descriptor: e.transaction.descriptor,
377
+ referenceNumber: e.transaction.referenceNumber
363
378
  })).sessionID;
364
379
  }
365
- function Z(e) {
380
+ function ee(t) {
366
381
  return {
367
- sessionID: e.sessionID,
368
- merchantName: e.merchantName,
369
- alreadyPromoted: N(e)
382
+ sessionID: t.sessionID,
383
+ merchantName: t.merchantName,
384
+ alreadyPromoted: N(t)
370
385
  };
371
386
  }
372
- function N(e) {
373
- return !!e.transactionID;
387
+ function N(t) {
388
+ return !!t.transactionID;
374
389
  }
375
- function ee({
376
- session: e,
377
- linkedTransaction: t
390
+ function te({
391
+ session: t,
392
+ linkedTransaction: e
378
393
  }) {
379
- return N(e) ? t ? !J.includes(t.status) : !0 : !1;
394
+ return N(t) ? e ? !Q.includes(e.status) : !0 : !1;
380
395
  }
381
- async function te({
382
- api: e,
383
- transactionID: t
396
+ async function ae({
397
+ api: t,
398
+ transactionID: e
384
399
  }) {
385
- if (!t)
400
+ if (!e)
386
401
  return null;
387
402
  try {
388
- return await e.getCryptoTransaction(t);
403
+ return await t.getCryptoTransaction(e);
389
404
  } catch (a) {
390
405
  return console.error("Failed to resolve the session transaction:", a), null;
391
406
  }
392
407
  }
393
- function P({
394
- message: e,
395
- reason: t,
408
+ function C({
409
+ message: t,
410
+ reason: e,
396
411
  shouldEndCheckout: a,
397
412
  transactionID: n,
398
413
  session: o
399
414
  }) {
400
415
  return {
401
- event: { reason: t, shouldEndCheckout: a, message: e },
416
+ event: { reason: e, shouldEndCheckout: a, message: t },
402
417
  failure: {
403
418
  shouldEndCheckout: a,
404
- reason: t,
419
+ reason: e,
405
420
  transactionID: n,
406
421
  // Only a failure that ends the checkout carries a redirect. A retryable one
407
422
  // leaves the customer mid-flow with something still to do, and a host that
@@ -410,7 +425,7 @@ function P({
410
425
  }
411
426
  };
412
427
  }
413
- const ae = {
428
+ const ne = {
414
429
  "common.cancelTransaction": "Cancel Transaction",
415
430
  "common.cancel": "Cancel",
416
431
  "common.back": "Back",
@@ -507,7 +522,14 @@ const ae = {
507
522
  "kyc.cityOfBirthLabel": "City of birth",
508
523
  "kyc.cityOfBirthPlaceholder": "Enter city",
509
524
  "kyc.nationalIdLabel": "ID number",
510
- "kyc.nationalIdPlaceholder": "Enter 16-digit ID number",
525
+ "kyc.nationalIdPlaceholder": "Enter your {documentType} ID",
526
+ "kyc.idDocumentLabel": "ID type",
527
+ "kyc.idDocumentPlaceholder": "Select ID type",
528
+ "kyc.idDocumentPassport": "Passport",
529
+ "kyc.idDocumentSss": "SSS",
530
+ "kyc.idDocumentDriverLicense": "Drivers License",
531
+ "kyc.idDocumentTin": "TIN",
532
+ "kyc.idDocumentOther": "Other",
511
533
  "kyc.nationalIdChoice": "National ID number",
512
534
  "kyc.customerIdLabel": "Customer identification number",
513
535
  "kyc.customerIdPlaceholder": "Enter customer ID number",
@@ -660,47 +682,48 @@ const ae = {
660
682
  "validation.emailOrCountryMissing": "Email or country is missing.",
661
683
  "validation.invalidEmail": "Please enter a valid email address.",
662
684
  "validation.invalidDateOfBirth": "Please enter a valid date of birth.",
685
+ "validation.invalidIdNumber": "Please enter an ID number of {min} to {max} characters.",
663
686
  "validation.reenterFullAddress": "Enter your full new address.",
664
687
  "validation.customerDetailsMissing": "Customer details are missing.",
665
688
  "validation.invalidOtp": "Please enter a valid 6-digit code.",
666
689
  "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>.'
667
- }, T = { en: ae }, R = "en";
690
+ }, T = { en: ne }, R = "en";
668
691
  let L = R;
669
- function fe() {
692
+ function we() {
670
693
  return L;
671
694
  }
672
- function f(e, t) {
695
+ function f(t, e) {
673
696
  var n;
674
- const a = ((n = T[L]) == null ? void 0 : n[e]) ?? T[R][e] ?? e;
675
- return t ? a.replace(
697
+ const a = ((n = T[L]) == null ? void 0 : n[t]) ?? T[R][t] ?? t;
698
+ return e ? a.replace(
676
699
  /\{(\w+)\}/g,
677
- (o, r) => t[r] != null ? String(t[r]) : `{${r}}`
700
+ (o, r) => e[r] != null ? String(e[r]) : `{${r}}`
678
701
  ) : a;
679
702
  }
680
- const ne = /* @__PURE__ */ new Set([
681
- i.SINGLE_PAYMENT_REQUIRED,
682
- i.API_CANCELLED,
683
- i.PAYMENT_TIMEOUT,
684
- i.FRAUD_DECLINED,
685
- i.FRAUD_REFUNDED,
686
- i.FRAUD_HELD,
687
- i.FORFEITED,
688
- i.CANCELLED,
689
- i.FRAUD
703
+ const oe = /* @__PURE__ */ new Set([
704
+ s.SINGLE_PAYMENT_REQUIRED,
705
+ s.API_CANCELLED,
706
+ s.PAYMENT_TIMEOUT,
707
+ s.FRAUD_DECLINED,
708
+ s.FRAUD_REFUNDED,
709
+ s.FRAUD_HELD,
710
+ s.FORFEITED,
711
+ s.CANCELLED,
712
+ s.FRAUD
690
713
  ]);
691
- function oe(e) {
692
- return e === i.SUCCESS ? "succeeded" : ne.has(e) ? "failed" : "active";
714
+ function re(t) {
715
+ return t === s.SUCCESS ? "succeeded" : oe.has(t) ? "failed" : "active";
693
716
  }
694
- function re({
695
- transaction: e,
696
- session: t
717
+ function se({
718
+ transaction: t,
719
+ session: e
697
720
  }) {
698
- var o, r, s;
699
- const a = oe(e.status);
721
+ var o, r, i;
722
+ const a = re(t.status);
700
723
  if (a === "active")
701
724
  return null;
702
725
  if (a === "failed") {
703
- const p = e.status === i.PAYMENT_TIMEOUT && e.paymentStatus === H.PARTIALLY_PAID || e.status === i.SINGLE_PAYMENT_REQUIRED;
726
+ const p = t.status === s.PAYMENT_TIMEOUT && t.paymentStatus === K.PARTIALLY_PAID || t.status === s.SINGLE_PAYMENT_REQUIRED;
704
727
  return {
705
728
  outcome: a,
706
729
  message: f(p ? "errors.paymentShortRefundRequested" : "errors.paymentCouldNotComplete"),
@@ -708,54 +731,54 @@ function re({
708
731
  shouldEndCheckout: !0,
709
732
  // Negative (non-KYC) status — cancelled / fraud / timeout.
710
733
  reason: "blocked",
711
- transactionID: e.transactionID,
712
- redirectURL: m(t == null ? void 0 : t.failureURL)
734
+ transactionID: t.transactionID,
735
+ redirectURL: m(e == null ? void 0 : e.failureURL)
713
736
  }
714
737
  };
715
738
  }
716
- const n = (o = e.payments) == null ? void 0 : o.find(
717
- (c) => c.status === j.CONFIRMED
739
+ const n = (o = t.payments) == null ? void 0 : o.find(
740
+ (l) => l.status === z.CONFIRMED
718
741
  );
719
742
  return {
720
743
  outcome: a,
721
744
  event: {
722
- transactionID: e.transactionID,
745
+ transactionID: t.transactionID,
723
746
  asset: n == null ? void 0 : n.cryptoAsset,
724
747
  network: n == null ? void 0 : n.cryptoNetwork
725
748
  },
726
749
  result: {
727
- transactionID: e.transactionID,
728
- amount: (r = e.amounts) == null ? void 0 : r.totalLocal,
729
- currency: (s = e.amounts) == null ? void 0 : s.currency,
750
+ transactionID: t.transactionID,
751
+ amount: (r = t.amounts) == null ? void 0 : r.totalLocal,
752
+ currency: (i = t.amounts) == null ? void 0 : i.currency,
730
753
  asset: n == null ? void 0 : n.cryptoAsset,
731
754
  network: n == null ? void 0 : n.cryptoNetwork,
732
755
  completedAt: n == null ? void 0 : n.completedAt,
733
- redirectURL: m(t == null ? void 0 : t.successURL)
756
+ redirectURL: m(e == null ? void 0 : e.successURL)
734
757
  }
735
758
  };
736
759
  }
737
- function se() {
738
- let e = null;
760
+ function ie() {
761
+ let t = null;
739
762
  return {
740
- setOptions: (t) => {
741
- e = t;
763
+ setOptions: (e) => {
764
+ t = e;
742
765
  },
743
- emit: (t, a) => I(e == null ? void 0 : e.onEvent, t, a),
744
- paymentFailed: (t, a) => {
766
+ emit: (e, a) => I(t == null ? void 0 : t.onEvent, e, a),
767
+ paymentFailed: (e, a) => {
745
768
  var n;
746
- return (n = e == null ? void 0 : e.paymentFailedListener) == null ? void 0 : n.call(e, t, a);
769
+ return (n = t == null ? void 0 : t.paymentFailedListener) == null ? void 0 : n.call(t, e, a);
747
770
  },
748
- paymentSucceeded: (t) => {
771
+ paymentSucceeded: (e) => {
749
772
  var a;
750
- return (a = e == null ? void 0 : e.paymentSuccessListener) == null ? void 0 : a.call(e, t);
773
+ return (a = t == null ? void 0 : t.paymentSuccessListener) == null ? void 0 : a.call(t, e);
751
774
  },
752
- paymentCanceled: (t) => {
775
+ paymentCanceled: (e) => {
753
776
  var a;
754
- return (a = e == null ? void 0 : e.paymentCanceledListener) == null ? void 0 : a.call(e, t);
777
+ return (a = t == null ? void 0 : t.paymentCanceledListener) == null ? void 0 : a.call(t, e);
755
778
  }
756
779
  };
757
780
  }
758
- class ie extends HTMLElement {
781
+ class ce extends HTMLElement {
759
782
  constructor() {
760
783
  super(), this.engine = null, this.engineLoadPromise = null, this.isTornDown = !1, this.shadow = this.attachShadow({ mode: "open" });
761
784
  }
@@ -764,26 +787,26 @@ class ie extends HTMLElement {
764
787
  connectedCallback() {
765
788
  this.isTornDown = !1;
766
789
  }
767
- async initialize(t) {
768
- const a = ce(t), n = le({ api: a, options: t }), o = await this.loadEngine(t, n);
769
- !o || this.isTornDown || (this.engine = o, await o.initialize(t, { api: a, sessionLoad: n }));
790
+ async initialize(e) {
791
+ const a = le(e), n = de({ api: a, options: e }), o = await this.loadEngine(e, n);
792
+ !o || this.isTornDown || (this.engine = o, await o.initialize(e, { api: a, sessionLoad: n }));
770
793
  }
771
- async loadEngine(t, a) {
794
+ async loadEngine(e, a) {
772
795
  const n = this.getOrLoadEngine();
773
796
  try {
774
797
  return await n;
775
798
  } catch {
776
799
  return await this.handleEngineLoadFailure({
777
800
  engineLoad: n,
778
- options: t,
801
+ options: e,
779
802
  sessionLoad: a
780
803
  }), null;
781
804
  }
782
805
  }
783
- async updateTransaction(t) {
806
+ async updateTransaction(e) {
784
807
  if (!this.engine)
785
808
  throw new Error("Tether Pay not initialized.");
786
- await this.engine.updateTransaction(t);
809
+ await this.engine.updateTransaction(e);
787
810
  }
788
811
  // A merchant SPA can unmount the element at any time; nothing else stops this
789
812
  // instance's timers.
@@ -793,8 +816,8 @@ class ie extends HTMLElement {
793
816
  // Not started in the constructor: a page can carry the tag and never check out.
794
817
  // Overlapping initialize() calls share one download.
795
818
  getOrLoadEngine() {
796
- return this.engineLoadPromise ?? (this.engineLoadPromise = import("./mountEngine-_G66fuAB.js").then((t) => t.m).then((t) => {
797
- const a = t.mountCheckoutEngine({
819
+ return this.engineLoadPromise ?? (this.engineLoadPromise = import("./mountEngine-DVTbWmeA.js").then((e) => e.m).then((e) => {
820
+ const a = e.mountCheckoutEngine({
798
821
  host: this,
799
822
  shadowRoot: this.shadow
800
823
  });
@@ -802,11 +825,11 @@ class ie extends HTMLElement {
802
825
  })), this.engineLoadPromise;
803
826
  }
804
827
  async handleEngineLoadFailure({
805
- engineLoad: t,
828
+ engineLoad: e,
806
829
  options: a,
807
830
  sessionLoad: n
808
831
  }) {
809
- this.engineLoadPromise === t && (this.engineLoadPromise = null, await this.reportEngineFailure({ options: a, sessionLoad: n }));
832
+ this.engineLoadPromise === e && (this.engineLoadPromise = null, await this.reportEngineFailure({ options: a, sessionLoad: n }));
810
833
  }
811
834
  // A host that removed the element has walked away; a failure report could send
812
835
  // it to a failureURL for a checkout it dismissed.
@@ -818,7 +841,7 @@ class ie extends HTMLElement {
818
841
  // an outcome the gateway has already decided — a session resumed after the
819
842
  // payment settled must report that payment, not a dead checkout.
820
843
  async reportEngineFailure({
821
- options: t,
844
+ options: e,
822
845
  sessionLoad: a
823
846
  }) {
824
847
  if (this.isDismissedByHost)
@@ -826,9 +849,9 @@ class ie extends HTMLElement {
826
849
  const n = await a;
827
850
  if (this.isDismissedByHost)
828
851
  return;
829
- const o = se();
830
- o.setOptions(t);
831
- const r = n.ok && n.linkedTransaction ? re({
852
+ const o = ie();
853
+ o.setOptions(e);
854
+ const r = n.ok && n.linkedTransaction ? se({
832
855
  transaction: n.linkedTransaction,
833
856
  session: n.session
834
857
  }) : null;
@@ -849,112 +872,112 @@ class ie extends HTMLElement {
849
872
  return;
850
873
  }
851
874
  if (!n.ok && n.failureURL) {
852
- const p = f("errors.unableToCreateSession"), C = P({
875
+ const p = f("errors.unableToCreateSession"), b = C({
853
876
  message: p,
854
877
  reason: "sessionExpired",
855
878
  shouldEndCheckout: !0,
856
879
  session: { failureURL: n.failureURL }
857
880
  });
858
- o.emit("payment.failed", C.event), o.paymentFailed(p, C.failure);
881
+ o.emit("payment.failed", b.event), o.paymentFailed(p, b.failure);
859
882
  return;
860
883
  }
861
- const s = f("errors.checkoutUnavailable"), c = P({
862
- message: s,
884
+ const i = f("errors.checkoutUnavailable"), l = C({
885
+ message: i,
863
886
  reason: "error",
864
887
  shouldEndCheckout: !0,
865
888
  session: n.ok ? n.session : null
866
889
  });
867
- o.emit("payment.failed", c.event), o.paymentFailed(s, c.failure);
890
+ o.emit("payment.failed", l.event), o.paymentFailed(i, l.failure);
868
891
  }
869
892
  // Always teardown and unmount together to avoid leaking the React engine.
870
893
  // Clear the cached load so a later initialize() creates a fresh engine.
871
- releaseEngine(t = this.engine) {
872
- t == null || t.teardown(), t == null || t.unmount(), this.engine = null, this.engineLoadPromise = null;
894
+ releaseEngine(e = this.engine) {
895
+ e == null || e.teardown(), e == null || e.unmount(), this.engine = null, this.engineLoadPromise = null;
873
896
  }
874
897
  }
875
- function ce(e) {
876
- return new G(
877
- K(e),
878
- u(e) ? void 0 : e.publishableKey
898
+ function le(t) {
899
+ return new H(
900
+ j(t),
901
+ u(t) ? void 0 : t.publishableKey
879
902
  );
880
903
  }
881
- function le({
882
- api: e,
883
- options: t
904
+ function de({
905
+ api: t,
906
+ options: e
884
907
  }) {
885
- return Q({
886
- api: e,
887
- options: t,
888
- emit: (a, n) => I(t.onEvent, a, n)
908
+ return X({
909
+ api: t,
910
+ options: e,
911
+ emit: (a, n) => I(e.onEvent, a, n)
889
912
  });
890
913
  }
891
- customElements.get("lydian-checkout") || customElements.define("lydian-checkout", ie);
892
- function b() {
914
+ customElements.get("lydian-checkout") || customElements.define("lydian-checkout", ce);
915
+ function g() {
893
916
  return document.querySelector("lydian-checkout");
894
917
  }
895
- async function de(e) {
896
- if (!e.publishableKey || !e.transaction.amount || !e.transaction.currency)
918
+ async function ue(t) {
919
+ if (!t.publishableKey || !t.transaction.amount || !t.transaction.currency)
897
920
  throw new Error("SDK initialization requires publishableKey and a transaction");
898
- const t = A(e);
899
- if (t)
900
- throw new Error(t);
901
- const a = v(e);
921
+ const e = A(t);
922
+ if (e)
923
+ throw new Error(e);
924
+ const a = v(t);
902
925
  if (a)
903
926
  throw new Error(a);
904
- if (!U(e.transaction.currency))
927
+ if (!U(t.transaction.currency))
905
928
  throw new Error("Invalid value for currency, valid values are: " + E.join(", "));
906
929
  const n = S({
907
- options: e,
930
+ options: t,
908
931
  unsupportedKeys: ["sessionID"],
909
932
  entryPoint: "init"
910
933
  });
911
934
  if (n)
912
935
  throw new Error(n);
913
- await b().initialize(e);
936
+ await g().initialize(t);
914
937
  }
915
- async function ue(e) {
916
- if (!e.sessionID)
938
+ async function ye(t) {
939
+ if (!t.sessionID)
917
940
  throw new Error("initExistingSession requires a sessionID");
918
- const t = A(e);
919
- if (t)
920
- throw new Error(t);
921
- const a = v(e);
941
+ const e = A(t);
942
+ if (e)
943
+ throw new Error(e);
944
+ const a = v(t);
922
945
  if (a)
923
946
  throw new Error(a);
924
947
  const n = S({
925
- options: e,
948
+ options: t,
926
949
  unsupportedKeys: ["publishableKey", "transaction"],
927
950
  entryPoint: "initExistingSession"
928
951
  });
929
952
  if (n)
930
953
  throw new Error(n);
931
- await b().initialize(e);
954
+ await g().initialize(t);
932
955
  }
933
- async function ye(e) {
934
- await b().updateTransaction(e);
956
+ async function pe(t) {
957
+ await g().updateTransaction(t);
935
958
  }
936
- window.Lydian = { init: de, initExistingSession: ue, updateTransaction: ye };
959
+ window.Lydian = { init: ue, initExistingSession: ye, updateTransaction: pe };
937
960
  export {
938
961
  O as G,
939
- H as P,
940
- i as T,
941
- j as a,
942
- he as b,
962
+ K as P,
963
+ s as T,
964
+ z as a,
965
+ me as b,
943
966
  E as c,
944
- Z as d,
945
- ee as e,
946
- te as f,
947
- fe as g,
967
+ ee as d,
968
+ te as e,
969
+ ae as f,
970
+ we as g,
948
971
  u as h,
949
972
  U as i,
950
- oe as j,
951
- re as k,
973
+ re as j,
974
+ se as k,
952
975
  N as l,
953
- me as m,
954
- P as n,
955
- pe as o,
956
- se as p,
957
- V as r,
976
+ fe as m,
977
+ C as n,
978
+ he as o,
979
+ ie as p,
980
+ Z as r,
958
981
  m as s,
959
982
  f as t
960
983
  };