Passing custom variables to paypal IPN

spotlightsnap picture spotlightsnap · Dec 3, 2009 · Viewed 34.1k times · Source

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

Answer

Residuum picture Residuum · Dec 3, 2009

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.