小编use*_*999的帖子

无法从paypal IPN沙箱获得响应

几天前突然停止接收来自paypal的IPN消息.我写了下面的代码

$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 { …
Run Code Online (Sandbox Code Playgroud)

php paypal paypal-ipn

3
推荐指数
1
解决办法
2242
查看次数

标签 统计

paypal ×1

paypal-ipn ×1

php ×1