ts
notificationRoutes.post("/notifications", (req, res) => {
const { pix } = req.body;
if (Array.isArray(pix)) {
for (const notification of pix) {
const isRecharge = notification.devolucoes;
const isSend = notification.gnExtras?.idEnvio && !notification.txid;
if (isRecharge) {
console.log("Pix recharge notification received", notification);
continue;
}
if (isSend) {
console.log("Pix send notification received", notification);
continue;
}
console.log("Pix payment notification received", notification);
}
}
res.json({ message: "Notification received" });
});
Fiz essas verificações, acredito que esteja correto, se alguém ver alguma falha e puder me dizer agradeço.notificationRoutes.post("/notifications", (req, res) => {
const { pix } = req.body;
if (Array.isArray(pix)) {
for (const notification of pix) {
const isRecharge = notification.devolucoes;
const isSend = notification.gnExtras?.idEnvio && !notification.txid;
if (isRecharge) {
console.log("Pix recharge notification received", notification);
continue;
}
if (isSend) {
console.log("Pix send notification received", notification);
continue;
}
console.log("Pix payment notification received", notification);
}
}
res.json({ message: "Notification received" });
});
Será que realmente compensa integrar o sistema de notificação por webhook ou verificar o pagamento periodicamente usando a API de consulta de pagamento a partir do taxid?