feat: implement background payment sync worker and admin trigger UI

This commit is contained in:
mstfyldz
2026-03-13 05:29:17 +03:00
parent d7bd2afc29
commit 67d0c61adb
7 changed files with 306 additions and 0 deletions

View File

@@ -108,6 +108,29 @@ export default function CryptoCheckout({ amount, currency, txId, wallets, onSucc
setSelectedToken(network.tokens[0]);
};
// Save payment intent to DB so background sync knows what to check
useEffect(() => {
if (!txId || !selectedNetwork || !selectedToken) return;
const saveIntent = async () => {
try {
await fetch(`/api/transactions/${txId}/intent`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
network: selectedNetwork.id,
token: selectedToken.symbol
})
});
} catch (err) {
console.error("Failed to save payment intent:", err);
}
};
const timer = setTimeout(saveIntent, 1000); // Debounce
return () => clearTimeout(timer);
}, [txId, selectedNetwork.id, selectedToken.symbol]);
const handleCopy = () => {
navigator.clipboard.writeText(depositAddress);
setCopied(true);