PayPal沙箱IPN不再响应

时间:2012-10-19 15:00:45

标签: php paypal paypal-ipn paypal-sandbox

我正在使用Paypal沙箱测试我的PHP脚本,该脚本适用于www.paypal.com但不适用www.sandbox.paypal.com。我最近收到了一封来自PayPal的电子邮件,要求使用HTTP 1.1协议而不是1.0,所以我已经这样做了,我在标题中使用Connection: close,但IPN URL挂起。当我用www.paypal.com尝试时,没有悬挂。

PayPal在第二封电子邮件中详细说明了这一点

  

这是我们于2012年9月6日发布的公告的后续行动   我们注意到一些商家遇到了问题   让他们的IPN脚本更新为使用HTTP 1.1因为脚本   会被“挂起”或需要很长时间才能得到“验证”的回复。我们   包括如何通过添加a来解决此问题的说明   HTTP请求中的“连接:关闭”标头。

但显然这不起作用。

$header = "POST /cgi-bin/webscr HTTP/1.1\r\n";
$header .= "Host: $url\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";

有什么想法吗?非常感谢。

2 个答案:

答案 0 :(得分:1)

你在第2行到最后一行有\ r \ n \ r \ n,它需要在最后一行...

$header = "POST /cgi-bin/webscr HTTP/1.1\r\n";
$header .= "Host: $url\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n";
$header .= "Host: www.paypal.com\r\n"; 
$header .= "Connection: close\r\n\r\n";

您还需要主机线。

答案 1 :(得分:0)

我不知道它为什么会挂起的答案,但使用curl代替fsockopen似乎可以解决我的问题。我在这里使用了解决方案;

https://www.x.com/developers/PayPal/documentation-tools/code-sample/216623

相关问题