...

View Full Version : unique order id



dalya
07-02-2007, 10:45 PM
I am integrating an online store with an epayment processing system (HSBC). They asked me to provide as part of every transaction, a unique order id. I need help with that.

At the moment, I am using php session as a customer id, but I realise this may not be ideal.

The problem is that I am not inserting any customer or order data into my database until the payment is complete and succesful (i.e. when i recieve the POST data back from HSBC and a flag that payment was succesful).

My current table structure:

Product (ProductCode(PK), ProductName, Price)
Customer (UserId (PK), Name, etc) --> I'm inserting php session as UserId
Order (OrderId (auto_increment), UserId (FK), date......)
Order_Item (OrderItemId (auto_increment)(PK), OrderId (PK + FK), ProductCode (PK+FK)....)

After the payment is succesful, i insert the session id into the UserId, and insert the order and orderItem details.

Now, I'm not sure how to generate and POST a unique order ID to HSBC before even inserting it into the database. I thought about inserting the order anyway, retrieve the OrderId and POST it with the order to HSBC and if payment successful, leave it there, otherwsie delete. But I don't think this is the best solution and my client agrees.

I would appreciate any help on:
- Generating Customer id, other than the session
- Sending a unique order with the data to HSBC.

By the way, the customers do not sign up at all even to make a purchase (this is a client requirement)

many thanks

rfresh
07-02-2007, 11:07 PM
Trying to determine the session id in mysql prior to doing the insert can be done is not advisable for many reasons so I would not recommend going down that path.

Instead, why don't you just create a starting cust ID number and keep it in a database and keep inc it as you need one? Pull it out, increment it and then store it back into the DB.

dalya
07-02-2007, 11:33 PM
Instead, why don't you just create a starting cust ID number and keep it in a database and keep inc it as you need one? Pull it out, increment it and then store it back into the DB.

i am not sure what you mean, sorry



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum