【问题标题】:Paypal : trouble with ipn responsePaypal:ipn响应问题
【发布时间】:2015-01-21 08:16:32
【问题描述】:

我可以使用 IPN 从贝宝获得已验证的答案 我通过 notify_url 从 PayPal 接收 POST 数据。然后我在数据前面使用 cmd=_notify-validate 将其发送回 PayPal。

使用 PayPals 记录的代码,我正在使用它向 PayPal 发送消息

$header = "POST /cgi-bin/webscr HTTP/1.1\r\n"; // HTTP POST request
$header.= "Content-Type: application/x-www-form-urlencoded\r\n";
$header.= "Host: www.sandbox.paypal.com\r\n";
$header.= "Content-Length: " . strlen($req) . "\r\n";
$header.= "Connection: Close\r\n\r\n";
$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);

那我就用这个

if (!$fp) {
    // HTTP ERROR; 
} else {
    var_dump(fputs($fp, $header . $req));
    while (!feof($fp)) {
        $res = stream_get_contents($fp, 1024); 
        if (strcmp ($res, "VERIFIED") == 0) {
            //Transaction verified
        }
    }
}

事实上,我有两个 $res(由于 while 循环)。第一个似乎不感兴趣,第二个是

55 GMT
Connection: close
Set-Cookie: X-PP-SILOVER=name%3DSANDBOX3.WEB.1%26silo_version%3D880%26app%3Dslingshot%26TIME%3D1273590100; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00:00:01 GMT
Set-Cookie: Apache=10.72.128.11.1416751435364358; path=/; expires=Tue, 15-Nov-44 14:03:55 GMT
Vary: Accept-Encoding
Strict-Transport-Security: max-age=14400
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8

8
VERIFIED
0

似乎第一部分是标题,第二部分(8 VERIFIED 0)是真正的响应,但为什么我有这个 0 和 8 ?通常人们使用

 if (strcmp ($res, "VERIFIED") == 0) {

要检查 $res 是否已验证...所以我可以认为响应是“已验证”,使用类似

if(strstr($res,'VERIFIED')) {

请帮忙?!?

谢谢

【问题讨论】:

    标签: php paypal


    【解决方案1】:

    我遇到了完全相同的问题,并且能够以相同的方式解决它。如果我使用 PayPal 的示例代码,我根本没有得到任何回应。

    但我在这里遇到了一些使用 cURL 的东西: https://github.com/paypal/ipn-code-samples/blob/master/paypal_ipn.php

    我需要使用以下说明安装 cURL: curl_init() function not working

    还可以下载并使用脚本 cmets 中的 cacert.pem。

    我仍然不确定为什么 stream_get_contents() 会返回标题。如果你弄明白了,能不能更新一下?

    【讨论】:

      【解决方案2】:

      我和你有同样的问题。我使用 strstr($res,'VERIFIED') 检查通知是否得到验证。

      【讨论】:

        猜你喜欢
        • 2011-07-18
        • 2010-11-20
        • 2017-05-10
        • 2016-04-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多