#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    22
    Rep Power
    0

    Need to generate transaction Id for my Cart


    Hi,

    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.

    Thanks.
  2. #2
  3. Come play with me!
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,754
    Rep Power
    9397
    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.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    22
    Rep Power
    0
    Originally Posted by requinix
    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.
    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.

    Thanks.
  6. #4
  7. Come play with me!
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,754
    Rep Power
    9397
    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.
  8. #5
  9. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,301
    Rep Power
    7170
    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.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    22
    Rep Power
    0
    Originally Posted by E-Oreo
    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.
    Created TEMP tables and my problem is resolved and worked like a charm. Thanks for the help.

    Regards

IMN logo majestic logo threadwatch logo seochat tools logo