title: PayPal sandbox IPN validation always return INVALID
body: <p>I googled this question and tried all suggestions but nothing works.</p>
  
  <p>I tried this code: <a href="https://developer.paypal.com/docs/classic/ipn/ht_ipn/" rel="nofollow">https://developer.paypal.com/docs/classic/ipn/ht_ipn/</a> but it don't work. Just copy-pasted it and deleted old magick_quotes routunes.</p>
  
  <p>I tried this code: <a href="http://samples.geekality.net/view-source.php?file=ipn/ipn_handler.class.php" rel="nofollow">http://samples.geekality.net/view-source.php?file=ipn/ipn_handler.class.php</a> and it also do not work.</p>
  
  <p>In all cases I tried to do following:</p>
  
  <pre><code>$req = 'cmd=_notify-validate&amp;' . file_get_contents('php://input');
  </code></pre>
  
  <p>To ensure I sent to IPN <strong>exactly</strong> what it sent to me. In addition I used the debug proxy (Fiddler) and saved what IPN sent to me and what I sent to IPN. The requests bodies are byte-to-byte identical except my request is prefixed by the <code>cmd=_notify-validate&amp;</code> string.</p>
  
  <p>Yes, I checked I use proper sandbox URL. Here are entire requests bodies:</p>
  
  <p>What IPN sent to me: (I just replaced personal data to XXX)</p>
  
  <pre><code>POST http://localhost.loc/en/payment/success/1 HTTP/1.1
  Host: localhost.loc
  Connection: keep-alive
  Content-Length: 921
  Cache-Control: max-age=0
  Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
  Origin: null
  User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36
  Content-Type: application/x-www-form-urlencoded
  Accept-Encoding: gzip, deflate
  Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4
  
  mc_gross=1.00&amp;protection_eligibility=Ineligible&amp;payer_id=5XNKM66NSDKC4&amp;tax=0.00&amp;payment_date=05%3A34%3A11+Jun+01%2C+2015+PDT&amp;payment_status=Completed&amp;charset=utf-8&amp;first_name=XXX&amp;mc_fee=0.33&amp;notify_version=3.8&amp;custom=topup%3A262262%3A1%3A1433162020&amp;payer_status=verified&amp;business=XXX&amp;quantity=1&amp;payer_email=XXX&amp;verify_sign=AG58dBsn5g2z8O8NEjotbuJGP14PAIpZ4k26VL8IyhaDPkcDRj002Keq&amp;memo=hmgvjgjhgfjhfggjhfjtfgjh&amp;txn_id=4CN141026K278934Y&amp;payment_type=instant&amp;last_name=XXX&amp;receiver_email=XXX&amp;payment_fee=0.33&amp;receiver_id=DCMXPXGX4QX6J&amp;txn_type=web_accept&amp;item_name=Account+top+up&amp;mc_currency=USD&amp;item_number=Account+262262+top+up&amp;residence_country=US&amp;test_ipn=1&amp;handling_amount=0.00&amp;transaction_subject=topup%3A262262%3A1%3A1433162020&amp;payment_gross=1.00&amp;shipping=0.00&amp;auth=ANSTBwT3znll-gJQZO2cLoV5QJFW9v8W.FqyWxffdtI0L-9mfsoe2xRL44M86Sn2XtYGtcqG4Fjjel1kdYZyxpQ
  </code></pre>
  
  <p>What I sent to IPN:</p>
  
  <pre><code>POST https://www.sandbox.paypal.com/cgi-bin/webscr HTTP/1.1
  Host: www.sandbox.paypal.com
  Accept: */*
  Content-Length: 942
  Content-Type: application/x-www-form-urlencoded
  
  cmd=_notify-validate&amp;mc_gross=1.00&amp;protection_eligibility=Ineligible&amp;payer_id=5XNKM66NSDKC4&amp;tax=0.00&amp;payment_date=05%3A34%3A11+Jun+01%2C+2015+PDT&amp;payment_status=Completed&amp;charset=utf-8&amp;first_name=XXX&amp;mc_fee=0.33&amp;notify_version=3.8&amp;custom=topup%3A262262%3A1%3A1433162020&amp;payer_status=verified&amp;business=XXX&amp;quantity=1&amp;payer_email=XXX&amp;verify_sign=AG58dBsn5g2z8O8NEjotbuJGP14PAIpZ4k26VL8IyhaDPkcDRj002Keq&amp;memo=hmgvjgjhgfjhfggjhfjtfgjh&amp;txn_id=4CN141026K278934Y&amp;payment_type=instant&amp;last_name=XXX&amp;receiver_email=XXX&amp;payment_fee=0.33&amp;receiver_id=DCMXPXGX4QX6J&amp;txn_type=web_accept&amp;item_name=Account+top+up&amp;mc_currency=USD&amp;item_number=Account+262262+top+up&amp;residence_country=US&amp;test_ipn=1&amp;handling_amount=0.00&amp;transaction_subject=topup%3A262262%3A1%3A1433162020&amp;payment_gross=1.00&amp;shipping=0.00&amp;auth=ANSTBwT3znll-gJQZO2cLoV5QJFW9v8W.FqyWxffdtI0L-9mfsoe2xRL44M86Sn2XtYGtcqG4Fjjel1kdYZyxpQ
  </code></pre>
  
  <p>Can anyone help me what I do wrong?
  Thanks.</p>