无法从Paypal IPN沙箱获得响应 [英] Unable to getting response from paypal IPN sandbox

查看:160
本文介绍了无法从Paypal IPN沙箱获得响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几天前,它突然停止接收来自Paypal的IPN消息. 我已经写了下面的代码

Few days ago suddenly it is stopped to receive IPN messages from paypal. I have written the code which are below

$url_parsed=parse_url('https://www.sandbox.paypal.com/cgi-bin/webscr');
$post_string = '';    
foreach ($_POST as $field=>$value) { 
    $post_string .= $field.'='.urlencode(stripslashes($value)).'&'; 
}
$post_string.="cmd=_notify-validate";
$fp = fsockopen($url_parsed['host'],"80",$err_num,$err_str,30);

$myFile = "testpaypal.txt";

$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = $post_string;
fwrite($fh, $stringData);
fwrite($fh, "------------");


if(!$fp){
    return false;
} else {

    fputs($fp, "POST $url_parsed[path] HTTP/1.0\r\n"); 
    fputs($fp, "Host: $url_parsed[host]\r\n"); 
    fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n"); 
    fputs($fp, "Content-length: ".strlen($post_string)."\r\n"); 
    fputs($fp, "Connection: close\r\n\r\n"); 
    fputs($fp, $post_string . "\r\n\r\n");      
    while(!feof($fp)) 
    { 
        $ipn_response .= fgets($fp, 1024); 
    } 
    fclose($fp);
    if (eregi("VERIFIED",$ipn_response)) {
        fwrite($fh, "VERIFIED");
        return true;
    } else {
        fwrite($fh, "UNVERIFIED");
        return false;
    }
}
    fclose($fh);

此代码将err_num返回到" 0 ",以及当我在"fclose($ fp);"之后打印$ ipn_response时.行中会显示" HTTP/1.0 302找到的位置: https://www.sandbox.paypal.com 服务器:BigIP连接:关闭内容长度:0 "

This code returns err_num to "0" as well as when i print $ipn_response after "fclose($fp);" line it prints "HTTP/1.0 302 Found Location: https://www.sandbox.paypal.com Server: BigIP Connection: close Content-Length: 0 "

但无法在$ ipn_respnse中获得已验证".

but unable to get "VERIFIED" in $ipn_respnse.

我尝试了所有可能的方法,例如使用"ssl://sandbox.paypal.com"更改解析网址 以及网络上建议的所有其他解决方案.

i have tried all possible method such as change parse url with "ssl://sandbox.paypal.com" and all other solution suggested on web.

自最近三天以来,我一直陷在这个问题上.所以,请帮帮我.

i have been stuck in this issue since last three days. So, please help me out.

提前谢谢.

推荐答案

我也曾为这个问题苦苦挣扎.这完全让我发疯了!!!问题是Hetzner(托管位置)由于某种原因阻止了PayPal IP.在这种情况下,当您查看PayPal帐户中的IPN历史记录时,您应该看到IPN从某个日期开始已停止发送通知.

I also struggled with this problem once. It completely job me crazy!!! The problem was that Hetzner (where is hosting located) has blocked PayPal IP by some reason. In this case when you will look at the IPN histiry in the PayPal account you shoud see that IPN has stoped send notifications from some date.

这篇关于无法从Paypal IPN沙箱获得响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆