import { createPoller } from "@zopay/js";
const poller = createPoller({
checkStatus: async () => {
const res = await fetch(`/api/zopay/status/${intent.id}`);
return normalizeIntent(await res.json());
},
pollIntervalMs: 3000,
timeoutMs: 15 * 60 * 1000,
onSuccess: (info) => {
document.getElementById("amount-received").textContent = String(info.amountReceived);
showSuccessScreen(info);
},
onError: (info) => showErrorScreen(info),
onExpire: () => showExpiredScreen(),
});
poller.start();
// En algún botón "verificar ahora":
button.onclick = () => poller.refresh();
// Al desmontar:
poller.stop();