This is a pretty generalized question which I am asking.
I have a product 'Pen' which has a quantity of 1. Now 2 users a and b has come to buy the product.User 'a' clicked on buy now and has started the payment processing and once the payment is completed the order for the product will be created and I would reduce the quantity to zero and user b will see the product as 'Out of stock'. This a more macroscopic explanation.
User a is making a payment and in between user b also clicked on pay and proceeded the payment process. user a completed the order and the quantity was reduced to zero.User b completed the payment and the order failed!
How does this problem is managed by e commerce sites? Is it like, when a user proceed for the payment of a product, is the quantity is reduced to zero and once if that order fails (due to a payment failure), does the quantity is incremented back so that other user can buy it?
How is this condition managed?