@lydianpay/sdk-web 3.15.4 → 3.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/dist/chunks/{browser-DNsXaImz.js → browser-CvvbM3fl.js} +1 -1
  2. package/dist/chunks/{connect-multichain-Ca3bMak3.js → connect-multichain-JrYKtq5o.js} +9 -9
  3. package/dist/chunks/{index-CcN4gJw2.js → index-Bwl_cWLK.js} +1 -1
  4. package/dist/chunks/{index-VdHF6yby.js → index-CD8P_mOo.js} +2 -2
  5. package/dist/chunks/{index-CcZ7kGqa.js → index-DAsQ6TuK.js} +1 -1
  6. package/dist/chunks/{index-9_6otDrw.js → index-DFLPr81C.js} +3 -3
  7. package/dist/chunks/{index-CwJ0YzMA.js → index-DGLVpgOJ.js} +2 -2
  8. package/dist/chunks/{index-ItSygWuh.js → index-GdvVEXe8.js} +318 -247
  9. package/dist/chunks/{mountEngine-B721ZzjQ.js → mountEngine-B9qRQyLg.js} +11153 -10944
  10. package/dist/lydian.js +1 -1
  11. package/dist/types/.tsbuildinfo +1 -1
  12. package/dist/types/network/gatewayRequestError.d.ts +9 -0
  13. package/dist/types/network/session/index.d.ts +2 -1
  14. package/dist/types/types.d.ts +6 -0
  15. package/dist/types/ui/failureReport.d.ts +3 -1
  16. package/dist/types/ui/flowConfig.d.ts +1 -0
  17. package/dist/types/ui/react/AlertBanner.d.ts +1 -1
  18. package/dist/types/ui/react/CheckboxField.d.ts +8 -0
  19. package/dist/types/ui/react/EmailReceiptCard/EmailReceiptCard.d.ts +4 -0
  20. package/dist/types/ui/react/EmailReceiptCard/EmailReceiptForm.d.ts +7 -0
  21. package/dist/types/ui/react/EmailReceiptCard/emailReceiptHelpers.d.ts +7 -0
  22. package/dist/types/ui/react/EmailReceiptCard/useEmailReceiptSender.d.ts +7 -0
  23. package/dist/types/ui/react/FormField.d.ts +2 -1
  24. package/dist/types/ui/react/checkoutStore.d.ts +2 -1
  25. package/dist/types/ui/sessionBootstrap.d.ts +5 -1
  26. package/package.json +1 -1
@@ -1,91 +1,112 @@
1
- const g = ["USD", "TRY", "PHP"];
2
- function S(t) {
3
- return typeof t == "string" && g.includes(t);
1
+ const v = ["USD", "TRY", "PHP"];
2
+ function U(e) {
3
+ return typeof e == "string" && v.includes(e);
4
+ }
5
+ function d(e) {
6
+ return "sessionID" in e && typeof e.sessionID == "string" && e.sessionID.length > 0;
7
+ }
8
+ class O extends Error {
9
+ constructor({
10
+ statusText: t,
11
+ errorCode: a,
12
+ response: n
13
+ }) {
14
+ super(t, { cause: n }), this.name = "GatewayRequestError", this.errorCode = a;
15
+ }
16
+ }
17
+ async function m(e) {
18
+ const t = await e.clone().json().catch(() => null);
19
+ return new O({
20
+ statusText: e.statusText,
21
+ errorCode: F(t),
22
+ response: e
23
+ });
4
24
  }
5
- function c(t) {
6
- return "sessionID" in t && typeof t.sessionID == "string" && t.sessionID.length > 0;
25
+ function F(e) {
26
+ if (!(typeof e != "object" || e === null || !("errorCode" in e)))
27
+ return typeof e.errorCode == "number" ? e.errorCode : void 0;
7
28
  }
8
- class y {
29
+ class p {
9
30
  // Optional: a caller-supplied session has no key and needs none (see Sessions).
10
31
  // The key is still required when the SDK creates the session, enforced in
11
32
  // index.ts where that is known.
12
- constructor(e, a) {
13
- if (this.baseUri = e, this.publishableKey = a, !this.baseUri)
33
+ constructor(t, a) {
34
+ if (this.baseUri = t, this.publishableKey = a, !this.baseUri)
14
35
  throw new Error("baseUri is required");
15
36
  }
16
37
  // Omitted rather than blank when there is no key: the gateway checks the pk_
17
38
  // prefix first, so an empty header is a 400 where an absent one is anonymous.
18
- headers(e) {
19
- const a = { ...e };
39
+ headers(t) {
40
+ const a = { ...t };
20
41
  return this.publishableKey && (a["X-Publishable-Key"] = this.publishableKey), a;
21
42
  }
22
- async request(e, a) {
23
- const n = `${this.baseUri}${e}`, o = this.headers({ "Content-Type": "application/json" }), r = Object.assign({}, a, { headers: o }), s = await fetch(n, r);
43
+ async request(t, a) {
44
+ const n = `${this.baseUri}${t}`, o = this.headers({ "Content-Type": "application/json" }), r = Object.assign({}, a, { headers: o }), s = await fetch(n, r);
24
45
  if (s.ok)
25
46
  return await s.json();
26
- throw new Error(s.statusText);
47
+ throw await m(s);
27
48
  }
28
49
  // For endpoints that reply text/plain rather than JSON (e.g. PATCH
29
50
  // /customer/otp -> "OTP sent"). Sends the same JSON request headers but does
30
51
  // not call response.json(), which would throw on a non-JSON body.
31
- async requestText(e, a) {
32
- const n = `${this.baseUri}${e}`, o = this.headers({ "Content-Type": "application/json" }), r = Object.assign({}, a, { headers: o }), s = await fetch(n, r);
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);
33
54
  if (s.ok)
34
55
  return await s.text();
35
- throw new Error(s.statusText);
56
+ throw await m(s);
36
57
  }
37
- async requestWithFormData(e, a) {
38
- const n = `${this.baseUri}${e}`, o = this.headers(), r = Object.assign({}, a, { headers: o }), s = await fetch(n, r);
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);
39
60
  if (s.ok)
40
61
  return await s.json();
41
- throw new Error(s.statusText);
62
+ throw await m(s);
42
63
  }
43
64
  }
44
- const l = "transaction";
45
- class A extends y {
46
- async getCryptoTransaction(e) {
47
- return await this.request(`/${l}/${e}`);
65
+ const c = "transaction";
66
+ class W extends p {
67
+ async getCryptoTransaction(t) {
68
+ return await this.request(`/${c}/${t}`);
48
69
  }
49
- async createPaymentRequest(e, a) {
70
+ async createPaymentRequest(t, a) {
50
71
  return await this.request(
51
- `/${l}/${e}/payment`,
72
+ `/${c}/${t}/payment`,
52
73
  {
53
74
  method: "POST",
54
75
  body: JSON.stringify(a)
55
76
  }
56
77
  );
57
78
  }
58
- async buildTransfer(e, a, n) {
79
+ async buildTransfer(t, a, n) {
59
80
  return await this.request(
60
- `/${l}/${e}/payment/${a}/transfer`,
81
+ `/${c}/${t}/payment/${a}/transfer`,
61
82
  {
62
83
  method: "POST",
63
84
  body: JSON.stringify(n)
64
85
  }
65
86
  );
66
87
  }
67
- async broadcastTransfer(e, a, n) {
88
+ async broadcastTransfer(t, a, n) {
68
89
  return await this.request(
69
- `/${l}/${e}/payment/${a}/transfer/broadcast`,
90
+ `/${c}/${t}/payment/${a}/transfer/broadcast`,
70
91
  {
71
92
  method: "POST",
72
93
  body: JSON.stringify(n)
73
94
  }
74
95
  );
75
96
  }
76
- async cancelCryptoTransaction(e, a) {
97
+ async cancelCryptoTransaction(t, a) {
77
98
  return await this.request(
78
- `/${l}/${e}/cancel`,
99
+ `/${c}/${t}/cancel`,
79
100
  {
80
101
  method: "PATCH",
81
102
  body: JSON.stringify(a)
82
103
  }
83
104
  );
84
105
  }
85
- async kycVerification(e, a) {
106
+ async kycVerification(t, a) {
86
107
  const n = new FormData();
87
108
  return n.append("asset", a.asset), n.append("network", a.network), n.append("firstName", a.firstName), n.append("lastName", a.lastName), n.append("email", a.email), n.append("street", a.street), n.append("city", a.city), n.append("region", a.region), n.append("postalCode", a.postalCode), n.append("country", a.country), 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((o) => n.append("documentFiles", o)), await this.requestWithFormData(
88
- `/${l}/${e}/verification`,
109
+ `/${c}/${t}/verification`,
89
110
  {
90
111
  method: "POST",
91
112
  body: n
@@ -93,48 +114,48 @@ class A extends y {
93
114
  );
94
115
  }
95
116
  }
96
- function I(t, e) {
97
- e.forEach((a) => {
117
+ function $(e, t) {
118
+ t.forEach((a) => {
98
119
  Object.getOwnPropertyNames(a.prototype).forEach((n) => {
99
120
  const o = Object.getOwnPropertyDescriptor(a.prototype, n);
100
- o && Object.defineProperty(t.prototype, n, o);
121
+ o && Object.defineProperty(e.prototype, n, o);
101
122
  });
102
123
  });
103
124
  }
104
- const w = "customer/otp";
105
- class L extends y {
125
+ const C = "customer/otp";
126
+ class x extends p {
106
127
  // PATCH /customer/otp -> text/plain "OTP sent" (no JSON body).
107
- async sendCustomerOTP(e) {
108
- return await this.requestText(`/${w}`, {
128
+ async sendCustomerOTP(t) {
129
+ return await this.requestText(`/${C}`, {
109
130
  method: "PATCH",
110
- body: JSON.stringify(e)
131
+ body: JSON.stringify(t)
111
132
  });
112
133
  }
113
134
  // PUT /customer/otp -> { customerUUID, kycValidated }.
114
- async authenticateCustomerOTP(e) {
115
- return await this.request(`/${w}`, {
135
+ async authenticateCustomerOTP(t) {
136
+ return await this.request(`/${C}`, {
116
137
  method: "PUT",
117
- body: JSON.stringify(e)
138
+ body: JSON.stringify(t)
118
139
  });
119
140
  }
120
141
  }
121
- const d = "session";
122
- class U extends y {
123
- async createSession(e) {
124
- return await this.request(`/${d}`, {
142
+ const l = "session";
143
+ class M extends p {
144
+ async createSession(t) {
145
+ return await this.request(`/${l}`, {
125
146
  method: "POST",
126
- body: JSON.stringify(e)
147
+ body: JSON.stringify(t)
127
148
  });
128
149
  }
129
- async getSession(e) {
130
- return await this.request(`/${d}/${e}`);
150
+ async getSession(t) {
151
+ return await this.request(`/${l}/${t}`);
131
152
  }
132
153
  // Promotes the session into a transaction. Allowed once per session — except
133
154
  // that a KYC-pending (-3) response does not consume the promotion, which is
134
155
  // what lets the restore-details flow re-promote with a customerUUID.
135
- async createSessionTransaction(e, a) {
156
+ async createSessionTransaction(t, a) {
136
157
  return await this.request(
137
- `/${d}/${e}/transaction`,
158
+ `/${l}/${t}/transaction`,
138
159
  {
139
160
  method: "POST",
140
161
  body: JSON.stringify(a)
@@ -143,16 +164,22 @@ class U extends y {
143
164
  }
144
165
  // PATCH /session/{id}/cancel replies text/plain (the merchant's cancel URL),
145
166
  // not JSON. Cancelling cascades to the linked transaction, if any.
146
- async cancelSession(e) {
147
- return await this.requestText(`/${d}/${e}/cancel`, {
167
+ async cancelSession(t) {
168
+ return await this.requestText(`/${l}/${t}/cancel`, {
148
169
  method: "PATCH"
149
170
  });
150
171
  }
172
+ async sendReceipt(t, a) {
173
+ await this.request(`/${l}/${t}/receipt`, {
174
+ method: "POST",
175
+ body: JSON.stringify(a)
176
+ });
177
+ }
151
178
  }
152
- class b extends y {
179
+ class E extends p {
153
180
  }
154
- I(b, [A, L, U]);
155
- const R = b;
181
+ $(E, [W, x, M]);
182
+ const Y = E;
156
183
  var u = {
157
184
  COMPLIANCE_PENDING: -10,
158
185
  API_CANCELLED: -9,
@@ -170,153 +197,170 @@ var u = {
170
197
  FRAUD: -1,
171
198
  PENDING: 0,
172
199
  SUCCESS: 1
173
- }, V = {
200
+ }, se = {
174
201
  PARTIALLY_PAID: 1,
175
202
  OVERPAID: 3
176
- }, O = {
203
+ }, B = {
177
204
  PENDING: 0,
178
205
  CONFIRMED: 1
179
- }, p = {
206
+ }, h = {
180
207
  dev: "https://api.lydian.dev",
181
208
  sandbox: "https://api.sandbox.lydian.com",
182
209
  prod: "https://api.lydian.com"
183
210
  };
184
- function F(t) {
185
- return t.gatewayUrl ? new URL(t.gatewayUrl).origin : t.dev ? p.dev : t.sandbox ? p.sandbox : p.prod;
211
+ function G(e) {
212
+ return e.gatewayUrl ? new URL(e.gatewayUrl).origin : e.dev ? h.dev : e.sandbox ? h.sandbox : h.prod;
186
213
  }
187
- function P({
188
- options: t,
189
- unsupportedKeys: e,
214
+ function S({
215
+ options: e,
216
+ unsupportedKeys: t,
190
217
  entryPoint: a
191
218
  }) {
192
- const n = e.filter((o) => t[o] !== void 0);
219
+ const n = t.filter((o) => e[o] !== void 0);
193
220
  return n.length === 0 ? null : `${n.join(" and ")} ${n.length > 1 ? "are" : "is"} not used by ${a}. Passing it has no effect, so this is almost always a mistake.`;
194
221
  }
195
- function C(t) {
196
- var e;
197
- return (e = t.flow) != null && e.walletConnect && !t.walletConnectProjectId ? "walletConnectProjectId is required when flow.walletConnect is on" : null;
222
+ function D(e) {
223
+ var t;
224
+ return (t = e.flow) != null && t.walletConnect && !e.walletConnectProjectId ? "walletConnectProjectId is required when flow.walletConnect is on" : null;
198
225
  }
199
- function k(t) {
200
- return t.gatewayUrl === void 0 || W(t.gatewayUrl) ? null : `gatewayUrl must be an http(s) origin such as http://localhost:8000, with no path, got ${JSON.stringify(t.gatewayUrl)}`;
226
+ function N(e) {
227
+ return e.gatewayUrl === void 0 || q(e.gatewayUrl) ? null : `gatewayUrl must be an http(s) origin such as http://localhost:8000, with no path, got ${JSON.stringify(e.gatewayUrl)}`;
201
228
  }
202
- function W(t) {
203
- let e;
229
+ function q(e) {
230
+ let t;
204
231
  try {
205
- e = new URL(t);
232
+ t = new URL(e);
206
233
  } catch {
207
234
  return !1;
208
235
  }
209
- return (e.protocol === "http:" || e.protocol === "https:") && e.pathname === "/" && e.search === "" && e.hash === "";
236
+ return (t.protocol === "http:" || t.protocol === "https:") && t.pathname === "/" && t.search === "" && t.hash === "";
210
237
  }
211
- function ee(t) {
212
- return t !== null && !c(t) && !!t.publishableKey;
238
+ function ie(e) {
239
+ return e !== null && !d(e) && !!e.publishableKey;
213
240
  }
214
- function te(t) {
215
- return t !== null && !c(t);
241
+ function ce(e) {
242
+ return e !== null && !d(e);
216
243
  }
217
- function ae({
218
- options: t,
219
- session: e,
244
+ function le({
245
+ options: e,
246
+ session: t,
220
247
  settled: a
221
248
  }) {
222
- return !a && e !== null && t !== null && c(t);
249
+ return !a && t !== null && e !== null && d(e);
223
250
  }
224
- function T(t, e, a) {
251
+ function A(e, t, a) {
225
252
  try {
226
- t == null || t(e, a);
253
+ e == null || e(t, a);
227
254
  } catch (n) {
228
- console.error(`onEvent("${e}") threw:`, n);
255
+ console.error(`onEvent("${t}") threw:`, n);
229
256
  }
230
257
  }
231
- async function $({
232
- api: t,
233
- options: e,
258
+ function y(e) {
259
+ if (!e)
260
+ return;
261
+ let t;
262
+ try {
263
+ t = new URL(e);
264
+ } catch {
265
+ return;
266
+ }
267
+ return t.protocol === "https:" || t.protocol === "http:" ? e : void 0;
268
+ }
269
+ async function _({
270
+ api: e,
271
+ options: t,
234
272
  emit: a
235
273
  }) {
236
274
  try {
237
- const n = await x({ api: t, options: e }), { session: o, sessionPromoted: r } = await M({ api: t, sessionID: n });
238
- a("session.loaded", Y(o));
239
- const s = await B({
240
- api: t,
275
+ const n = await H({ api: e, options: t }), { session: o, sessionPromoted: r } = await K({ api: e, sessionID: n });
276
+ a("session.loaded", z(o));
277
+ const s = await J({
278
+ api: e,
241
279
  transactionID: o.transactionID
242
280
  });
243
281
  return { ok: !0, session: o, sessionPromoted: r, linkedTransaction: s };
282
+ } catch (n) {
283
+ return { ok: !1, ...await j(n) };
284
+ }
285
+ }
286
+ async function j(e) {
287
+ const t = e instanceof Error ? e.cause : void 0;
288
+ if (!(t instanceof Response && t.status === 404))
289
+ return {};
290
+ try {
291
+ const n = await t.json();
292
+ return {
293
+ failureURL: P(n == null ? void 0 : n.failureURL),
294
+ cancelURL: P(n == null ? void 0 : n.cancelURL)
295
+ };
244
296
  } catch {
245
- return { ok: !1 };
297
+ return {};
246
298
  }
247
299
  }
248
- async function x({
249
- api: t,
250
- options: e
300
+ function P(e) {
301
+ return typeof e == "string" ? y(e) : void 0;
302
+ }
303
+ async function H({
304
+ api: e,
305
+ options: t
251
306
  }) {
252
- return c(e) ? e.sessionID : (await t.createSession({
253
- amount: e.transaction.amount,
254
- amountCurrency: e.transaction.currency,
255
- descriptor: e.transaction.descriptor,
256
- referenceNumber: e.transaction.referenceNumber
307
+ return d(t) ? t.sessionID : (await e.createSession({
308
+ amount: t.transaction.amount,
309
+ amountCurrency: t.transaction.currency,
310
+ descriptor: t.transaction.descriptor,
311
+ referenceNumber: t.transaction.referenceNumber
257
312
  })).sessionID;
258
313
  }
259
- async function M({
260
- api: t,
261
- sessionID: e
314
+ async function K({
315
+ api: e,
316
+ sessionID: t
262
317
  }) {
263
- const a = await t.getSession(e);
264
- return { session: a, sessionPromoted: E(a) };
318
+ const a = await e.getSession(t);
319
+ return { session: a, sessionPromoted: I(a) };
265
320
  }
266
- function Y(t) {
321
+ function z(e) {
267
322
  return {
268
- sessionID: t.sessionID,
269
- merchantName: t.merchantName,
270
- alreadyPromoted: E(t)
323
+ sessionID: e.sessionID,
324
+ merchantName: e.merchantName,
325
+ alreadyPromoted: I(e)
271
326
  };
272
327
  }
273
- function E(t) {
274
- return !!t.transactionID;
328
+ function I(e) {
329
+ return !!e.transactionID;
275
330
  }
276
- async function B({
277
- api: t,
278
- transactionID: e
331
+ async function J({
332
+ api: e,
333
+ transactionID: t
279
334
  }) {
280
- if (!e)
335
+ if (!t)
281
336
  return null;
282
337
  try {
283
- return await t.getCryptoTransaction(e);
338
+ return await e.getCryptoTransaction(t);
284
339
  } catch (a) {
285
340
  return console.error("Failed to resolve the session transaction:", a), null;
286
341
  }
287
342
  }
288
- function h(t) {
289
- if (!t)
290
- return;
291
- let e;
292
- try {
293
- e = new URL(t);
294
- } catch {
295
- return;
296
- }
297
- return e.protocol === "https:" || e.protocol === "http:" ? t : void 0;
298
- }
299
- function _({
300
- message: t,
301
- reason: e,
343
+ function k({
344
+ message: e,
345
+ reason: t,
302
346
  shouldEndCheckout: a,
303
347
  transactionID: n,
304
348
  session: o
305
349
  }) {
306
350
  return {
307
- event: { reason: e, shouldEndCheckout: a, message: t },
351
+ event: { reason: t, shouldEndCheckout: a, message: e },
308
352
  failure: {
309
353
  shouldEndCheckout: a,
310
- reason: e,
354
+ reason: t,
311
355
  transactionID: n,
312
356
  // Only a failure that ends the checkout carries a redirect. A retryable one
313
357
  // leaves the customer mid-flow with something still to do, and a host that
314
358
  // navigated on it would eject them on a hiccup.
315
- redirectURL: a ? h(o == null ? void 0 : o.failureURL) : void 0
359
+ redirectURL: a ? y(o == null ? void 0 : o.failureURL) : void 0
316
360
  }
317
361
  };
318
362
  }
319
- const q = {
363
+ const Q = {
320
364
  "common.cancelTransaction": "Cancel Transaction",
321
365
  "common.cancel": "Cancel",
322
366
  "common.back": "Back",
@@ -464,10 +508,22 @@ const q = {
464
508
  "success.totalAmountPaid": "Total amount paid",
465
509
  "success.cryptoMethod": "Crypto – {asset} on {network}",
466
510
  "success.cryptoMethodWallet": "Crypto – {wallet}",
511
+ "success.cryptoMethodInParts": "Crypto – paid in {count} parts",
512
+ "success.paymentPart": "Part {part}",
513
+ "success.paymentPartAmount": "{amount} on {network}",
467
514
  "success.getAppHeading": "GET THE APP",
468
515
  "success.getAppBody": "Want a simpler checkout experience? Try the <strong>Lydian Wallet</strong> next time.",
469
516
  "success.downloadFromAppStore": "Download from the App Store",
470
517
  "success.downloadFromGooglePlay": "Get it on Google Play",
518
+ "receipt.title": "Email Receipt",
519
+ "receipt.subtitle": "Get a copy of these payment details by email.",
520
+ "receipt.marketingConsent": "I’d like to receive promotional updates, offers, and announcements from Lydian.",
521
+ "receipt.send": "Send Receipt",
522
+ "receipt.sending": "Sending...",
523
+ "receipt.sent": "Your receipt is on its way. Contact support if you need another copy.",
524
+ "receipt.sendFailed": "We couldn't send your receipt. Please try again.",
525
+ "receipt.unavailable": "Email receipts aren't available for this payment.",
526
+ "receipt.alreadySent": "A receipt has already been sent for this payment. Contact support if you need another copy.",
471
527
  "failure.title": "We couldn't complete your payment",
472
528
  "failure.paymentId": "Payment ID",
473
529
  "failure.copyPaymentId": "Copy payment ID",
@@ -539,85 +595,85 @@ const q = {
539
595
  "validation.customerDetailsMissing": "Customer details are missing.",
540
596
  "validation.invalidOtp": "Please enter a valid 6-digit code.",
541
597
  "terms.notice": 'By continuing, you agree to Lydian <a href="https://lydian.com/privacy" target="_blank" rel="noopener noreferrer">Terms and Conditions</a> and understand your data will be processed according to the <a href="https://lydian.com/privacy" target="_blank" rel="noopener noreferrer">Privacy Notice</a>.'
542
- }, f = { en: q }, v = "en";
543
- let D = v;
544
- function ne() {
545
- return D;
598
+ }, T = { en: Q }, L = "en";
599
+ let R = L;
600
+ function de() {
601
+ return R;
546
602
  }
547
- function N(t, e) {
603
+ function w(e, t) {
548
604
  var n;
549
- const a = ((n = f[D]) == null ? void 0 : n[t]) ?? f[v][t] ?? t;
550
- return e ? a.replace(
605
+ const a = ((n = T[R]) == null ? void 0 : n[e]) ?? T[L][e] ?? e;
606
+ return t ? a.replace(
551
607
  /\{(\w+)\}/g,
552
- (o, r) => e[r] != null ? String(e[r]) : `{${r}}`
608
+ (o, r) => t[r] != null ? String(t[r]) : `{${r}}`
553
609
  ) : a;
554
610
  }
555
- function G(t) {
556
- return t === u.SUCCESS ? "succeeded" : t < u.PENDING && t !== u.KYC_VERIFICATION_PENDING && t !== u.COMPLIANCE_PENDING ? "failed" : "active";
611
+ function Z(e) {
612
+ return e === u.SUCCESS ? "succeeded" : e < u.PENDING && e !== u.KYC_VERIFICATION_PENDING && e !== u.COMPLIANCE_PENDING ? "failed" : "active";
557
613
  }
558
- function H({
559
- transaction: t,
560
- session: e
614
+ function X({
615
+ transaction: e,
616
+ session: t
561
617
  }) {
562
618
  var o, r, s;
563
- const a = G(t.status);
619
+ const a = Z(e.status);
564
620
  if (a === "active")
565
621
  return null;
566
622
  if (a === "failed")
567
623
  return {
568
624
  outcome: a,
569
- message: N("errors.paymentCouldNotComplete"),
625
+ message: w("errors.paymentCouldNotComplete"),
570
626
  failure: {
571
627
  shouldEndCheckout: !0,
572
628
  // Negative (non-KYC) status — cancelled / fraud / timeout.
573
629
  reason: "blocked",
574
- transactionID: t.transactionID,
575
- redirectURL: h(e == null ? void 0 : e.failureURL)
630
+ transactionID: e.transactionID,
631
+ redirectURL: y(t == null ? void 0 : t.failureURL)
576
632
  }
577
633
  };
578
- const n = (o = t.payments) == null ? void 0 : o.find(
579
- (i) => i.status === O.CONFIRMED
634
+ const n = (o = e.payments) == null ? void 0 : o.find(
635
+ (i) => i.status === B.CONFIRMED
580
636
  );
581
637
  return {
582
638
  outcome: a,
583
639
  event: {
584
- transactionID: t.transactionID,
640
+ transactionID: e.transactionID,
585
641
  asset: n == null ? void 0 : n.cryptoAsset,
586
642
  network: n == null ? void 0 : n.cryptoNetwork
587
643
  },
588
644
  result: {
589
- transactionID: t.transactionID,
590
- amount: (r = t.amounts) == null ? void 0 : r.totalLocal,
591
- currency: (s = t.amounts) == null ? void 0 : s.currency,
645
+ transactionID: e.transactionID,
646
+ amount: (r = e.amounts) == null ? void 0 : r.totalLocal,
647
+ currency: (s = e.amounts) == null ? void 0 : s.currency,
592
648
  asset: n == null ? void 0 : n.cryptoAsset,
593
649
  network: n == null ? void 0 : n.cryptoNetwork,
594
650
  completedAt: n == null ? void 0 : n.completedAt,
595
- redirectURL: h(e == null ? void 0 : e.successURL)
651
+ redirectURL: y(t == null ? void 0 : t.successURL)
596
652
  }
597
653
  };
598
654
  }
599
- function K() {
600
- let t = null;
655
+ function V() {
656
+ let e = null;
601
657
  return {
602
- setOptions: (e) => {
603
- t = e;
658
+ setOptions: (t) => {
659
+ e = t;
604
660
  },
605
- emit: (e, a) => T(t == null ? void 0 : t.onEvent, e, a),
606
- paymentFailed: (e, a) => {
661
+ emit: (t, a) => A(e == null ? void 0 : e.onEvent, t, a),
662
+ paymentFailed: (t, a) => {
607
663
  var n;
608
- return (n = t == null ? void 0 : t.paymentFailedListener) == null ? void 0 : n.call(t, e, a);
664
+ return (n = e == null ? void 0 : e.paymentFailedListener) == null ? void 0 : n.call(e, t, a);
609
665
  },
610
- paymentSucceeded: (e) => {
666
+ paymentSucceeded: (t) => {
611
667
  var a;
612
- return (a = t == null ? void 0 : t.paymentSuccessListener) == null ? void 0 : a.call(t, e);
668
+ return (a = e == null ? void 0 : e.paymentSuccessListener) == null ? void 0 : a.call(e, t);
613
669
  },
614
- paymentCanceled: (e) => {
670
+ paymentCanceled: (t) => {
615
671
  var a;
616
- return (a = t == null ? void 0 : t.paymentCanceledListener) == null ? void 0 : a.call(t, e);
672
+ return (a = e == null ? void 0 : e.paymentCanceledListener) == null ? void 0 : a.call(e, t);
617
673
  }
618
674
  };
619
675
  }
620
- class j extends HTMLElement {
676
+ class ee extends HTMLElement {
621
677
  constructor() {
622
678
  super(), this.engine = null, this.engineLoadPromise = null, this.isTornDown = !1, this.shadow = this.attachShadow({ mode: "open" });
623
679
  }
@@ -626,26 +682,26 @@ class j extends HTMLElement {
626
682
  connectedCallback() {
627
683
  this.isTornDown = !1;
628
684
  }
629
- async initialize(e) {
630
- const a = z(e), n = J({ api: a, options: e }), o = await this.loadEngine(e, n);
631
- !o || this.isTornDown || (this.engine = o, await o.initialize(e, { api: a, sessionLoad: n }));
685
+ async initialize(t) {
686
+ const a = te(t), n = ae({ api: a, options: t }), o = await this.loadEngine(t, n);
687
+ !o || this.isTornDown || (this.engine = o, await o.initialize(t, { api: a, sessionLoad: n }));
632
688
  }
633
- async loadEngine(e, a) {
689
+ async loadEngine(t, a) {
634
690
  const n = this.getOrLoadEngine();
635
691
  try {
636
692
  return await n;
637
693
  } catch {
638
694
  return await this.handleEngineLoadFailure({
639
695
  engineLoad: n,
640
- options: e,
696
+ options: t,
641
697
  sessionLoad: a
642
698
  }), null;
643
699
  }
644
700
  }
645
- async updateTransaction(e) {
701
+ async updateTransaction(t) {
646
702
  if (!this.engine)
647
703
  throw new Error("Tether Pay not initialized.");
648
- await this.engine.updateTransaction(e);
704
+ await this.engine.updateTransaction(t);
649
705
  }
650
706
  // A merchant SPA can unmount the element at any time; nothing else stops this
651
707
  // instance's timers.
@@ -655,8 +711,8 @@ class j extends HTMLElement {
655
711
  // Not started in the constructor: a page can carry the tag and never check out.
656
712
  // Overlapping initialize() calls share one download.
657
713
  getOrLoadEngine() {
658
- return this.engineLoadPromise ?? (this.engineLoadPromise = import("./mountEngine-B721ZzjQ.js").then((e) => e.m).then((e) => {
659
- const a = e.mountCheckoutEngine({
714
+ return this.engineLoadPromise ?? (this.engineLoadPromise = import("./mountEngine-B9qRQyLg.js").then((t) => t.m).then((t) => {
715
+ const a = t.mountCheckoutEngine({
660
716
  host: this,
661
717
  shadowRoot: this.shadow
662
718
  });
@@ -664,11 +720,11 @@ class j extends HTMLElement {
664
720
  })), this.engineLoadPromise;
665
721
  }
666
722
  async handleEngineLoadFailure({
667
- engineLoad: e,
723
+ engineLoad: t,
668
724
  options: a,
669
725
  sessionLoad: n
670
726
  }) {
671
- this.engineLoadPromise === e && (this.engineLoadPromise = null, await this.reportEngineFailure({ options: a, sessionLoad: n }));
727
+ this.engineLoadPromise === t && (this.engineLoadPromise = null, await this.reportEngineFailure({ options: a, sessionLoad: n }));
672
728
  }
673
729
  // A host that removed the element has walked away; a failure report could send
674
730
  // it to a failureURL for a checkout it dismissed.
@@ -680,7 +736,7 @@ class j extends HTMLElement {
680
736
  // an outcome the gateway has already decided — a session resumed after the
681
737
  // payment settled must report that payment, not a dead checkout.
682
738
  async reportEngineFailure({
683
- options: e,
739
+ options: t,
684
740
  sessionLoad: a
685
741
  }) {
686
742
  if (this.isDismissedByHost)
@@ -688,9 +744,9 @@ class j extends HTMLElement {
688
744
  const n = await a;
689
745
  if (this.isDismissedByHost)
690
746
  return;
691
- const o = K();
692
- o.setOptions(e);
693
- const r = n.ok && n.linkedTransaction ? H({
747
+ const o = V();
748
+ o.setOptions(t);
749
+ const r = n.ok && n.linkedTransaction ? X({
694
750
  transaction: n.linkedTransaction,
695
751
  session: n.session
696
752
  }) : null;
@@ -706,7 +762,21 @@ class j extends HTMLElement {
706
762
  }), o.paymentFailed(r.message, r.failure);
707
763
  return;
708
764
  }
709
- const s = N("errors.checkoutUnavailable"), i = _({
765
+ if (!n.ok && n.cancelURL) {
766
+ o.emit("payment.canceled"), o.paymentCanceled({ redirectURL: n.cancelURL });
767
+ return;
768
+ }
769
+ if (!n.ok && n.failureURL) {
770
+ const g = w("errors.unableToCreateSession"), b = k({
771
+ message: g,
772
+ reason: "sessionExpired",
773
+ shouldEndCheckout: !0,
774
+ session: { failureURL: n.failureURL }
775
+ });
776
+ o.emit("payment.failed", b.event), o.paymentFailed(g, b.failure);
777
+ return;
778
+ }
779
+ const s = w("errors.checkoutUnavailable"), i = k({
710
780
  message: s,
711
781
  reason: "error",
712
782
  shouldEndCheckout: !0,
@@ -716,92 +786,93 @@ class j extends HTMLElement {
716
786
  }
717
787
  // Always teardown and unmount together to avoid leaking the React engine.
718
788
  // Clear the cached load so a later initialize() creates a fresh engine.
719
- releaseEngine(e = this.engine) {
720
- e == null || e.teardown(), e == null || e.unmount(), this.engine = null, this.engineLoadPromise = null;
789
+ releaseEngine(t = this.engine) {
790
+ t == null || t.teardown(), t == null || t.unmount(), this.engine = null, this.engineLoadPromise = null;
721
791
  }
722
792
  }
723
- function z(t) {
724
- return new R(
725
- F(t),
726
- c(t) ? void 0 : t.publishableKey
793
+ function te(e) {
794
+ return new Y(
795
+ G(e),
796
+ d(e) ? void 0 : e.publishableKey
727
797
  );
728
798
  }
729
- function J({
730
- api: t,
731
- options: e
799
+ function ae({
800
+ api: e,
801
+ options: t
732
802
  }) {
733
- return $({
734
- api: t,
735
- options: e,
736
- emit: (a, n) => T(e.onEvent, a, n)
803
+ return _({
804
+ api: e,
805
+ options: t,
806
+ emit: (a, n) => A(t.onEvent, a, n)
737
807
  });
738
808
  }
739
- customElements.get("lydian-checkout") || customElements.define("lydian-checkout", j);
740
- function m() {
809
+ customElements.get("lydian-checkout") || customElements.define("lydian-checkout", ee);
810
+ function f() {
741
811
  return document.querySelector("lydian-checkout");
742
812
  }
743
- async function Q(t) {
744
- if (!t.publishableKey || !t.transaction.amount || !t.transaction.currency)
813
+ async function ne(e) {
814
+ if (!e.publishableKey || !e.transaction.amount || !e.transaction.currency)
745
815
  throw new Error("SDK initialization requires publishableKey and a transaction");
746
- const e = C(t);
747
- if (e)
748
- throw new Error(e);
749
- const a = k(t);
816
+ const t = D(e);
817
+ if (t)
818
+ throw new Error(t);
819
+ const a = N(e);
750
820
  if (a)
751
821
  throw new Error(a);
752
- if (!S(t.transaction.currency))
753
- throw new Error("Invalid value for currency, valid values are: " + g.join(", "));
754
- const n = P({
755
- options: t,
822
+ if (!U(e.transaction.currency))
823
+ throw new Error("Invalid value for currency, valid values are: " + v.join(", "));
824
+ const n = S({
825
+ options: e,
756
826
  unsupportedKeys: ["sessionID"],
757
827
  entryPoint: "init"
758
828
  });
759
829
  if (n)
760
830
  throw new Error(n);
761
- await m().initialize(t);
831
+ await f().initialize(e);
762
832
  }
763
- async function Z(t) {
764
- if (!t.sessionID)
833
+ async function oe(e) {
834
+ if (!e.sessionID)
765
835
  throw new Error("initExistingSession requires a sessionID");
766
- const e = C(t);
767
- if (e)
768
- throw new Error(e);
769
- const a = k(t);
836
+ const t = D(e);
837
+ if (t)
838
+ throw new Error(t);
839
+ const a = N(e);
770
840
  if (a)
771
841
  throw new Error(a);
772
- const n = P({
773
- options: t,
842
+ const n = S({
843
+ options: e,
774
844
  unsupportedKeys: ["publishableKey", "transaction"],
775
845
  entryPoint: "initExistingSession"
776
846
  });
777
847
  if (n)
778
848
  throw new Error(n);
779
- await m().initialize(t);
849
+ await f().initialize(e);
780
850
  }
781
- async function X(t) {
782
- await m().updateTransaction(t);
851
+ async function re(e) {
852
+ await f().updateTransaction(e);
783
853
  }
784
- window.Lydian = { init: Q, initExistingSession: Z, updateTransaction: X };
854
+ window.Lydian = { init: ne, initExistingSession: oe, updateTransaction: re };
785
855
  export {
786
- O as P,
856
+ O as G,
857
+ se as P,
787
858
  u as T,
788
- V as a,
789
- te as b,
790
- g as c,
791
- M as d,
792
- Y as e,
793
- B as f,
794
- ne as g,
795
- c as h,
796
- S as i,
797
- G as j,
798
- H as k,
799
- E as l,
800
- ae as m,
801
- _ as n,
802
- ee as o,
803
- K as p,
804
- x as r,
805
- h as s,
806
- N as t
859
+ B as a,
860
+ ce as b,
861
+ v as c,
862
+ K as d,
863
+ z as e,
864
+ J as f,
865
+ de as g,
866
+ d as h,
867
+ U as i,
868
+ Z as j,
869
+ X as k,
870
+ I as l,
871
+ le as m,
872
+ k as n,
873
+ ie as o,
874
+ V as p,
875
+ H as r,
876
+ y as s,
877
+ w as t
807
878
  };