Paypal IPN process more than one custom variable

inrob picture inrob · Jul 24, 2012 · Viewed 10.3k times · Source

So I've implemented paypal IPN in my site and I'm in the middle of the work process. Now I want to use more than 1 custom variable in the pp form currently I'm using this one only

<input type="hidden" name="custom" value="<?php echo $user_id; ?>">

So I know the variable with the name 'custom' is allowed. I want to know if I can pass more variables so I can filter the payments based on their criterias. So if for example shipping is more than $0.00 I set a variable "shipping_cost" like this:

<input type="hidden" name="shipping_cost" value="<?php echo $cost; ?>">

or for other purposes. Is this allowed? Or paypal has an already defined list of allowed variables we can use? I really want to solve this problem as there's not always one type of payment we can process... Thank you guys.

Answer

Varadha picture Varadha · Aug 22, 2015

this way you can pass more parameters

<input type="hidden" name="custom" value="variable1=234&var2=summa&etc=xyz"/>

use the above one on your paypal form.

and process through the following code.

 parse_str($_POST['custom'],$_MYVAR);

echo $_MYVAR['variable1'];
echo $_MYVAR['var2'];
echo $_MYVAR['etc'];

i hope this one help you.