@doujins/payments-ui 0.0.7 → 0.0.8
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.cjs +12 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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
|
-
|
|
1843
|
+
onErrorRef.current?.(message);
|
|
1836
1844
|
}
|
|
1837
1845
|
},
|
|
1838
|
-
[clearTimers,
|
|
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
|
-
|
|
1856
|
+
onSuccessRef.current?.(status.payment_id, status.transaction || "");
|
|
1849
1857
|
},
|
|
1850
|
-
[clearTimers,
|
|
1858
|
+
[clearTimers, resetState]
|
|
1851
1859
|
);
|
|
1852
1860
|
const pollStatus = useCallback(
|
|
1853
1861
|
async (reference) => {
|