@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.cjs
CHANGED
|
@@ -1820,6 +1820,8 @@ var useSolanaQrPayment = (options) => {
|
|
|
1820
1820
|
const { priceId, selectedToken, onSuccess, onError } = options;
|
|
1821
1821
|
const solanaService = useSolanaService();
|
|
1822
1822
|
const tokenSymbol = selectedToken?.symbol ?? null;
|
|
1823
|
+
const onSuccessRef = React3.useRef(onSuccess);
|
|
1824
|
+
const onErrorRef = React3.useRef(onError);
|
|
1823
1825
|
const [intent, setIntent] = React3.useState(null);
|
|
1824
1826
|
const [qrDataUri, setQrDataUri] = React3.useState(null);
|
|
1825
1827
|
const [isLoading, setIsLoading] = React3.useState(false);
|
|
@@ -1856,16 +1858,22 @@ var useSolanaQrPayment = (options) => {
|
|
|
1856
1858
|
},
|
|
1857
1859
|
[clearTimers]
|
|
1858
1860
|
);
|
|
1861
|
+
React3.useEffect(() => {
|
|
1862
|
+
onSuccessRef.current = onSuccess;
|
|
1863
|
+
}, [onSuccess]);
|
|
1864
|
+
React3.useEffect(() => {
|
|
1865
|
+
onErrorRef.current = onError;
|
|
1866
|
+
}, [onError]);
|
|
1859
1867
|
const handleError = React3.useCallback(
|
|
1860
1868
|
(message, notifyParent = false) => {
|
|
1861
1869
|
console.error("[payments-ui] Solana Pay QR error:", message);
|
|
1862
1870
|
clearTimers();
|
|
1863
1871
|
resetState(message);
|
|
1864
1872
|
if (notifyParent) {
|
|
1865
|
-
|
|
1873
|
+
onErrorRef.current?.(message);
|
|
1866
1874
|
}
|
|
1867
1875
|
},
|
|
1868
|
-
[clearTimers,
|
|
1876
|
+
[clearTimers, resetState]
|
|
1869
1877
|
);
|
|
1870
1878
|
const handleSuccess = React3.useCallback(
|
|
1871
1879
|
(status) => {
|
|
@@ -1875,9 +1883,9 @@ var useSolanaQrPayment = (options) => {
|
|
|
1875
1883
|
paymentId: status.payment_id,
|
|
1876
1884
|
intentId: status.intent_id
|
|
1877
1885
|
});
|
|
1878
|
-
|
|
1886
|
+
onSuccessRef.current?.(status.payment_id, status.transaction || "");
|
|
1879
1887
|
},
|
|
1880
|
-
[clearTimers,
|
|
1888
|
+
[clearTimers, resetState]
|
|
1881
1889
|
);
|
|
1882
1890
|
const pollStatus = React3.useCallback(
|
|
1883
1891
|
async (reference) => {
|