That system can be simply like in Diablo II.
You sell a item by mistake.
You still have a chance to buy that again but for a higher price than you got it. But you can only get that in same window of vendor you opened. Meaning you get out of "Sell" and go to "buy" and the item will be there.

Now if you get out totally of vendor menus (getting back to game and move around) and go there again the item wont be there because it was refreshed. So it was your fault for not buying when you could.

Other bad luck may occur is if when you sell that item and dc, well item lost...