tags:

views:

2746

answers:

3

Hi,

I am trying to pass custom variables to paypal IPN. I can manage to pass one variable. But i don't know how to pass multiple variables.

My Process is something like this

  1. User fill up the form
  2. They click button and it goes to paypal
  3. They paid, IPN send me back the information and that ipn.php added variables that passed to the database.

My custom variables are

  1. total lines (whenever they write, i count the lines)
  2. message (their message that they wrote)
  3. advertisement id

But for now, I can only pass one variable like this

form.php

<input name="custom" type="hidden" id="custom" value="{$line_count}">

   $_SESSION['line_count'] = $_POST['lines_txt'];

ipn.php

  $sql="INSERT INTO `form` (
       `totalline` ,
       )
       VALUES (
       '" .$_POST['custom']. "'
       );";
A: 

A vague memory tells me there are two options for sending data to PayPal. The command x_click and i thought there was something like an upload parameter. When the upload parameter is set to 1 you can send multiple lines to paypal.

Update PayPal information about this

Ben Fransen
+4  A: 

I am not sure, if it is even possible with Paypal to send and receive multiple variables. If it is not possible due to Paypal's restrictions, you could use one of the following approaches:

  • Send the data serialized, and deserialize on return.
  • Write the data to the database in form.php (with status notpaid) and send the id. In ipn.php catch the id and set status = paid / error / whatever happened in the database.
Residuum
thanks for your reply. Currently I am checking and custom variable can only hold 200 characters, my variables are more than that value, so i cannot pass. Only one thing i can do is, like you says, first, when they submit the form, i store all the things i need to store in database, then get the IPN result, if that's success, update the status, if that's fail, remove the entry. But another one problem is, if they close the browser and never make payment, how can i remove that entry ? Does I need to run cron and delete ? :( it's alot of process and works
spotlightsnap
@spotligthsnap: If the user closes the browser while on the Paypal website, then the database entry persists, correct. You could delete them via a cronjob, but you could also leave them in the database to analyse later (payments / redirects to paypal). In the same spirit, you could write error after returning from Paypal instead of just deleting the entry.
Residuum
Thanks. This works great. Also, storing some values to db and then sending to paypal is a better idea.
noobcode
A: 

How safe is it to pass variable thru input type="hidden" to PayPal?

Daveel
This should be a separate question, not an answer to another question.
TRiG
@TRiG - his question is fair in that he is pointing out security flaws in the original questions design. While he may have simply shown above for simplicity sake - using unencrypted buttons is foolish.
JM4