@dj-test/payment-sdk 1.0.5 → 1.0.7

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/index.d.mts CHANGED
@@ -1638,7 +1638,11 @@ declare const supportedChains: ({
1638
1638
  };
1639
1639
  readonly network: "base-sepolia";
1640
1640
  })[];
1641
- declare const createWagmiConfig: (projectId?: string) => Config$1;
1641
+ /**
1642
+ * Create wagmi config following Daimo Pay approach
1643
+ * Uses injected connectors + deep links, no WalletConnect dependency
1644
+ */
1645
+ declare const createWagmiConfig: () => Config$1;
1642
1646
  declare const getEvmChainById: (chainId: number) => {
1643
1647
  blockExplorers: {
1644
1648
  readonly default: {
@@ -3594,7 +3598,6 @@ declare const PaymentModal: React.FC<PaymentModalProps>;
3594
3598
 
3595
3599
  interface WalletProviderProps {
3596
3600
  children: ReactNode;
3597
- projectId?: string;
3598
3601
  queryClient?: QueryClient;
3599
3602
  }
3600
3603
  declare const WalletProvider: React.FC<WalletProviderProps>;
package/dist/index.d.ts CHANGED
@@ -1638,7 +1638,11 @@ declare const supportedChains: ({
1638
1638
  };
1639
1639
  readonly network: "base-sepolia";
1640
1640
  })[];
1641
- declare const createWagmiConfig: (projectId?: string) => Config$1;
1641
+ /**
1642
+ * Create wagmi config following Daimo Pay approach
1643
+ * Uses injected connectors + deep links, no WalletConnect dependency
1644
+ */
1645
+ declare const createWagmiConfig: () => Config$1;
1642
1646
  declare const getEvmChainById: (chainId: number) => {
1643
1647
  blockExplorers: {
1644
1648
  readonly default: {
@@ -3594,7 +3598,6 @@ declare const PaymentModal: React.FC<PaymentModalProps>;
3594
3598
 
3595
3599
  interface WalletProviderProps {
3596
3600
  children: ReactNode;
3597
- projectId?: string;
3598
3601
  queryClient?: QueryClient;
3599
3602
  }
3600
3603
  declare const WalletProvider: React.FC<WalletProviderProps>;
package/dist/index.js CHANGED
@@ -166,28 +166,32 @@ var supportedEvmChains = [
166
166
  import_chains.baseSepolia
167
167
  ];
168
168
  var supportedChains = supportedEvmChains;
169
- var createWagmiConfig = (projectId) => {
170
- const connectors = [(0, import_connectors.injected)()];
171
- if (projectId) {
172
- const sdkConfig = config.getConfig();
173
- const environment = sdkConfig.environment || "sandbox";
174
- const paymentDomain = PAYMENT_DOMAINS[environment];
175
- connectors.push(
176
- (0, import_connectors.walletConnect)({
177
- projectId,
178
- metadata: {
179
- name: "Payment SDK",
180
- description: "Multi-chain Payment SDK",
181
- url: paymentDomain,
182
- icons: [`${paymentDomain}/icon.png`]
183
- },
184
- showQrModal: true
185
- })
186
- );
187
- }
169
+ var createWagmiConfig = () => {
188
170
  return (0, import_wagmi.createConfig)({
189
171
  chains: [import_chains.mainnet, import_chains.sepolia, import_chains.polygon, import_chains.polygonAmoy, import_chains.base, import_chains.baseSepolia],
190
- connectors,
172
+ connectors: [
173
+ // Injected connector - primary method for both web and mobile in-app browsers
174
+ (0, import_connectors.injected)({
175
+ target() {
176
+ return {
177
+ id: "injected",
178
+ name: "Browser Wallet",
179
+ provider: typeof window !== "undefined" ? window.ethereum : void 0
180
+ };
181
+ }
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
+ })
194
+ ],
191
195
  transports: {
192
196
  [import_chains.mainnet.id]: (0, import_wagmi.http)(),
193
197
  [import_chains.sepolia.id]: (0, import_wagmi.http)(),
@@ -618,7 +622,9 @@ var useOrder = (publicOrderId, options) => {
618
622
  const sdkError = handleAPIError(err);
619
623
  if (isInitial && retryCount < maxRetries && (sdkError.message.includes("incomplete") || sdkError.message.includes("null or invalid"))) {
620
624
  retryCount++;
621
- console.log(`[useOrder] Retrying order fetch (${retryCount}/${maxRetries})...`);
625
+ console.log(
626
+ `[useOrder] Retrying order fetch (${retryCount}/${maxRetries})...`
627
+ );
622
628
  setTimeout(() => fetchOrder(true), 500);
623
629
  return;
624
630
  }
@@ -632,7 +638,10 @@ var useOrder = (publicOrderId, options) => {
632
638
  fetchOrder(true);
633
639
  isInitialFetch.current = false;
634
640
  if (enablePolling) {
635
- intervalRef.current = setInterval(() => fetchOrder(false), pollingInterval);
641
+ intervalRef.current = setInterval(
642
+ () => fetchOrder(false),
643
+ pollingInterval
644
+ );
636
645
  }
637
646
  return () => {
638
647
  if (intervalRef.current) {
@@ -2510,7 +2519,10 @@ var OrderPayment = ({
2510
2519
  }
2511
2520
  }, [order, hasNotifiedSuccess, onSuccess, onError, publicOrderId]);
2512
2521
  const handleWalletPaymentSuccess = (result) => {
2513
- console.log("[OrderPayment] Wallet payment success, txHash:", result.txHash);
2522
+ console.log(
2523
+ "[OrderPayment] Wallet payment success, txHash:",
2524
+ result.txHash
2525
+ );
2514
2526
  };
2515
2527
  const handleRetry = () => {
2516
2528
  window.location.reload();
@@ -2557,13 +2569,30 @@ var OrderPayment = ({
2557
2569
  if (error) {
2558
2570
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: `order-payment error ${className}`, children: [
2559
2571
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "error-container", children: [
2560
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("svg", { width: "64", height: "64", viewBox: "0 0 24 24", fill: "none", stroke: "#ef4444", children: [
2561
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("circle", { cx: "12", cy: "12", r: "10", strokeWidth: "2" }),
2562
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("path", { d: "M12 8v4M12 16h.01", strokeWidth: "2", strokeLinecap: "round" })
2563
- ] }),
2572
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
2573
+ "svg",
2574
+ {
2575
+ width: "64",
2576
+ height: "64",
2577
+ viewBox: "0 0 24 24",
2578
+ fill: "none",
2579
+ stroke: "#ef4444",
2580
+ children: [
2581
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("circle", { cx: "12", cy: "12", r: "10", strokeWidth: "2" }),
2582
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("path", { d: "M12 8v4M12 16h.01", strokeWidth: "2", strokeLinecap: "round" })
2583
+ ]
2584
+ }
2585
+ ),
2564
2586
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("h3", { children: "Payment Error" }),
2565
2587
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { children: error.message }),
2566
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { onClick: () => window.location.reload(), className: "retry-button", children: "Try Again" })
2588
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2589
+ "button",
2590
+ {
2591
+ onClick: () => window.location.reload(),
2592
+ className: "retry-button",
2593
+ children: "Try Again"
2594
+ }
2595
+ )
2567
2596
  ] }),
2568
2597
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("style", { children: `
2569
2598
  .order-payment.error {
@@ -2615,7 +2644,10 @@ var OrderPayment = ({
2615
2644
  return null;
2616
2645
  }
2617
2646
  const orderState = getOrderState(order.orderStat);
2618
- const isExpired = new Date(order.expireDt) < /* @__PURE__ */ new Date();
2647
+ const expireDate = new Date(
2648
+ order.expireDt.endsWith("Z") ? order.expireDt : order.expireDt + "Z"
2649
+ );
2650
+ const isExpired = expireDate < /* @__PURE__ */ new Date();
2619
2651
  if (orderState !== "waiting" /* WAITING */ || isExpired) {
2620
2652
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2621
2653
  OrderStatusScreen,
@@ -3487,13 +3519,9 @@ var defaultQueryClient = new import_react_query.QueryClient({
3487
3519
  });
3488
3520
  var WalletProvider = ({
3489
3521
  children,
3490
- projectId,
3491
3522
  queryClient = defaultQueryClient
3492
3523
  }) => {
3493
- const wagmiConfig = (0, import_react12.useMemo)(
3494
- () => createWagmiConfig(projectId),
3495
- [projectId]
3496
- );
3524
+ const wagmiConfig = (0, import_react12.useMemo)(() => createWagmiConfig(), []);
3497
3525
  const adapterFactory = (0, import_react12.useMemo)(() => {
3498
3526
  const factory = new WalletAdapterFactory();
3499
3527
  factory.initializeEvmAdapter(wagmiConfig);
package/dist/index.mjs CHANGED
@@ -86,7 +86,7 @@ import {
86
86
  base,
87
87
  baseSepolia
88
88
  } from "wagmi/chains";
89
- import { injected, walletConnect } from "@wagmi/connectors";
89
+ import { injected, coinbaseWallet, metaMask } from "@wagmi/connectors";
90
90
  var supportedEvmChains = [
91
91
  mainnet,
92
92
  sepolia,
@@ -96,28 +96,32 @@ var supportedEvmChains = [
96
96
  baseSepolia
97
97
  ];
98
98
  var supportedChains = supportedEvmChains;
99
- var createWagmiConfig = (projectId) => {
100
- const connectors = [injected()];
101
- if (projectId) {
102
- const sdkConfig = config.getConfig();
103
- const environment = sdkConfig.environment || "sandbox";
104
- const paymentDomain = PAYMENT_DOMAINS[environment];
105
- connectors.push(
106
- walletConnect({
107
- projectId,
108
- metadata: {
109
- name: "Payment SDK",
110
- description: "Multi-chain Payment SDK",
111
- url: paymentDomain,
112
- icons: [`${paymentDomain}/icon.png`]
113
- },
114
- showQrModal: true
115
- })
116
- );
117
- }
99
+ var createWagmiConfig = () => {
118
100
  return createConfig({
119
101
  chains: [mainnet, sepolia, polygon, polygonAmoy, base, baseSepolia],
120
- connectors,
102
+ connectors: [
103
+ // Injected connector - primary method for both web and mobile in-app browsers
104
+ injected({
105
+ target() {
106
+ return {
107
+ id: "injected",
108
+ name: "Browser Wallet",
109
+ provider: typeof window !== "undefined" ? window.ethereum : void 0
110
+ };
111
+ }
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
+ })
124
+ ],
121
125
  transports: {
122
126
  [mainnet.id]: http(),
123
127
  [sepolia.id]: http(),
@@ -548,7 +552,9 @@ var useOrder = (publicOrderId, options) => {
548
552
  const sdkError = handleAPIError(err);
549
553
  if (isInitial && retryCount < maxRetries && (sdkError.message.includes("incomplete") || sdkError.message.includes("null or invalid"))) {
550
554
  retryCount++;
551
- console.log(`[useOrder] Retrying order fetch (${retryCount}/${maxRetries})...`);
555
+ console.log(
556
+ `[useOrder] Retrying order fetch (${retryCount}/${maxRetries})...`
557
+ );
552
558
  setTimeout(() => fetchOrder(true), 500);
553
559
  return;
554
560
  }
@@ -562,7 +568,10 @@ var useOrder = (publicOrderId, options) => {
562
568
  fetchOrder(true);
563
569
  isInitialFetch.current = false;
564
570
  if (enablePolling) {
565
- intervalRef.current = setInterval(() => fetchOrder(false), pollingInterval);
571
+ intervalRef.current = setInterval(
572
+ () => fetchOrder(false),
573
+ pollingInterval
574
+ );
566
575
  }
567
576
  return () => {
568
577
  if (intervalRef.current) {
@@ -2451,7 +2460,10 @@ var OrderPayment = ({
2451
2460
  }
2452
2461
  }, [order, hasNotifiedSuccess, onSuccess, onError, publicOrderId]);
2453
2462
  const handleWalletPaymentSuccess = (result) => {
2454
- console.log("[OrderPayment] Wallet payment success, txHash:", result.txHash);
2463
+ console.log(
2464
+ "[OrderPayment] Wallet payment success, txHash:",
2465
+ result.txHash
2466
+ );
2455
2467
  };
2456
2468
  const handleRetry = () => {
2457
2469
  window.location.reload();
@@ -2498,13 +2510,30 @@ var OrderPayment = ({
2498
2510
  if (error) {
2499
2511
  return /* @__PURE__ */ jsxs5("div", { className: `order-payment error ${className}`, children: [
2500
2512
  /* @__PURE__ */ jsxs5("div", { className: "error-container", children: [
2501
- /* @__PURE__ */ jsxs5("svg", { width: "64", height: "64", viewBox: "0 0 24 24", fill: "none", stroke: "#ef4444", children: [
2502
- /* @__PURE__ */ jsx7("circle", { cx: "12", cy: "12", r: "10", strokeWidth: "2" }),
2503
- /* @__PURE__ */ jsx7("path", { d: "M12 8v4M12 16h.01", strokeWidth: "2", strokeLinecap: "round" })
2504
- ] }),
2513
+ /* @__PURE__ */ jsxs5(
2514
+ "svg",
2515
+ {
2516
+ width: "64",
2517
+ height: "64",
2518
+ viewBox: "0 0 24 24",
2519
+ fill: "none",
2520
+ stroke: "#ef4444",
2521
+ children: [
2522
+ /* @__PURE__ */ jsx7("circle", { cx: "12", cy: "12", r: "10", strokeWidth: "2" }),
2523
+ /* @__PURE__ */ jsx7("path", { d: "M12 8v4M12 16h.01", strokeWidth: "2", strokeLinecap: "round" })
2524
+ ]
2525
+ }
2526
+ ),
2505
2527
  /* @__PURE__ */ jsx7("h3", { children: "Payment Error" }),
2506
2528
  /* @__PURE__ */ jsx7("p", { children: error.message }),
2507
- /* @__PURE__ */ jsx7("button", { onClick: () => window.location.reload(), className: "retry-button", children: "Try Again" })
2529
+ /* @__PURE__ */ jsx7(
2530
+ "button",
2531
+ {
2532
+ onClick: () => window.location.reload(),
2533
+ className: "retry-button",
2534
+ children: "Try Again"
2535
+ }
2536
+ )
2508
2537
  ] }),
2509
2538
  /* @__PURE__ */ jsx7("style", { children: `
2510
2539
  .order-payment.error {
@@ -2556,7 +2585,10 @@ var OrderPayment = ({
2556
2585
  return null;
2557
2586
  }
2558
2587
  const orderState = getOrderState(order.orderStat);
2559
- const isExpired = new Date(order.expireDt) < /* @__PURE__ */ new Date();
2588
+ const expireDate = new Date(
2589
+ order.expireDt.endsWith("Z") ? order.expireDt : order.expireDt + "Z"
2590
+ );
2591
+ const isExpired = expireDate < /* @__PURE__ */ new Date();
2560
2592
  if (orderState !== "waiting" /* WAITING */ || isExpired) {
2561
2593
  return /* @__PURE__ */ jsx7("div", { className, children: /* @__PURE__ */ jsx7(
2562
2594
  OrderStatusScreen,
@@ -3428,13 +3460,9 @@ var defaultQueryClient = new QueryClient({
3428
3460
  });
3429
3461
  var WalletProvider = ({
3430
3462
  children,
3431
- projectId,
3432
3463
  queryClient = defaultQueryClient
3433
3464
  }) => {
3434
- const wagmiConfig = useMemo2(
3435
- () => createWagmiConfig(projectId),
3436
- [projectId]
3437
- );
3465
+ const wagmiConfig = useMemo2(() => createWagmiConfig(), []);
3438
3466
  const adapterFactory = useMemo2(() => {
3439
3467
  const factory = new WalletAdapterFactory();
3440
3468
  factory.initializeEvmAdapter(wagmiConfig);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dj-test/payment-sdk",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "Payment SDK for blockchain-based payment system",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",