title: Paypal Sandbox IPN Simulator - Not getting response
body: <p>I have used exactly same code from paypal and try to get response from IPN simulator from Payapl Sandbox. I have set up ipn.php file on my website where I will get IPN response and it has below code. Still I am not getting any mail for either VERIFIED or INVALID status as I stated in below code. So please let me know what is missing or what is wrong in my code so I can correct it.</p>
  
  <pre><code>&lt;?php
  $raw_post_data = file_get_contents('php://input');
  $raw_post_array = explode('&amp;', $raw_post_data);
  $myPost = array();
  foreach ($raw_post_array as $keyval) {
  $keyval = explode ('=', $keyval);
  if (count($keyval) == 2)
      $myPost[$keyval[0]] = urldecode($keyval[1]);
  }
  
  $req = 'cmd=_notify-validate';
  if(function_exists('get_magic_quotes_gpc')) {
  $get_magic_quotes_exists = true;
  } 
  foreach ($myPost as $key =&gt; $value) {        
  if($get_magic_quotes_exists == true &amp;&amp; get_magic_quotes_gpc() == 1) { 
      $value = urlencode(stripslashes($value)); 
  } else {
      $value = urlencode($value);
  }
  $req .= "&amp;$key=$value"; 
  }
  
  $ch = curl_init('https://www.sandbox.paypal.com/cgi-bin/webscr');
  curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
  curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
  curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));
  
  if( !($res = curl_exec($ch)) ) {
  // error_log("Got " . curl_error($ch) . " when processing IPN data");
  curl_close($ch);
  exit;
  }
  curl_close($ch);
  
  if (strcmp ($res, "VERIFIED") == 0) {
  $item_name = $_POST['item_name'];
  $item_number = $_POST['item_number'];
  $payment_status = $_POST['payment_status'];
  $payment_amount = $_POST['mc_gross'];
  $payment_currency = $_POST['mc_currency'];
  $txn_id = $_POST['txn_id'];
  $receiver_email = $_POST['receiver_email'];
  $payer_email = $_POST['payer_email'];
  
  mail('mymailid@yahoo.com', 'PayPal IPN', 'Working...');
  } 
  else if (strcmp ($res, "INVALID") == 0) 
  {
  // log for manual investigation
  mail('kra_14_05@yahoo.co.in', 'PayPal IPN', 'NOT Working...');  
  }
  ?&gt;
  </code></pre>
  
  <hr>
  
  <p>I have tried to test using test merchant and buyer accounts in paypal sandbox. I can see IPN history under test merchant account. There I can see HTTP response code = 200 so I guess my ipn script is accessed by Paypal. $0.25 amount is debited from buyer account and deposited into merchant account so I guess that part is also working fine.</p>
  
  <p>Now I have passed 2 values in single variable like.</p>
  
  <pre><code>&lt;input type="hidden" name="custom" value="mem001::mempass001"&gt;
  </code></pre>
  
  <p>Then I am trying to receive values of "custom" variable on my ipn.php (ipn script is on this page) page. Using php functions I have separated both values and stored in different variables. </p>
  
  <p>For testing purpose, I am trying to store above values in database but values are not stored into database. </p>
  
  <p>So finally what wrong I am doing so far? And how can i make sure that I am really getting "VERIFIED" status from IPN after all above processes? Please help.</p>