Jump to content


Photo

Shopping Cart, PHP & MySQL


  • Please log in to reply
3 replies to this topic

#1 raydenl

raydenl
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 16 July 2006 - 09:44 PM

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?




#2 pixy

pixy
  • Members
  • PipPipPip
  • Advanced Member
  • 295 posts

Posted 16 July 2006 - 09:49 PM

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 is a .44 Caliber Loveletter straight through my heart.

Tabulas + Threadless + Hire Me!


#3 raydenl

raydenl
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 16 July 2006 - 09:54 PM

Yes I am using mysql transactions and yes I am using Innodb tables

#4 pixy

pixy
  • Members
  • PipPipPip
  • Advanced Member
  • 295 posts

Posted 16 July 2006 - 10:07 PM

Why not just do the entire thing, and committ it to the database when everything is sucessfull?

This is a .44 Caliber Loveletter straight through my heart.

Tabulas + Threadless + Hire Me!





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users