@lydianpay/sdk-web 3.5.0 → 3.7.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/{index-Jy1rNN_e.js → index-DJHqzaLI.js} +195 -190
- package/dist/chunks/{index-p0lBvolb.js → index-Du8LmTIv.js} +1 -1
- package/dist/chunks/{metamask-sdk-DWaj3Api.js → metamask-sdk-DekYRxAk.js} +1 -1
- package/dist/chunks/{mountEngine-DI19rA1h.js → mountEngine-uNB2ytN4.js} +10650 -10418
- package/dist/lydian.js +1 -1
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/services/lydianConnectService.d.ts +3 -3
- 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 +16 -0
- package/dist/types/ui/react/checkoutActions.d.ts +5 -0
- package/dist/types/ui/react/checkoutStore.d.ts +6 -0
- package/dist/types/ui/walletConnection.d.ts +4 -0
- package/dist/types/ui/walletRejection.d.ts +1 -0
- package/package.json +3 -3
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
const g = ["USD", "TRY", "PHP"];
|
|
2
|
-
function
|
|
3
|
-
return typeof
|
|
2
|
+
function A(e) {
|
|
3
|
+
return typeof e == "string" && g.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 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
|
-
const
|
|
45
|
-
class
|
|
46
|
-
async getCryptoTransaction(
|
|
47
|
-
return await this.request(`/${
|
|
44
|
+
const c = "transaction";
|
|
45
|
+
class N extends y {
|
|
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 cancelCryptoTransaction(
|
|
58
|
+
async cancelCryptoTransaction(t, a) {
|
|
59
59
|
return await this.request(
|
|
60
|
-
`/${
|
|
60
|
+
`/${c}/${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
|
-
`/${
|
|
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
|
+
`/${c}/${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 P extends
|
|
134
|
+
class P extends y {
|
|
135
135
|
}
|
|
136
|
-
|
|
136
|
+
S(P, [N, I, L]);
|
|
137
137
|
const R = P;
|
|
138
|
-
var
|
|
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
169
|
function b({
|
|
169
|
-
options:
|
|
170
|
-
unsupportedKeys:
|
|
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 T(
|
|
177
|
-
var
|
|
178
|
-
return (
|
|
177
|
+
function T(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 && !l(e) && !!e.publishableKey;
|
|
182
183
|
}
|
|
183
|
-
function V(
|
|
184
|
-
return
|
|
184
|
+
function V(e) {
|
|
185
|
+
return e !== null && !l(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 && l(e);
|
|
192
193
|
}
|
|
193
|
-
function
|
|
194
|
+
function C(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 W({
|
|
201
|
-
api:
|
|
202
|
-
options:
|
|
202
|
+
api: e,
|
|
203
|
+
options: t,
|
|
203
204
|
emit: a
|
|
204
205
|
}) {
|
|
205
206
|
try {
|
|
206
|
-
const n = await F({ api:
|
|
207
|
-
a("session.loaded",
|
|
208
|
-
const s = await
|
|
209
|
-
api:
|
|
207
|
+
const n = await F({ 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 W({
|
|
|
215
216
|
}
|
|
216
217
|
}
|
|
217
218
|
async function F({
|
|
218
|
-
api:
|
|
219
|
-
options:
|
|
219
|
+
api: e,
|
|
220
|
+
options: t
|
|
220
221
|
}) {
|
|
221
|
-
return
|
|
222
|
-
amount:
|
|
223
|
-
amountCurrency:
|
|
224
|
-
descriptor:
|
|
225
|
-
referenceNumber:
|
|
222
|
+
return l(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: k(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: k(e)
|
|
240
241
|
};
|
|
241
242
|
}
|
|
242
|
-
function
|
|
243
|
-
return !!
|
|
243
|
+
function k(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
|
|
@@ -315,6 +316,9 @@ const B = {
|
|
|
315
316
|
"wallet.manualQrName": "Manual QR Code",
|
|
316
317
|
"wallet.otherWallets": "Other wallets",
|
|
317
318
|
"wallet.connectingTo": "Connecting to {wallet}",
|
|
319
|
+
"wallet.discoveryFailedTitle": "Couldn't connect to {wallet}",
|
|
320
|
+
"wallet.discoveryFailedHint": "The connection didn't go through. Try again, or choose another way to pay.",
|
|
321
|
+
"wallet.tryAgain": "Try again",
|
|
318
322
|
"wallet.approveInApp": "Open {wallet} to connect your wallet, then navigate back to this page.",
|
|
319
323
|
"wallet.openFailedHint": "Didn't see {wallet} open? Tap the button above to try again, or make sure it's installed.",
|
|
320
324
|
"wallet.openApp": "Open {wallet}",
|
|
@@ -336,6 +340,7 @@ const B = {
|
|
|
336
340
|
"network.recommended": "RECOMMENDED",
|
|
337
341
|
"network.fee": "Network fee: {fee}",
|
|
338
342
|
"kyc.additionalInfoRequired": "Additional info required",
|
|
343
|
+
"kyc.complianceWaiting": "Your details are being verified. This can take a few moments.",
|
|
339
344
|
"kyc.stepBasic": "Basic details",
|
|
340
345
|
"kyc.stepAddress": "Address",
|
|
341
346
|
"kyc.stepDocument": "Verification document",
|
|
@@ -487,28 +492,28 @@ const B = {
|
|
|
487
492
|
"validation.customerDetailsMissing": "Customer details are missing.",
|
|
488
493
|
"validation.invalidOtp": "Please enter a valid 6-digit code.",
|
|
489
494
|
"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>.'
|
|
490
|
-
}, f = { en: B },
|
|
491
|
-
let
|
|
495
|
+
}, f = { en: B }, E = "en";
|
|
496
|
+
let D = E;
|
|
492
497
|
function te() {
|
|
493
|
-
return
|
|
498
|
+
return D;
|
|
494
499
|
}
|
|
495
|
-
function v(
|
|
500
|
+
function v(e, t) {
|
|
496
501
|
var n;
|
|
497
|
-
const a = ((n = f[
|
|
498
|
-
return
|
|
502
|
+
const a = ((n = f[D]) == null ? void 0 : n[e]) ?? f[E][e] ?? e;
|
|
503
|
+
return t ? a.replace(
|
|
499
504
|
/\{(\w+)\}/g,
|
|
500
|
-
(o, r) =>
|
|
505
|
+
(o, r) => t[r] != null ? String(t[r]) : `{${r}}`
|
|
501
506
|
) : a;
|
|
502
507
|
}
|
|
503
|
-
function
|
|
504
|
-
return
|
|
508
|
+
function _(e) {
|
|
509
|
+
return e === u.SUCCESS ? "succeeded" : e < u.PENDING && e !== u.KYC_VERIFICATION_PENDING && e !== u.COMPLIANCE_PENDING ? "failed" : "active";
|
|
505
510
|
}
|
|
506
|
-
function
|
|
507
|
-
transaction:
|
|
508
|
-
session:
|
|
511
|
+
function q({
|
|
512
|
+
transaction: e,
|
|
513
|
+
session: t
|
|
509
514
|
}) {
|
|
510
515
|
var o, r, s;
|
|
511
|
-
const a =
|
|
516
|
+
const a = _(e.status);
|
|
512
517
|
if (a === "active")
|
|
513
518
|
return null;
|
|
514
519
|
if (a === "failed")
|
|
@@ -519,53 +524,53 @@ function _({
|
|
|
519
524
|
shouldEndCheckout: !0,
|
|
520
525
|
// Negative (non-KYC) status — cancelled / fraud / timeout.
|
|
521
526
|
reason: "blocked",
|
|
522
|
-
transactionID:
|
|
523
|
-
redirectURL: m(
|
|
527
|
+
transactionID: e.transactionID,
|
|
528
|
+
redirectURL: m(t == null ? void 0 : t.failureURL)
|
|
524
529
|
}
|
|
525
530
|
};
|
|
526
|
-
const n = (o =
|
|
527
|
-
(i) => i.status ===
|
|
531
|
+
const n = (o = e.payments) == null ? void 0 : o.find(
|
|
532
|
+
(i) => i.status === O.CONFIRMED
|
|
528
533
|
);
|
|
529
534
|
return {
|
|
530
535
|
outcome: a,
|
|
531
536
|
event: {
|
|
532
|
-
transactionID:
|
|
537
|
+
transactionID: e.transactionID,
|
|
533
538
|
asset: n == null ? void 0 : n.cryptoAsset,
|
|
534
539
|
network: n == null ? void 0 : n.cryptoNetwork
|
|
535
540
|
},
|
|
536
541
|
result: {
|
|
537
|
-
transactionID:
|
|
538
|
-
amount: (r =
|
|
539
|
-
currency: (s =
|
|
542
|
+
transactionID: e.transactionID,
|
|
543
|
+
amount: (r = e.amounts) == null ? void 0 : r.totalLocal,
|
|
544
|
+
currency: (s = e.amounts) == null ? void 0 : s.currency,
|
|
540
545
|
asset: n == null ? void 0 : n.cryptoAsset,
|
|
541
546
|
network: n == null ? void 0 : n.cryptoNetwork,
|
|
542
547
|
completedAt: n == null ? void 0 : n.completedAt,
|
|
543
|
-
redirectURL: m(
|
|
548
|
+
redirectURL: m(t == null ? void 0 : t.successURL)
|
|
544
549
|
}
|
|
545
550
|
};
|
|
546
551
|
}
|
|
547
552
|
function K() {
|
|
548
|
-
let
|
|
553
|
+
let e = null;
|
|
549
554
|
return {
|
|
550
|
-
setOptions: (
|
|
551
|
-
|
|
555
|
+
setOptions: (t) => {
|
|
556
|
+
e = t;
|
|
552
557
|
},
|
|
553
|
-
emit: (
|
|
554
|
-
paymentFailed: (
|
|
558
|
+
emit: (t, a) => C(e == null ? void 0 : e.onEvent, t, a),
|
|
559
|
+
paymentFailed: (t, a) => {
|
|
555
560
|
var n;
|
|
556
|
-
return (n =
|
|
561
|
+
return (n = e == null ? void 0 : e.paymentFailedListener) == null ? void 0 : n.call(e, t, a);
|
|
557
562
|
},
|
|
558
|
-
paymentSucceeded: (
|
|
563
|
+
paymentSucceeded: (t) => {
|
|
559
564
|
var a;
|
|
560
|
-
return (a =
|
|
565
|
+
return (a = e == null ? void 0 : e.paymentSuccessListener) == null ? void 0 : a.call(e, t);
|
|
561
566
|
},
|
|
562
|
-
paymentCanceled: (
|
|
567
|
+
paymentCanceled: (t) => {
|
|
563
568
|
var a;
|
|
564
|
-
return (a =
|
|
569
|
+
return (a = e == null ? void 0 : e.paymentCanceledListener) == null ? void 0 : a.call(e, t);
|
|
565
570
|
}
|
|
566
571
|
};
|
|
567
572
|
}
|
|
568
|
-
class
|
|
573
|
+
class G extends HTMLElement {
|
|
569
574
|
constructor() {
|
|
570
575
|
super(), this.engine = null, this.engineLoadPromise = null, this.isTornDown = !1, this.shadow = this.attachShadow({ mode: "open" });
|
|
571
576
|
}
|
|
@@ -574,26 +579,26 @@ class j extends HTMLElement {
|
|
|
574
579
|
connectedCallback() {
|
|
575
580
|
this.isTornDown = !1;
|
|
576
581
|
}
|
|
577
|
-
async initialize(
|
|
578
|
-
const a =
|
|
579
|
-
!o || this.isTornDown || (this.engine = o, await o.initialize(
|
|
582
|
+
async initialize(t) {
|
|
583
|
+
const a = H(t), n = j({ api: a, options: t }), o = await this.loadEngine(t, n);
|
|
584
|
+
!o || this.isTornDown || (this.engine = o, await o.initialize(t, { api: a, sessionLoad: n }));
|
|
580
585
|
}
|
|
581
|
-
async loadEngine(
|
|
586
|
+
async loadEngine(t, a) {
|
|
582
587
|
const n = this.getOrLoadEngine();
|
|
583
588
|
try {
|
|
584
589
|
return await n;
|
|
585
590
|
} catch {
|
|
586
591
|
return await this.handleEngineLoadFailure({
|
|
587
592
|
engineLoad: n,
|
|
588
|
-
options:
|
|
593
|
+
options: t,
|
|
589
594
|
sessionLoad: a
|
|
590
595
|
}), null;
|
|
591
596
|
}
|
|
592
597
|
}
|
|
593
|
-
async updateTransaction(
|
|
598
|
+
async updateTransaction(t) {
|
|
594
599
|
if (!this.engine)
|
|
595
600
|
throw new Error("Tether Pay not initialized.");
|
|
596
|
-
await this.engine.updateTransaction(
|
|
601
|
+
await this.engine.updateTransaction(t);
|
|
597
602
|
}
|
|
598
603
|
// A merchant SPA can unmount the element at any time; nothing else stops this
|
|
599
604
|
// instance's timers.
|
|
@@ -603,8 +608,8 @@ class j extends HTMLElement {
|
|
|
603
608
|
// Not started in the constructor: a page can carry the tag and never check out.
|
|
604
609
|
// Overlapping initialize() calls share one download.
|
|
605
610
|
getOrLoadEngine() {
|
|
606
|
-
return this.engineLoadPromise ?? (this.engineLoadPromise = import("./mountEngine-
|
|
607
|
-
const a =
|
|
611
|
+
return this.engineLoadPromise ?? (this.engineLoadPromise = import("./mountEngine-uNB2ytN4.js").then((t) => t.m).then((t) => {
|
|
612
|
+
const a = t.mountCheckoutEngine({
|
|
608
613
|
host: this,
|
|
609
614
|
shadowRoot: this.shadow
|
|
610
615
|
});
|
|
@@ -612,11 +617,11 @@ class j extends HTMLElement {
|
|
|
612
617
|
})), this.engineLoadPromise;
|
|
613
618
|
}
|
|
614
619
|
async handleEngineLoadFailure({
|
|
615
|
-
engineLoad:
|
|
620
|
+
engineLoad: t,
|
|
616
621
|
options: a,
|
|
617
622
|
sessionLoad: n
|
|
618
623
|
}) {
|
|
619
|
-
this.engineLoadPromise ===
|
|
624
|
+
this.engineLoadPromise === t && (this.engineLoadPromise = null, await this.reportEngineFailure({ options: a, sessionLoad: n }));
|
|
620
625
|
}
|
|
621
626
|
// A host that removed the element has walked away; a failure report could send
|
|
622
627
|
// it to a failureURL for a checkout it dismissed.
|
|
@@ -628,7 +633,7 @@ class j extends HTMLElement {
|
|
|
628
633
|
// an outcome the gateway has already decided — a session resumed after the
|
|
629
634
|
// payment settled must report that payment, not a dead checkout.
|
|
630
635
|
async reportEngineFailure({
|
|
631
|
-
options:
|
|
636
|
+
options: t,
|
|
632
637
|
sessionLoad: a
|
|
633
638
|
}) {
|
|
634
639
|
if (this.isDismissedByHost)
|
|
@@ -637,8 +642,8 @@ class j extends HTMLElement {
|
|
|
637
642
|
if (this.isDismissedByHost)
|
|
638
643
|
return;
|
|
639
644
|
const o = K();
|
|
640
|
-
o.setOptions(
|
|
641
|
-
const r = n.ok && n.linkedTransaction ?
|
|
645
|
+
o.setOptions(t);
|
|
646
|
+
const r = n.ok && n.linkedTransaction ? q({
|
|
642
647
|
transaction: n.linkedTransaction,
|
|
643
648
|
session: n.session
|
|
644
649
|
}) : null;
|
|
@@ -654,7 +659,7 @@ class j extends HTMLElement {
|
|
|
654
659
|
}), o.paymentFailed(r.message, r.failure);
|
|
655
660
|
return;
|
|
656
661
|
}
|
|
657
|
-
const s = v("errors.checkoutUnavailable"), i =
|
|
662
|
+
const s = v("errors.checkoutUnavailable"), i = $({
|
|
658
663
|
message: s,
|
|
659
664
|
reason: "error",
|
|
660
665
|
shouldEndCheckout: !0,
|
|
@@ -664,83 +669,83 @@ class j extends HTMLElement {
|
|
|
664
669
|
}
|
|
665
670
|
// Always teardown and unmount together to avoid leaking the React engine.
|
|
666
671
|
// Clear the cached load so a later initialize() creates a fresh engine.
|
|
667
|
-
releaseEngine(
|
|
668
|
-
|
|
672
|
+
releaseEngine(t = this.engine) {
|
|
673
|
+
t == null || t.teardown(), t == null || t.unmount(), this.engine = null, this.engineLoadPromise = null;
|
|
669
674
|
}
|
|
670
675
|
}
|
|
671
|
-
function
|
|
676
|
+
function H(e) {
|
|
672
677
|
return new R(
|
|
673
|
-
|
|
674
|
-
|
|
678
|
+
U(e),
|
|
679
|
+
l(e) ? void 0 : e.publishableKey
|
|
675
680
|
);
|
|
676
681
|
}
|
|
677
|
-
function
|
|
678
|
-
api:
|
|
679
|
-
options:
|
|
682
|
+
function j({
|
|
683
|
+
api: e,
|
|
684
|
+
options: t
|
|
680
685
|
}) {
|
|
681
686
|
return W({
|
|
682
|
-
api:
|
|
683
|
-
options:
|
|
684
|
-
emit: (a, n) =>
|
|
687
|
+
api: e,
|
|
688
|
+
options: t,
|
|
689
|
+
emit: (a, n) => C(t.onEvent, a, n)
|
|
685
690
|
});
|
|
686
691
|
}
|
|
687
|
-
customElements.get("lydian-checkout") || customElements.define("lydian-checkout",
|
|
692
|
+
customElements.get("lydian-checkout") || customElements.define("lydian-checkout", G);
|
|
688
693
|
function h() {
|
|
689
694
|
return document.querySelector("lydian-checkout");
|
|
690
695
|
}
|
|
691
|
-
async function z(
|
|
692
|
-
if (!
|
|
696
|
+
async function z(e) {
|
|
697
|
+
if (!e.publishableKey || !e.transaction.amount || !e.transaction.currency)
|
|
693
698
|
throw new Error("SDK initialization requires publishableKey and a transaction");
|
|
694
|
-
const
|
|
695
|
-
if (
|
|
696
|
-
throw new Error(
|
|
697
|
-
if (!
|
|
699
|
+
const t = T(e);
|
|
700
|
+
if (t)
|
|
701
|
+
throw new Error(t);
|
|
702
|
+
if (!A(e.transaction.currency))
|
|
698
703
|
throw new Error("Invalid value for currency, valid values are: " + g.join(", "));
|
|
699
704
|
const a = b({
|
|
700
|
-
options:
|
|
705
|
+
options: e,
|
|
701
706
|
unsupportedKeys: ["sessionID"],
|
|
702
707
|
entryPoint: "init"
|
|
703
708
|
});
|
|
704
709
|
if (a)
|
|
705
710
|
throw new Error(a);
|
|
706
|
-
await h().initialize(
|
|
711
|
+
await h().initialize(e);
|
|
707
712
|
}
|
|
708
|
-
async function Q(
|
|
709
|
-
if (!
|
|
713
|
+
async function Q(e) {
|
|
714
|
+
if (!e.sessionID)
|
|
710
715
|
throw new Error("initExistingSession requires a sessionID");
|
|
711
|
-
const
|
|
712
|
-
if (
|
|
713
|
-
throw new Error(
|
|
716
|
+
const t = T(e);
|
|
717
|
+
if (t)
|
|
718
|
+
throw new Error(t);
|
|
714
719
|
const a = b({
|
|
715
|
-
options:
|
|
720
|
+
options: e,
|
|
716
721
|
unsupportedKeys: ["publishableKey", "transaction"],
|
|
717
722
|
entryPoint: "initExistingSession"
|
|
718
723
|
});
|
|
719
724
|
if (a)
|
|
720
725
|
throw new Error(a);
|
|
721
|
-
await h().initialize(
|
|
726
|
+
await h().initialize(e);
|
|
722
727
|
}
|
|
723
|
-
async function J(
|
|
724
|
-
await h().updateTransaction(
|
|
728
|
+
async function J(e) {
|
|
729
|
+
await h().updateTransaction(e);
|
|
725
730
|
}
|
|
726
731
|
window.Lydian = { init: z, initExistingSession: Q, updateTransaction: J };
|
|
727
732
|
export {
|
|
728
|
-
|
|
729
|
-
|
|
733
|
+
O as P,
|
|
734
|
+
u as T,
|
|
730
735
|
Z as a,
|
|
731
736
|
V as b,
|
|
732
737
|
g as c,
|
|
733
738
|
x as d,
|
|
734
|
-
|
|
735
|
-
|
|
739
|
+
M as e,
|
|
740
|
+
Y as f,
|
|
736
741
|
te as g,
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
+
l as h,
|
|
743
|
+
A as i,
|
|
744
|
+
_ as j,
|
|
745
|
+
q as k,
|
|
746
|
+
k as l,
|
|
742
747
|
ee as m,
|
|
743
|
-
|
|
748
|
+
$ as n,
|
|
744
749
|
X as o,
|
|
745
750
|
K as p,
|
|
746
751
|
F as r,
|