Jump to content

Shopping Cart, PHP & MySQL


raydenl

Recommended Posts

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


Link to comment
https://forums.phpfreaks.com/topic/14794-shopping-cart-php-mysql/
Share on other sites

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.