在集成paypal时不能收到ipn
1. 采用标准集成的方式,按钮进行支付(已经成功)
2. return 能收到。
3. ipn不能收到。。。但是在卖家账号设置里可以看到ipn已经发出去了。
4. sandbox环境
$value) {  
$value = urlencode(stripslashes($value));  
$req .= &$key=$value;  
}  
//建议在此将接受到的信息记录到日志文件中以确认是否收到 ipn 信息  
//将信息 post 回给 paypal 进行验证  
$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;  
//在 sandbox 情况下,设置:  
$fp = fsockopen('www.sandbox.paypal.com',80,$errno,$errstr,30);  
//$fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);  
//将 post 变量记录在本地变量中  
//该付款明细所有变量可参考:  
//https://www.paypal.com/integrationcenter/ic_ipn-pdt-variable-reference.htm
$item_name = $_post['item_name'];  
$item_number = $_post['item_number'];  
$payment_status = $_post['payment_status'];  
$payment_amount = $_post['mc_gross'];  
$payment_currency = $_post['mc_currency'];  
$txn_id = $_post['txn_id'];  
$receiver_email = $_post['receiver_email'];  
$payer_email = $_post['payer_email'];  
//…  
//判断回复 post 是否创建成功  
if (!$fp) {  
//http 错误  
}else {  
//将回复 post 信息写入 socket 端口  
fputs ($fp, $header .$req);  
//开始接受 paypal 对回复 post 信息的认证信息  
while (!feof($fp)) {  
$res = fgets ($fp, 1024);  
//已经通过认证  
if (strcmp ($res, verified) == 0) {
@$fp = fopen(aaa.txt,w);
     if(!$fp){
         echo system error;
         exit();
     }else {
             fwrite($fp,完成);
             fclose($fp);
     }
//检查付款状态  
//检查 txn_id 是否已经处理过  
//检查 receiver_email 是否是您的 paypal 账户中的 email 地址  
//检查付款金额和货币单位是否正确  
//处理这次付款,包括写数据库  
}else if (strcmp ($res, invalid) == 0) {  
//未通过认证,有可能是编码错误或非法的 post  
@$fp = fopen(bbb.txt,w);
     if(!$fp){
         echo system error;
         exit();
     }else {
             fwrite($fp,有错);
             fclose($fp);
     }
}  
}  
fclose ($fp);  
}  
?>
------解决方案--------------------
php code//session_start();$req = 'cmd=_notify-validate';foreach ($_post as $key => $value) {$value = urlencode(stripslashes($value));$req .= &$key=$value;}$url='https://www.paypal.com/cgi-bin/webscr';    $curl_result=$curl_err='';    $ch = curl_init();    curl_setopt($ch, curlopt_url,$url);    curl_setopt($ch, curlopt_returntransfer,1);    curl_setopt($ch, curlopt_post, 1);    curl_setopt($ch, curlopt_postfields, $req);    curl_setopt($ch, curlopt_httpheader, array(content-type: application/x-www-form-urlencoded, content-length:  . strlen($req)));    curl_setopt($ch, curlopt_header , 0);       curl_setopt($ch, curlopt_verbose, 1);    curl_setopt($ch, curlopt_ssl_verifypeer, false);    curl_setopt($ch, curlopt_timeout, 3000);    $curl_result = @curl_exec($ch);    $curl_err = curl_error($ch);    curl_close($ch);$mc_gross = $_post['mc_gross']; 
   
 
   