不再支持PayPal IPN和fsockopen?

问题描述 投票:2回答:1

多年来,我的PayPal IPN脚本已经运行。昨天它坏了,我们的网络服务器没有任何变化。当我收到IPN时,我的PHP脚本调用:

    // read the post from PayPal system and add 'cmd'
    $req = 'cmd=_notify-validate';

    foreach ($_POST as $key => $value)
    {
        $value = urlencode(stripslashes($value));
        $req .= "&$key=$value";
    }

    // post back to PayPal system to validate
    $header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
    $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
    $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
    $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 120);
    if ($fp)
    {
        fputs ($fp, $header . $req);
        while (!feof($fp))
        {
          ...
        }
    }
}

PayPal的文档现在谈论:

将回复消息发回PayPal:

https://ipnpb.sandbox.paypal.com/cgi-bin/webscr(用于Sandbox IPN)

https://ipnpb.paypal.com/cgi-bin/webscr(用于直播IPN)

我的上述代码是否不再受支持? PayPal打电话给我,但似乎没有验证。

php paypal paypal-ipn
1个回答
4
投票

这是一个HTTP / 1.1问题。

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

...

if (strcmp(trim($result), "VERIFIED") == 0)
© www.soinside.com 2019 - 2024. All rights reserved.