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