So I have a multi-page checkout system that relies on sessions to store the contents of the shopping cart. I also use a third-party credit card processing system that displays the actual payment page on my servers. I just need to send a message to the page with the final result.
The problem that I foresee is that if someone clicks to go to the payment page, and then, for some legitimate or sinister reason, changes the contents of the shopping basket on another tab. I originally planned that when the hosted payment page is redirected back to my receipt page, I will then insert the order into my database. But, if the session is changed at this moment, the order will differ from the total cost.
What will be the solution to this problem. I see that this is a problem for all trolley systems, so I wonder how they do it.
Maybe when the user clicks the button to go to the posted payment page, I can make a temporary record of the order in the temp_order table in the database, and then, when the payment will be processed, can I transfer this temporary record to the permanent records table? This way, I am not inserting a record from the session information that has changed. But if I need to send a POST to the payment page, where can I save a shopping cart in the temp table?
In addition, the temp order ID must be unique for both temporary and permanent tables, since I don't want to overlap.
Finally, I need to frequently clear the temp order table, as they are only temporary entries. Some of them may fail, because the user can change his mind on the page of the payment posted.
I am really confused what I have to do!
source share