raydenl Posted July 16, 2006 Share Posted July 16, 2006 Hi,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 gatewayThe 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? Quote Link to comment https://forums.phpfreaks.com/topic/14794-shopping-cart-php-mysql/ Share on other sites More sharing options...
pixy Posted July 16, 2006 Share Posted July 16, 2006 I am assuming you are going to be using transations for this? You can do all the queries and if one of them fails, tell the user to try again and it will rollback all changes.You've got to use the mysqli connections and functions to use transactions, and must be using an InnoDB database type. Quote Link to comment https://forums.phpfreaks.com/topic/14794-shopping-cart-php-mysql/#findComment-59081 Share on other sites More sharing options...
raydenl Posted July 16, 2006 Author Share Posted July 16, 2006 Yes I am using mysql transactions and yes I am using Innodb tables Quote Link to comment https://forums.phpfreaks.com/topic/14794-shopping-cart-php-mysql/#findComment-59083 Share on other sites More sharing options...
pixy Posted July 16, 2006 Share Posted July 16, 2006 Why not just do the entire thing, and committ it to the database when everything is sucessfull? Quote Link to comment https://forums.phpfreaks.com/topic/14794-shopping-cart-php-mysql/#findComment-59087 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.