@dj-test/payment-sdk 1.0.7 → 1.0.9

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
@@ -222,13 +222,73 @@ function AutoDetectPayment({ depositAddress }: { depositAddress: string }) {
222
222
 
223
223
  ### EVM Wallets
224
224
  - **Injected Wallets**: MetaMask, Trust Wallet, Brave Wallet
225
- - **WalletConnect**: 200+ 모바일 지갑
226
- - **Coinbase Wallet**: Coinbase 공식 지갑
225
+ - **Desktop**: Browser extensions (MetaMask, etc.)
226
+ - **Mobile Web**: In-app browsers + deep links (MetaMask app)
227
227
 
228
228
  ### Tron Wallets
229
229
  - **TronLink**: Official Tron wallet extension
230
230
  - **TronLink Pro**: Mobile wallet with WalletConnect support
231
231
 
232
+ ## Mobile Web Support
233
+
234
+ SDK follows **Daimo Pay approach** for mobile web:
235
+ - ✅ **In-app browser detection**: Auto-detects MetaMask in-app browser
236
+ - ✅ **Deep link support**: Opens MetaMask app from regular mobile browsers
237
+ - ✅ **No WalletConnect needed**: Lightweight solution without WC dependency
238
+
239
+ ### Mobile Web Flow
240
+
241
+ **Option 1: MetaMask In-App Browser** (Recommended)
242
+ ```
243
+ User opens your site in MetaMask app browser
244
+ → SDK detects window.ethereum
245
+ → Direct wallet connection works
246
+ ```
247
+
248
+ **Option 2: Regular Mobile Browser**
249
+ ```tsx
250
+ import { getConnectionStrategy, openMetaMaskDeepLink } from 'payment-sdk';
251
+
252
+ function ConnectButton() {
253
+ const strategy = getConnectionStrategy();
254
+
255
+ const handleConnect = () => {
256
+ if (strategy.type === 'deeplink') {
257
+ // Opens MetaMask app
258
+ openMetaMaskDeepLink();
259
+ } else if (strategy.type === 'injected') {
260
+ // Use wagmi connect
261
+ connect();
262
+ }
263
+ };
264
+
265
+ return <button onClick={handleConnect}>{strategy.message}</button>;
266
+ }
267
+ ```
268
+
269
+ ### Mobile Utilities
270
+
271
+ ```tsx
272
+ import {
273
+ isMobile,
274
+ isMetaMaskBrowser,
275
+ isMetaMaskAvailable,
276
+ shouldUseDeepLink,
277
+ } from 'payment-sdk';
278
+
279
+ // Check if on mobile device
280
+ const mobile = isMobile();
281
+
282
+ // Check if in MetaMask in-app browser
283
+ const inMetaMask = isMetaMaskBrowser();
284
+
285
+ // Check if MetaMask is available (extension or in-app)
286
+ const hasMetaMask = isMetaMaskAvailable();
287
+
288
+ // Determine if should use deep link
289
+ const useDeepLink = shouldUseDeepLink();
290
+ ```
291
+
232
292
  ## API Reference
233
293
 
234
294
  ### PaymentProvider Props
package/dist/index.d.mts CHANGED
@@ -1640,7 +1640,16 @@ declare const supportedChains: ({
1640
1640
  })[];
1641
1641
  /**
1642
1642
  * Create wagmi config following Daimo Pay approach
1643
- * Uses injected connectors + deep links, no WalletConnect dependency
1643
+ * Uses injected connector + deep links, no WalletConnect dependency
1644
+ *
1645
+ * Mobile web flow:
1646
+ * 1. User clicks "Connect Wallet" in mobile browser
1647
+ * 2. If in MetaMask in-app browser -> injected connector detects window.ethereum
1648
+ * 3. If in regular browser -> Use deep link to open MetaMask app (handled by UI layer)
1649
+ *
1650
+ * Desktop flow:
1651
+ * 1. MetaMask extension -> injected connector detects window.ethereum
1652
+ * 2. Other wallets -> injected connector detects their providers
1644
1653
  */
1645
1654
  declare const createWagmiConfig: () => Config$1;
1646
1655
  declare const getEvmChainById: (chainId: number) => {
@@ -3904,4 +3913,41 @@ declare function generatePaymentQRUrl(publicOrderId: string): string;
3904
3913
  */
3905
3914
  declare function getPaymentDomain(): string;
3906
3915
 
3907
- export { APIError, API_ENDPOINTS, ChainType, ChainType as ChainTypes, type CoinChain, type CoinChainResponse, type ConnectorInfo, type CreateOrderParams, DEFAULT_TIMEOUT, ENVIRONMENT_URLS, ERROR_CODES, EvmWalletAdapter, type IWalletAdapter, MIN_WITHDRAWAL_AMOUNT, ORDER_EXPIRY_MINUTES, type Order, type OrderCreateRequest, type OrderDetailResponse, OrderPayment, type OrderResponse, OrderStatus, PAYMENT_DOMAINS, PayWithAddress, type PayWithAddressParams, PayWithWallet, type PayWithWalletParams, PaymentButton, PaymentContext, PaymentFlow, type PaymentMethod$1 as PaymentMethod, type PaymentMethodType, PaymentModal, type PaymentMode, PaymentProvider, PaymentQRCode, type PaymentQRCodeProps, PaymentQRModal, type PaymentQRModalProps, type PaymentSession, type PaymentStatus, type PaymentTransaction, type PaymentTransactionParams, type SDKConfig, type SDKContext, SDKError, SDK_VERSION, SUPPORTED_CHAINS, type SupportedChain, TRON_NETWORKS, type TransactionResult, type TransactionResultInfo, TronWalletAdapter, type UseWalletAdapterOptions, ValidationError, type ValidationResult, WalletAdapterFactory, type WalletBalance, type WalletConnectionInfo, type WalletInfo, WalletProvider, WalletType, WalletType as WalletTypes, type WebhookPayload, type WithdrawalParams, coins as coinsAPI, config, createWagmiConfig, detectChainType, generatePaymentQRUrl, getChainById, getErrorMessage, getEvmChainById, getPaymentDomain, handleAPIError, isEvmAddress, isTronAddress, isValidAddress, orders as ordersAPI, supportedChains, supportedEvmChains, useOrder, usePayment, useWallet, useWalletAdapter, useWalletContext, validation };
3916
+ /**
3917
+ * Mobile wallet utilities for deep links and mobile detection
3918
+ * Following Daimo Pay approach for mobile web wallet connections
3919
+ */
3920
+ /**
3921
+ * Detect if user is on mobile device
3922
+ */
3923
+ declare const isMobile: () => boolean;
3924
+ /**
3925
+ * Detect if user is in MetaMask in-app browser
3926
+ */
3927
+ declare const isMetaMaskBrowser: () => boolean;
3928
+ /**
3929
+ * Detect if MetaMask is available (extension or in-app browser)
3930
+ */
3931
+ declare const isMetaMaskAvailable: () => boolean;
3932
+ /**
3933
+ * Open MetaMask mobile app via deep link
3934
+ * Used when user is on mobile browser but not in MetaMask in-app browser
3935
+ *
3936
+ * @param returnUrl - The URL to return to after wallet connection (optional)
3937
+ */
3938
+ declare const openMetaMaskDeepLink: (returnUrl?: string) => void;
3939
+ /**
3940
+ * Get connection strategy based on environment
3941
+ * Returns the recommended action for connecting wallet
3942
+ */
3943
+ declare const getConnectionStrategy: () => {
3944
+ type: "injected" | "deeplink" | "unavailable";
3945
+ message: string;
3946
+ action?: () => void;
3947
+ };
3948
+ /**
3949
+ * Check if we should use deep link for wallet connection
3950
+ */
3951
+ declare const shouldUseDeepLink: () => boolean;
3952
+
3953
+ export { APIError, API_ENDPOINTS, ChainType, ChainType as ChainTypes, type CoinChain, type CoinChainResponse, type ConnectorInfo, type CreateOrderParams, DEFAULT_TIMEOUT, ENVIRONMENT_URLS, ERROR_CODES, EvmWalletAdapter, type IWalletAdapter, MIN_WITHDRAWAL_AMOUNT, ORDER_EXPIRY_MINUTES, type Order, type OrderCreateRequest, type OrderDetailResponse, OrderPayment, type OrderResponse, OrderStatus, PAYMENT_DOMAINS, PayWithAddress, type PayWithAddressParams, PayWithWallet, type PayWithWalletParams, PaymentButton, PaymentContext, PaymentFlow, type PaymentMethod$1 as PaymentMethod, type PaymentMethodType, PaymentModal, type PaymentMode, PaymentProvider, PaymentQRCode, type PaymentQRCodeProps, PaymentQRModal, type PaymentQRModalProps, type PaymentSession, type PaymentStatus, type PaymentTransaction, type PaymentTransactionParams, type SDKConfig, type SDKContext, SDKError, SDK_VERSION, SUPPORTED_CHAINS, type SupportedChain, TRON_NETWORKS, type TransactionResult, type TransactionResultInfo, TronWalletAdapter, type UseWalletAdapterOptions, ValidationError, type ValidationResult, WalletAdapterFactory, type WalletBalance, type WalletConnectionInfo, type WalletInfo, WalletProvider, WalletType, WalletType as WalletTypes, type WebhookPayload, type WithdrawalParams, coins as coinsAPI, config, createWagmiConfig, detectChainType, generatePaymentQRUrl, getChainById, getConnectionStrategy, getErrorMessage, getEvmChainById, getPaymentDomain, handleAPIError, isEvmAddress, isMetaMaskAvailable, isMetaMaskBrowser, isMobile, isTronAddress, isValidAddress, openMetaMaskDeepLink, orders as ordersAPI, shouldUseDeepLink, supportedChains, supportedEvmChains, useOrder, usePayment, useWallet, useWalletAdapter, useWalletContext, validation };
package/dist/index.d.ts CHANGED
@@ -1640,7 +1640,16 @@ declare const supportedChains: ({
1640
1640
  })[];
1641
1641
  /**
1642
1642
  * Create wagmi config following Daimo Pay approach
1643
- * Uses injected connectors + deep links, no WalletConnect dependency
1643
+ * Uses injected connector + deep links, no WalletConnect dependency
1644
+ *
1645
+ * Mobile web flow:
1646
+ * 1. User clicks "Connect Wallet" in mobile browser
1647
+ * 2. If in MetaMask in-app browser -> injected connector detects window.ethereum
1648
+ * 3. If in regular browser -> Use deep link to open MetaMask app (handled by UI layer)
1649
+ *
1650
+ * Desktop flow:
1651
+ * 1. MetaMask extension -> injected connector detects window.ethereum
1652
+ * 2. Other wallets -> injected connector detects their providers
1644
1653
  */
1645
1654
  declare const createWagmiConfig: () => Config$1;
1646
1655
  declare const getEvmChainById: (chainId: number) => {
@@ -3904,4 +3913,41 @@ declare function generatePaymentQRUrl(publicOrderId: string): string;
3904
3913
  */
3905
3914
  declare function getPaymentDomain(): string;
3906
3915
 
3907
- export { APIError, API_ENDPOINTS, ChainType, ChainType as ChainTypes, type CoinChain, type CoinChainResponse, type ConnectorInfo, type CreateOrderParams, DEFAULT_TIMEOUT, ENVIRONMENT_URLS, ERROR_CODES, EvmWalletAdapter, type IWalletAdapter, MIN_WITHDRAWAL_AMOUNT, ORDER_EXPIRY_MINUTES, type Order, type OrderCreateRequest, type OrderDetailResponse, OrderPayment, type OrderResponse, OrderStatus, PAYMENT_DOMAINS, PayWithAddress, type PayWithAddressParams, PayWithWallet, type PayWithWalletParams, PaymentButton, PaymentContext, PaymentFlow, type PaymentMethod$1 as PaymentMethod, type PaymentMethodType, PaymentModal, type PaymentMode, PaymentProvider, PaymentQRCode, type PaymentQRCodeProps, PaymentQRModal, type PaymentQRModalProps, type PaymentSession, type PaymentStatus, type PaymentTransaction, type PaymentTransactionParams, type SDKConfig, type SDKContext, SDKError, SDK_VERSION, SUPPORTED_CHAINS, type SupportedChain, TRON_NETWORKS, type TransactionResult, type TransactionResultInfo, TronWalletAdapter, type UseWalletAdapterOptions, ValidationError, type ValidationResult, WalletAdapterFactory, type WalletBalance, type WalletConnectionInfo, type WalletInfo, WalletProvider, WalletType, WalletType as WalletTypes, type WebhookPayload, type WithdrawalParams, coins as coinsAPI, config, createWagmiConfig, detectChainType, generatePaymentQRUrl, getChainById, getErrorMessage, getEvmChainById, getPaymentDomain, handleAPIError, isEvmAddress, isTronAddress, isValidAddress, orders as ordersAPI, supportedChains, supportedEvmChains, useOrder, usePayment, useWallet, useWalletAdapter, useWalletContext, validation };
3916
+ /**
3917
+ * Mobile wallet utilities for deep links and mobile detection
3918
+ * Following Daimo Pay approach for mobile web wallet connections
3919
+ */
3920
+ /**
3921
+ * Detect if user is on mobile device
3922
+ */
3923
+ declare const isMobile: () => boolean;
3924
+ /**
3925
+ * Detect if user is in MetaMask in-app browser
3926
+ */
3927
+ declare const isMetaMaskBrowser: () => boolean;
3928
+ /**
3929
+ * Detect if MetaMask is available (extension or in-app browser)
3930
+ */
3931
+ declare const isMetaMaskAvailable: () => boolean;
3932
+ /**
3933
+ * Open MetaMask mobile app via deep link
3934
+ * Used when user is on mobile browser but not in MetaMask in-app browser
3935
+ *
3936
+ * @param returnUrl - The URL to return to after wallet connection (optional)
3937
+ */
3938
+ declare const openMetaMaskDeepLink: (returnUrl?: string) => void;
3939
+ /**
3940
+ * Get connection strategy based on environment
3941
+ * Returns the recommended action for connecting wallet
3942
+ */
3943
+ declare const getConnectionStrategy: () => {
3944
+ type: "injected" | "deeplink" | "unavailable";
3945
+ message: string;
3946
+ action?: () => void;
3947
+ };
3948
+ /**
3949
+ * Check if we should use deep link for wallet connection
3950
+ */
3951
+ declare const shouldUseDeepLink: () => boolean;
3952
+
3953
+ export { APIError, API_ENDPOINTS, ChainType, ChainType as ChainTypes, type CoinChain, type CoinChainResponse, type ConnectorInfo, type CreateOrderParams, DEFAULT_TIMEOUT, ENVIRONMENT_URLS, ERROR_CODES, EvmWalletAdapter, type IWalletAdapter, MIN_WITHDRAWAL_AMOUNT, ORDER_EXPIRY_MINUTES, type Order, type OrderCreateRequest, type OrderDetailResponse, OrderPayment, type OrderResponse, OrderStatus, PAYMENT_DOMAINS, PayWithAddress, type PayWithAddressParams, PayWithWallet, type PayWithWalletParams, PaymentButton, PaymentContext, PaymentFlow, type PaymentMethod$1 as PaymentMethod, type PaymentMethodType, PaymentModal, type PaymentMode, PaymentProvider, PaymentQRCode, type PaymentQRCodeProps, PaymentQRModal, type PaymentQRModalProps, type PaymentSession, type PaymentStatus, type PaymentTransaction, type PaymentTransactionParams, type SDKConfig, type SDKContext, SDKError, SDK_VERSION, SUPPORTED_CHAINS, type SupportedChain, TRON_NETWORKS, type TransactionResult, type TransactionResultInfo, TronWalletAdapter, type UseWalletAdapterOptions, ValidationError, type ValidationResult, WalletAdapterFactory, type WalletBalance, type WalletConnectionInfo, type WalletInfo, WalletProvider, WalletType, WalletType as WalletTypes, type WebhookPayload, type WithdrawalParams, coins as coinsAPI, config, createWagmiConfig, detectChainType, generatePaymentQRUrl, getChainById, getConnectionStrategy, getErrorMessage, getEvmChainById, getPaymentDomain, handleAPIError, isEvmAddress, isMetaMaskAvailable, isMetaMaskBrowser, isMobile, isTronAddress, isValidAddress, openMetaMaskDeepLink, orders as ordersAPI, shouldUseDeepLink, supportedChains, supportedEvmChains, useOrder, usePayment, useWallet, useWalletAdapter, useWalletContext, validation };
package/dist/index.js CHANGED
@@ -62,14 +62,20 @@ __export(index_exports, {
62
62
  detectChainType: () => detectChainType,
63
63
  generatePaymentQRUrl: () => generatePaymentQRUrl,
64
64
  getChainById: () => getChainById,
65
+ getConnectionStrategy: () => getConnectionStrategy,
65
66
  getErrorMessage: () => getErrorMessage,
66
67
  getEvmChainById: () => getEvmChainById,
67
68
  getPaymentDomain: () => getPaymentDomain,
68
69
  handleAPIError: () => handleAPIError,
69
70
  isEvmAddress: () => isEvmAddress,
71
+ isMetaMaskAvailable: () => isMetaMaskAvailable,
72
+ isMetaMaskBrowser: () => isMetaMaskBrowser,
73
+ isMobile: () => isMobile,
70
74
  isTronAddress: () => isTronAddress,
71
75
  isValidAddress: () => isValidAddress,
76
+ openMetaMaskDeepLink: () => openMetaMaskDeepLink,
72
77
  ordersAPI: () => orders_exports,
78
+ shouldUseDeepLink: () => shouldUseDeepLink,
73
79
  supportedChains: () => supportedChains,
74
80
  supportedEvmChains: () => supportedEvmChains,
75
81
  useOrder: () => useOrder,
@@ -170,7 +176,9 @@ var createWagmiConfig = () => {
170
176
  return (0, import_wagmi.createConfig)({
171
177
  chains: [import_chains.mainnet, import_chains.sepolia, import_chains.polygon, import_chains.polygonAmoy, import_chains.base, import_chains.baseSepolia],
172
178
  connectors: [
173
- // Injected connector - primary method for both web and mobile in-app browsers
179
+ // Injected connector - works for all wallets (MetaMask, Trust Wallet, etc.)
180
+ // Mobile: detects in-app browser's window.ethereum
181
+ // Desktop: detects browser extension's window.ethereum
174
182
  (0, import_connectors.injected)({
175
183
  target() {
176
184
  return {
@@ -179,17 +187,6 @@ var createWagmiConfig = () => {
179
187
  provider: typeof window !== "undefined" ? window.ethereum : void 0
180
188
  };
181
189
  }
182
- }),
183
- // MetaMask specific connector
184
- (0, import_connectors.metaMask)({
185
- dappMetadata: {
186
- name: "Payment SDK",
187
- url: typeof window !== "undefined" ? window.location.origin : ""
188
- }
189
- }),
190
- // Coinbase Wallet
191
- (0, import_connectors.coinbaseWallet)({
192
- appName: "Payment SDK"
193
190
  })
194
191
  ],
195
192
  transports: {
@@ -1140,6 +1137,52 @@ var shortenErrorMessage = (error) => {
1140
1137
  return message;
1141
1138
  };
1142
1139
 
1140
+ // src/utils/mobile.ts
1141
+ var isMobile = () => {
1142
+ if (typeof window === "undefined") return false;
1143
+ return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
1144
+ navigator.userAgent
1145
+ );
1146
+ };
1147
+ var isMetaMaskBrowser = () => {
1148
+ if (typeof window === "undefined") return false;
1149
+ const { ethereum } = window;
1150
+ return Boolean(ethereum && ethereum.isMetaMask);
1151
+ };
1152
+ var isMetaMaskAvailable = () => {
1153
+ if (typeof window === "undefined") return false;
1154
+ const { ethereum } = window;
1155
+ return Boolean(ethereum && ethereum.isMetaMask);
1156
+ };
1157
+ var openMetaMaskDeepLink = (returnUrl) => {
1158
+ if (typeof window === "undefined") return;
1159
+ const url = returnUrl || window.location.href;
1160
+ const deepLink = `https://metamask.app.link/dapp/${url.replace(/^https?:\/\//, "")}`;
1161
+ window.location.href = deepLink;
1162
+ };
1163
+ var getConnectionStrategy = () => {
1164
+ if (!isMobile() || isMetaMaskBrowser()) {
1165
+ if (isMetaMaskAvailable()) {
1166
+ return {
1167
+ type: "injected",
1168
+ message: "Connect with browser wallet"
1169
+ };
1170
+ }
1171
+ return {
1172
+ type: "unavailable",
1173
+ message: "Please install MetaMask extension"
1174
+ };
1175
+ }
1176
+ return {
1177
+ type: "deeplink",
1178
+ message: "Open in MetaMask app",
1179
+ action: () => openMetaMaskDeepLink()
1180
+ };
1181
+ };
1182
+ var shouldUseDeepLink = () => {
1183
+ return isMobile() && !isMetaMaskBrowser();
1184
+ };
1185
+
1143
1186
  // src/components/PayWithWallet.tsx
1144
1187
  var import_jsx_runtime3 = require("react/jsx-runtime");
1145
1188
  var PayWithWallet = ({
@@ -1403,10 +1446,21 @@ var PayWithWallet = ({
1403
1446
  },
1404
1447
  connector.id
1405
1448
  )) })
1406
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "no-wallets", children: [
1449
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "no-wallets", children: isMobile() && !isMetaMaskBrowser() && adapterType === "evm" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
1450
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { children: "Open in MetaMask App" }),
1451
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "wallet-hint", children: "MetaMask browser extension not detected" }),
1452
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1453
+ "button",
1454
+ {
1455
+ onClick: () => openMetaMaskDeepLink(),
1456
+ className: "btn-deep-link",
1457
+ children: "Open MetaMask App"
1458
+ }
1459
+ )
1460
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
1407
1461
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { children: "No compatible wallet detected" }),
1408
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "wallet-hint", children: adapterType === "tron" ? "Please install TronLink extension to continue" : "Please install MetaMask, Trust Wallet, or WalletConnect to continue" })
1409
- ] })
1462
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "wallet-hint", children: adapterType === "tron" ? "Please install TronLink extension to continue" : "Please install MetaMask, Trust Wallet, or compatible wallet to continue" })
1463
+ ] }) })
1410
1464
  ] }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "wallet-connected", children: [
1411
1465
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "connected-info", children: [
1412
1466
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "connected-address", children: truncateAddress(wallet.address, 6, 4) }),
@@ -1695,6 +1749,28 @@ var PayWithWallet = ({
1695
1749
  color: hsl(25 95.8% 35%) !important;
1696
1750
  }
1697
1751
 
1752
+ .btn-deep-link {
1753
+ margin-top: 1rem;
1754
+ padding: 0.625rem 1.25rem;
1755
+ background: hsl(222.2 47.4% 11.2%);
1756
+ color: hsl(210 40% 98%);
1757
+ border: none;
1758
+ border-radius: 0.5rem;
1759
+ font-weight: 600;
1760
+ cursor: pointer;
1761
+ transition: all 0.15s;
1762
+ font-size: 0.875rem;
1763
+ width: 100%;
1764
+ height: 2.5rem;
1765
+ display: inline-flex;
1766
+ align-items: center;
1767
+ justify-content: center;
1768
+ }
1769
+
1770
+ .btn-deep-link:hover {
1771
+ background: hsl(222.2 47.4% 8%);
1772
+ }
1773
+
1698
1774
  @keyframes spin {
1699
1775
  to { transform: rotate(360deg); }
1700
1776
  }
@@ -3874,14 +3950,20 @@ var useWallet = () => {
3874
3950
  detectChainType,
3875
3951
  generatePaymentQRUrl,
3876
3952
  getChainById,
3953
+ getConnectionStrategy,
3877
3954
  getErrorMessage,
3878
3955
  getEvmChainById,
3879
3956
  getPaymentDomain,
3880
3957
  handleAPIError,
3881
3958
  isEvmAddress,
3959
+ isMetaMaskAvailable,
3960
+ isMetaMaskBrowser,
3961
+ isMobile,
3882
3962
  isTronAddress,
3883
3963
  isValidAddress,
3964
+ openMetaMaskDeepLink,
3884
3965
  ordersAPI,
3966
+ shouldUseDeepLink,
3885
3967
  supportedChains,
3886
3968
  supportedEvmChains,
3887
3969
  useOrder,
package/dist/index.mjs CHANGED
@@ -86,7 +86,7 @@ import {
86
86
  base,
87
87
  baseSepolia
88
88
  } from "wagmi/chains";
89
- import { injected, coinbaseWallet, metaMask } from "@wagmi/connectors";
89
+ import { injected } from "@wagmi/connectors";
90
90
  var supportedEvmChains = [
91
91
  mainnet,
92
92
  sepolia,
@@ -100,7 +100,9 @@ var createWagmiConfig = () => {
100
100
  return createConfig({
101
101
  chains: [mainnet, sepolia, polygon, polygonAmoy, base, baseSepolia],
102
102
  connectors: [
103
- // Injected connector - primary method for both web and mobile in-app browsers
103
+ // Injected connector - works for all wallets (MetaMask, Trust Wallet, etc.)
104
+ // Mobile: detects in-app browser's window.ethereum
105
+ // Desktop: detects browser extension's window.ethereum
104
106
  injected({
105
107
  target() {
106
108
  return {
@@ -109,17 +111,6 @@ var createWagmiConfig = () => {
109
111
  provider: typeof window !== "undefined" ? window.ethereum : void 0
110
112
  };
111
113
  }
112
- }),
113
- // MetaMask specific connector
114
- metaMask({
115
- dappMetadata: {
116
- name: "Payment SDK",
117
- url: typeof window !== "undefined" ? window.location.origin : ""
118
- }
119
- }),
120
- // Coinbase Wallet
121
- coinbaseWallet({
122
- appName: "Payment SDK"
123
114
  })
124
115
  ],
125
116
  transports: {
@@ -1081,6 +1072,52 @@ var shortenErrorMessage = (error) => {
1081
1072
  return message;
1082
1073
  };
1083
1074
 
1075
+ // src/utils/mobile.ts
1076
+ var isMobile = () => {
1077
+ if (typeof window === "undefined") return false;
1078
+ return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
1079
+ navigator.userAgent
1080
+ );
1081
+ };
1082
+ var isMetaMaskBrowser = () => {
1083
+ if (typeof window === "undefined") return false;
1084
+ const { ethereum } = window;
1085
+ return Boolean(ethereum && ethereum.isMetaMask);
1086
+ };
1087
+ var isMetaMaskAvailable = () => {
1088
+ if (typeof window === "undefined") return false;
1089
+ const { ethereum } = window;
1090
+ return Boolean(ethereum && ethereum.isMetaMask);
1091
+ };
1092
+ var openMetaMaskDeepLink = (returnUrl) => {
1093
+ if (typeof window === "undefined") return;
1094
+ const url = returnUrl || window.location.href;
1095
+ const deepLink = `https://metamask.app.link/dapp/${url.replace(/^https?:\/\//, "")}`;
1096
+ window.location.href = deepLink;
1097
+ };
1098
+ var getConnectionStrategy = () => {
1099
+ if (!isMobile() || isMetaMaskBrowser()) {
1100
+ if (isMetaMaskAvailable()) {
1101
+ return {
1102
+ type: "injected",
1103
+ message: "Connect with browser wallet"
1104
+ };
1105
+ }
1106
+ return {
1107
+ type: "unavailable",
1108
+ message: "Please install MetaMask extension"
1109
+ };
1110
+ }
1111
+ return {
1112
+ type: "deeplink",
1113
+ message: "Open in MetaMask app",
1114
+ action: () => openMetaMaskDeepLink()
1115
+ };
1116
+ };
1117
+ var shouldUseDeepLink = () => {
1118
+ return isMobile() && !isMetaMaskBrowser();
1119
+ };
1120
+
1084
1121
  // src/components/PayWithWallet.tsx
1085
1122
  import { Fragment, jsx as jsx3, jsxs } from "react/jsx-runtime";
1086
1123
  var PayWithWallet = ({
@@ -1344,10 +1381,21 @@ var PayWithWallet = ({
1344
1381
  },
1345
1382
  connector.id
1346
1383
  )) })
1347
- ] }) : /* @__PURE__ */ jsxs("div", { className: "no-wallets", children: [
1384
+ ] }) : /* @__PURE__ */ jsx3("div", { className: "no-wallets", children: isMobile() && !isMetaMaskBrowser() && adapterType === "evm" ? /* @__PURE__ */ jsxs(Fragment, { children: [
1385
+ /* @__PURE__ */ jsx3("p", { children: "Open in MetaMask App" }),
1386
+ /* @__PURE__ */ jsx3("p", { className: "wallet-hint", children: "MetaMask browser extension not detected" }),
1387
+ /* @__PURE__ */ jsx3(
1388
+ "button",
1389
+ {
1390
+ onClick: () => openMetaMaskDeepLink(),
1391
+ className: "btn-deep-link",
1392
+ children: "Open MetaMask App"
1393
+ }
1394
+ )
1395
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
1348
1396
  /* @__PURE__ */ jsx3("p", { children: "No compatible wallet detected" }),
1349
- /* @__PURE__ */ jsx3("p", { className: "wallet-hint", children: adapterType === "tron" ? "Please install TronLink extension to continue" : "Please install MetaMask, Trust Wallet, or WalletConnect to continue" })
1350
- ] })
1397
+ /* @__PURE__ */ jsx3("p", { className: "wallet-hint", children: adapterType === "tron" ? "Please install TronLink extension to continue" : "Please install MetaMask, Trust Wallet, or compatible wallet to continue" })
1398
+ ] }) })
1351
1399
  ] }) : /* @__PURE__ */ jsxs("div", { className: "wallet-connected", children: [
1352
1400
  /* @__PURE__ */ jsxs("div", { className: "connected-info", children: [
1353
1401
  /* @__PURE__ */ jsx3("p", { className: "connected-address", children: truncateAddress(wallet.address, 6, 4) }),
@@ -1636,6 +1684,28 @@ var PayWithWallet = ({
1636
1684
  color: hsl(25 95.8% 35%) !important;
1637
1685
  }
1638
1686
 
1687
+ .btn-deep-link {
1688
+ margin-top: 1rem;
1689
+ padding: 0.625rem 1.25rem;
1690
+ background: hsl(222.2 47.4% 11.2%);
1691
+ color: hsl(210 40% 98%);
1692
+ border: none;
1693
+ border-radius: 0.5rem;
1694
+ font-weight: 600;
1695
+ cursor: pointer;
1696
+ transition: all 0.15s;
1697
+ font-size: 0.875rem;
1698
+ width: 100%;
1699
+ height: 2.5rem;
1700
+ display: inline-flex;
1701
+ align-items: center;
1702
+ justify-content: center;
1703
+ }
1704
+
1705
+ .btn-deep-link:hover {
1706
+ background: hsl(222.2 47.4% 8%);
1707
+ }
1708
+
1639
1709
  @keyframes spin {
1640
1710
  to { transform: rotate(360deg); }
1641
1711
  }
@@ -3814,14 +3884,20 @@ export {
3814
3884
  detectChainType,
3815
3885
  generatePaymentQRUrl,
3816
3886
  getChainById,
3887
+ getConnectionStrategy,
3817
3888
  getErrorMessage,
3818
3889
  getEvmChainById,
3819
3890
  getPaymentDomain,
3820
3891
  handleAPIError,
3821
3892
  isEvmAddress,
3893
+ isMetaMaskAvailable,
3894
+ isMetaMaskBrowser,
3895
+ isMobile,
3822
3896
  isTronAddress,
3823
3897
  isValidAddress,
3898
+ openMetaMaskDeepLink,
3824
3899
  orders_exports as ordersAPI,
3900
+ shouldUseDeepLink,
3825
3901
  supportedChains,
3826
3902
  supportedEvmChains,
3827
3903
  useOrder,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dj-test/payment-sdk",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "Payment SDK for blockchain-based payment system",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",