@lydianpay/sdk-web 3.1.0 → 3.2.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/README.md CHANGED
@@ -102,9 +102,10 @@ Optional per-embed settings. Only settings your Lydian account cannot express li
102
102
  here — everything else is configured once on the merchant portal and applies to
103
103
  every checkout automatically.
104
104
 
105
- | Field | Type | Default | Description |
106
- | --------------- | --------- | ------- | --------------------------------------------------------------------------------- |
107
- | `walletConnect` | `boolean` | `false` | Offer wallet connection alongside the QR code. Not available from account config. |
105
+ | Field | Type | Default | Description |
106
+ | --------------- | --------- | ------- | ------------------------------------------------------------------------------------------------- |
107
+ | `walletConnect` | `boolean` | `false` | Offer wallet connection alongside the QR code. Not available from account config. |
108
+ | `assetFirst` | `boolean` | `false` | Ask the customer to pick the coin before the network, instead of the default network-first order. |
108
109
 
109
110
  Configured on your Lydian account, not here. They apply to every checkout and there
110
111
  is no per-embed override:
@@ -112,12 +113,12 @@ is no per-embed override:
112
113
  | Setting | Description |
113
114
  | -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
114
115
  | `showApprovalPage` | Show the scan-to-pay screen as a confirmation step before asking a connected wallet to sign. Off by default — the wallet opens straight away. |
115
- | `hideNoWalletOption` | Hide the "I don't have a supported wallet" link. |
116
+ | `hideNoWalletOption` | Legacy field name retained for compatibility. When true, hides the "Other wallets" option on the wallet selection screen. |
116
117
 
117
118
  ```js
118
119
  window.Lydian.init({
119
120
  // ...
120
- flow: { walletConnect: true },
121
+ flow: { walletConnect: true, assetFirst: true },
121
122
  });
122
123
  ```
123
124
 
@@ -2,7 +2,7 @@ const g = ["USD", "TRY", "PHP"];
2
2
  function S(t) {
3
3
  return typeof t == "string" && g.includes(t);
4
4
  }
5
- function l(t) {
5
+ function c(t) {
6
6
  return "sessionID" in t && typeof t.sessionID == "string" && t.sessionID.length > 0;
7
7
  }
8
8
  class u {
@@ -41,14 +41,14 @@ class u {
41
41
  throw new Error(s.statusText);
42
42
  }
43
43
  }
44
- const c = "transaction";
45
- class I extends u {
44
+ const l = "transaction";
45
+ class N extends u {
46
46
  async getCryptoTransaction(e) {
47
- return await this.request(`/${c}/${e}`);
47
+ return await this.request(`/${l}/${e}`);
48
48
  }
49
49
  async createPaymentRequest(e, a) {
50
50
  return await this.request(
51
- `/${c}/${e}/payment`,
51
+ `/${l}/${e}/payment`,
52
52
  {
53
53
  method: "POST",
54
54
  body: JSON.stringify(a)
@@ -57,7 +57,7 @@ class I extends u {
57
57
  }
58
58
  async cancelCryptoTransaction(e, a) {
59
59
  return await this.request(
60
- `/${c}/${e}/cancel`,
60
+ `/${l}/${e}/cancel`,
61
61
  {
62
62
  method: "PATCH",
63
63
  body: JSON.stringify(a)
@@ -67,7 +67,7 @@ class I extends u {
67
67
  async kycVerification(e, a) {
68
68
  const n = new FormData();
69
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
- `/${c}/${e}/verification`,
70
+ `/${l}/${e}/verification`,
71
71
  {
72
72
  method: "POST",
73
73
  body: n
@@ -75,7 +75,7 @@ class I extends u {
75
75
  );
76
76
  }
77
77
  }
78
- function A(t, e) {
78
+ function I(t, e) {
79
79
  e.forEach((a) => {
80
80
  Object.getOwnPropertyNames(a.prototype).forEach((n) => {
81
81
  const o = Object.getOwnPropertyDescriptor(a.prototype, n);
@@ -84,7 +84,7 @@ function A(t, e) {
84
84
  });
85
85
  }
86
86
  const w = "customer/otp";
87
- class N extends u {
87
+ class A extends u {
88
88
  // PATCH /customer/otp -> text/plain "OTP sent" (no JSON body).
89
89
  async sendCustomerOTP(e) {
90
90
  return await this.requestText(`/${w}`, {
@@ -133,7 +133,7 @@ class L extends u {
133
133
  }
134
134
  class P extends u {
135
135
  }
136
- A(P, [I, N, L]);
136
+ I(P, [N, A, L]);
137
137
  const R = P;
138
138
  var y = {
139
139
  API_CANCELLED: -9,
@@ -178,17 +178,17 @@ function C(t) {
178
178
  return (e = t.flow) != null && e.walletConnect && !t.walletConnectProjectId ? "walletConnectProjectId is required when flow.walletConnect is on" : null;
179
179
  }
180
180
  function X(t) {
181
- return t !== null && !l(t) && !!t.publishableKey;
181
+ return t !== null && !c(t) && !!t.publishableKey;
182
182
  }
183
183
  function V(t) {
184
- return t !== null && !l(t);
184
+ return t !== null && !c(t);
185
185
  }
186
186
  function ee({
187
187
  options: t,
188
188
  session: e,
189
189
  settled: a
190
190
  }) {
191
- return !a && e !== null && t !== null && l(t);
191
+ return !a && e !== null && t !== null && c(t);
192
192
  }
193
193
  function T(t, e, a) {
194
194
  try {
@@ -197,13 +197,13 @@ function T(t, e, a) {
197
197
  console.error(`onEvent("${e}") threw:`, n);
198
198
  }
199
199
  }
200
- async function W({
200
+ async function F({
201
201
  api: t,
202
202
  options: e,
203
203
  emit: a
204
204
  }) {
205
205
  try {
206
- const n = await F({ api: t, options: e }), { session: o, sessionPromoted: r } = await x({ api: t, sessionID: n });
206
+ const n = await W({ api: t, options: e }), { session: o, sessionPromoted: r } = await x({ api: t, sessionID: n });
207
207
  a("session.loaded", $(o));
208
208
  const s = await M({
209
209
  api: t,
@@ -214,11 +214,11 @@ async function W({
214
214
  return { ok: !1 };
215
215
  }
216
216
  }
217
- async function F({
217
+ async function W({
218
218
  api: t,
219
219
  options: e
220
220
  }) {
221
- return l(e) ? e.sessionID : (await t.createSession({
221
+ return c(e) ? e.sessionID : (await t.createSession({
222
222
  amount: e.transaction.amount,
223
223
  amountCurrency: e.transaction.currency,
224
224
  descriptor: e.transaction.descriptor,
@@ -311,27 +311,23 @@ const q = {
311
311
  "header.merchantLogoAlt": "Merchant logo",
312
312
  "header.changePaymentMethod": "Change payment method",
313
313
  "wallet.chooseWallet": "Choose your crypto wallet",
314
- "wallet.noSupportedWallet": "I don't have a supported wallet",
315
314
  "wallet.featured": "FEATURED",
316
315
  "wallet.manualQrName": "Manual QR Code",
317
316
  "wallet.otherWallets": "Other wallets",
318
317
  "wallet.connectingTo": "Connecting to {wallet}",
319
- "wallet.approveInApp": "Open the {wallet} app and approve the connection request.",
318
+ "wallet.approveInApp": "Open {wallet} to connect your wallet, then navigate back to this page.",
320
319
  "wallet.openFailedHint": "Didn't see {wallet} open? Tap the button above to try again, or make sure it's installed.",
321
320
  "wallet.openApp": "Open {wallet}",
322
321
  "wallet.openInBrowser": "Try a different way to open {wallet}",
323
322
  "wallet.install": "Install {wallet}",
324
323
  "wallet.connectNamed": "Connect {wallet}",
325
324
  "wallet.scanToConnect": "Scan with your phone to connect with {wallet}.",
326
- "wallet.downloadLydian": "Download Lydian",
327
- "wallet.downloadLydianDescription": "Download the Lydian Wallet to easily load funds, manage your assets, and make seamless payments with crypto.",
328
- "wallet.downloadFromAppStore": "Download from the App Store",
329
- "wallet.downloadFromGooglePlay": "Get it on Google Play",
330
- "wallet.backToWallets": "Back to wallets",
331
325
  "asset.chooseCoin": "Choose a coin",
332
326
  "asset.markupNotice": "Conversion includes a {percent}% markup fee",
333
327
  "network.chooseNetwork": "Choose a network",
334
328
  "network.walletSupportWarning": "Please make sure you choose a network that your crypto wallet supports.",
329
+ "network.noSupportedNetworks": "{wallet} doesn't support any of the networks available for this payment.",
330
+ "network.noSupportedNetworksForMerchant": "{wallet} doesn't support any of the networks available for {merchant}.",
335
331
  "network.recommended": "RECOMMENDED",
336
332
  "network.fee": "Network fee: {fee}",
337
333
  "kyc.additionalInfoRequired": "Additional info required",
@@ -570,7 +566,7 @@ class j extends HTMLElement {
570
566
  this.isTornDown = !1;
571
567
  }
572
568
  async initialize(e) {
573
- const a = G(e), n = H({ api: a, options: e }), o = await this.loadEngine(e, n);
569
+ const a = H(e), n = z({ api: a, options: e }), o = await this.loadEngine(e, n);
574
570
  !o || this.isTornDown || (this.engine = o, await o.initialize(e, { api: a, sessionLoad: n }));
575
571
  }
576
572
  async loadEngine(e, a) {
@@ -598,7 +594,7 @@ class j extends HTMLElement {
598
594
  // Not started in the constructor: a page can carry the tag and never check out.
599
595
  // Overlapping initialize() calls share one download.
600
596
  getOrLoadEngine() {
601
- return this.engineLoadPromise ?? (this.engineLoadPromise = import("./mountEngine-DjacHrH_.js").then((e) => e.m).then((e) => {
597
+ return this.engineLoadPromise ?? (this.engineLoadPromise = import("./mountEngine-P1Ws89oo.js").then((e) => e.m).then((e) => {
602
598
  const a = e.mountCheckoutEngine({
603
599
  host: this,
604
600
  shadowRoot: this.shadow
@@ -663,17 +659,17 @@ class j extends HTMLElement {
663
659
  e == null || e.teardown(), e == null || e.unmount(), this.engine = null, this.engineLoadPromise = null;
664
660
  }
665
661
  }
666
- function G(t) {
662
+ function H(t) {
667
663
  return new R(
668
664
  O(t),
669
- l(t) ? void 0 : t.publishableKey
665
+ c(t) ? void 0 : t.publishableKey
670
666
  );
671
667
  }
672
- function H({
668
+ function z({
673
669
  api: t,
674
670
  options: e
675
671
  }) {
676
- return W({
672
+ return F({
677
673
  api: t,
678
674
  options: e,
679
675
  emit: (a, n) => T(e.onEvent, a, n)
@@ -683,7 +679,7 @@ customElements.get("lydian-checkout") || customElements.define("lydian-checkout"
683
679
  function h() {
684
680
  return document.querySelector("lydian-checkout");
685
681
  }
686
- async function z(t) {
682
+ async function G(t) {
687
683
  if (!t.publishableKey || !t.transaction.amount || !t.transaction.currency)
688
684
  throw new Error("SDK initialization requires publishableKey and a transaction");
689
685
  const e = C(t);
@@ -718,7 +714,7 @@ async function Q(t) {
718
714
  async function J(t) {
719
715
  await h().updateTransaction(t);
720
716
  }
721
- window.Lydian = { init: z, initExistingSession: Q, updateTransaction: J };
717
+ window.Lydian = { init: G, initExistingSession: Q, updateTransaction: J };
722
718
  export {
723
719
  U as P,
724
720
  y as T,
@@ -729,7 +725,7 @@ export {
729
725
  $ as e,
730
726
  M as f,
731
727
  te as g,
732
- l as h,
728
+ c as h,
733
729
  S as i,
734
730
  B as j,
735
731
  _ as k,
@@ -738,7 +734,7 @@ export {
738
734
  Y as n,
739
735
  X as o,
740
736
  K as p,
741
- F as r,
737
+ W as r,
742
738
  m as s,
743
739
  v as t
744
740
  };
@@ -1,4 +1,4 @@
1
- import { i as Fe, I as ft, g as Qt, h as pt, b as jn, s as Bn } from "./mountEngine-DjacHrH_.js";
1
+ import { i as Fe, I as ft, g as Qt, h as pt, b as jn, s as Bn } from "./mountEngine-P1Ws89oo.js";
2
2
  function Wn(t, e) {
3
3
  if (!Fe(t, { strict: !1 }))
4
4
  throw new ft({ address: t });
@@ -1,7 +1,7 @@
1
1
  var Gf = Object.defineProperty;
2
2
  var Yf = (t, e, n) => e in t ? Gf(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
3
  var Ht = (t, e, n) => Yf(t, typeof e != "symbol" ? e + "" : e, n);
4
- import { c as ei, g as ga } from "./mountEngine-DjacHrH_.js";
4
+ import { c as ei, g as ga } from "./mountEngine-P1Ws89oo.js";
5
5
  var ti = { exports: {} }, cc;
6
6
  function Zf() {
7
7
  return cc || (cc = 1, (function(t, e) {