0
I’m having trouble with the code below. The code reaches postbackRef.add and adds the information in the database, but after that it does not enter transactionsRef.Where to perform the update just below in transactionUpdate.update. What can it be?
pagarme.post("/retornoPagarme", function (req, res) {
var transactionsRef = db.collection('transactions');
var postbackRef = db.collection('postback_return');
var setPostback = postbackRef.add({
return: req.body
}).then((ref) => {
var transactionSnapShot = transactionsRef.where('id_pagarme', '==', req.body.id).get();
let values = null;
transactionSnapShot.forEach(doc => {
values = doc.data();
});
var transactionUpdate = transactionsRef.doc(values.id);
transactionUpdate.update({
status_pagarme: req.body.current_status,
status: req.body.current_status
})
postbackRef.doc(ref.id).set({ status: req.body.current_status });
return res.status(200);
});
return res.status(200);
});
Have you ever tried to make one
console.log
before the linevar transactionSnapshot...
? Console shows no error?– Rosário Pereira Fernandes