Shopping Cart, PHP & MySQL
Posted 16 July 2006 - 09:44 PM
I am developing a e-commerce site in Flash using PHP and MySQL as the backend. I am now at the stage where I have to integrate the site with our payment gateway and I am not sure of the best way to do this.
The following steps have to occur when the "Place Order" button is pressed:
- Customer and Order information has to be entered into the database (using transactions)
- The total price and a few other params have to be sent to the payment gateway
The problem is I am not sure of the order I should process these steps.
If I send the data to the payment gateway first and on success insert the customer and order information, if an error occurrs (causing the trans to rollback) I have an order that has been paid for but no way of knowing who made it.
This is how I think I should do it:
Once the "Place Order" button is pressed, insert the customer and order information into the MySQL database, on error rollback the trans and notify the user, on success send the total price to the payment gateway, if payment gateway response is an error rollback the trans and notify the user, if payment success notify the user that their payment was accepted and commit the trans.
Does this seem right?
Posted 16 July 2006 - 09:49 PM
You've got to use the mysqli connections and functions to use transactions, and must be using an InnoDB database type.
Posted 16 July 2006 - 09:54 PM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users