ruby-on-railsonline-store

How do you synchronize stock and payment on an online store?


I am working on an online store i developp from scratch using Ruby On rails.

I have a design question about stock and orders.

When do you update stock when a user select a product

-If i lower stock once the payment is valid, i may have two different customers buying the same product when only one is left, and the shop now must deliver two product when he has only one left.

Do you know how online store handle this problem ?

Where can i find design documents of open source online store ?


Solution

  • Well normally you keep inventory separated such that you have one value for what is in the warehouse and one value for submitted but not shipped orders.

    When an item is placed in a shopping cart all you can do is inform the user when the effective inventory changes, i.e. when another user has submitted an order. There are no guarantees until the cart has been checked out.