@doujins/payments-ui 0.0.7 → 0.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/dist/index.js CHANGED
@@ -1790,6 +1790,8 @@ var useSolanaQrPayment = (options) => {
1790
1790
  const { priceId, selectedToken, onSuccess, onError } = options;
1791
1791
  const solanaService = useSolanaService();
1792
1792
  const tokenSymbol = selectedToken?.symbol ?? null;
1793
+ const onSuccessRef = useRef(onSuccess);
1794
+ const onErrorRef = useRef(onError);
1793
1795
  const [intent, setIntent] = useState(null);
1794
1796
  const [qrDataUri, setQrDataUri] = useState(null);
1795
1797
  const [isLoading, setIsLoading] = useState(false);
@@ -1826,16 +1828,22 @@ var useSolanaQrPayment = (options) => {
1826
1828
  },
1827
1829
  [clearTimers]
1828
1830
  );
1831
+ useEffect(() => {
1832
+ onSuccessRef.current = onSuccess;
1833
+ }, [onSuccess]);
1834
+ useEffect(() => {
1835
+ onErrorRef.current = onError;
1836
+ }, [onError]);
1829
1837
  const handleError = useCallback(
1830
1838
  (message, notifyParent = false) => {
1831
1839
  console.error("[payments-ui] Solana Pay QR error:", message);
1832
1840
  clearTimers();
1833
1841
  resetState(message);
1834
1842
  if (notifyParent) {
1835
- onError(message);
1843
+ onErrorRef.current?.(message);
1836
1844
  }
1837
1845
  },
1838
- [clearTimers, onError, resetState]
1846
+ [clearTimers, resetState]
1839
1847
  );
1840
1848
  const handleSuccess = useCallback(
1841
1849
  (status) => {
@@ -1845,9 +1853,9 @@ var useSolanaQrPayment = (options) => {
1845
1853
  paymentId: status.payment_id,
1846
1854
  intentId: status.intent_id
1847
1855
  });
1848
- onSuccess(status.payment_id, status.transaction || "");
1856
+ onSuccessRef.current?.(status.payment_id, status.transaction || "");
1849
1857
  },
1850
- [clearTimers, onSuccess, resetState]
1858
+ [clearTimers, resetState]
1851
1859
  );
1852
1860
  const pollStatus = useCallback(
1853
1861
  async (reference) => {
@@ -2470,7 +2478,7 @@ var SolanaPaymentSelector = ({
2470
2478
  " Scan QR Code"
2471
2479
  ] })
2472
2480
  ] }),
2473
- /* @__PURE__ */ jsx(TabsContent, { value: "wallet", className: "mt-4", children: /* @__PURE__ */ jsx(
2481
+ /* @__PURE__ */ jsx(TabsContent, { value: "wallet", className: "mt-4", children: activeTab === "wallet" && /* @__PURE__ */ jsx(
2474
2482
  DirectPayment,
2475
2483
  {
2476
2484
  priceId,
@@ -2483,7 +2491,7 @@ var SolanaPaymentSelector = ({
2483
2491
  onPaymentError: handlePaymentError
2484
2492
  }
2485
2493
  ) }),
2486
- /* @__PURE__ */ jsx(TabsContent, { value: "qr", className: "mt-4", children: /* @__PURE__ */ jsx(
2494
+ /* @__PURE__ */ jsx(TabsContent, { value: "qr", className: "mt-4", children: activeTab === "qr" && /* @__PURE__ */ jsx(
2487
2495
  QRCodePayment,
2488
2496
  {
2489
2497
  priceId,