Testing PayPal IPN results

Posted by & filed under PHP.

If you are getting 400 errors back from paypal make sure you add a Host header. It won’t do any harm to add the Connection close header too. Notice the host depends on whether you’re aiming at sandbox or live paypal.

// post back to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
/******** this line from http://stackoverflow.com/questions/11810344/paypal-ipn-bad-request-400-error ************/
$header .= "Host: www.sandbox.paypal.com\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$header .= "Connection: close\r\n";

Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>