Passing custom variables to paypal IPN

Viewed 34679

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']. "');";
6 Answers

Haven't tested, but according to documentation, you could use multiple hidden inputs with name item_number_X (X=number) inside paypal form to store variables:

<INPUT TYPE="hidden" name="item_number_1" value="value1">
<INPUT TYPE="hidden" name="item_number_2" value="value2">

From paypal docs:

Recordkeeping with passthrough variables

Some variables are exclusively for your own use, such as order management. PayPal returns the values that you send through Instant Payment Notification exactly as you sent them. For this reason, they are called passthrough variables. Their values are not recorded or used by PayPal.

The following are passthrough variables:

  • custom
  • item_number or item_number_x
  • invoice

Yes, you can! You can use 'custom' variable and add in your form

<INPUT TYPE="hidden" name="custom" value="user_id=1&uname=jj">

And in your IPN.php:

$custom = $_POST['custom'];

And extract the variables from string

Related