I'm having problems with the code below. The code arrives at the postbackRef.add and adds the information to the database, but after that it does not go into transactionsRef.where to perform the update just under 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);
});