简体   繁体   English

PayPal沙箱IPN不再响应

[英]PayPal sandbox IPN not responding anymore

I'm testing my PHP script with Paypal sandbox, the script works with www.paypal.com but not www.sandbox.paypal.com . 我正在使用Paypal沙箱测试我的PHP脚本,该脚本可用于www.paypal.com但不能与www.sandbox.paypal.com I recently received an email from PayPal asking to use HTTP 1.1 protocol instead of 1.0 so I have done that, and i'm using the Connection: close in the header as specified, but the IPN URL hangs. 我最近从PayPal收到一封电子邮件,要求使用HTTP 1.1协议而不是1.0,所以我做到了,而且我正在使用Connection: close按指定的标题Connection: close ,但IPN URL挂起。 When I try it with www.paypal.com there is no hanging. 当我在www.paypal.com上尝试时,没有悬挂。

PayPal did specificy this in their second email 贝宝在第二封电子邮件中对此做了具体说明

This is a follow-up to the bulletin we sent on 6 September, 2012. It has come to our attention that some merchants were experiencing issues getting their IPN scripts updated to use HTTP 1.1 because the scripts would get "hung" or take a long time to get a 'VERIFIED' response. 这是我们在2012年9月6日发送的公告的后续措施。引起我们注意的是,一些商家遇到了使其IPN脚本更新为使用HTTP 1.1的问题,因为这些脚本会“挂”或花费很长时间。是时候获得“验证”答复了。 We are including instructions on how to remedy this issue by adding a "Connection: close" header in the HTTP request. 我们包括有关如何通过在HTTP请求中添加“ Connection:close”标头来解决此问题的说明。

But clearly that doesn't work. 但是很显然那是行不通的。

$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";

Any ideas? 有任何想法吗? Help much appreciated. 帮助非常感谢。

You have the \\r\\n\\r\\n on the 2nd to last line, it needs to go on the last line... 您在倒数第二行有\\ 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";

You also need the Host line. 您还需要主机行。

I don't know the answer as to why it hangs, but using curl instead of fsockopen seemed to solve my problem. 我不知道它为什么挂起的答案,但是使用curl而不是fsockopen似乎可以解决我的问题。 I used the solution on here; 我在这里使用了解决方案;

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM