Created
June 2, 2023 02:08
-
-
Save almcarvalho/6a3ec613edd42e83dd4a1d3a0921f4ab to your computer and use it in GitHub Desktop.
código pronto
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//INTEGRAÇÃO PIX VÍDEO 2- Efí, antiga Gerencianet | |
var valorDoPix = 0; | |
var valorAux = 0; | |
app.get("/rafael", async (req, res) => { | |
if (valorDoPix > 0) { | |
valorAux = valorDoPix; | |
valorDoPix = 0; | |
if (valorAux >= 2) { //trocar pra 2 | |
valorAux = 2; | |
} | |
return res.status(200).json({ "": valorAux }); | |
} else { | |
return res.status(200).json({ "": 0 }); | |
} | |
}); | |
app.post("/rota-recebimento", async (req, res) => { | |
try { | |
var ip = req.headers['x-forwarded-for'] || req.socket.remoteAddress; | |
console.log("ip"); | |
console.log(ip); | |
var qy = req.query.hmac; | |
console.log("query"); | |
console.log(qy); | |
if (ip != '34.193.116.226') { | |
return res.status(401).json({ "unauthorized": "unauthorized" }); | |
} | |
if (qy != 'myhash1234' && qy != 'myhash1234/pix') { | |
return res.status(401).json({ "unauthorized": "unauthorized" }); | |
} | |
console.log("Novo pix detectado:"); | |
console.log(req.body); | |
console.log("valor:"); | |
valorDoPix = req.body.pix[0].valor; | |
console.log(req.body.pix[0].valor); | |
} catch (error) { | |
console.error(error); | |
return res.status(402).json({ "error": "error: " + error }); | |
} | |
return res.status(200).json({ "ok": "ok" }); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment