【问题标题】:PayPal IPN and fsockopen no longer supported?不再支持 PayPal IPN 和 fsockopen?
【发布时间】:2019-02-13 19:12:24
【问题描述】:

多年来,我的 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(用于沙盒 IPN)

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

我上面的代码不再受支持了吗? PayPal 正在给我打电话,但似乎没有验证。

【问题讨论】:

    标签: php paypal paypal-ipn


    【解决方案1】:

    这是一个 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)
    

    【讨论】:

      猜你喜欢
      • 2016-04-29
      • 2019-02-05
      • 2011-06-17
      • 2014-02-12
      • 2011-11-14
      • 2012-02-02
      • 2012-10-10
      • 2017-08-09
      • 2014-06-23
      相关资源
      最近更新 更多