title: Migrating CodeIgniter PayPal IPN Handler to Payza IPN Handler
body: <p>Apologies for such a neophyte request but guidance greatly appreciated.  I need to integrate the Payza (formerly AlertPay) IPN handler into the class/function structure that was previously used with PayPal.  </p>
  
  <p>My PayPal IPN handler has this construction:</p>
  
  <pre><code>class PayPalIPN {
  
  public $paypal_url;
  public $socket_url;
  public $ipn_response;
  public $ipn_data;
  
  
  
  function __construct() {
      $this-&gt;paypal_url       = 'https://www.paypal.com/cgi-bin/webscr';
      $this-&gt;socket_url       = 'www.paypal.com';
      $this-&gt;ipn_response     = '';
  }
  
  
  
  function validate_ipn($logId = null) {
  
  Do stuff
  }
  </code></pre>
  
  <p>The Payza (formerly AlertPay) IPN handler sample code looks like this:</p>
  
  <pre><code>define("IPN_V2_HANDLER", "https://secure.payza.com/ipn2.ashx");
  define("TOKEN_IDENTIFIER", "token=");
  
  // get the token from Payza
  $token = urlencode($_POST['token']);
  
  //preappend the identifier string "token=" 
  $token = TOKEN_IDENTIFIER.$token;
  
  /**
   * 
   * Sends the URL encoded TOKEN string to the Payza's IPN handler
   * using cURL and retrieves the response.
   * 
   * variable $response holds the response string from the Payza's IPN V2.
   */
  
  $response = '';
  
  $ch = curl_init();
  
  curl_setopt($ch, CURLOPT_URL, IPN_V2_HANDLER);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $token);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_HEADER, false);
  curl_setopt($ch, CURLOPT_TIMEOUT, 60);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  
  $response = curl_exec($ch);
  
  curl_close($ch);
  </code></pre>
  
  <p>I started off with this: </p>
  
  <pre><code>class PayzaIPN {
  
  public $IPN_V2_HANDLER;
  public $TOKEN_IDENTIFIER;
  public $response;
  public $ipn_data;
  public $token;  
  
  
  //define("TOKEN_IDENTIFIER", "token=");
  
  //define("IPN_V2_HANDLER", "https://secure.payza.com/ipn2.ashx");
  //define("IPN_V2_HANDLER", "https://sandbox.Payza.com/sandbox/IPN2.ashx");
  
  function validate_ipn($logId = null)  { 
  $this-&gt;IPN_V2_HANDLER = 'https://sandbox.Payza.com/sandbox/IPN2.ashx';
  $this-&gt;token = TOKEN_IDENTIFIER.$token;
  </code></pre>
  
  <p>I am having trouble getting the variables properly declared in the correct structure - getting T_function expected errors and undefined constant errors.  </p>