@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.
- package/dist/chunks/{browser-DNsXaImz.js → browser-CvvbM3fl.js} +1 -1
- package/dist/chunks/{connect-multichain-Ca3bMak3.js → connect-multichain-JrYKtq5o.js} +9 -9
- package/dist/chunks/{index-CcN4gJw2.js → index-Bwl_cWLK.js} +1 -1
- package/dist/chunks/{index-VdHF6yby.js → index-CD8P_mOo.js} +2 -2
- package/dist/chunks/{index-CcZ7kGqa.js → index-DAsQ6TuK.js} +1 -1
- package/dist/chunks/{index-9_6otDrw.js → index-DFLPr81C.js} +3 -3
- package/dist/chunks/{index-CwJ0YzMA.js → index-DGLVpgOJ.js} +2 -2
- package/dist/chunks/{index-ItSygWuh.js → index-GdvVEXe8.js} +318 -247
- package/dist/chunks/{mountEngine-B721ZzjQ.js → mountEngine-B9qRQyLg.js} +11153 -10944
- package/dist/lydian.js +1 -1
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/network/gatewayRequestError.d.ts +9 -0
- package/dist/types/network/session/index.d.ts +2 -1
- package/dist/types/types.d.ts +6 -0
- package/dist/types/ui/failureReport.d.ts +3 -1
- package/dist/types/ui/flowConfig.d.ts +1 -0
- package/dist/types/ui/react/AlertBanner.d.ts +1 -1
- package/dist/types/ui/react/CheckboxField.d.ts +8 -0
- package/dist/types/ui/react/EmailReceiptCard/EmailReceiptCard.d.ts +4 -0
- package/dist/types/ui/react/EmailReceiptCard/EmailReceiptForm.d.ts +7 -0
- package/dist/types/ui/react/EmailReceiptCard/emailReceiptHelpers.d.ts +7 -0
- package/dist/types/ui/react/EmailReceiptCard/useEmailReceiptSender.d.ts +7 -0
- package/dist/types/ui/react/FormField.d.ts +2 -1
- package/dist/types/ui/react/checkoutStore.d.ts +2 -1
- package/dist/types/ui/sessionBootstrap.d.ts +5 -1
- package/package.json +1 -1
|
@@ -1,91 +1,112 @@
|
|
|
1
|
-
const
|
|
2
|
-
function
|
|
3
|
-
return typeof
|
|
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
|
|
6
|
-
|
|
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
|
|
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(
|
|
13
|
-
if (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(
|
|
19
|
-
const a = { ...
|
|
39
|
+
headers(t) {
|
|
40
|
+
const a = { ...t };
|
|
20
41
|
return this.publishableKey && (a["X-Publishable-Key"] = this.publishableKey), a;
|
|
21
42
|
}
|
|
22
|
-
async request(
|
|
23
|
-
const n = `${this.baseUri}${
|
|
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
|
|
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(
|
|
32
|
-
const n = `${this.baseUri}${
|
|
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
|
|
56
|
+
throw await m(s);
|
|
36
57
|
}
|
|
37
|
-
async requestWithFormData(
|
|
38
|
-
const n = `${this.baseUri}${
|
|
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
|
|
62
|
+
throw await m(s);
|
|
42
63
|
}
|
|
43
64
|
}
|
|
44
|
-
const
|
|
45
|
-
class
|
|
46
|
-
async getCryptoTransaction(
|
|
47
|
-
return await this.request(`/${
|
|
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(
|
|
70
|
+
async createPaymentRequest(t, a) {
|
|
50
71
|
return await this.request(
|
|
51
|
-
`/${
|
|
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(
|
|
79
|
+
async buildTransfer(t, a, n) {
|
|
59
80
|
return await this.request(
|
|
60
|
-
`/${
|
|
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(
|
|
88
|
+
async broadcastTransfer(t, a, n) {
|
|
68
89
|
return await this.request(
|
|
69
|
-
`/${
|
|
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(
|
|
97
|
+
async cancelCryptoTransaction(t, a) {
|
|
77
98
|
return await this.request(
|
|
78
|
-
`/${
|
|
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(
|
|
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
|
-
`/${
|
|
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
|
|
97
|
-
|
|
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(
|
|
121
|
+
o && Object.defineProperty(e.prototype, n, o);
|
|
101
122
|
});
|
|
102
123
|
});
|
|
103
124
|
}
|
|
104
|
-
const
|
|
105
|
-
class
|
|
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(
|
|
108
|
-
return await this.requestText(`/${
|
|
128
|
+
async sendCustomerOTP(t) {
|
|
129
|
+
return await this.requestText(`/${C}`, {
|
|
109
130
|
method: "PATCH",
|
|
110
|
-
body: JSON.stringify(
|
|
131
|
+
body: JSON.stringify(t)
|
|
111
132
|
});
|
|
112
133
|
}
|
|
113
134
|
// PUT /customer/otp -> { customerUUID, kycValidated }.
|
|
114
|
-
async authenticateCustomerOTP(
|
|
115
|
-
return await this.request(`/${
|
|
135
|
+
async authenticateCustomerOTP(t) {
|
|
136
|
+
return await this.request(`/${C}`, {
|
|
116
137
|
method: "PUT",
|
|
117
|
-
body: JSON.stringify(
|
|
138
|
+
body: JSON.stringify(t)
|
|
118
139
|
});
|
|
119
140
|
}
|
|
120
141
|
}
|
|
121
|
-
const
|
|
122
|
-
class
|
|
123
|
-
async createSession(
|
|
124
|
-
return await this.request(`/${
|
|
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(
|
|
147
|
+
body: JSON.stringify(t)
|
|
127
148
|
});
|
|
128
149
|
}
|
|
129
|
-
async getSession(
|
|
130
|
-
return await this.request(`/${
|
|
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(
|
|
156
|
+
async createSessionTransaction(t, a) {
|
|
136
157
|
return await this.request(
|
|
137
|
-
`/${
|
|
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(
|
|
147
|
-
return await this.requestText(`/${
|
|
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
|
|
179
|
+
class E extends p {
|
|
153
180
|
}
|
|
154
|
-
|
|
155
|
-
const
|
|
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
|
-
},
|
|
200
|
+
}, se = {
|
|
174
201
|
PARTIALLY_PAID: 1,
|
|
175
202
|
OVERPAID: 3
|
|
176
|
-
},
|
|
203
|
+
}, B = {
|
|
177
204
|
PENDING: 0,
|
|
178
205
|
CONFIRMED: 1
|
|
179
|
-
},
|
|
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
|
|
185
|
-
return
|
|
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
|
|
188
|
-
options:
|
|
189
|
-
unsupportedKeys:
|
|
214
|
+
function S({
|
|
215
|
+
options: e,
|
|
216
|
+
unsupportedKeys: t,
|
|
190
217
|
entryPoint: a
|
|
191
218
|
}) {
|
|
192
|
-
const n =
|
|
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
|
|
196
|
-
var
|
|
197
|
-
return (
|
|
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
|
|
200
|
-
return
|
|
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
|
|
203
|
-
let
|
|
229
|
+
function q(e) {
|
|
230
|
+
let t;
|
|
204
231
|
try {
|
|
205
|
-
|
|
232
|
+
t = new URL(e);
|
|
206
233
|
} catch {
|
|
207
234
|
return !1;
|
|
208
235
|
}
|
|
209
|
-
return (
|
|
236
|
+
return (t.protocol === "http:" || t.protocol === "https:") && t.pathname === "/" && t.search === "" && t.hash === "";
|
|
210
237
|
}
|
|
211
|
-
function
|
|
212
|
-
return
|
|
238
|
+
function ie(e) {
|
|
239
|
+
return e !== null && !d(e) && !!e.publishableKey;
|
|
213
240
|
}
|
|
214
|
-
function
|
|
215
|
-
return
|
|
241
|
+
function ce(e) {
|
|
242
|
+
return e !== null && !d(e);
|
|
216
243
|
}
|
|
217
|
-
function
|
|
218
|
-
options:
|
|
219
|
-
session:
|
|
244
|
+
function le({
|
|
245
|
+
options: e,
|
|
246
|
+
session: t,
|
|
220
247
|
settled: a
|
|
221
248
|
}) {
|
|
222
|
-
return !a &&
|
|
249
|
+
return !a && t !== null && e !== null && d(e);
|
|
223
250
|
}
|
|
224
|
-
function
|
|
251
|
+
function A(e, t, a) {
|
|
225
252
|
try {
|
|
226
|
-
|
|
253
|
+
e == null || e(t, a);
|
|
227
254
|
} catch (n) {
|
|
228
|
-
console.error(`onEvent("${
|
|
255
|
+
console.error(`onEvent("${t}") threw:`, n);
|
|
229
256
|
}
|
|
230
257
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
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
|
|
238
|
-
a("session.loaded",
|
|
239
|
-
const s = await
|
|
240
|
-
api:
|
|
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 {
|
|
297
|
+
return {};
|
|
246
298
|
}
|
|
247
299
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
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
|
|
253
|
-
amount:
|
|
254
|
-
amountCurrency:
|
|
255
|
-
descriptor:
|
|
256
|
-
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
|
|
260
|
-
api:
|
|
261
|
-
sessionID:
|
|
314
|
+
async function K({
|
|
315
|
+
api: e,
|
|
316
|
+
sessionID: t
|
|
262
317
|
}) {
|
|
263
|
-
const a = await
|
|
264
|
-
return { session: a, sessionPromoted:
|
|
318
|
+
const a = await e.getSession(t);
|
|
319
|
+
return { session: a, sessionPromoted: I(a) };
|
|
265
320
|
}
|
|
266
|
-
function
|
|
321
|
+
function z(e) {
|
|
267
322
|
return {
|
|
268
|
-
sessionID:
|
|
269
|
-
merchantName:
|
|
270
|
-
alreadyPromoted:
|
|
323
|
+
sessionID: e.sessionID,
|
|
324
|
+
merchantName: e.merchantName,
|
|
325
|
+
alreadyPromoted: I(e)
|
|
271
326
|
};
|
|
272
327
|
}
|
|
273
|
-
function
|
|
274
|
-
return !!
|
|
328
|
+
function I(e) {
|
|
329
|
+
return !!e.transactionID;
|
|
275
330
|
}
|
|
276
|
-
async function
|
|
277
|
-
api:
|
|
278
|
-
transactionID:
|
|
331
|
+
async function J({
|
|
332
|
+
api: e,
|
|
333
|
+
transactionID: t
|
|
279
334
|
}) {
|
|
280
|
-
if (!
|
|
335
|
+
if (!t)
|
|
281
336
|
return null;
|
|
282
337
|
try {
|
|
283
|
-
return await
|
|
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
|
|
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,
|
|
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:
|
|
351
|
+
event: { reason: t, shouldEndCheckout: a, message: e },
|
|
308
352
|
failure: {
|
|
309
353
|
shouldEndCheckout: a,
|
|
310
|
-
reason:
|
|
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 ?
|
|
359
|
+
redirectURL: a ? y(o == null ? void 0 : o.failureURL) : void 0
|
|
316
360
|
}
|
|
317
361
|
};
|
|
318
362
|
}
|
|
319
|
-
const
|
|
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
|
-
},
|
|
543
|
-
let
|
|
544
|
-
function
|
|
545
|
-
return
|
|
598
|
+
}, T = { en: Q }, L = "en";
|
|
599
|
+
let R = L;
|
|
600
|
+
function de() {
|
|
601
|
+
return R;
|
|
546
602
|
}
|
|
547
|
-
function
|
|
603
|
+
function w(e, t) {
|
|
548
604
|
var n;
|
|
549
|
-
const a = ((n =
|
|
550
|
-
return
|
|
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) =>
|
|
608
|
+
(o, r) => t[r] != null ? String(t[r]) : `{${r}}`
|
|
553
609
|
) : a;
|
|
554
610
|
}
|
|
555
|
-
function
|
|
556
|
-
return
|
|
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
|
|
559
|
-
transaction:
|
|
560
|
-
session:
|
|
614
|
+
function X({
|
|
615
|
+
transaction: e,
|
|
616
|
+
session: t
|
|
561
617
|
}) {
|
|
562
618
|
var o, r, s;
|
|
563
|
-
const a =
|
|
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:
|
|
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:
|
|
575
|
-
redirectURL:
|
|
630
|
+
transactionID: e.transactionID,
|
|
631
|
+
redirectURL: y(t == null ? void 0 : t.failureURL)
|
|
576
632
|
}
|
|
577
633
|
};
|
|
578
|
-
const n = (o =
|
|
579
|
-
(i) => i.status ===
|
|
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:
|
|
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:
|
|
590
|
-
amount: (r =
|
|
591
|
-
currency: (s =
|
|
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:
|
|
651
|
+
redirectURL: y(t == null ? void 0 : t.successURL)
|
|
596
652
|
}
|
|
597
653
|
};
|
|
598
654
|
}
|
|
599
|
-
function
|
|
600
|
-
let
|
|
655
|
+
function V() {
|
|
656
|
+
let e = null;
|
|
601
657
|
return {
|
|
602
|
-
setOptions: (
|
|
603
|
-
|
|
658
|
+
setOptions: (t) => {
|
|
659
|
+
e = t;
|
|
604
660
|
},
|
|
605
|
-
emit: (
|
|
606
|
-
paymentFailed: (
|
|
661
|
+
emit: (t, a) => A(e == null ? void 0 : e.onEvent, t, a),
|
|
662
|
+
paymentFailed: (t, a) => {
|
|
607
663
|
var n;
|
|
608
|
-
return (n =
|
|
664
|
+
return (n = e == null ? void 0 : e.paymentFailedListener) == null ? void 0 : n.call(e, t, a);
|
|
609
665
|
},
|
|
610
|
-
paymentSucceeded: (
|
|
666
|
+
paymentSucceeded: (t) => {
|
|
611
667
|
var a;
|
|
612
|
-
return (a =
|
|
668
|
+
return (a = e == null ? void 0 : e.paymentSuccessListener) == null ? void 0 : a.call(e, t);
|
|
613
669
|
},
|
|
614
|
-
paymentCanceled: (
|
|
670
|
+
paymentCanceled: (t) => {
|
|
615
671
|
var a;
|
|
616
|
-
return (a =
|
|
672
|
+
return (a = e == null ? void 0 : e.paymentCanceledListener) == null ? void 0 : a.call(e, t);
|
|
617
673
|
}
|
|
618
674
|
};
|
|
619
675
|
}
|
|
620
|
-
class
|
|
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(
|
|
630
|
-
const a =
|
|
631
|
-
!o || this.isTornDown || (this.engine = o, await o.initialize(
|
|
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(
|
|
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:
|
|
696
|
+
options: t,
|
|
641
697
|
sessionLoad: a
|
|
642
698
|
}), null;
|
|
643
699
|
}
|
|
644
700
|
}
|
|
645
|
-
async updateTransaction(
|
|
701
|
+
async updateTransaction(t) {
|
|
646
702
|
if (!this.engine)
|
|
647
703
|
throw new Error("Tether Pay not initialized.");
|
|
648
|
-
await this.engine.updateTransaction(
|
|
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-
|
|
659
|
-
const a =
|
|
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:
|
|
723
|
+
engineLoad: t,
|
|
668
724
|
options: a,
|
|
669
725
|
sessionLoad: n
|
|
670
726
|
}) {
|
|
671
|
-
this.engineLoadPromise ===
|
|
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:
|
|
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 =
|
|
692
|
-
o.setOptions(
|
|
693
|
-
const r = n.ok && n.linkedTransaction ?
|
|
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
|
-
|
|
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(
|
|
720
|
-
|
|
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
|
|
724
|
-
return new
|
|
725
|
-
|
|
726
|
-
|
|
793
|
+
function te(e) {
|
|
794
|
+
return new Y(
|
|
795
|
+
G(e),
|
|
796
|
+
d(e) ? void 0 : e.publishableKey
|
|
727
797
|
);
|
|
728
798
|
}
|
|
729
|
-
function
|
|
730
|
-
api:
|
|
731
|
-
options:
|
|
799
|
+
function ae({
|
|
800
|
+
api: e,
|
|
801
|
+
options: t
|
|
732
802
|
}) {
|
|
733
|
-
return
|
|
734
|
-
api:
|
|
735
|
-
options:
|
|
736
|
-
emit: (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",
|
|
740
|
-
function
|
|
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
|
|
744
|
-
if (!
|
|
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
|
|
747
|
-
if (
|
|
748
|
-
throw new Error(
|
|
749
|
-
const a =
|
|
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 (!
|
|
753
|
-
throw new Error("Invalid value for currency, valid values are: " +
|
|
754
|
-
const n =
|
|
755
|
-
options:
|
|
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
|
|
831
|
+
await f().initialize(e);
|
|
762
832
|
}
|
|
763
|
-
async function
|
|
764
|
-
if (!
|
|
833
|
+
async function oe(e) {
|
|
834
|
+
if (!e.sessionID)
|
|
765
835
|
throw new Error("initExistingSession requires a sessionID");
|
|
766
|
-
const
|
|
767
|
-
if (
|
|
768
|
-
throw new Error(
|
|
769
|
-
const a =
|
|
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 =
|
|
773
|
-
options:
|
|
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
|
|
849
|
+
await f().initialize(e);
|
|
780
850
|
}
|
|
781
|
-
async function
|
|
782
|
-
await
|
|
851
|
+
async function re(e) {
|
|
852
|
+
await f().updateTransaction(e);
|
|
783
853
|
}
|
|
784
|
-
window.Lydian = { init:
|
|
854
|
+
window.Lydian = { init: ne, initExistingSession: oe, updateTransaction: re };
|
|
785
855
|
export {
|
|
786
|
-
O as
|
|
856
|
+
O as G,
|
|
857
|
+
se as P,
|
|
787
858
|
u as T,
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
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
|
};
|