@lydianpay/sdk-web 3.15.4 → 3.15.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.
- package/dist/chunks/{browser-DNsXaImz.js → browser-CH7eaWyg.js} +1 -1
- package/dist/chunks/{connect-multichain-Ca3bMak3.js → connect-multichain-DUlpFu-U.js} +9 -9
- package/dist/chunks/{index-VdHF6yby.js → index-B0KsTd4q.js} +2 -2
- package/dist/chunks/{index-CcN4gJw2.js → index-BWDzkEUT.js} +1 -1
- package/dist/chunks/{index-CcZ7kGqa.js → index-C3_NkCKr.js} +1 -1
- package/dist/chunks/{index-9_6otDrw.js → index-DLmUAaTw.js} +3 -3
- package/dist/chunks/{index-CwJ0YzMA.js → index-Dgq02q9R.js} +2 -2
- package/dist/chunks/{index-ItSygWuh.js → index-DwADRT3v.js} +277 -243
- package/dist/chunks/{mountEngine-B721ZzjQ.js → mountEngine-Bk-qJ-ZC.js} +6611 -6539
- package/dist/lydian.js +1 -1
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/ui/failureReport.d.ts +3 -1
- package/dist/types/ui/sessionBootstrap.d.ts +5 -1
- package/package.json +1 -1
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
const
|
|
2
|
-
function
|
|
3
|
-
return typeof
|
|
1
|
+
const T = ["USD", "TRY", "PHP"];
|
|
2
|
+
function U(e) {
|
|
3
|
+
return typeof e == "string" && T.includes(e);
|
|
4
4
|
}
|
|
5
|
-
function
|
|
6
|
-
return "sessionID" in
|
|
5
|
+
function l(e) {
|
|
6
|
+
return "sessionID" in e && typeof e.sessionID == "string" && e.sessionID.length > 0;
|
|
7
7
|
}
|
|
8
|
-
class
|
|
8
|
+
class p {
|
|
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(t, a) {
|
|
13
|
+
if (this.baseUri = t, 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(t) {
|
|
19
|
+
const a = { ...t };
|
|
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(t, a) {
|
|
23
|
+
const n = `${this.baseUri}${t}`, 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
|
-
throw new Error(s.statusText);
|
|
26
|
+
throw new Error(s.statusText, { cause: s });
|
|
27
27
|
}
|
|
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(t, a) {
|
|
32
|
+
const n = `${this.baseUri}${t}`, 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(t, a) {
|
|
38
|
+
const n = `${this.baseUri}${t}`, 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 c = "transaction";
|
|
45
|
+
class R extends p {
|
|
46
|
+
async getCryptoTransaction(t) {
|
|
47
|
+
return await this.request(`/${c}/${t}`);
|
|
48
48
|
}
|
|
49
|
-
async createPaymentRequest(
|
|
49
|
+
async createPaymentRequest(t, a) {
|
|
50
50
|
return await this.request(
|
|
51
|
-
`/${
|
|
51
|
+
`/${c}/${t}/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(t, a, n) {
|
|
59
59
|
return await this.request(
|
|
60
|
-
`/${
|
|
60
|
+
`/${c}/${t}/payment/${a}/transfer`,
|
|
61
61
|
{
|
|
62
62
|
method: "POST",
|
|
63
63
|
body: JSON.stringify(n)
|
|
64
64
|
}
|
|
65
65
|
);
|
|
66
66
|
}
|
|
67
|
-
async broadcastTransfer(
|
|
67
|
+
async broadcastTransfer(t, a, n) {
|
|
68
68
|
return await this.request(
|
|
69
|
-
`/${
|
|
69
|
+
`/${c}/${t}/payment/${a}/transfer/broadcast`,
|
|
70
70
|
{
|
|
71
71
|
method: "POST",
|
|
72
72
|
body: JSON.stringify(n)
|
|
73
73
|
}
|
|
74
74
|
);
|
|
75
75
|
}
|
|
76
|
-
async cancelCryptoTransaction(
|
|
76
|
+
async cancelCryptoTransaction(t, a) {
|
|
77
77
|
return await this.request(
|
|
78
|
-
`/${
|
|
78
|
+
`/${c}/${t}/cancel`,
|
|
79
79
|
{
|
|
80
80
|
method: "PATCH",
|
|
81
81
|
body: JSON.stringify(a)
|
|
82
82
|
}
|
|
83
83
|
);
|
|
84
84
|
}
|
|
85
|
-
async kycVerification(
|
|
85
|
+
async kycVerification(t, a) {
|
|
86
86
|
const n = new FormData();
|
|
87
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(
|
|
88
|
-
`/${
|
|
88
|
+
`/${c}/${t}/verification`,
|
|
89
89
|
{
|
|
90
90
|
method: "POST",
|
|
91
91
|
body: n
|
|
@@ -93,48 +93,48 @@ class A extends y {
|
|
|
93
93
|
);
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
-
function
|
|
97
|
-
|
|
96
|
+
function O(e, t) {
|
|
97
|
+
t.forEach((a) => {
|
|
98
98
|
Object.getOwnPropertyNames(a.prototype).forEach((n) => {
|
|
99
99
|
const o = Object.getOwnPropertyDescriptor(a.prototype, n);
|
|
100
|
-
o && Object.defineProperty(
|
|
100
|
+
o && Object.defineProperty(e.prototype, n, o);
|
|
101
101
|
});
|
|
102
102
|
});
|
|
103
103
|
}
|
|
104
|
-
const
|
|
105
|
-
class
|
|
104
|
+
const b = "customer/otp";
|
|
105
|
+
class F extends p {
|
|
106
106
|
// PATCH /customer/otp -> text/plain "OTP sent" (no JSON body).
|
|
107
|
-
async sendCustomerOTP(
|
|
108
|
-
return await this.requestText(`/${
|
|
107
|
+
async sendCustomerOTP(t) {
|
|
108
|
+
return await this.requestText(`/${b}`, {
|
|
109
109
|
method: "PATCH",
|
|
110
|
-
body: JSON.stringify(
|
|
110
|
+
body: JSON.stringify(t)
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
113
|
// PUT /customer/otp -> { customerUUID, kycValidated }.
|
|
114
|
-
async authenticateCustomerOTP(
|
|
115
|
-
return await this.request(`/${
|
|
114
|
+
async authenticateCustomerOTP(t) {
|
|
115
|
+
return await this.request(`/${b}`, {
|
|
116
116
|
method: "PUT",
|
|
117
|
-
body: JSON.stringify(
|
|
117
|
+
body: JSON.stringify(t)
|
|
118
118
|
});
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
const d = "session";
|
|
122
|
-
class
|
|
123
|
-
async createSession(
|
|
122
|
+
class W extends p {
|
|
123
|
+
async createSession(t) {
|
|
124
124
|
return await this.request(`/${d}`, {
|
|
125
125
|
method: "POST",
|
|
126
|
-
body: JSON.stringify(
|
|
126
|
+
body: JSON.stringify(t)
|
|
127
127
|
});
|
|
128
128
|
}
|
|
129
|
-
async getSession(
|
|
130
|
-
return await this.request(`/${d}/${
|
|
129
|
+
async getSession(t) {
|
|
130
|
+
return await this.request(`/${d}/${t}`);
|
|
131
131
|
}
|
|
132
132
|
// Promotes the session into a transaction. Allowed once per session — except
|
|
133
133
|
// that a KYC-pending (-3) response does not consume the promotion, which is
|
|
134
134
|
// what lets the restore-details flow re-promote with a customerUUID.
|
|
135
|
-
async createSessionTransaction(
|
|
135
|
+
async createSessionTransaction(t, a) {
|
|
136
136
|
return await this.request(
|
|
137
|
-
`/${d}/${
|
|
137
|
+
`/${d}/${t}/transaction`,
|
|
138
138
|
{
|
|
139
139
|
method: "POST",
|
|
140
140
|
body: JSON.stringify(a)
|
|
@@ -143,16 +143,16 @@ class U extends y {
|
|
|
143
143
|
}
|
|
144
144
|
// PATCH /session/{id}/cancel replies text/plain (the merchant's cancel URL),
|
|
145
145
|
// not JSON. Cancelling cascades to the linked transaction, if any.
|
|
146
|
-
async cancelSession(
|
|
147
|
-
return await this.requestText(`/${d}/${
|
|
146
|
+
async cancelSession(t) {
|
|
147
|
+
return await this.requestText(`/${d}/${t}/cancel`, {
|
|
148
148
|
method: "PATCH"
|
|
149
149
|
});
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
|
-
class
|
|
152
|
+
class v extends p {
|
|
153
153
|
}
|
|
154
|
-
|
|
155
|
-
const
|
|
154
|
+
O(v, [R, F, W]);
|
|
155
|
+
const $ = v;
|
|
156
156
|
var u = {
|
|
157
157
|
COMPLIANCE_PENDING: -10,
|
|
158
158
|
API_CANCELLED: -9,
|
|
@@ -170,153 +170,170 @@ var u = {
|
|
|
170
170
|
FRAUD: -1,
|
|
171
171
|
PENDING: 0,
|
|
172
172
|
SUCCESS: 1
|
|
173
|
-
},
|
|
173
|
+
}, ne = {
|
|
174
174
|
PARTIALLY_PAID: 1,
|
|
175
175
|
OVERPAID: 3
|
|
176
|
-
},
|
|
176
|
+
}, x = {
|
|
177
177
|
PENDING: 0,
|
|
178
178
|
CONFIRMED: 1
|
|
179
|
-
},
|
|
179
|
+
}, m = {
|
|
180
180
|
dev: "https://api.lydian.dev",
|
|
181
181
|
sandbox: "https://api.sandbox.lydian.com",
|
|
182
182
|
prod: "https://api.lydian.com"
|
|
183
183
|
};
|
|
184
|
-
function
|
|
185
|
-
return
|
|
184
|
+
function M(e) {
|
|
185
|
+
return e.gatewayUrl ? new URL(e.gatewayUrl).origin : e.dev ? m.dev : e.sandbox ? m.sandbox : m.prod;
|
|
186
186
|
}
|
|
187
|
-
function
|
|
188
|
-
options:
|
|
189
|
-
unsupportedKeys:
|
|
187
|
+
function E({
|
|
188
|
+
options: e,
|
|
189
|
+
unsupportedKeys: t,
|
|
190
190
|
entryPoint: a
|
|
191
191
|
}) {
|
|
192
|
-
const n =
|
|
192
|
+
const n = t.filter((o) => e[o] !== void 0);
|
|
193
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.`;
|
|
194
194
|
}
|
|
195
|
-
function
|
|
196
|
-
var
|
|
197
|
-
return (
|
|
195
|
+
function S(e) {
|
|
196
|
+
var t;
|
|
197
|
+
return (t = e.flow) != null && t.walletConnect && !e.walletConnectProjectId ? "walletConnectProjectId is required when flow.walletConnect is on" : null;
|
|
198
198
|
}
|
|
199
|
-
function
|
|
200
|
-
return
|
|
199
|
+
function D(e) {
|
|
200
|
+
return e.gatewayUrl === void 0 || Y(e.gatewayUrl) ? null : `gatewayUrl must be an http(s) origin such as http://localhost:8000, with no path, got ${JSON.stringify(e.gatewayUrl)}`;
|
|
201
201
|
}
|
|
202
|
-
function
|
|
203
|
-
let
|
|
202
|
+
function Y(e) {
|
|
203
|
+
let t;
|
|
204
204
|
try {
|
|
205
|
-
|
|
205
|
+
t = new URL(e);
|
|
206
206
|
} catch {
|
|
207
207
|
return !1;
|
|
208
208
|
}
|
|
209
|
-
return (
|
|
209
|
+
return (t.protocol === "http:" || t.protocol === "https:") && t.pathname === "/" && t.search === "" && t.hash === "";
|
|
210
210
|
}
|
|
211
|
-
function
|
|
212
|
-
return
|
|
211
|
+
function oe(e) {
|
|
212
|
+
return e !== null && !l(e) && !!e.publishableKey;
|
|
213
213
|
}
|
|
214
|
-
function
|
|
215
|
-
return
|
|
214
|
+
function re(e) {
|
|
215
|
+
return e !== null && !l(e);
|
|
216
216
|
}
|
|
217
|
-
function
|
|
218
|
-
options:
|
|
219
|
-
session:
|
|
217
|
+
function se({
|
|
218
|
+
options: e,
|
|
219
|
+
session: t,
|
|
220
220
|
settled: a
|
|
221
221
|
}) {
|
|
222
|
-
return !a &&
|
|
222
|
+
return !a && t !== null && e !== null && l(e);
|
|
223
223
|
}
|
|
224
|
-
function
|
|
224
|
+
function N(e, t, a) {
|
|
225
225
|
try {
|
|
226
|
-
|
|
226
|
+
e == null || e(t, a);
|
|
227
227
|
} catch (n) {
|
|
228
|
-
console.error(`onEvent("${
|
|
228
|
+
console.error(`onEvent("${t}") threw:`, n);
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
231
|
+
function y(e) {
|
|
232
|
+
if (!e)
|
|
233
|
+
return;
|
|
234
|
+
let t;
|
|
235
|
+
try {
|
|
236
|
+
t = new URL(e);
|
|
237
|
+
} catch {
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
return t.protocol === "https:" || t.protocol === "http:" ? e : void 0;
|
|
241
|
+
}
|
|
242
|
+
async function B({
|
|
243
|
+
api: e,
|
|
244
|
+
options: t,
|
|
234
245
|
emit: a
|
|
235
246
|
}) {
|
|
236
247
|
try {
|
|
237
|
-
const n = await
|
|
238
|
-
a("session.loaded",
|
|
239
|
-
const s = await
|
|
240
|
-
api:
|
|
248
|
+
const n = await q({ api: e, options: t }), { session: o, sessionPromoted: r } = await G({ api: e, sessionID: n });
|
|
249
|
+
a("session.loaded", H(o));
|
|
250
|
+
const s = await K({
|
|
251
|
+
api: e,
|
|
241
252
|
transactionID: o.transactionID
|
|
242
253
|
});
|
|
243
254
|
return { ok: !0, session: o, sessionPromoted: r, linkedTransaction: s };
|
|
255
|
+
} catch (n) {
|
|
256
|
+
return { ok: !1, ...await _(n) };
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
async function _(e) {
|
|
260
|
+
const t = e instanceof Error ? e.cause : void 0;
|
|
261
|
+
if (!(t instanceof Response && t.status === 404))
|
|
262
|
+
return {};
|
|
263
|
+
try {
|
|
264
|
+
const n = await t.json();
|
|
265
|
+
return {
|
|
266
|
+
failureURL: P(n == null ? void 0 : n.failureURL),
|
|
267
|
+
cancelURL: P(n == null ? void 0 : n.cancelURL)
|
|
268
|
+
};
|
|
244
269
|
} catch {
|
|
245
|
-
return {
|
|
270
|
+
return {};
|
|
246
271
|
}
|
|
247
272
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
273
|
+
function P(e) {
|
|
274
|
+
return typeof e == "string" ? y(e) : void 0;
|
|
275
|
+
}
|
|
276
|
+
async function q({
|
|
277
|
+
api: e,
|
|
278
|
+
options: t
|
|
251
279
|
}) {
|
|
252
|
-
return
|
|
253
|
-
amount:
|
|
254
|
-
amountCurrency:
|
|
255
|
-
descriptor:
|
|
256
|
-
referenceNumber:
|
|
280
|
+
return l(t) ? t.sessionID : (await e.createSession({
|
|
281
|
+
amount: t.transaction.amount,
|
|
282
|
+
amountCurrency: t.transaction.currency,
|
|
283
|
+
descriptor: t.transaction.descriptor,
|
|
284
|
+
referenceNumber: t.transaction.referenceNumber
|
|
257
285
|
})).sessionID;
|
|
258
286
|
}
|
|
259
|
-
async function
|
|
260
|
-
api:
|
|
261
|
-
sessionID:
|
|
287
|
+
async function G({
|
|
288
|
+
api: e,
|
|
289
|
+
sessionID: t
|
|
262
290
|
}) {
|
|
263
|
-
const a = await
|
|
264
|
-
return { session: a, sessionPromoted:
|
|
291
|
+
const a = await e.getSession(t);
|
|
292
|
+
return { session: a, sessionPromoted: A(a) };
|
|
265
293
|
}
|
|
266
|
-
function
|
|
294
|
+
function H(e) {
|
|
267
295
|
return {
|
|
268
|
-
sessionID:
|
|
269
|
-
merchantName:
|
|
270
|
-
alreadyPromoted:
|
|
296
|
+
sessionID: e.sessionID,
|
|
297
|
+
merchantName: e.merchantName,
|
|
298
|
+
alreadyPromoted: A(e)
|
|
271
299
|
};
|
|
272
300
|
}
|
|
273
|
-
function
|
|
274
|
-
return !!
|
|
301
|
+
function A(e) {
|
|
302
|
+
return !!e.transactionID;
|
|
275
303
|
}
|
|
276
|
-
async function
|
|
277
|
-
api:
|
|
278
|
-
transactionID:
|
|
304
|
+
async function K({
|
|
305
|
+
api: e,
|
|
306
|
+
transactionID: t
|
|
279
307
|
}) {
|
|
280
|
-
if (!
|
|
308
|
+
if (!t)
|
|
281
309
|
return null;
|
|
282
310
|
try {
|
|
283
|
-
return await
|
|
311
|
+
return await e.getCryptoTransaction(t);
|
|
284
312
|
} catch (a) {
|
|
285
313
|
return console.error("Failed to resolve the session transaction:", a), null;
|
|
286
314
|
}
|
|
287
315
|
}
|
|
288
|
-
function
|
|
289
|
-
|
|
290
|
-
|
|
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,
|
|
316
|
+
function C({
|
|
317
|
+
message: e,
|
|
318
|
+
reason: t,
|
|
302
319
|
shouldEndCheckout: a,
|
|
303
320
|
transactionID: n,
|
|
304
321
|
session: o
|
|
305
322
|
}) {
|
|
306
323
|
return {
|
|
307
|
-
event: { reason:
|
|
324
|
+
event: { reason: t, shouldEndCheckout: a, message: e },
|
|
308
325
|
failure: {
|
|
309
326
|
shouldEndCheckout: a,
|
|
310
|
-
reason:
|
|
327
|
+
reason: t,
|
|
311
328
|
transactionID: n,
|
|
312
329
|
// Only a failure that ends the checkout carries a redirect. A retryable one
|
|
313
330
|
// leaves the customer mid-flow with something still to do, and a host that
|
|
314
331
|
// navigated on it would eject them on a hiccup.
|
|
315
|
-
redirectURL: a ?
|
|
332
|
+
redirectURL: a ? y(o == null ? void 0 : o.failureURL) : void 0
|
|
316
333
|
}
|
|
317
334
|
};
|
|
318
335
|
}
|
|
319
|
-
const
|
|
336
|
+
const j = {
|
|
320
337
|
"common.cancelTransaction": "Cancel Transaction",
|
|
321
338
|
"common.cancel": "Cancel",
|
|
322
339
|
"common.back": "Back",
|
|
@@ -464,6 +481,9 @@ const q = {
|
|
|
464
481
|
"success.totalAmountPaid": "Total amount paid",
|
|
465
482
|
"success.cryptoMethod": "Crypto – {asset} on {network}",
|
|
466
483
|
"success.cryptoMethodWallet": "Crypto – {wallet}",
|
|
484
|
+
"success.cryptoMethodInParts": "Crypto – paid in {count} parts",
|
|
485
|
+
"success.paymentPart": "Part {part}",
|
|
486
|
+
"success.paymentPartAmount": "{amount} on {network}",
|
|
467
487
|
"success.getAppHeading": "GET THE APP",
|
|
468
488
|
"success.getAppBody": "Want a simpler checkout experience? Try the <strong>Lydian Wallet</strong> next time.",
|
|
469
489
|
"success.downloadFromAppStore": "Download from the App Store",
|
|
@@ -539,85 +559,85 @@ const q = {
|
|
|
539
559
|
"validation.customerDetailsMissing": "Customer details are missing.",
|
|
540
560
|
"validation.invalidOtp": "Please enter a valid 6-digit code.",
|
|
541
561
|
"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
|
-
},
|
|
543
|
-
let
|
|
544
|
-
function
|
|
545
|
-
return
|
|
562
|
+
}, k = { en: j }, I = "en";
|
|
563
|
+
let L = I;
|
|
564
|
+
function ie() {
|
|
565
|
+
return L;
|
|
546
566
|
}
|
|
547
|
-
function
|
|
567
|
+
function h(e, t) {
|
|
548
568
|
var n;
|
|
549
|
-
const a = ((n =
|
|
550
|
-
return
|
|
569
|
+
const a = ((n = k[L]) == null ? void 0 : n[e]) ?? k[I][e] ?? e;
|
|
570
|
+
return t ? a.replace(
|
|
551
571
|
/\{(\w+)\}/g,
|
|
552
|
-
(o, r) =>
|
|
572
|
+
(o, r) => t[r] != null ? String(t[r]) : `{${r}}`
|
|
553
573
|
) : a;
|
|
554
574
|
}
|
|
555
|
-
function
|
|
556
|
-
return
|
|
575
|
+
function z(e) {
|
|
576
|
+
return e === u.SUCCESS ? "succeeded" : e < u.PENDING && e !== u.KYC_VERIFICATION_PENDING && e !== u.COMPLIANCE_PENDING ? "failed" : "active";
|
|
557
577
|
}
|
|
558
|
-
function
|
|
559
|
-
transaction:
|
|
560
|
-
session:
|
|
578
|
+
function J({
|
|
579
|
+
transaction: e,
|
|
580
|
+
session: t
|
|
561
581
|
}) {
|
|
562
582
|
var o, r, s;
|
|
563
|
-
const a =
|
|
583
|
+
const a = z(e.status);
|
|
564
584
|
if (a === "active")
|
|
565
585
|
return null;
|
|
566
586
|
if (a === "failed")
|
|
567
587
|
return {
|
|
568
588
|
outcome: a,
|
|
569
|
-
message:
|
|
589
|
+
message: h("errors.paymentCouldNotComplete"),
|
|
570
590
|
failure: {
|
|
571
591
|
shouldEndCheckout: !0,
|
|
572
592
|
// Negative (non-KYC) status — cancelled / fraud / timeout.
|
|
573
593
|
reason: "blocked",
|
|
574
|
-
transactionID:
|
|
575
|
-
redirectURL:
|
|
594
|
+
transactionID: e.transactionID,
|
|
595
|
+
redirectURL: y(t == null ? void 0 : t.failureURL)
|
|
576
596
|
}
|
|
577
597
|
};
|
|
578
|
-
const n = (o =
|
|
579
|
-
(i) => i.status ===
|
|
598
|
+
const n = (o = e.payments) == null ? void 0 : o.find(
|
|
599
|
+
(i) => i.status === x.CONFIRMED
|
|
580
600
|
);
|
|
581
601
|
return {
|
|
582
602
|
outcome: a,
|
|
583
603
|
event: {
|
|
584
|
-
transactionID:
|
|
604
|
+
transactionID: e.transactionID,
|
|
585
605
|
asset: n == null ? void 0 : n.cryptoAsset,
|
|
586
606
|
network: n == null ? void 0 : n.cryptoNetwork
|
|
587
607
|
},
|
|
588
608
|
result: {
|
|
589
|
-
transactionID:
|
|
590
|
-
amount: (r =
|
|
591
|
-
currency: (s =
|
|
609
|
+
transactionID: e.transactionID,
|
|
610
|
+
amount: (r = e.amounts) == null ? void 0 : r.totalLocal,
|
|
611
|
+
currency: (s = e.amounts) == null ? void 0 : s.currency,
|
|
592
612
|
asset: n == null ? void 0 : n.cryptoAsset,
|
|
593
613
|
network: n == null ? void 0 : n.cryptoNetwork,
|
|
594
614
|
completedAt: n == null ? void 0 : n.completedAt,
|
|
595
|
-
redirectURL:
|
|
615
|
+
redirectURL: y(t == null ? void 0 : t.successURL)
|
|
596
616
|
}
|
|
597
617
|
};
|
|
598
618
|
}
|
|
599
|
-
function
|
|
600
|
-
let
|
|
619
|
+
function Q() {
|
|
620
|
+
let e = null;
|
|
601
621
|
return {
|
|
602
|
-
setOptions: (
|
|
603
|
-
|
|
622
|
+
setOptions: (t) => {
|
|
623
|
+
e = t;
|
|
604
624
|
},
|
|
605
|
-
emit: (
|
|
606
|
-
paymentFailed: (
|
|
625
|
+
emit: (t, a) => N(e == null ? void 0 : e.onEvent, t, a),
|
|
626
|
+
paymentFailed: (t, a) => {
|
|
607
627
|
var n;
|
|
608
|
-
return (n =
|
|
628
|
+
return (n = e == null ? void 0 : e.paymentFailedListener) == null ? void 0 : n.call(e, t, a);
|
|
609
629
|
},
|
|
610
|
-
paymentSucceeded: (
|
|
630
|
+
paymentSucceeded: (t) => {
|
|
611
631
|
var a;
|
|
612
|
-
return (a =
|
|
632
|
+
return (a = e == null ? void 0 : e.paymentSuccessListener) == null ? void 0 : a.call(e, t);
|
|
613
633
|
},
|
|
614
|
-
paymentCanceled: (
|
|
634
|
+
paymentCanceled: (t) => {
|
|
615
635
|
var a;
|
|
616
|
-
return (a =
|
|
636
|
+
return (a = e == null ? void 0 : e.paymentCanceledListener) == null ? void 0 : a.call(e, t);
|
|
617
637
|
}
|
|
618
638
|
};
|
|
619
639
|
}
|
|
620
|
-
class
|
|
640
|
+
class Z extends HTMLElement {
|
|
621
641
|
constructor() {
|
|
622
642
|
super(), this.engine = null, this.engineLoadPromise = null, this.isTornDown = !1, this.shadow = this.attachShadow({ mode: "open" });
|
|
623
643
|
}
|
|
@@ -626,26 +646,26 @@ class j extends HTMLElement {
|
|
|
626
646
|
connectedCallback() {
|
|
627
647
|
this.isTornDown = !1;
|
|
628
648
|
}
|
|
629
|
-
async initialize(
|
|
630
|
-
const a =
|
|
631
|
-
!o || this.isTornDown || (this.engine = o, await o.initialize(
|
|
649
|
+
async initialize(t) {
|
|
650
|
+
const a = X(t), n = V({ api: a, options: t }), o = await this.loadEngine(t, n);
|
|
651
|
+
!o || this.isTornDown || (this.engine = o, await o.initialize(t, { api: a, sessionLoad: n }));
|
|
632
652
|
}
|
|
633
|
-
async loadEngine(
|
|
653
|
+
async loadEngine(t, a) {
|
|
634
654
|
const n = this.getOrLoadEngine();
|
|
635
655
|
try {
|
|
636
656
|
return await n;
|
|
637
657
|
} catch {
|
|
638
658
|
return await this.handleEngineLoadFailure({
|
|
639
659
|
engineLoad: n,
|
|
640
|
-
options:
|
|
660
|
+
options: t,
|
|
641
661
|
sessionLoad: a
|
|
642
662
|
}), null;
|
|
643
663
|
}
|
|
644
664
|
}
|
|
645
|
-
async updateTransaction(
|
|
665
|
+
async updateTransaction(t) {
|
|
646
666
|
if (!this.engine)
|
|
647
667
|
throw new Error("Tether Pay not initialized.");
|
|
648
|
-
await this.engine.updateTransaction(
|
|
668
|
+
await this.engine.updateTransaction(t);
|
|
649
669
|
}
|
|
650
670
|
// A merchant SPA can unmount the element at any time; nothing else stops this
|
|
651
671
|
// instance's timers.
|
|
@@ -655,8 +675,8 @@ class j extends HTMLElement {
|
|
|
655
675
|
// Not started in the constructor: a page can carry the tag and never check out.
|
|
656
676
|
// Overlapping initialize() calls share one download.
|
|
657
677
|
getOrLoadEngine() {
|
|
658
|
-
return this.engineLoadPromise ?? (this.engineLoadPromise = import("./mountEngine-
|
|
659
|
-
const a =
|
|
678
|
+
return this.engineLoadPromise ?? (this.engineLoadPromise = import("./mountEngine-Bk-qJ-ZC.js").then((t) => t.m).then((t) => {
|
|
679
|
+
const a = t.mountCheckoutEngine({
|
|
660
680
|
host: this,
|
|
661
681
|
shadowRoot: this.shadow
|
|
662
682
|
});
|
|
@@ -664,11 +684,11 @@ class j extends HTMLElement {
|
|
|
664
684
|
})), this.engineLoadPromise;
|
|
665
685
|
}
|
|
666
686
|
async handleEngineLoadFailure({
|
|
667
|
-
engineLoad:
|
|
687
|
+
engineLoad: t,
|
|
668
688
|
options: a,
|
|
669
689
|
sessionLoad: n
|
|
670
690
|
}) {
|
|
671
|
-
this.engineLoadPromise ===
|
|
691
|
+
this.engineLoadPromise === t && (this.engineLoadPromise = null, await this.reportEngineFailure({ options: a, sessionLoad: n }));
|
|
672
692
|
}
|
|
673
693
|
// A host that removed the element has walked away; a failure report could send
|
|
674
694
|
// it to a failureURL for a checkout it dismissed.
|
|
@@ -680,7 +700,7 @@ class j extends HTMLElement {
|
|
|
680
700
|
// an outcome the gateway has already decided — a session resumed after the
|
|
681
701
|
// payment settled must report that payment, not a dead checkout.
|
|
682
702
|
async reportEngineFailure({
|
|
683
|
-
options:
|
|
703
|
+
options: t,
|
|
684
704
|
sessionLoad: a
|
|
685
705
|
}) {
|
|
686
706
|
if (this.isDismissedByHost)
|
|
@@ -688,9 +708,9 @@ class j extends HTMLElement {
|
|
|
688
708
|
const n = await a;
|
|
689
709
|
if (this.isDismissedByHost)
|
|
690
710
|
return;
|
|
691
|
-
const o =
|
|
692
|
-
o.setOptions(
|
|
693
|
-
const r = n.ok && n.linkedTransaction ?
|
|
711
|
+
const o = Q();
|
|
712
|
+
o.setOptions(t);
|
|
713
|
+
const r = n.ok && n.linkedTransaction ? J({
|
|
694
714
|
transaction: n.linkedTransaction,
|
|
695
715
|
session: n.session
|
|
696
716
|
}) : null;
|
|
@@ -706,7 +726,21 @@ class j extends HTMLElement {
|
|
|
706
726
|
}), o.paymentFailed(r.message, r.failure);
|
|
707
727
|
return;
|
|
708
728
|
}
|
|
709
|
-
|
|
729
|
+
if (!n.ok && n.cancelURL) {
|
|
730
|
+
o.emit("payment.canceled"), o.paymentCanceled({ redirectURL: n.cancelURL });
|
|
731
|
+
return;
|
|
732
|
+
}
|
|
733
|
+
if (!n.ok && n.failureURL) {
|
|
734
|
+
const f = h("errors.unableToCreateSession"), g = C({
|
|
735
|
+
message: f,
|
|
736
|
+
reason: "sessionExpired",
|
|
737
|
+
shouldEndCheckout: !0,
|
|
738
|
+
session: { failureURL: n.failureURL }
|
|
739
|
+
});
|
|
740
|
+
o.emit("payment.failed", g.event), o.paymentFailed(f, g.failure);
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
743
|
+
const s = h("errors.checkoutUnavailable"), i = C({
|
|
710
744
|
message: s,
|
|
711
745
|
reason: "error",
|
|
712
746
|
shouldEndCheckout: !0,
|
|
@@ -716,92 +750,92 @@ class j extends HTMLElement {
|
|
|
716
750
|
}
|
|
717
751
|
// Always teardown and unmount together to avoid leaking the React engine.
|
|
718
752
|
// Clear the cached load so a later initialize() creates a fresh engine.
|
|
719
|
-
releaseEngine(
|
|
720
|
-
|
|
753
|
+
releaseEngine(t = this.engine) {
|
|
754
|
+
t == null || t.teardown(), t == null || t.unmount(), this.engine = null, this.engineLoadPromise = null;
|
|
721
755
|
}
|
|
722
756
|
}
|
|
723
|
-
function
|
|
724
|
-
return new
|
|
725
|
-
|
|
726
|
-
|
|
757
|
+
function X(e) {
|
|
758
|
+
return new $(
|
|
759
|
+
M(e),
|
|
760
|
+
l(e) ? void 0 : e.publishableKey
|
|
727
761
|
);
|
|
728
762
|
}
|
|
729
|
-
function
|
|
730
|
-
api:
|
|
731
|
-
options:
|
|
763
|
+
function V({
|
|
764
|
+
api: e,
|
|
765
|
+
options: t
|
|
732
766
|
}) {
|
|
733
|
-
return
|
|
734
|
-
api:
|
|
735
|
-
options:
|
|
736
|
-
emit: (a, n) =>
|
|
767
|
+
return B({
|
|
768
|
+
api: e,
|
|
769
|
+
options: t,
|
|
770
|
+
emit: (a, n) => N(t.onEvent, a, n)
|
|
737
771
|
});
|
|
738
772
|
}
|
|
739
|
-
customElements.get("lydian-checkout") || customElements.define("lydian-checkout",
|
|
740
|
-
function
|
|
773
|
+
customElements.get("lydian-checkout") || customElements.define("lydian-checkout", Z);
|
|
774
|
+
function w() {
|
|
741
775
|
return document.querySelector("lydian-checkout");
|
|
742
776
|
}
|
|
743
|
-
async function
|
|
744
|
-
if (!
|
|
777
|
+
async function ee(e) {
|
|
778
|
+
if (!e.publishableKey || !e.transaction.amount || !e.transaction.currency)
|
|
745
779
|
throw new Error("SDK initialization requires publishableKey and a transaction");
|
|
746
|
-
const
|
|
747
|
-
if (
|
|
748
|
-
throw new Error(
|
|
749
|
-
const a =
|
|
780
|
+
const t = S(e);
|
|
781
|
+
if (t)
|
|
782
|
+
throw new Error(t);
|
|
783
|
+
const a = D(e);
|
|
750
784
|
if (a)
|
|
751
785
|
throw new Error(a);
|
|
752
|
-
if (!
|
|
753
|
-
throw new Error("Invalid value for currency, valid values are: " +
|
|
754
|
-
const n =
|
|
755
|
-
options:
|
|
786
|
+
if (!U(e.transaction.currency))
|
|
787
|
+
throw new Error("Invalid value for currency, valid values are: " + T.join(", "));
|
|
788
|
+
const n = E({
|
|
789
|
+
options: e,
|
|
756
790
|
unsupportedKeys: ["sessionID"],
|
|
757
791
|
entryPoint: "init"
|
|
758
792
|
});
|
|
759
793
|
if (n)
|
|
760
794
|
throw new Error(n);
|
|
761
|
-
await
|
|
795
|
+
await w().initialize(e);
|
|
762
796
|
}
|
|
763
|
-
async function
|
|
764
|
-
if (!
|
|
797
|
+
async function te(e) {
|
|
798
|
+
if (!e.sessionID)
|
|
765
799
|
throw new Error("initExistingSession requires a sessionID");
|
|
766
|
-
const
|
|
767
|
-
if (
|
|
768
|
-
throw new Error(
|
|
769
|
-
const a =
|
|
800
|
+
const t = S(e);
|
|
801
|
+
if (t)
|
|
802
|
+
throw new Error(t);
|
|
803
|
+
const a = D(e);
|
|
770
804
|
if (a)
|
|
771
805
|
throw new Error(a);
|
|
772
|
-
const n =
|
|
773
|
-
options:
|
|
806
|
+
const n = E({
|
|
807
|
+
options: e,
|
|
774
808
|
unsupportedKeys: ["publishableKey", "transaction"],
|
|
775
809
|
entryPoint: "initExistingSession"
|
|
776
810
|
});
|
|
777
811
|
if (n)
|
|
778
812
|
throw new Error(n);
|
|
779
|
-
await
|
|
813
|
+
await w().initialize(e);
|
|
780
814
|
}
|
|
781
|
-
async function
|
|
782
|
-
await
|
|
815
|
+
async function ae(e) {
|
|
816
|
+
await w().updateTransaction(e);
|
|
783
817
|
}
|
|
784
|
-
window.Lydian = { init:
|
|
818
|
+
window.Lydian = { init: ee, initExistingSession: te, updateTransaction: ae };
|
|
785
819
|
export {
|
|
786
|
-
|
|
820
|
+
ne as P,
|
|
787
821
|
u as T,
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
822
|
+
x as a,
|
|
823
|
+
re as b,
|
|
824
|
+
T as c,
|
|
825
|
+
G as d,
|
|
826
|
+
H as e,
|
|
827
|
+
K as f,
|
|
828
|
+
ie as g,
|
|
829
|
+
l as h,
|
|
830
|
+
U as i,
|
|
831
|
+
z as j,
|
|
832
|
+
J as k,
|
|
833
|
+
A as l,
|
|
834
|
+
se as m,
|
|
835
|
+
C as n,
|
|
836
|
+
oe as o,
|
|
837
|
+
Q as p,
|
|
838
|
+
q as r,
|
|
839
|
+
y as s,
|
|
840
|
+
h as t
|
|
807
841
|
};
|