I have a website in which i sell PIN numbers of telephone cards.
Telephone cards will be added to the shopping cart by the user. After payment he will be emailed the PIN number of the card he bought
I need to solve two issues
1) How to make sure that a unsold product is in the database after payment. example: suppose there is only 1 product in the database. Two users selected the product. Two of them made the payment. But only one will get the product (What i can do here?)
2) How i can block access to a record in the database when other process is using it? Suppose 2 users bought a card , how can i prevent issuing same PIN to two different users?
What about having a bit field called "CheckedOut" in the table, and when the first user selects the product, it flags the item as "checked out," you then just check for that flag everytime a user tries to select a product.
This introduces an issue though where a user may select a product, but then close their browser, leaving an orphaned checked out item. You can get around this by adding a timestamp column to the table and automatically "checking in" the item if the customer has been idle for, say after 20 minutes of inactivity.