I have generated an online shopping cart to be used on my website. The cart content is stored in an Associated Array stored in a PHP session variable.
I have opted to use Worldpay to handle all credit card transactions.
My question is: at what stage of the shopping process should I update the quantity fields in the stock table to reflect the purchase?
Obviously I do not want to do this before payment has been taken for obvious reasons...
Worldpay offer a callback service so that a script on my website can be run after a successful transaction has been processed. What I plan to do is write the order information to a partially completed table in the database before the credit card transaction takes place. Then, when Worldpay issue the callback, information will be deleted from the partial orders table, written to a completed orders table and the quantity fields in the stock table updated accordingly.
If the callback fails, I will still have the basket ID of the order, thus emabling me to manually update the stock table with the information held in the partial orders table.
Please can anyone give their thoughts / opinions of this method? The advice I have received from these pages in the past has been invaluable.