@lydianpay/sdk-web 3.6.0 → 3.7.1
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/{index-9i2S104v.js → index-BBPxP59-.js} +200 -192
- package/dist/chunks/{index-bKFtUHLc.js → index-DYVfFYby.js} +1 -1
- package/dist/chunks/{metamask-sdk-CK1SAg_K.js → metamask-sdk-DVrLlEpt.js} +1 -1
- package/dist/chunks/{mountEngine-CVnwr305.js → mountEngine-7GpOY00I.js} +8156 -7924
- package/dist/lydian.js +1 -1
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/types.d.ts +1 -0
- package/dist/types/ui/kycFlow.d.ts +2 -1
- package/dist/types/ui/kycVerificationRequest.d.ts +2 -1
- package/dist/types/ui/networkListHelpers.d.ts +35 -0
- package/dist/types/ui/react/AssetSelectScreen/AssetListEmptyState.d.ts +13 -0
- package/dist/types/ui/react/AssetSelectScreen/AssetSelectList.d.ts +12 -0
- package/dist/types/ui/react/{AssetSelectOption.d.ts → AssetSelectScreen/AssetSelectOption.d.ts} +4 -3
- package/dist/types/ui/react/AssetSelectScreen/AssetSelectionHeader.d.ts +4 -0
- package/dist/types/ui/react/AssetSelectScreen/AssetSelectionSummary.d.ts +5 -0
- package/dist/types/ui/react/AssetSelectScreen/useAssetSelectionState.d.ts +9 -0
- package/dist/types/ui/walletConnection.d.ts +1 -0
- package/package.json +2 -2
- /package/dist/types/ui/react/{AssetSelectScreen.d.ts → AssetSelectScreen/AssetSelectScreen.d.ts} +0 -0
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
const g = ["USD", "TRY", "PHP"];
|
|
2
|
-
function
|
|
3
|
-
return typeof
|
|
2
|
+
function N(e) {
|
|
3
|
+
return typeof e == "string" && g.includes(e);
|
|
4
4
|
}
|
|
5
|
-
function c(
|
|
6
|
-
return "sessionID" in
|
|
5
|
+
function c(e) {
|
|
6
|
+
return "sessionID" in e && typeof e.sessionID == "string" && e.sessionID.length > 0;
|
|
7
7
|
}
|
|
8
|
-
class
|
|
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(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
26
|
throw new Error(s.statusText);
|
|
@@ -28,46 +28,46 @@ class u {
|
|
|
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
44
|
const l = "transaction";
|
|
45
|
-
class A extends
|
|
46
|
-
async getCryptoTransaction(
|
|
47
|
-
return await this.request(`/${l}/${
|
|
45
|
+
class A extends y {
|
|
46
|
+
async getCryptoTransaction(t) {
|
|
47
|
+
return await this.request(`/${l}/${t}`);
|
|
48
48
|
}
|
|
49
|
-
async createPaymentRequest(
|
|
49
|
+
async createPaymentRequest(t, a) {
|
|
50
50
|
return await this.request(
|
|
51
|
-
`/${l}/${
|
|
51
|
+
`/${l}/${t}/payment`,
|
|
52
52
|
{
|
|
53
53
|
method: "POST",
|
|
54
54
|
body: JSON.stringify(a)
|
|
55
55
|
}
|
|
56
56
|
);
|
|
57
57
|
}
|
|
58
|
-
async cancelCryptoTransaction(
|
|
58
|
+
async cancelCryptoTransaction(t, a) {
|
|
59
59
|
return await this.request(
|
|
60
|
-
`/${l}/${
|
|
60
|
+
`/${l}/${t}/cancel`,
|
|
61
61
|
{
|
|
62
62
|
method: "PATCH",
|
|
63
63
|
body: JSON.stringify(a)
|
|
64
64
|
}
|
|
65
65
|
);
|
|
66
66
|
}
|
|
67
|
-
async kycVerification(
|
|
67
|
+
async kycVerification(t, a) {
|
|
68
68
|
const n = new FormData();
|
|
69
|
-
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.documentType && n.append("documentType", a.documentType), a.documentFiles.forEach((o) => n.append("documentFiles", o)), await this.requestWithFormData(
|
|
70
|
-
`/${l}/${
|
|
69
|
+
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
|
+
`/${l}/${t}/verification`,
|
|
71
71
|
{
|
|
72
72
|
method: "POST",
|
|
73
73
|
body: n
|
|
@@ -75,48 +75,48 @@ class A extends u {
|
|
|
75
75
|
);
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
-
function
|
|
79
|
-
|
|
78
|
+
function S(e, t) {
|
|
79
|
+
t.forEach((a) => {
|
|
80
80
|
Object.getOwnPropertyNames(a.prototype).forEach((n) => {
|
|
81
81
|
const o = Object.getOwnPropertyDescriptor(a.prototype, n);
|
|
82
|
-
o && Object.defineProperty(
|
|
82
|
+
o && Object.defineProperty(e.prototype, n, o);
|
|
83
83
|
});
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
86
|
const w = "customer/otp";
|
|
87
|
-
class I extends
|
|
87
|
+
class I extends y {
|
|
88
88
|
// PATCH /customer/otp -> text/plain "OTP sent" (no JSON body).
|
|
89
|
-
async sendCustomerOTP(
|
|
89
|
+
async sendCustomerOTP(t) {
|
|
90
90
|
return await this.requestText(`/${w}`, {
|
|
91
91
|
method: "PATCH",
|
|
92
|
-
body: JSON.stringify(
|
|
92
|
+
body: JSON.stringify(t)
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
95
|
// PUT /customer/otp -> { customerUUID, kycValidated }.
|
|
96
|
-
async authenticateCustomerOTP(
|
|
96
|
+
async authenticateCustomerOTP(t) {
|
|
97
97
|
return await this.request(`/${w}`, {
|
|
98
98
|
method: "PUT",
|
|
99
|
-
body: JSON.stringify(
|
|
99
|
+
body: JSON.stringify(t)
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
const d = "session";
|
|
104
|
-
class L extends
|
|
105
|
-
async createSession(
|
|
104
|
+
class L extends y {
|
|
105
|
+
async createSession(t) {
|
|
106
106
|
return await this.request(`/${d}`, {
|
|
107
107
|
method: "POST",
|
|
108
|
-
body: JSON.stringify(
|
|
108
|
+
body: JSON.stringify(t)
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
|
-
async getSession(
|
|
112
|
-
return await this.request(`/${d}/${
|
|
111
|
+
async getSession(t) {
|
|
112
|
+
return await this.request(`/${d}/${t}`);
|
|
113
113
|
}
|
|
114
114
|
// Promotes the session into a transaction. Allowed once per session — except
|
|
115
115
|
// that a KYC-pending (-3) response does not consume the promotion, which is
|
|
116
116
|
// what lets the restore-details flow re-promote with a customerUUID.
|
|
117
|
-
async createSessionTransaction(
|
|
117
|
+
async createSessionTransaction(t, a) {
|
|
118
118
|
return await this.request(
|
|
119
|
-
`/${d}/${
|
|
119
|
+
`/${d}/${t}/transaction`,
|
|
120
120
|
{
|
|
121
121
|
method: "POST",
|
|
122
122
|
body: JSON.stringify(a)
|
|
@@ -125,17 +125,18 @@ class L extends u {
|
|
|
125
125
|
}
|
|
126
126
|
// PATCH /session/{id}/cancel replies text/plain (the merchant's cancel URL),
|
|
127
127
|
// not JSON. Cancelling cascades to the linked transaction, if any.
|
|
128
|
-
async cancelSession(
|
|
129
|
-
return await this.requestText(`/${d}/${
|
|
128
|
+
async cancelSession(t) {
|
|
129
|
+
return await this.requestText(`/${d}/${t}/cancel`, {
|
|
130
130
|
method: "PATCH"
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
|
-
class
|
|
134
|
+
class b extends y {
|
|
135
135
|
}
|
|
136
|
-
|
|
137
|
-
const R =
|
|
138
|
-
var
|
|
136
|
+
S(b, [A, I, L]);
|
|
137
|
+
const R = b;
|
|
138
|
+
var u = {
|
|
139
|
+
COMPLIANCE_PENDING: -10,
|
|
139
140
|
API_CANCELLED: -9,
|
|
140
141
|
PAYMENT_TIMEOUT: -8,
|
|
141
142
|
FRAUD_DECLINED: -7,
|
|
@@ -154,7 +155,7 @@ var y = {
|
|
|
154
155
|
}, Z = {
|
|
155
156
|
PARTIALLY_PAID: 1,
|
|
156
157
|
OVERPAID: 3
|
|
157
|
-
},
|
|
158
|
+
}, O = {
|
|
158
159
|
PENDING: 0,
|
|
159
160
|
CONFIRMED: 1
|
|
160
161
|
}, p = {
|
|
@@ -162,51 +163,51 @@ var y = {
|
|
|
162
163
|
sandbox: "https://api.sandbox.lydian.com",
|
|
163
164
|
prod: "https://api.lydian.com"
|
|
164
165
|
};
|
|
165
|
-
function
|
|
166
|
-
return
|
|
166
|
+
function U(e) {
|
|
167
|
+
return e.dev ? p.dev : e.sandbox ? p.sandbox : p.prod;
|
|
167
168
|
}
|
|
168
|
-
function
|
|
169
|
-
options:
|
|
170
|
-
unsupportedKeys:
|
|
169
|
+
function C({
|
|
170
|
+
options: e,
|
|
171
|
+
unsupportedKeys: t,
|
|
171
172
|
entryPoint: a
|
|
172
173
|
}) {
|
|
173
|
-
const n =
|
|
174
|
+
const n = t.filter((o) => e[o] !== void 0);
|
|
174
175
|
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.`;
|
|
175
176
|
}
|
|
176
|
-
function
|
|
177
|
-
var
|
|
178
|
-
return (
|
|
177
|
+
function P(e) {
|
|
178
|
+
var t;
|
|
179
|
+
return (t = e.flow) != null && t.walletConnect && !e.walletConnectProjectId ? "walletConnectProjectId is required when flow.walletConnect is on" : null;
|
|
179
180
|
}
|
|
180
|
-
function X(
|
|
181
|
-
return
|
|
181
|
+
function X(e) {
|
|
182
|
+
return e !== null && !c(e) && !!e.publishableKey;
|
|
182
183
|
}
|
|
183
|
-
function V(
|
|
184
|
-
return
|
|
184
|
+
function V(e) {
|
|
185
|
+
return e !== null && !c(e);
|
|
185
186
|
}
|
|
186
187
|
function ee({
|
|
187
|
-
options:
|
|
188
|
-
session:
|
|
188
|
+
options: e,
|
|
189
|
+
session: t,
|
|
189
190
|
settled: a
|
|
190
191
|
}) {
|
|
191
|
-
return !a &&
|
|
192
|
+
return !a && t !== null && e !== null && c(e);
|
|
192
193
|
}
|
|
193
|
-
function
|
|
194
|
+
function k(e, t, a) {
|
|
194
195
|
try {
|
|
195
|
-
|
|
196
|
+
e == null || e(t, a);
|
|
196
197
|
} catch (n) {
|
|
197
|
-
console.error(`onEvent("${
|
|
198
|
+
console.error(`onEvent("${t}") threw:`, n);
|
|
198
199
|
}
|
|
199
200
|
}
|
|
200
201
|
async function F({
|
|
201
|
-
api:
|
|
202
|
-
options:
|
|
202
|
+
api: e,
|
|
203
|
+
options: t,
|
|
203
204
|
emit: a
|
|
204
205
|
}) {
|
|
205
206
|
try {
|
|
206
|
-
const n = await W({ api:
|
|
207
|
-
a("session.loaded",
|
|
208
|
-
const s = await
|
|
209
|
-
api:
|
|
207
|
+
const n = await W({ api: e, options: t }), { session: o, sessionPromoted: r } = await x({ api: e, sessionID: n });
|
|
208
|
+
a("session.loaded", M(o));
|
|
209
|
+
const s = await Y({
|
|
210
|
+
api: e,
|
|
210
211
|
transactionID: o.transactionID
|
|
211
212
|
});
|
|
212
213
|
return { ok: !0, session: o, sessionPromoted: r, linkedTransaction: s };
|
|
@@ -215,68 +216,68 @@ async function F({
|
|
|
215
216
|
}
|
|
216
217
|
}
|
|
217
218
|
async function W({
|
|
218
|
-
api:
|
|
219
|
-
options:
|
|
219
|
+
api: e,
|
|
220
|
+
options: t
|
|
220
221
|
}) {
|
|
221
|
-
return c(
|
|
222
|
-
amount:
|
|
223
|
-
amountCurrency:
|
|
224
|
-
descriptor:
|
|
225
|
-
referenceNumber:
|
|
222
|
+
return c(t) ? t.sessionID : (await e.createSession({
|
|
223
|
+
amount: t.transaction.amount,
|
|
224
|
+
amountCurrency: t.transaction.currency,
|
|
225
|
+
descriptor: t.transaction.descriptor,
|
|
226
|
+
referenceNumber: t.transaction.referenceNumber
|
|
226
227
|
})).sessionID;
|
|
227
228
|
}
|
|
228
229
|
async function x({
|
|
229
|
-
api:
|
|
230
|
-
sessionID:
|
|
230
|
+
api: e,
|
|
231
|
+
sessionID: t
|
|
231
232
|
}) {
|
|
232
|
-
const a = await
|
|
233
|
-
return { session: a, sessionPromoted:
|
|
233
|
+
const a = await e.getSession(t);
|
|
234
|
+
return { session: a, sessionPromoted: T(a) };
|
|
234
235
|
}
|
|
235
|
-
function
|
|
236
|
+
function M(e) {
|
|
236
237
|
return {
|
|
237
|
-
sessionID:
|
|
238
|
-
merchantName:
|
|
239
|
-
alreadyPromoted:
|
|
238
|
+
sessionID: e.sessionID,
|
|
239
|
+
merchantName: e.merchantName,
|
|
240
|
+
alreadyPromoted: T(e)
|
|
240
241
|
};
|
|
241
242
|
}
|
|
242
|
-
function
|
|
243
|
-
return !!
|
|
243
|
+
function T(e) {
|
|
244
|
+
return !!e.transactionID;
|
|
244
245
|
}
|
|
245
|
-
async function
|
|
246
|
-
api:
|
|
247
|
-
transactionID:
|
|
246
|
+
async function Y({
|
|
247
|
+
api: e,
|
|
248
|
+
transactionID: t
|
|
248
249
|
}) {
|
|
249
|
-
if (!
|
|
250
|
+
if (!t)
|
|
250
251
|
return null;
|
|
251
252
|
try {
|
|
252
|
-
return await
|
|
253
|
+
return await e.getCryptoTransaction(t);
|
|
253
254
|
} catch (a) {
|
|
254
255
|
return console.error("Failed to resolve the session transaction:", a), null;
|
|
255
256
|
}
|
|
256
257
|
}
|
|
257
|
-
function m(
|
|
258
|
-
if (!
|
|
258
|
+
function m(e) {
|
|
259
|
+
if (!e)
|
|
259
260
|
return;
|
|
260
|
-
let
|
|
261
|
+
let t;
|
|
261
262
|
try {
|
|
262
|
-
|
|
263
|
+
t = new URL(e);
|
|
263
264
|
} catch {
|
|
264
265
|
return;
|
|
265
266
|
}
|
|
266
|
-
return
|
|
267
|
+
return t.protocol === "https:" || t.protocol === "http:" ? e : void 0;
|
|
267
268
|
}
|
|
268
|
-
function
|
|
269
|
-
message:
|
|
270
|
-
reason:
|
|
269
|
+
function $({
|
|
270
|
+
message: e,
|
|
271
|
+
reason: t,
|
|
271
272
|
shouldEndCheckout: a,
|
|
272
273
|
transactionID: n,
|
|
273
274
|
session: o
|
|
274
275
|
}) {
|
|
275
276
|
return {
|
|
276
|
-
event: { reason:
|
|
277
|
+
event: { reason: t, shouldEndCheckout: a, message: e },
|
|
277
278
|
failure: {
|
|
278
279
|
shouldEndCheckout: a,
|
|
279
|
-
reason:
|
|
280
|
+
reason: t,
|
|
280
281
|
transactionID: n,
|
|
281
282
|
// Only a failure that ends the checkout carries a redirect. A retryable one
|
|
282
283
|
// leaves the customer mid-flow with something still to do, and a host that
|
|
@@ -332,13 +333,20 @@ const B = {
|
|
|
332
333
|
"asset.insufficientBalanceWarning": "Your {codes} balance won't fully cover this payment. Top up, or choose a different coin.",
|
|
333
334
|
"asset.noAssetsOnNetwork": "{wallet} doesn't have any of the accepted coins on {network}. Add {coins} to your wallet, or choose a different network or wallet.",
|
|
334
335
|
"asset.backToNetworks": "Back to networks",
|
|
336
|
+
"asset.noBalance": "No balance",
|
|
337
|
+
"asset.noSupportedCoins": "None of the coins accepted for this payment can be paid from this checkout.",
|
|
338
|
+
"asset.noSupportedCoinsForMerchant": "None of the coins {merchant} accepts can be paid from this checkout.",
|
|
339
|
+
"asset.noCoinsForWalletChains": "{wallet} didn't approve a network these coins can be sent on. Choose a different wallet, or reconnect and approve one.",
|
|
340
|
+
"asset.noAcceptedCoinsOnNetwork": "None of the coins accepted for this payment can be sent on {network}. Choose a different network.",
|
|
335
341
|
"network.chooseNetwork": "Choose a network",
|
|
336
342
|
"network.walletSupportWarning": "Please make sure you choose a network that your crypto wallet supports.",
|
|
337
343
|
"network.noSupportedNetworks": "{wallet} doesn't support any of the networks available for this payment.",
|
|
338
344
|
"network.noSupportedNetworksForMerchant": "{wallet} doesn't support any of the networks available for {merchant}.",
|
|
345
|
+
"network.noNetworksAvailable": "No networks are available for this payment. Contact the merchant if you think this is wrong.",
|
|
339
346
|
"network.recommended": "RECOMMENDED",
|
|
340
347
|
"network.fee": "Network fee: {fee}",
|
|
341
348
|
"kyc.additionalInfoRequired": "Additional info required",
|
|
349
|
+
"kyc.complianceWaiting": "Your details are being verified. This can take a few moments.",
|
|
342
350
|
"kyc.stepBasic": "Basic details",
|
|
343
351
|
"kyc.stepAddress": "Address",
|
|
344
352
|
"kyc.stepDocument": "Verification document",
|
|
@@ -490,28 +498,28 @@ const B = {
|
|
|
490
498
|
"validation.customerDetailsMissing": "Customer details are missing.",
|
|
491
499
|
"validation.invalidOtp": "Please enter a valid 6-digit code.",
|
|
492
500
|
"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>.'
|
|
493
|
-
}, f = { en: B },
|
|
494
|
-
let
|
|
501
|
+
}, f = { en: B }, E = "en";
|
|
502
|
+
let D = E;
|
|
495
503
|
function te() {
|
|
496
|
-
return
|
|
504
|
+
return D;
|
|
497
505
|
}
|
|
498
|
-
function v(
|
|
506
|
+
function v(e, t) {
|
|
499
507
|
var n;
|
|
500
|
-
const a = ((n = f[
|
|
501
|
-
return
|
|
508
|
+
const a = ((n = f[D]) == null ? void 0 : n[e]) ?? f[E][e] ?? e;
|
|
509
|
+
return t ? a.replace(
|
|
502
510
|
/\{(\w+)\}/g,
|
|
503
|
-
(o, r) =>
|
|
511
|
+
(o, r) => t[r] != null ? String(t[r]) : `{${r}}`
|
|
504
512
|
) : a;
|
|
505
513
|
}
|
|
506
|
-
function
|
|
507
|
-
return
|
|
514
|
+
function _(e) {
|
|
515
|
+
return e === u.SUCCESS ? "succeeded" : e < u.PENDING && e !== u.KYC_VERIFICATION_PENDING && e !== u.COMPLIANCE_PENDING ? "failed" : "active";
|
|
508
516
|
}
|
|
509
|
-
function
|
|
510
|
-
transaction:
|
|
511
|
-
session:
|
|
517
|
+
function q({
|
|
518
|
+
transaction: e,
|
|
519
|
+
session: t
|
|
512
520
|
}) {
|
|
513
521
|
var o, r, s;
|
|
514
|
-
const a =
|
|
522
|
+
const a = _(e.status);
|
|
515
523
|
if (a === "active")
|
|
516
524
|
return null;
|
|
517
525
|
if (a === "failed")
|
|
@@ -522,53 +530,53 @@ function _({
|
|
|
522
530
|
shouldEndCheckout: !0,
|
|
523
531
|
// Negative (non-KYC) status — cancelled / fraud / timeout.
|
|
524
532
|
reason: "blocked",
|
|
525
|
-
transactionID:
|
|
526
|
-
redirectURL: m(
|
|
533
|
+
transactionID: e.transactionID,
|
|
534
|
+
redirectURL: m(t == null ? void 0 : t.failureURL)
|
|
527
535
|
}
|
|
528
536
|
};
|
|
529
|
-
const n = (o =
|
|
530
|
-
(i) => i.status ===
|
|
537
|
+
const n = (o = e.payments) == null ? void 0 : o.find(
|
|
538
|
+
(i) => i.status === O.CONFIRMED
|
|
531
539
|
);
|
|
532
540
|
return {
|
|
533
541
|
outcome: a,
|
|
534
542
|
event: {
|
|
535
|
-
transactionID:
|
|
543
|
+
transactionID: e.transactionID,
|
|
536
544
|
asset: n == null ? void 0 : n.cryptoAsset,
|
|
537
545
|
network: n == null ? void 0 : n.cryptoNetwork
|
|
538
546
|
},
|
|
539
547
|
result: {
|
|
540
|
-
transactionID:
|
|
541
|
-
amount: (r =
|
|
542
|
-
currency: (s =
|
|
548
|
+
transactionID: e.transactionID,
|
|
549
|
+
amount: (r = e.amounts) == null ? void 0 : r.totalLocal,
|
|
550
|
+
currency: (s = e.amounts) == null ? void 0 : s.currency,
|
|
543
551
|
asset: n == null ? void 0 : n.cryptoAsset,
|
|
544
552
|
network: n == null ? void 0 : n.cryptoNetwork,
|
|
545
553
|
completedAt: n == null ? void 0 : n.completedAt,
|
|
546
|
-
redirectURL: m(
|
|
554
|
+
redirectURL: m(t == null ? void 0 : t.successURL)
|
|
547
555
|
}
|
|
548
556
|
};
|
|
549
557
|
}
|
|
550
558
|
function K() {
|
|
551
|
-
let
|
|
559
|
+
let e = null;
|
|
552
560
|
return {
|
|
553
|
-
setOptions: (
|
|
554
|
-
|
|
561
|
+
setOptions: (t) => {
|
|
562
|
+
e = t;
|
|
555
563
|
},
|
|
556
|
-
emit: (
|
|
557
|
-
paymentFailed: (
|
|
564
|
+
emit: (t, a) => k(e == null ? void 0 : e.onEvent, t, a),
|
|
565
|
+
paymentFailed: (t, a) => {
|
|
558
566
|
var n;
|
|
559
|
-
return (n =
|
|
567
|
+
return (n = e == null ? void 0 : e.paymentFailedListener) == null ? void 0 : n.call(e, t, a);
|
|
560
568
|
},
|
|
561
|
-
paymentSucceeded: (
|
|
569
|
+
paymentSucceeded: (t) => {
|
|
562
570
|
var a;
|
|
563
|
-
return (a =
|
|
571
|
+
return (a = e == null ? void 0 : e.paymentSuccessListener) == null ? void 0 : a.call(e, t);
|
|
564
572
|
},
|
|
565
|
-
paymentCanceled: (
|
|
573
|
+
paymentCanceled: (t) => {
|
|
566
574
|
var a;
|
|
567
|
-
return (a =
|
|
575
|
+
return (a = e == null ? void 0 : e.paymentCanceledListener) == null ? void 0 : a.call(e, t);
|
|
568
576
|
}
|
|
569
577
|
};
|
|
570
578
|
}
|
|
571
|
-
class
|
|
579
|
+
class G extends HTMLElement {
|
|
572
580
|
constructor() {
|
|
573
581
|
super(), this.engine = null, this.engineLoadPromise = null, this.isTornDown = !1, this.shadow = this.attachShadow({ mode: "open" });
|
|
574
582
|
}
|
|
@@ -577,26 +585,26 @@ class H extends HTMLElement {
|
|
|
577
585
|
connectedCallback() {
|
|
578
586
|
this.isTornDown = !1;
|
|
579
587
|
}
|
|
580
|
-
async initialize(
|
|
581
|
-
const a =
|
|
582
|
-
!o || this.isTornDown || (this.engine = o, await o.initialize(
|
|
588
|
+
async initialize(t) {
|
|
589
|
+
const a = H(t), n = j({ api: a, options: t }), o = await this.loadEngine(t, n);
|
|
590
|
+
!o || this.isTornDown || (this.engine = o, await o.initialize(t, { api: a, sessionLoad: n }));
|
|
583
591
|
}
|
|
584
|
-
async loadEngine(
|
|
592
|
+
async loadEngine(t, a) {
|
|
585
593
|
const n = this.getOrLoadEngine();
|
|
586
594
|
try {
|
|
587
595
|
return await n;
|
|
588
596
|
} catch {
|
|
589
597
|
return await this.handleEngineLoadFailure({
|
|
590
598
|
engineLoad: n,
|
|
591
|
-
options:
|
|
599
|
+
options: t,
|
|
592
600
|
sessionLoad: a
|
|
593
601
|
}), null;
|
|
594
602
|
}
|
|
595
603
|
}
|
|
596
|
-
async updateTransaction(
|
|
604
|
+
async updateTransaction(t) {
|
|
597
605
|
if (!this.engine)
|
|
598
606
|
throw new Error("Tether Pay not initialized.");
|
|
599
|
-
await this.engine.updateTransaction(
|
|
607
|
+
await this.engine.updateTransaction(t);
|
|
600
608
|
}
|
|
601
609
|
// A merchant SPA can unmount the element at any time; nothing else stops this
|
|
602
610
|
// instance's timers.
|
|
@@ -606,8 +614,8 @@ class H extends HTMLElement {
|
|
|
606
614
|
// Not started in the constructor: a page can carry the tag and never check out.
|
|
607
615
|
// Overlapping initialize() calls share one download.
|
|
608
616
|
getOrLoadEngine() {
|
|
609
|
-
return this.engineLoadPromise ?? (this.engineLoadPromise = import("./mountEngine-
|
|
610
|
-
const a =
|
|
617
|
+
return this.engineLoadPromise ?? (this.engineLoadPromise = import("./mountEngine-7GpOY00I.js").then((t) => t.m).then((t) => {
|
|
618
|
+
const a = t.mountCheckoutEngine({
|
|
611
619
|
host: this,
|
|
612
620
|
shadowRoot: this.shadow
|
|
613
621
|
});
|
|
@@ -615,11 +623,11 @@ class H extends HTMLElement {
|
|
|
615
623
|
})), this.engineLoadPromise;
|
|
616
624
|
}
|
|
617
625
|
async handleEngineLoadFailure({
|
|
618
|
-
engineLoad:
|
|
626
|
+
engineLoad: t,
|
|
619
627
|
options: a,
|
|
620
628
|
sessionLoad: n
|
|
621
629
|
}) {
|
|
622
|
-
this.engineLoadPromise ===
|
|
630
|
+
this.engineLoadPromise === t && (this.engineLoadPromise = null, await this.reportEngineFailure({ options: a, sessionLoad: n }));
|
|
623
631
|
}
|
|
624
632
|
// A host that removed the element has walked away; a failure report could send
|
|
625
633
|
// it to a failureURL for a checkout it dismissed.
|
|
@@ -631,7 +639,7 @@ class H extends HTMLElement {
|
|
|
631
639
|
// an outcome the gateway has already decided — a session resumed after the
|
|
632
640
|
// payment settled must report that payment, not a dead checkout.
|
|
633
641
|
async reportEngineFailure({
|
|
634
|
-
options:
|
|
642
|
+
options: t,
|
|
635
643
|
sessionLoad: a
|
|
636
644
|
}) {
|
|
637
645
|
if (this.isDismissedByHost)
|
|
@@ -640,8 +648,8 @@ class H extends HTMLElement {
|
|
|
640
648
|
if (this.isDismissedByHost)
|
|
641
649
|
return;
|
|
642
650
|
const o = K();
|
|
643
|
-
o.setOptions(
|
|
644
|
-
const r = n.ok && n.linkedTransaction ?
|
|
651
|
+
o.setOptions(t);
|
|
652
|
+
const r = n.ok && n.linkedTransaction ? q({
|
|
645
653
|
transaction: n.linkedTransaction,
|
|
646
654
|
session: n.session
|
|
647
655
|
}) : null;
|
|
@@ -657,7 +665,7 @@ class H extends HTMLElement {
|
|
|
657
665
|
}), o.paymentFailed(r.message, r.failure);
|
|
658
666
|
return;
|
|
659
667
|
}
|
|
660
|
-
const s = v("errors.checkoutUnavailable"), i =
|
|
668
|
+
const s = v("errors.checkoutUnavailable"), i = $({
|
|
661
669
|
message: s,
|
|
662
670
|
reason: "error",
|
|
663
671
|
shouldEndCheckout: !0,
|
|
@@ -667,83 +675,83 @@ class H extends HTMLElement {
|
|
|
667
675
|
}
|
|
668
676
|
// Always teardown and unmount together to avoid leaking the React engine.
|
|
669
677
|
// Clear the cached load so a later initialize() creates a fresh engine.
|
|
670
|
-
releaseEngine(
|
|
671
|
-
|
|
678
|
+
releaseEngine(t = this.engine) {
|
|
679
|
+
t == null || t.teardown(), t == null || t.unmount(), this.engine = null, this.engineLoadPromise = null;
|
|
672
680
|
}
|
|
673
681
|
}
|
|
674
|
-
function
|
|
682
|
+
function H(e) {
|
|
675
683
|
return new R(
|
|
676
|
-
|
|
677
|
-
c(
|
|
684
|
+
U(e),
|
|
685
|
+
c(e) ? void 0 : e.publishableKey
|
|
678
686
|
);
|
|
679
687
|
}
|
|
680
|
-
function
|
|
681
|
-
api:
|
|
682
|
-
options:
|
|
688
|
+
function j({
|
|
689
|
+
api: e,
|
|
690
|
+
options: t
|
|
683
691
|
}) {
|
|
684
692
|
return F({
|
|
685
|
-
api:
|
|
686
|
-
options:
|
|
687
|
-
emit: (a, n) =>
|
|
693
|
+
api: e,
|
|
694
|
+
options: t,
|
|
695
|
+
emit: (a, n) => k(t.onEvent, a, n)
|
|
688
696
|
});
|
|
689
697
|
}
|
|
690
|
-
customElements.get("lydian-checkout") || customElements.define("lydian-checkout",
|
|
698
|
+
customElements.get("lydian-checkout") || customElements.define("lydian-checkout", G);
|
|
691
699
|
function h() {
|
|
692
700
|
return document.querySelector("lydian-checkout");
|
|
693
701
|
}
|
|
694
|
-
async function z(
|
|
695
|
-
if (!
|
|
702
|
+
async function z(e) {
|
|
703
|
+
if (!e.publishableKey || !e.transaction.amount || !e.transaction.currency)
|
|
696
704
|
throw new Error("SDK initialization requires publishableKey and a transaction");
|
|
697
|
-
const
|
|
698
|
-
if (
|
|
699
|
-
throw new Error(
|
|
700
|
-
if (!
|
|
705
|
+
const t = P(e);
|
|
706
|
+
if (t)
|
|
707
|
+
throw new Error(t);
|
|
708
|
+
if (!N(e.transaction.currency))
|
|
701
709
|
throw new Error("Invalid value for currency, valid values are: " + g.join(", "));
|
|
702
|
-
const a =
|
|
703
|
-
options:
|
|
710
|
+
const a = C({
|
|
711
|
+
options: e,
|
|
704
712
|
unsupportedKeys: ["sessionID"],
|
|
705
713
|
entryPoint: "init"
|
|
706
714
|
});
|
|
707
715
|
if (a)
|
|
708
716
|
throw new Error(a);
|
|
709
|
-
await h().initialize(
|
|
717
|
+
await h().initialize(e);
|
|
710
718
|
}
|
|
711
|
-
async function Q(
|
|
712
|
-
if (!
|
|
719
|
+
async function Q(e) {
|
|
720
|
+
if (!e.sessionID)
|
|
713
721
|
throw new Error("initExistingSession requires a sessionID");
|
|
714
|
-
const
|
|
715
|
-
if (
|
|
716
|
-
throw new Error(
|
|
717
|
-
const a =
|
|
718
|
-
options:
|
|
722
|
+
const t = P(e);
|
|
723
|
+
if (t)
|
|
724
|
+
throw new Error(t);
|
|
725
|
+
const a = C({
|
|
726
|
+
options: e,
|
|
719
727
|
unsupportedKeys: ["publishableKey", "transaction"],
|
|
720
728
|
entryPoint: "initExistingSession"
|
|
721
729
|
});
|
|
722
730
|
if (a)
|
|
723
731
|
throw new Error(a);
|
|
724
|
-
await h().initialize(
|
|
732
|
+
await h().initialize(e);
|
|
725
733
|
}
|
|
726
|
-
async function J(
|
|
727
|
-
await h().updateTransaction(
|
|
734
|
+
async function J(e) {
|
|
735
|
+
await h().updateTransaction(e);
|
|
728
736
|
}
|
|
729
737
|
window.Lydian = { init: z, initExistingSession: Q, updateTransaction: J };
|
|
730
738
|
export {
|
|
731
|
-
|
|
732
|
-
|
|
739
|
+
O as P,
|
|
740
|
+
u as T,
|
|
733
741
|
Z as a,
|
|
734
742
|
V as b,
|
|
735
743
|
g as c,
|
|
736
744
|
x as d,
|
|
737
|
-
|
|
738
|
-
|
|
745
|
+
M as e,
|
|
746
|
+
Y as f,
|
|
739
747
|
te as g,
|
|
740
748
|
c as h,
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
749
|
+
N as i,
|
|
750
|
+
_ as j,
|
|
751
|
+
q as k,
|
|
752
|
+
T as l,
|
|
745
753
|
ee as m,
|
|
746
|
-
|
|
754
|
+
$ as n,
|
|
747
755
|
X as o,
|
|
748
756
|
K as p,
|
|
749
757
|
W as r,
|