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