【问题标题】:PayPal sandbox IPN not responding anymorePayPal沙盒IPN不再响应
【发布时间】:2012-10-10 05:33:04
【问题描述】:

我正在使用 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,因为这些脚本 会被“挂起”或需要很长时间才能得到“已验证”的响应。我们 包括有关如何通过添加 HTTP 请求中的“Connection: close”标头。

但显然这是行不通的。

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

有什么想法吗?非常感谢您的帮助。

【问题讨论】:

    标签: php paypal paypal-ipn paypal-sandbox


    【解决方案1】:

    你有 \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";
    

    您还需要 Host 行。

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-11-25
        • 2016-07-13
        • 2012-01-08
        • 2011-01-19
        • 2013-05-09
        • 2011-08-07
        • 2018-08-14
        • 2011-11-01
        相关资源
        最近更新 更多