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
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