Jump to content

PHP, MySQL and PayPal


leeh14

Recommended Posts

Hi,

 

I am about to incorporate some PayPal functions to my site and am just asking for some advice before I start.

 

Basically a user is going to enter some data into a form and then be passed to PayPal to pay an X amount, once the payment has been verified I want the information entered in the form (before going to PayPal),  to be added to a database.

 

But it seems that PayPal does not allow you to pass multiple (about 13) variables through their system. Is this correct?

 

So what I was going to do is just before the customer goes to the PayPal site, I was going to insert all the data into the database and set a payment status, then once the payment is confirmed re-setting the payment status to paid or non-paid. Is that a good way to do what I want? If not is there a better way?

 

Any help would be great.

 

Lee

 

Link to comment
Share on other sites

Yeah thats how i would do it. That whay the only thing paypal needs to send your back is the ID of the member when the paiement is done.

 

agreed, in fact, in your database table, you don't even need a "paid" or "unpaid" status.  Just have a field for the transaction ID.  If the field is blank in your database, you know the status is "unpaid"

Link to comment
Share on other sites

Sweet, well that is pretty much all I needed to hear! I have not yet experimented with this yet, but I can imagine that the thing which will be the hardest is getting hold of the 'ID' field and then sending that off to PayPal, as the ID field is created with auto increment as the data is inserted to the database.

 

Does anyone have a quick idea for how I would be able to get hold of this field before going into PayPal??

 

Link to comment
Share on other sites

Cheers, that seems easy enough and shouldwork fine. The last thing i would like to know is what would happen if say two people where using the site at the same time. Small chance but still worth thinking about? Like will there be a queue as the collect ID is in the same function already being run.

Link to comment
Share on other sites

Cheers, that seems easy enough and shouldwork fine. The last thing i would like to know is what would happen if say two people where using the site at the same time. Small chance but still worth thinking about? Like will there be a queue as the collect ID is in the same function already being run.

 

if you are really concerned about Internet race conditions, where mysql_query() is executed in two different scripts simultaneously and therefore mysql_insert_id() returns the wrong id value, than you could *not* use mysql_insert_id() and instead do a query for the data you just entered.

 

so like:

<?php
session_start();
mysql_query("INSERT INTO table_name (col_1,col_2,user_token) VALUES ('val_1','val_2','".session_id()."') ");
$get_mysql_inserted_id = mysql_query("SELECT `id` FROM table_name WHERE user_token = '".session_id()."'");
$id = mysql_result($get_mysql_inserted_id,0,0);
echo $id; 

Link to comment
Share on other sites

  • 2 weeks later...
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.