Let say this is my API:
app.post('/refund', function (req, res) {
Transaction.findOneAndUpdate({_id: req.body.transaction_id}, {$set: {refund_status: true}}).
exec(function (err, transaction_status) {
res.end("Refund successfully")
}
}
If two admins click the refund button at the same time. My customer will receive a double refund.
So, how to prevent these issues?