@lydianpay/sdk-web 3.15.1 → 3.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{browser-DY-UjlLA.js → browser-DF_DKcVK.js} +1 -1
- package/dist/chunks/{connect-multichain-wBdEwKyo.js → connect-multichain-YCjUNosy.js} +9 -9
- package/dist/chunks/{index-CXemgulL.js → index-BWTclqPv.js} +2 -2
- package/dist/chunks/{index-D5SHnWSP.js → index-BmaYHJhy.js} +2 -2
- package/dist/chunks/{index-DOukN_y9.js → index-CwGq7YO0.js} +1 -1
- package/dist/chunks/{index-Dcas8XfB.js → index-odEhT4rR.js} +188 -178
- package/dist/chunks/{index-rTVbAb-M.js → index-pr0nrRQZ.js} +3 -3
- package/dist/chunks/{index-DI_XOVX4.js → index-yi6xk8E8.js} +1 -1
- package/dist/chunks/{mountEngine-B8GaOfwA.js → mountEngine-SwisFe5z.js} +3986 -3939
- package/dist/lydian.js +1 -1
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/chains/adapters.d.ts +6 -0
- package/dist/types/network/cryptotransaction/index.d.ts +2 -1
- package/dist/types/types.d.ts +8 -0
- package/package.json +2 -2
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
const g = ["USD", "TRY", "PHP"];
|
|
2
|
-
function
|
|
3
|
-
return typeof
|
|
2
|
+
function S(t) {
|
|
3
|
+
return typeof t == "string" && g.includes(t);
|
|
4
4
|
}
|
|
5
|
-
function c(
|
|
6
|
-
return "sessionID" in
|
|
5
|
+
function c(t) {
|
|
6
|
+
return "sessionID" in t && typeof t.sessionID == "string" && t.sessionID.length > 0;
|
|
7
7
|
}
|
|
8
8
|
class y {
|
|
9
9
|
// Optional: a caller-supplied session has no key and needs none (see Sessions).
|
|
10
10
|
// The key is still required when the SDK creates the session, enforced in
|
|
11
11
|
// index.ts where that is known.
|
|
12
|
-
constructor(
|
|
13
|
-
if (this.baseUri =
|
|
12
|
+
constructor(e, a) {
|
|
13
|
+
if (this.baseUri = e, this.publishableKey = a, !this.baseUri)
|
|
14
14
|
throw new Error("baseUri is required");
|
|
15
15
|
}
|
|
16
16
|
// Omitted rather than blank when there is no key: the gateway checks the pk_
|
|
17
17
|
// prefix first, so an empty header is a 400 where an absent one is anonymous.
|
|
18
|
-
headers(
|
|
19
|
-
const a = { ...
|
|
18
|
+
headers(e) {
|
|
19
|
+
const a = { ...e };
|
|
20
20
|
return this.publishableKey && (a["X-Publishable-Key"] = this.publishableKey), a;
|
|
21
21
|
}
|
|
22
|
-
async request(
|
|
23
|
-
const n = `${this.baseUri}${
|
|
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);
|
|
24
24
|
if (s.ok)
|
|
25
25
|
return await s.json();
|
|
26
26
|
throw new Error(s.statusText);
|
|
@@ -28,55 +28,64 @@ class y {
|
|
|
28
28
|
// For endpoints that reply text/plain rather than JSON (e.g. PATCH
|
|
29
29
|
// /customer/otp -> "OTP sent"). Sends the same JSON request headers but does
|
|
30
30
|
// not call response.json(), which would throw on a non-JSON body.
|
|
31
|
-
async requestText(
|
|
32
|
-
const n = `${this.baseUri}${
|
|
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);
|
|
33
33
|
if (s.ok)
|
|
34
34
|
return await s.text();
|
|
35
35
|
throw new Error(s.statusText);
|
|
36
36
|
}
|
|
37
|
-
async requestWithFormData(
|
|
38
|
-
const n = `${this.baseUri}${
|
|
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);
|
|
39
39
|
if (s.ok)
|
|
40
40
|
return await s.json();
|
|
41
41
|
throw new Error(s.statusText);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
const l = "transaction";
|
|
45
|
-
class
|
|
46
|
-
async getCryptoTransaction(
|
|
47
|
-
return await this.request(`/${l}/${
|
|
45
|
+
class A extends y {
|
|
46
|
+
async getCryptoTransaction(e) {
|
|
47
|
+
return await this.request(`/${l}/${e}`);
|
|
48
48
|
}
|
|
49
|
-
async createPaymentRequest(
|
|
49
|
+
async createPaymentRequest(e, a) {
|
|
50
50
|
return await this.request(
|
|
51
|
-
`/${l}/${
|
|
51
|
+
`/${l}/${e}/payment`,
|
|
52
52
|
{
|
|
53
53
|
method: "POST",
|
|
54
54
|
body: JSON.stringify(a)
|
|
55
55
|
}
|
|
56
56
|
);
|
|
57
57
|
}
|
|
58
|
-
async buildTransfer(
|
|
58
|
+
async buildTransfer(e, a, n) {
|
|
59
59
|
return await this.request(
|
|
60
|
-
`/${l}/${
|
|
60
|
+
`/${l}/${e}/payment/${a}/transfer`,
|
|
61
61
|
{
|
|
62
62
|
method: "POST",
|
|
63
63
|
body: JSON.stringify(n)
|
|
64
64
|
}
|
|
65
65
|
);
|
|
66
66
|
}
|
|
67
|
-
async
|
|
67
|
+
async broadcastTransfer(e, a, n) {
|
|
68
68
|
return await this.request(
|
|
69
|
-
`/${l}/${
|
|
69
|
+
`/${l}/${e}/payment/${a}/transfer/broadcast`,
|
|
70
|
+
{
|
|
71
|
+
method: "POST",
|
|
72
|
+
body: JSON.stringify(n)
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
async cancelCryptoTransaction(e, a) {
|
|
77
|
+
return await this.request(
|
|
78
|
+
`/${l}/${e}/cancel`,
|
|
70
79
|
{
|
|
71
80
|
method: "PATCH",
|
|
72
81
|
body: JSON.stringify(a)
|
|
73
82
|
}
|
|
74
83
|
);
|
|
75
84
|
}
|
|
76
|
-
async kycVerification(
|
|
85
|
+
async kycVerification(e, a) {
|
|
77
86
|
const n = new FormData();
|
|
78
87
|
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(
|
|
79
|
-
`/${l}/${
|
|
88
|
+
`/${l}/${e}/verification`,
|
|
80
89
|
{
|
|
81
90
|
method: "POST",
|
|
82
91
|
body: n
|
|
@@ -84,48 +93,48 @@ class S extends y {
|
|
|
84
93
|
);
|
|
85
94
|
}
|
|
86
95
|
}
|
|
87
|
-
function I(
|
|
88
|
-
|
|
96
|
+
function I(t, e) {
|
|
97
|
+
e.forEach((a) => {
|
|
89
98
|
Object.getOwnPropertyNames(a.prototype).forEach((n) => {
|
|
90
99
|
const o = Object.getOwnPropertyDescriptor(a.prototype, n);
|
|
91
|
-
o && Object.defineProperty(
|
|
100
|
+
o && Object.defineProperty(t.prototype, n, o);
|
|
92
101
|
});
|
|
93
102
|
});
|
|
94
103
|
}
|
|
95
104
|
const w = "customer/otp";
|
|
96
105
|
class L extends y {
|
|
97
106
|
// PATCH /customer/otp -> text/plain "OTP sent" (no JSON body).
|
|
98
|
-
async sendCustomerOTP(
|
|
107
|
+
async sendCustomerOTP(e) {
|
|
99
108
|
return await this.requestText(`/${w}`, {
|
|
100
109
|
method: "PATCH",
|
|
101
|
-
body: JSON.stringify(
|
|
110
|
+
body: JSON.stringify(e)
|
|
102
111
|
});
|
|
103
112
|
}
|
|
104
113
|
// PUT /customer/otp -> { customerUUID, kycValidated }.
|
|
105
|
-
async authenticateCustomerOTP(
|
|
114
|
+
async authenticateCustomerOTP(e) {
|
|
106
115
|
return await this.request(`/${w}`, {
|
|
107
116
|
method: "PUT",
|
|
108
|
-
body: JSON.stringify(
|
|
117
|
+
body: JSON.stringify(e)
|
|
109
118
|
});
|
|
110
119
|
}
|
|
111
120
|
}
|
|
112
121
|
const d = "session";
|
|
113
122
|
class U extends y {
|
|
114
|
-
async createSession(
|
|
123
|
+
async createSession(e) {
|
|
115
124
|
return await this.request(`/${d}`, {
|
|
116
125
|
method: "POST",
|
|
117
|
-
body: JSON.stringify(
|
|
126
|
+
body: JSON.stringify(e)
|
|
118
127
|
});
|
|
119
128
|
}
|
|
120
|
-
async getSession(
|
|
121
|
-
return await this.request(`/${d}/${
|
|
129
|
+
async getSession(e) {
|
|
130
|
+
return await this.request(`/${d}/${e}`);
|
|
122
131
|
}
|
|
123
132
|
// Promotes the session into a transaction. Allowed once per session — except
|
|
124
133
|
// that a KYC-pending (-3) response does not consume the promotion, which is
|
|
125
134
|
// what lets the restore-details flow re-promote with a customerUUID.
|
|
126
|
-
async createSessionTransaction(
|
|
135
|
+
async createSessionTransaction(e, a) {
|
|
127
136
|
return await this.request(
|
|
128
|
-
`/${d}/${
|
|
137
|
+
`/${d}/${e}/transaction`,
|
|
129
138
|
{
|
|
130
139
|
method: "POST",
|
|
131
140
|
body: JSON.stringify(a)
|
|
@@ -134,15 +143,15 @@ class U extends y {
|
|
|
134
143
|
}
|
|
135
144
|
// PATCH /session/{id}/cancel replies text/plain (the merchant's cancel URL),
|
|
136
145
|
// not JSON. Cancelling cascades to the linked transaction, if any.
|
|
137
|
-
async cancelSession(
|
|
138
|
-
return await this.requestText(`/${d}/${
|
|
146
|
+
async cancelSession(e) {
|
|
147
|
+
return await this.requestText(`/${d}/${e}/cancel`, {
|
|
139
148
|
method: "PATCH"
|
|
140
149
|
});
|
|
141
150
|
}
|
|
142
151
|
}
|
|
143
152
|
class b extends y {
|
|
144
153
|
}
|
|
145
|
-
I(b, [
|
|
154
|
+
I(b, [A, L, U]);
|
|
146
155
|
const R = b;
|
|
147
156
|
var u = {
|
|
148
157
|
COMPLIANCE_PENDING: -10,
|
|
@@ -172,63 +181,63 @@ var u = {
|
|
|
172
181
|
sandbox: "https://api.sandbox.lydian.com",
|
|
173
182
|
prod: "https://api.lydian.com"
|
|
174
183
|
};
|
|
175
|
-
function F(
|
|
176
|
-
return
|
|
184
|
+
function F(t) {
|
|
185
|
+
return t.gatewayUrl ? new URL(t.gatewayUrl).origin : t.dev ? p.dev : t.sandbox ? p.sandbox : p.prod;
|
|
177
186
|
}
|
|
178
|
-
function
|
|
179
|
-
options:
|
|
180
|
-
unsupportedKeys:
|
|
187
|
+
function P({
|
|
188
|
+
options: t,
|
|
189
|
+
unsupportedKeys: e,
|
|
181
190
|
entryPoint: a
|
|
182
191
|
}) {
|
|
183
|
-
const n =
|
|
192
|
+
const n = e.filter((o) => t[o] !== void 0);
|
|
184
193
|
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.`;
|
|
185
194
|
}
|
|
186
|
-
function
|
|
187
|
-
var
|
|
188
|
-
return (
|
|
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;
|
|
189
198
|
}
|
|
190
|
-
function k(
|
|
191
|
-
return
|
|
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)}`;
|
|
192
201
|
}
|
|
193
|
-
function W(
|
|
194
|
-
let
|
|
202
|
+
function W(t) {
|
|
203
|
+
let e;
|
|
195
204
|
try {
|
|
196
|
-
|
|
205
|
+
e = new URL(t);
|
|
197
206
|
} catch {
|
|
198
207
|
return !1;
|
|
199
208
|
}
|
|
200
|
-
return (
|
|
209
|
+
return (e.protocol === "http:" || e.protocol === "https:") && e.pathname === "/" && e.search === "" && e.hash === "";
|
|
201
210
|
}
|
|
202
|
-
function ee(
|
|
203
|
-
return
|
|
211
|
+
function ee(t) {
|
|
212
|
+
return t !== null && !c(t) && !!t.publishableKey;
|
|
204
213
|
}
|
|
205
|
-
function te(
|
|
206
|
-
return
|
|
214
|
+
function te(t) {
|
|
215
|
+
return t !== null && !c(t);
|
|
207
216
|
}
|
|
208
217
|
function ae({
|
|
209
|
-
options:
|
|
210
|
-
session:
|
|
218
|
+
options: t,
|
|
219
|
+
session: e,
|
|
211
220
|
settled: a
|
|
212
221
|
}) {
|
|
213
|
-
return !a &&
|
|
222
|
+
return !a && e !== null && t !== null && c(t);
|
|
214
223
|
}
|
|
215
|
-
function T(
|
|
224
|
+
function T(t, e, a) {
|
|
216
225
|
try {
|
|
217
|
-
|
|
226
|
+
t == null || t(e, a);
|
|
218
227
|
} catch (n) {
|
|
219
|
-
console.error(`onEvent("${
|
|
228
|
+
console.error(`onEvent("${e}") threw:`, n);
|
|
220
229
|
}
|
|
221
230
|
}
|
|
222
|
-
async function
|
|
223
|
-
api:
|
|
224
|
-
options:
|
|
231
|
+
async function $({
|
|
232
|
+
api: t,
|
|
233
|
+
options: e,
|
|
225
234
|
emit: a
|
|
226
235
|
}) {
|
|
227
236
|
try {
|
|
228
|
-
const n = await
|
|
237
|
+
const n = await x({ api: t, options: e }), { session: o, sessionPromoted: r } = await M({ api: t, sessionID: n });
|
|
229
238
|
a("session.loaded", Y(o));
|
|
230
239
|
const s = await B({
|
|
231
|
-
api:
|
|
240
|
+
api: t,
|
|
232
241
|
transactionID: o.transactionID
|
|
233
242
|
});
|
|
234
243
|
return { ok: !0, session: o, sessionPromoted: r, linkedTransaction: s };
|
|
@@ -236,69 +245,69 @@ async function x({
|
|
|
236
245
|
return { ok: !1 };
|
|
237
246
|
}
|
|
238
247
|
}
|
|
239
|
-
async function
|
|
240
|
-
api:
|
|
241
|
-
options:
|
|
248
|
+
async function x({
|
|
249
|
+
api: t,
|
|
250
|
+
options: e
|
|
242
251
|
}) {
|
|
243
|
-
return c(
|
|
244
|
-
amount:
|
|
245
|
-
amountCurrency:
|
|
246
|
-
descriptor:
|
|
247
|
-
referenceNumber:
|
|
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
|
|
248
257
|
})).sessionID;
|
|
249
258
|
}
|
|
250
259
|
async function M({
|
|
251
|
-
api:
|
|
252
|
-
sessionID:
|
|
260
|
+
api: t,
|
|
261
|
+
sessionID: e
|
|
253
262
|
}) {
|
|
254
|
-
const a = await
|
|
263
|
+
const a = await t.getSession(e);
|
|
255
264
|
return { session: a, sessionPromoted: E(a) };
|
|
256
265
|
}
|
|
257
|
-
function Y(
|
|
266
|
+
function Y(t) {
|
|
258
267
|
return {
|
|
259
|
-
sessionID:
|
|
260
|
-
merchantName:
|
|
261
|
-
alreadyPromoted: E(
|
|
268
|
+
sessionID: t.sessionID,
|
|
269
|
+
merchantName: t.merchantName,
|
|
270
|
+
alreadyPromoted: E(t)
|
|
262
271
|
};
|
|
263
272
|
}
|
|
264
|
-
function E(
|
|
265
|
-
return !!
|
|
273
|
+
function E(t) {
|
|
274
|
+
return !!t.transactionID;
|
|
266
275
|
}
|
|
267
276
|
async function B({
|
|
268
|
-
api:
|
|
269
|
-
transactionID:
|
|
277
|
+
api: t,
|
|
278
|
+
transactionID: e
|
|
270
279
|
}) {
|
|
271
|
-
if (!
|
|
280
|
+
if (!e)
|
|
272
281
|
return null;
|
|
273
282
|
try {
|
|
274
|
-
return await
|
|
283
|
+
return await t.getCryptoTransaction(e);
|
|
275
284
|
} catch (a) {
|
|
276
285
|
return console.error("Failed to resolve the session transaction:", a), null;
|
|
277
286
|
}
|
|
278
287
|
}
|
|
279
|
-
function h(
|
|
280
|
-
if (!
|
|
288
|
+
function h(t) {
|
|
289
|
+
if (!t)
|
|
281
290
|
return;
|
|
282
|
-
let
|
|
291
|
+
let e;
|
|
283
292
|
try {
|
|
284
|
-
|
|
293
|
+
e = new URL(t);
|
|
285
294
|
} catch {
|
|
286
295
|
return;
|
|
287
296
|
}
|
|
288
|
-
return
|
|
297
|
+
return e.protocol === "https:" || e.protocol === "http:" ? t : void 0;
|
|
289
298
|
}
|
|
290
299
|
function _({
|
|
291
|
-
message:
|
|
292
|
-
reason:
|
|
300
|
+
message: t,
|
|
301
|
+
reason: e,
|
|
293
302
|
shouldEndCheckout: a,
|
|
294
303
|
transactionID: n,
|
|
295
304
|
session: o
|
|
296
305
|
}) {
|
|
297
306
|
return {
|
|
298
|
-
event: { reason:
|
|
307
|
+
event: { reason: e, shouldEndCheckout: a, message: t },
|
|
299
308
|
failure: {
|
|
300
309
|
shouldEndCheckout: a,
|
|
301
|
-
reason:
|
|
310
|
+
reason: e,
|
|
302
311
|
transactionID: n,
|
|
303
312
|
// Only a failure that ends the checkout carries a redirect. A retryable one
|
|
304
313
|
// leaves the customer mid-flow with something still to do, and a host that
|
|
@@ -307,7 +316,7 @@ function _({
|
|
|
307
316
|
}
|
|
308
317
|
};
|
|
309
318
|
}
|
|
310
|
-
const
|
|
319
|
+
const q = {
|
|
311
320
|
"common.cancelTransaction": "Cancel Transaction",
|
|
312
321
|
"common.cancel": "Cancel",
|
|
313
322
|
"common.back": "Back",
|
|
@@ -509,6 +518,7 @@ const G = {
|
|
|
509
518
|
"errors.walletOnWrongNetwork": "Your wallet is on a different network. Switch to {network} to pay from it, or scan the code below instead.",
|
|
510
519
|
"errors.walletDisconnected": "Your wallet disconnected. Reconnect it, or scan the code below to pay.",
|
|
511
520
|
"errors.walletDeclinedScanInstead": "Your wallet didn’t approve the payment. You can still pay by scanning the code below.",
|
|
521
|
+
"errors.walletSignedNotSent": "Your wallet signed the payment, but it couldn’t be sent. You can still pay by scanning the code below.",
|
|
512
522
|
"errors.unableToCreateCryptoTransaction": "We couldn't set up your payment. Please try again, or choose a different coin.",
|
|
513
523
|
"errors.cryptoTransactionNotCreated": "Your payment hasn’t been set up yet. Choose a coin and network to continue.",
|
|
514
524
|
"errors.unableToVerifyDetails": "We could not verify your details. Please try again or contact support.",
|
|
@@ -529,28 +539,28 @@ const G = {
|
|
|
529
539
|
"validation.customerDetailsMissing": "Customer details are missing.",
|
|
530
540
|
"validation.invalidOtp": "Please enter a valid 6-digit code.",
|
|
531
541
|
"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>.'
|
|
532
|
-
}, f = { en:
|
|
542
|
+
}, f = { en: q }, v = "en";
|
|
533
543
|
let D = v;
|
|
534
544
|
function ne() {
|
|
535
545
|
return D;
|
|
536
546
|
}
|
|
537
|
-
function N(
|
|
547
|
+
function N(t, e) {
|
|
538
548
|
var n;
|
|
539
|
-
const a = ((n = f[D]) == null ? void 0 : n[
|
|
540
|
-
return
|
|
549
|
+
const a = ((n = f[D]) == null ? void 0 : n[t]) ?? f[v][t] ?? t;
|
|
550
|
+
return e ? a.replace(
|
|
541
551
|
/\{(\w+)\}/g,
|
|
542
|
-
(o, r) =>
|
|
552
|
+
(o, r) => e[r] != null ? String(e[r]) : `{${r}}`
|
|
543
553
|
) : a;
|
|
544
554
|
}
|
|
545
|
-
function
|
|
546
|
-
return
|
|
555
|
+
function G(t) {
|
|
556
|
+
return t === u.SUCCESS ? "succeeded" : t < u.PENDING && t !== u.KYC_VERIFICATION_PENDING && t !== u.COMPLIANCE_PENDING ? "failed" : "active";
|
|
547
557
|
}
|
|
548
558
|
function H({
|
|
549
|
-
transaction:
|
|
550
|
-
session:
|
|
559
|
+
transaction: t,
|
|
560
|
+
session: e
|
|
551
561
|
}) {
|
|
552
562
|
var o, r, s;
|
|
553
|
-
const a =
|
|
563
|
+
const a = G(t.status);
|
|
554
564
|
if (a === "active")
|
|
555
565
|
return null;
|
|
556
566
|
if (a === "failed")
|
|
@@ -561,49 +571,49 @@ function H({
|
|
|
561
571
|
shouldEndCheckout: !0,
|
|
562
572
|
// Negative (non-KYC) status — cancelled / fraud / timeout.
|
|
563
573
|
reason: "blocked",
|
|
564
|
-
transactionID:
|
|
565
|
-
redirectURL: h(
|
|
574
|
+
transactionID: t.transactionID,
|
|
575
|
+
redirectURL: h(e == null ? void 0 : e.failureURL)
|
|
566
576
|
}
|
|
567
577
|
};
|
|
568
|
-
const n = (o =
|
|
578
|
+
const n = (o = t.payments) == null ? void 0 : o.find(
|
|
569
579
|
(i) => i.status === O.CONFIRMED
|
|
570
580
|
);
|
|
571
581
|
return {
|
|
572
582
|
outcome: a,
|
|
573
583
|
event: {
|
|
574
|
-
transactionID:
|
|
584
|
+
transactionID: t.transactionID,
|
|
575
585
|
asset: n == null ? void 0 : n.cryptoAsset,
|
|
576
586
|
network: n == null ? void 0 : n.cryptoNetwork
|
|
577
587
|
},
|
|
578
588
|
result: {
|
|
579
|
-
transactionID:
|
|
580
|
-
amount: (r =
|
|
581
|
-
currency: (s =
|
|
589
|
+
transactionID: t.transactionID,
|
|
590
|
+
amount: (r = t.amounts) == null ? void 0 : r.totalLocal,
|
|
591
|
+
currency: (s = t.amounts) == null ? void 0 : s.currency,
|
|
582
592
|
asset: n == null ? void 0 : n.cryptoAsset,
|
|
583
593
|
network: n == null ? void 0 : n.cryptoNetwork,
|
|
584
594
|
completedAt: n == null ? void 0 : n.completedAt,
|
|
585
|
-
redirectURL: h(
|
|
595
|
+
redirectURL: h(e == null ? void 0 : e.successURL)
|
|
586
596
|
}
|
|
587
597
|
};
|
|
588
598
|
}
|
|
589
599
|
function K() {
|
|
590
|
-
let
|
|
600
|
+
let t = null;
|
|
591
601
|
return {
|
|
592
|
-
setOptions: (
|
|
593
|
-
|
|
602
|
+
setOptions: (e) => {
|
|
603
|
+
t = e;
|
|
594
604
|
},
|
|
595
|
-
emit: (
|
|
596
|
-
paymentFailed: (
|
|
605
|
+
emit: (e, a) => T(t == null ? void 0 : t.onEvent, e, a),
|
|
606
|
+
paymentFailed: (e, a) => {
|
|
597
607
|
var n;
|
|
598
|
-
return (n =
|
|
608
|
+
return (n = t == null ? void 0 : t.paymentFailedListener) == null ? void 0 : n.call(t, e, a);
|
|
599
609
|
},
|
|
600
|
-
paymentSucceeded: (
|
|
610
|
+
paymentSucceeded: (e) => {
|
|
601
611
|
var a;
|
|
602
|
-
return (a =
|
|
612
|
+
return (a = t == null ? void 0 : t.paymentSuccessListener) == null ? void 0 : a.call(t, e);
|
|
603
613
|
},
|
|
604
|
-
paymentCanceled: (
|
|
614
|
+
paymentCanceled: (e) => {
|
|
605
615
|
var a;
|
|
606
|
-
return (a =
|
|
616
|
+
return (a = t == null ? void 0 : t.paymentCanceledListener) == null ? void 0 : a.call(t, e);
|
|
607
617
|
}
|
|
608
618
|
};
|
|
609
619
|
}
|
|
@@ -616,26 +626,26 @@ class j extends HTMLElement {
|
|
|
616
626
|
connectedCallback() {
|
|
617
627
|
this.isTornDown = !1;
|
|
618
628
|
}
|
|
619
|
-
async initialize(
|
|
620
|
-
const a = z(
|
|
621
|
-
!o || this.isTornDown || (this.engine = o, await o.initialize(
|
|
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 }));
|
|
622
632
|
}
|
|
623
|
-
async loadEngine(
|
|
633
|
+
async loadEngine(e, a) {
|
|
624
634
|
const n = this.getOrLoadEngine();
|
|
625
635
|
try {
|
|
626
636
|
return await n;
|
|
627
637
|
} catch {
|
|
628
638
|
return await this.handleEngineLoadFailure({
|
|
629
639
|
engineLoad: n,
|
|
630
|
-
options:
|
|
640
|
+
options: e,
|
|
631
641
|
sessionLoad: a
|
|
632
642
|
}), null;
|
|
633
643
|
}
|
|
634
644
|
}
|
|
635
|
-
async updateTransaction(
|
|
645
|
+
async updateTransaction(e) {
|
|
636
646
|
if (!this.engine)
|
|
637
647
|
throw new Error("Tether Pay not initialized.");
|
|
638
|
-
await this.engine.updateTransaction(
|
|
648
|
+
await this.engine.updateTransaction(e);
|
|
639
649
|
}
|
|
640
650
|
// A merchant SPA can unmount the element at any time; nothing else stops this
|
|
641
651
|
// instance's timers.
|
|
@@ -645,8 +655,8 @@ class j extends HTMLElement {
|
|
|
645
655
|
// Not started in the constructor: a page can carry the tag and never check out.
|
|
646
656
|
// Overlapping initialize() calls share one download.
|
|
647
657
|
getOrLoadEngine() {
|
|
648
|
-
return this.engineLoadPromise ?? (this.engineLoadPromise = import("./mountEngine-
|
|
649
|
-
const a =
|
|
658
|
+
return this.engineLoadPromise ?? (this.engineLoadPromise = import("./mountEngine-SwisFe5z.js").then((e) => e.m).then((e) => {
|
|
659
|
+
const a = e.mountCheckoutEngine({
|
|
650
660
|
host: this,
|
|
651
661
|
shadowRoot: this.shadow
|
|
652
662
|
});
|
|
@@ -654,11 +664,11 @@ class j extends HTMLElement {
|
|
|
654
664
|
})), this.engineLoadPromise;
|
|
655
665
|
}
|
|
656
666
|
async handleEngineLoadFailure({
|
|
657
|
-
engineLoad:
|
|
667
|
+
engineLoad: e,
|
|
658
668
|
options: a,
|
|
659
669
|
sessionLoad: n
|
|
660
670
|
}) {
|
|
661
|
-
this.engineLoadPromise ===
|
|
671
|
+
this.engineLoadPromise === e && (this.engineLoadPromise = null, await this.reportEngineFailure({ options: a, sessionLoad: n }));
|
|
662
672
|
}
|
|
663
673
|
// A host that removed the element has walked away; a failure report could send
|
|
664
674
|
// it to a failureURL for a checkout it dismissed.
|
|
@@ -670,7 +680,7 @@ class j extends HTMLElement {
|
|
|
670
680
|
// an outcome the gateway has already decided — a session resumed after the
|
|
671
681
|
// payment settled must report that payment, not a dead checkout.
|
|
672
682
|
async reportEngineFailure({
|
|
673
|
-
options:
|
|
683
|
+
options: e,
|
|
674
684
|
sessionLoad: a
|
|
675
685
|
}) {
|
|
676
686
|
if (this.isDismissedByHost)
|
|
@@ -679,7 +689,7 @@ class j extends HTMLElement {
|
|
|
679
689
|
if (this.isDismissedByHost)
|
|
680
690
|
return;
|
|
681
691
|
const o = K();
|
|
682
|
-
o.setOptions(
|
|
692
|
+
o.setOptions(e);
|
|
683
693
|
const r = n.ok && n.linkedTransaction ? H({
|
|
684
694
|
transaction: n.linkedTransaction,
|
|
685
695
|
session: n.session
|
|
@@ -706,70 +716,70 @@ class j extends HTMLElement {
|
|
|
706
716
|
}
|
|
707
717
|
// Always teardown and unmount together to avoid leaking the React engine.
|
|
708
718
|
// Clear the cached load so a later initialize() creates a fresh engine.
|
|
709
|
-
releaseEngine(
|
|
710
|
-
|
|
719
|
+
releaseEngine(e = this.engine) {
|
|
720
|
+
e == null || e.teardown(), e == null || e.unmount(), this.engine = null, this.engineLoadPromise = null;
|
|
711
721
|
}
|
|
712
722
|
}
|
|
713
|
-
function z(
|
|
723
|
+
function z(t) {
|
|
714
724
|
return new R(
|
|
715
|
-
F(
|
|
716
|
-
c(
|
|
725
|
+
F(t),
|
|
726
|
+
c(t) ? void 0 : t.publishableKey
|
|
717
727
|
);
|
|
718
728
|
}
|
|
719
729
|
function J({
|
|
720
|
-
api:
|
|
721
|
-
options:
|
|
730
|
+
api: t,
|
|
731
|
+
options: e
|
|
722
732
|
}) {
|
|
723
|
-
return
|
|
724
|
-
api:
|
|
725
|
-
options:
|
|
726
|
-
emit: (a, n) => T(
|
|
733
|
+
return $({
|
|
734
|
+
api: t,
|
|
735
|
+
options: e,
|
|
736
|
+
emit: (a, n) => T(e.onEvent, a, n)
|
|
727
737
|
});
|
|
728
738
|
}
|
|
729
739
|
customElements.get("lydian-checkout") || customElements.define("lydian-checkout", j);
|
|
730
740
|
function m() {
|
|
731
741
|
return document.querySelector("lydian-checkout");
|
|
732
742
|
}
|
|
733
|
-
async function Q(
|
|
734
|
-
if (!
|
|
743
|
+
async function Q(t) {
|
|
744
|
+
if (!t.publishableKey || !t.transaction.amount || !t.transaction.currency)
|
|
735
745
|
throw new Error("SDK initialization requires publishableKey and a transaction");
|
|
736
|
-
const
|
|
737
|
-
if (
|
|
738
|
-
throw new Error(
|
|
739
|
-
const a = k(
|
|
746
|
+
const e = C(t);
|
|
747
|
+
if (e)
|
|
748
|
+
throw new Error(e);
|
|
749
|
+
const a = k(t);
|
|
740
750
|
if (a)
|
|
741
751
|
throw new Error(a);
|
|
742
|
-
if (!
|
|
752
|
+
if (!S(t.transaction.currency))
|
|
743
753
|
throw new Error("Invalid value for currency, valid values are: " + g.join(", "));
|
|
744
|
-
const n =
|
|
745
|
-
options:
|
|
754
|
+
const n = P({
|
|
755
|
+
options: t,
|
|
746
756
|
unsupportedKeys: ["sessionID"],
|
|
747
757
|
entryPoint: "init"
|
|
748
758
|
});
|
|
749
759
|
if (n)
|
|
750
760
|
throw new Error(n);
|
|
751
|
-
await m().initialize(
|
|
761
|
+
await m().initialize(t);
|
|
752
762
|
}
|
|
753
|
-
async function Z(
|
|
754
|
-
if (!
|
|
763
|
+
async function Z(t) {
|
|
764
|
+
if (!t.sessionID)
|
|
755
765
|
throw new Error("initExistingSession requires a sessionID");
|
|
756
|
-
const
|
|
757
|
-
if (
|
|
758
|
-
throw new Error(
|
|
759
|
-
const a = k(
|
|
766
|
+
const e = C(t);
|
|
767
|
+
if (e)
|
|
768
|
+
throw new Error(e);
|
|
769
|
+
const a = k(t);
|
|
760
770
|
if (a)
|
|
761
771
|
throw new Error(a);
|
|
762
|
-
const n =
|
|
763
|
-
options:
|
|
772
|
+
const n = P({
|
|
773
|
+
options: t,
|
|
764
774
|
unsupportedKeys: ["publishableKey", "transaction"],
|
|
765
775
|
entryPoint: "initExistingSession"
|
|
766
776
|
});
|
|
767
777
|
if (n)
|
|
768
778
|
throw new Error(n);
|
|
769
|
-
await m().initialize(
|
|
779
|
+
await m().initialize(t);
|
|
770
780
|
}
|
|
771
|
-
async function X(
|
|
772
|
-
await m().updateTransaction(
|
|
781
|
+
async function X(t) {
|
|
782
|
+
await m().updateTransaction(t);
|
|
773
783
|
}
|
|
774
784
|
window.Lydian = { init: Q, initExistingSession: Z, updateTransaction: X };
|
|
775
785
|
export {
|
|
@@ -783,15 +793,15 @@ export {
|
|
|
783
793
|
B as f,
|
|
784
794
|
ne as g,
|
|
785
795
|
c as h,
|
|
786
|
-
|
|
787
|
-
|
|
796
|
+
S as i,
|
|
797
|
+
G as j,
|
|
788
798
|
H as k,
|
|
789
799
|
E as l,
|
|
790
800
|
ae as m,
|
|
791
801
|
_ as n,
|
|
792
802
|
ee as o,
|
|
793
803
|
K as p,
|
|
794
|
-
|
|
804
|
+
x as r,
|
|
795
805
|
h as s,
|
|
796
806
|
N as t
|
|
797
807
|
};
|