July 25th, 2013, 06:43 PM
Need to generate transaction Id for my Cart
I have a website where a transaction ID is generate by the DB as the field is set to auto-increment. This value is basically generated when the payment transaction is successful.
I need a transaction ID before the transaction is successful as I need to pass this transaction ID to the payment merchant. I am unable to figure out a way on how to go about generating the transaction ID before the payment is successful and use the same transaction ID to post the record to my table.
July 25th, 2013, 06:51 PM
Simple solution: insert a record before you do the transaction with a status of "pending" or something, grab the ID, do the transaction, and update the record with the results.
July 25th, 2013, 06:57 PM
Since the cart is already working then we'll have to implement the function to validate the status. I was thinking if we could create a temporary table and store the values there, once the transaction is good we move the transactions from a temp table to the actual table and clear the temp table. Will that be a good approach to this problem.
Originally Posted by requinix
July 25th, 2013, 07:47 PM
The records could process out of order and temporary row ID=123 may insert before row ID=122.
Either you rely on the database to give you the ID numbers, which can only happen when you're inserting into the table for real, or you don't, in which case you have to figure it out yourself.
Want a "pending" table? Okay. But use it to generate the ID numbers and not the original order table.
July 25th, 2013, 07:58 PM
You could also rename your current orders table to something else, add a status column to it, then create a view with the same name as your previous order table and only include orders with an active status in the view.
That way you don't have to deal with copying orders from one table to the other.
July 25th, 2013, 10:31 PM
Created TEMP tables and my problem is resolved and worked like a charm. Thanks for the help.
Originally Posted by E-Oreo