Jump to content

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.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.