Ask for help about paying an order at the same time.

  node.js, question

For example, if the order amount of a product is 100 yuan, three people will pay for the order, and each person can pay whatever amount he wants to pay. My idea is to request the remaining payment amount of the order in the server every second, and then refresh the display to each user. However, in a certain second, A and B will see that the remaining payment amount is 30 yuan at the same time, and then both of them will pay for the 30 yuan, which will lead to excess. How can you avoid this situation at the front end?

Check again before payment, that is, check the payment before jumping to the payment platform.