@lydianpay/sdk-web 2.0.0 → 2.0.2

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.
@@ -39,7 +39,6 @@ export declare const AllowedAssetUSDP = "USDP";
39
39
  export declare const AllowedAssetUSDS = "USDS";
40
40
  export declare const AllowedAssetUSDT = "USDT";
41
41
  export declare const AllowedAssetZKsync = "ZKSYNC";
42
- export declare const SupportedCheckoutNetworks: string[];
43
42
  export declare const AssetUSDT: DisplayAsset;
44
43
  export declare const AssetUSDC: DisplayAsset;
45
44
  export declare const AssetEthereum: DisplayAsset;
@@ -73,6 +72,8 @@ export type CheckoutNetwork = {
73
72
  };
74
73
  export declare const CheckoutNetworks: Record<string, CheckoutNetwork>;
75
74
  export declare const NetworkAssetContracts: Record<string, Record<string, string>>;
75
+ export declare const SupportedCheckoutNetworks: string[];
76
+ export declare const CheckoutNativeAssets: Record<string, string>;
76
77
  /** The onchain contract for an asset on a network, or undefined for a native coin. */
77
78
  export declare function tokenContract(networkCode: string, assetCode: string): string | undefined;
78
79
  export type CheckoutWallet = {
@@ -9,8 +9,6 @@ export type Transaction = {
9
9
  };
10
10
  export type InitFlowOptions = {
11
11
  walletConnect?: boolean;
12
- skipConfirmationPage?: boolean;
13
- hideNoWalletOption?: boolean;
14
12
  };
15
13
  /**
16
14
  * Every `redirectURL` below is the merchant's own URL from the session, and is only
@@ -74,7 +74,7 @@ export declare class Checkout extends HTMLElement {
74
74
  private qrCodeLink;
75
75
  private pendingWalletSend;
76
76
  private countdownBanner;
77
- private checkoutSettled;
77
+ private isCheckoutSettled;
78
78
  private btnAppPayment;
79
79
  private btnCryptoPayment;
80
80
  private selectedAsset;
@@ -168,6 +168,8 @@ export declare class Checkout extends HTMLElement {
168
168
  private enterCryptoFlow;
169
169
  private emit;
170
170
  private handleWalletChainChanged;
171
+ private expectedChains;
172
+ private warnWrongChain;
171
173
  private showButtons;
172
174
  private hideButtons;
173
175
  private showQRCode;
@@ -182,6 +184,8 @@ export declare class Checkout extends HTMLElement {
182
184
  private flashCopyFeedback;
183
185
  private attachListeners;
184
186
  private startListeningCryptoTransaction;
187
+ private readTransactionOnce;
188
+ private collectUnderpaidBalance;
185
189
  private clearInterval;
186
190
  private settleTerminalTransaction;
187
191
  private updatePaymentHeader;
@@ -222,6 +226,7 @@ export declare class Checkout extends HTMLElement {
222
226
  private populateKycSummaryRows;
223
227
  private applyKycFieldVisibility;
224
228
  private renderKycStep;
229
+ private syncKycContinueEnabled;
225
230
  private readKycFieldValues;
226
231
  private showKycFieldError;
227
232
  private clearKycFieldErrors;
@@ -1,2 +1,5 @@
1
1
  import { CheckoutWallet } from '../../constants';
2
- export default function WalletButton(wallet: CheckoutWallet): string;
2
+ export default function WalletButton({ wallet, badgeLabel, }: {
3
+ wallet: CheckoutWallet;
4
+ badgeLabel?: string;
5
+ }): string;
@@ -0,0 +1 @@
1
+ export default function ChangePaymentMethodRow(): string;
@@ -0,0 +1,3 @@
1
+ export default function FeaturedWalletBanner({ note }: {
2
+ note: string;
3
+ }): string;
@@ -1,9 +1,9 @@
1
1
  export declare const caretDownIconSvg = "<svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M2.5 5.5L8 11L13.5 5.5\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>";
2
2
  export declare const arrowLeftIconSvg = "<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M19 12H5M5 12L11 6M5 12L11 18\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>";
3
3
  export declare const caretRightIconSvg = "<svg width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M9 4.5L16.5 12L9 19.5\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>";
4
- export declare const alertCircleIconSvg = "<svg width=\"20\" height=\"20\" viewBox=\"0 0 512 512\" fill=\"currentColor\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M256 32C132.3 32 32 132.3 32 256s100.3 224 224 224 224-100.3 224-224S379.7 32 256 32zm0 338a26 26 0 1 1 0-52 26 26 0 0 1 0 52zm25-122c-.7 15-11.5 25-25 25s-24.3-10-25-25l-6-114c-.6-17.6 12.2-32 31-32s31.6 14.4 31 32z\"/>\n</svg>";
4
+ export declare const alertCircleIconSvg = "<svg width=\"24\" height=\"24\" viewBox=\"0 0 512 512\" fill=\"currentColor\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M256 32C132.3 32 32 132.3 32 256s100.3 224 224 224 224-100.3 224-224S379.7 32 256 32zm0 338a26 26 0 1 1 0-52 26 26 0 0 1 0 52zm25-122c-.7 15-11.5 25-25 25s-24.3-10-25-25l-6-114c-.6-17.6 12.2-32 31-32s31.6 14.4 31 32z\"/>\n</svg>";
5
5
  export declare const warningTriangleIconSvg = "<svg width=\"20\" height=\"18\" viewBox=\"0 0 21 19\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M10.5 2.23152L18.7952 16.7657H2.20476L10.5 2.23152ZM0.298949 15.6485C-0.549302 17.1344 0.508258 19 2.20476 19H18.7952C20.4917 19 21.5493 17.1344 20.7011 15.6485L12.4058 1.11436C11.5576 -0.371454 9.44244 -0.371454 8.59419 1.11436L0.298949 15.6485ZM9.39837 7.82846V10.0628C9.39837 10.6772 9.89411 11.1799 10.5 11.1799C11.1059 11.1799 11.6016 10.6772 11.6016 10.0628V7.82846C11.6016 7.21402 11.1059 6.7113 10.5 6.7113C9.89411 6.7113 9.39837 7.21402 9.39837 7.82846ZM9.39837 13.4142H11.6016V15.6485H9.39837Z\" fill=\"currentColor\"/>\n</svg>";
6
- export declare const clockIconSvg = "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M8.62788 16.8262C7.9509 16.6726 7.30072 16.4186 6.69896 16.0725M11.739 3.17285C13.2854 3.52603 14.6661 4.39375 15.655 5.63395C16.6438 6.87415 17.1824 8.41335 17.1824 9.99954C17.1824 11.5857 16.6438 13.1249 15.655 14.3651C14.6661 15.6053 13.2854 16.4731 11.739 16.8262M4.41149 13.9611C3.98721 13.3447 3.66497 12.6639 3.45714 11.945M3.27979 8.83275C3.40423 8.09385 3.64379 7.39384 3.9798 6.75216L4.11125 6.51493M6.22233 4.22754C6.95008 3.72656 7.7665 3.36863 8.62805 3.17285M10.1835 6.88863V9.99981L12.5168 12.3332\" stroke=\"currentColor\" stroke-width=\"1.66667\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>";
6
+ export declare const clockIconSvg = "<svg width=\"28\" height=\"28\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M8.62788 16.8262C7.9509 16.6726 7.30072 16.4186 6.69896 16.0725M11.739 3.17285C13.2854 3.52603 14.6661 4.39375 15.655 5.63395C16.6438 6.87415 17.1824 8.41335 17.1824 9.99954C17.1824 11.5857 16.6438 13.1249 15.655 14.3651C14.6661 15.6053 13.2854 16.4731 11.739 16.8262M4.41149 13.9611C3.98721 13.3447 3.66497 12.6639 3.45714 11.945M3.27979 8.83275C3.40423 8.09385 3.64379 7.39384 3.9798 6.75216L4.11125 6.51493M6.22233 4.22754C6.95008 3.72656 7.7665 3.36863 8.62805 3.17285M10.1835 6.88863V9.99981L12.5168 12.3332\" stroke=\"currentColor\" stroke-width=\"1.66667\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>";
7
7
  export declare const checkCircleIconSvg = "<svg width=\"72\" height=\"72\" viewBox=\"0 0 64 64\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <circle cx=\"32\" cy=\"32\" r=\"32\" fill=\"currentColor\"/>\n <path d=\"M19 33L28 42L45 24\" stroke=\"#ffffff\" stroke-width=\"5.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>";
8
8
  export declare const copyIconSvg = "<svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"currentColor\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M15 1H4C2.9 1 2 1.9 2 3V16C2 16.55 2.45 17 3 17C3.55 17 4 16.55 4 16V4C4 3.45 4.45 3 5 3H15C15.55 3 16 2.55 16 2C16 1.45 15.55 1 15 1ZM19 5H8C6.9 5 6 5.9 6 7V21C6 22.1 6.9 23 8 23H19C20.1 23 21 22.1 21 21V7C21 5.9 20.1 5 19 5ZM18 21H9C8.45 21 8 20.55 8 20V8C8 7.45 8.45 7 9 7H18C18.55 7 19 7.45 19 8V20C19 20.55 18.55 21 18 21Z\"/>\n</svg>";
9
9
  export declare const arrowBendIconSvg = "<svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"currentColor\" xmlns=\"http://www.w3.org/2000/svg\">\n <path fill-rule=\"evenodd\" d=\"M14.854 4.854a.5.5 0 0 0 0-.708l-4-4a.5.5 0 0 0-.708.708L13.293 4H3.5A2.5 2.5 0 0 0 1 6.5v8a.5.5 0 0 0 1 0v-8A1.5 1.5 0 0 1 3.5 5h9.793l-3.147 3.146a.5.5 0 0 0 .708.708l4-4z\"/>\n</svg>";
@@ -14,3 +14,5 @@ export declare const fileIconSvg = "<svg width=\"28\" height=\"28\" viewBox=\"0
14
14
  export declare const checkSmallIconSvg = "<svg width=\"22\" height=\"22\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <circle cx=\"12\" cy=\"12\" r=\"11\" fill=\"currentColor\" opacity=\"0.15\"/>\n <path d=\"M7.5 12.5 10.5 15.5 16.5 9\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>";
15
15
  export declare const checkMarkIconSvg = "<svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M5 12.5 10 17.5 19 7\" stroke=\"currentColor\" stroke-width=\"4\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>";
16
16
  export declare const xCircleIconSvg = "<svg width=\"22\" height=\"22\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <circle cx=\"12\" cy=\"12\" r=\"11\" stroke=\"currentColor\" stroke-width=\"1.6\"/>\n <path d=\"M9 9l6 6M15 9l-6 6\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\"/>\n</svg>";
17
+ export declare const alertCircleOutlineIconSvg = "<svg width=\"40\" height=\"40\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <circle cx=\"12\" cy=\"12\" r=\"10\" stroke=\"currentColor\" stroke-width=\"1.6\"/>\n <path d=\"M12 7v6\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\"/>\n <circle cx=\"12\" cy=\"16.5\" r=\"1.1\" fill=\"currentColor\"/>\n</svg>";
18
+ export declare const walletIconSvg = "<svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M18 7V5.5A1.5 1.5 0 0 0 16.5 4H5a2 2 0 0 0 0 4h13a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n <circle cx=\"16.5\" cy=\"13.5\" r=\"1.25\" fill=\"currentColor\"/>\n</svg>";
@@ -0,0 +1,15 @@
1
+ import { AllowedWalletConfig } from '../types';
2
+ export type FeaturedWallet = {
3
+ id: string;
4
+ note?: string;
5
+ };
6
+ export declare const FEATURED_NOTE_MAX_LENGTH = 60;
7
+ export declare function resolveFeaturedWallet({ allowedWalletsConfig, }: {
8
+ allowedWalletsConfig: AllowedWalletConfig[] | null | undefined;
9
+ }): FeaturedWallet | null;
10
+ export declare function hoistWallet<T extends {
11
+ id: string;
12
+ }>({ wallets, id, }: {
13
+ wallets: T[];
14
+ id: string | undefined;
15
+ }): T[];
@@ -0,0 +1 @@
1
+ export declare function maskEmail(email: string): string;
@@ -10,6 +10,11 @@ export declare function filterAllowedWallets<T extends {
10
10
  id: string;
11
11
  }>(wallets: T[], allowedWalletsConfig: AllowedWalletConfig[] | null | undefined): T[];
12
12
  export declare function matchesExpectedChain(reported: string, expected: readonly string[]): boolean;
13
+ export declare function shouldWarnWrongChain({ connected, reported, expected, }: {
14
+ connected: boolean;
15
+ reported: string;
16
+ expected: readonly string[] | undefined;
17
+ }): boolean;
13
18
  export type OpenInWalletButton = {
14
19
  labelKey: 'scan.openWalletToPay' | 'scan.payWithWallet';
15
20
  walletName: string;
@@ -15,11 +15,14 @@ export declare class RestoreDetailsController {
15
15
  private readonly otpError;
16
16
  private readonly otpEmailLabel;
17
17
  private readonly processingMessage;
18
+ private readonly errorTitle;
18
19
  private readonly errorMessage;
19
20
  private readonly retryButton;
21
+ private readonly sendAgainButton;
20
22
  private readonly otpBoxes;
21
23
  private email;
22
24
  private country;
25
+ private resending;
23
26
  constructor(root: ShadowRoot, deps: RestoreDetailsDeps);
24
27
  private el;
25
28
  private wireControls;
@@ -35,7 +38,10 @@ export declare class RestoreDetailsController {
35
38
  private setFieldError;
36
39
  private setProcessing;
37
40
  private showError;
41
+ private returnToEmailStep;
38
42
  private open;
39
43
  private sendOtp;
44
+ private showOtpStep;
45
+ private sendOtpAgain;
40
46
  private verifyOtp;
41
47
  }
@@ -25,6 +25,10 @@ export declare function getCountdownExpiry({ transaction, session, }: {
25
25
  expiration?: string;
26
26
  } | null;
27
27
  }): number | null;
28
+ export declare function hasOutstandingPaymentRequest(payments: {
29
+ status: number;
30
+ expiration?: string;
31
+ }[], now?: number): boolean;
28
32
  export type RestoreContext = {
29
33
  customerUUID: string;
30
34
  country: string;
@@ -0,0 +1,7 @@
1
+ /** The items in first-seen order, with later duplicates dropped. */
2
+ export declare function unique<T>(items: T[]): T[];
3
+ /**
4
+ * Collects `[key, value]` entries into a Map of key to every value seen for it,
5
+ * both in first-seen order. Keys with one value still get an array.
6
+ */
7
+ export declare function groupValuesByKey<K, V>(entries: [K, V][]): Map<K, V[]>;
@@ -5,12 +5,8 @@ export declare function capitalizeFirstLetter(str: string): string;
5
5
  * @param currency - The currency code (USD or TRY)
6
6
  * @returns Formatted currency string
7
7
  */
8
- export declare function formatCurrency(amount: number, currency?: string | null): string;
8
+ export declare function formatCurrency(amount: number, currency?: string | null, maximumFractionDigits?: number): string;
9
9
  export declare function formatExchangeRate(asset: string, cryptoRatePerUSD: number, fxRateToUSD: number, currency: string): string;
10
10
  export declare function formatDateForTransactionDetails(isoDateString: string): string;
11
11
  export declare function formatDateShort(isoDateString?: string | null): string;
12
- export declare function formatCryptoAmount(num: number): string;
13
- export declare function trimTrailingZeros(decimal: string): string;
14
- export declare function formatToTwoDecimals(num: number): string;
15
- export declare function formatToNDecimals(num: number, precision: number): string;
16
12
  export declare function canvasSafeImageUrl(imageUrl: string): string;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * A USD figure in the customer's local currency.
3
+ *
4
+ * fxRateToUSD is USD-per-local, so this divides. A zero rate returns null rather
5
+ * than Infinity — the caller hides the row instead of printing a nonsense amount.
6
+ */
7
+ export declare function localFromUsd(usdAmount: number, fxRateToUSD: number): number | null;
8
+ /** How much of a partially-paid invoice has landed, in local currency. */
9
+ export declare function paidSoFar(totalLocal: number, remainingLocal: number): number;
10
+ /**
11
+ * The local-currency price of one unit of the asset.
12
+ *
13
+ * cryptoRatePerUSD is USD-per-crypto and fxRateToUSD is USD-per-local, so
14
+ * local-per-crypto is their quotient in this order — inverting it reads correctly
15
+ * only when both are 1. Returns null when either rate is missing or the result is
16
+ * not finite, which is the caller's signal to print nothing.
17
+ */
18
+ export declare function localPerCrypto(cryptoRatePerUSD: number, fxRateToUSD: number): number | null;
19
+ export declare function rateFractionDigits(value: number): number;
20
+ export declare function formatCryptoAmount(num: number): string;
21
+ export declare function trimTrailingZeros(decimal: string): string;
22
+ export declare function formatToTwoDecimals(num: number): string;
23
+ export declare function formatToNDecimals(num: number, precision: number): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lydianpay/sdk-web",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "Drop-in crypto payment checkout for the web — a <lydian-checkout> web component and window.Lydian API across 20+ chains and major stablecoins.",
5
5
  "license": "MIT",
6
6
  "repository": {