我正在尝试使用paypal IPN,但它只返回一个空白字段而不是“已验证”或未经验证? 是否可以返回一个空白字段?
函数VerifyPayment(){
// parse the Paypal URL
$url_parsed=parse_url($this->GatewayUrl);
// generate the post string from the _POST vars aswell as load the
// _POST vars into an array so we can play with them from the calling
// script.
//print_r($_POST);
$this->InvoiceNo = $_POST['invoice'];
$post_string = '';
foreach ($_POST as $field=>$value) {
$this->ipn_data["$field"] = $value;
$post_string .= $field.'='.urlencode(stripslashes($value)).'&';
}
$post_string.="cmd=_notify-validate"; // append ipn command
// open the connection to Paypal
$fp = fsockopen($url_parsed[host],"80",$err_num,$err_str,30);
if(!$fp) {
// could not open the connection. If loggin is on, the error message
// will be in the log.
$this->last_error = "fsockopen error no. $errnum: $errstr";
$this->log_ipn_results(false);
return false;
} else {
// Post the data back to Paypal
fputs($fp, "POST $url_parsed[path] HTTP/1.1\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");
// loop through the response from the server and append to variable
while(!feof($fp)) {
$this->ipn_response .= fgets($fp, 1024);
}
fclose($fp); // close connection
}
if (eregi("VERIFIED",$this->ipn_response)) {
// Valid IPN transaction.
$to = "my-emailo@gmail.com";
$subject = "VerifyPayment TRUE";
$message = "text";
$from = "zezecamarinha@gajas.come";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
return true;
} else {
$to = "my-email@gmail.com";
$subject = "VerifyPayment FALSE";
$message = "||response:".$this->ipn_response."||errornum:".$err_num."||errorstr:".$err_str."||url_parsed[path]:".$url_parsed[path]."||url_parsed[host]:".$url_parsed[host]."||post_string:".$post_string;
$from = "zezecamarinha@gajas.come";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
// Invalid IPN transaction. Check the log for details.
return false;
}
}
我得到的回复(可能是电子邮件)是:
'||响应:HTTP / 1.0 302找到位置: https://www.sandbox.paypal.com服务器:BigIP连接:关闭 内容长度:0
|| ERRORNUM:0 || errorstr:|| url_parsed [路径]:/ cgi-bin目录|| url_parsed [主持人]:www.sandbox.Paypal.com || post_string:mc_gross = 0.04&安培;发票= 5138d0b85e6b5&安培; protection_eligibility =合格&安培; address_status =确认&安培; payer_id = DM32R376STZLY&安培;税务= 0.00&安培; address_street = 1 +主+ ST&安培; PAYMENT_DATE = 09%3A40%3A14 +月+ 07%2C + 2013 + PST&安培; PAYMENT_STATUS =完成&安培;字符集=窗-1252&放大器; address_zip = 95131&放大器; FIRST_NAME =泽和放大器; mc_fee = 0.04安培; address_country_code = US&放大器; ADDRESS_NAME =泽+ malh%E3o和放大器; notify_version = 3.7&放;定制= 5138d0b85e6b5和放大器; payer_status =验证和放大器;商业= admin_1362650103_biz%40gmail.com和放大器; ADDRESS_COUNTRY =美+美国和放大器; ADDRESS_CITY =圣+何塞&放大器;数量= 1&安培; verify_sign = AALyDIKsAioIkAct58DvtIPZSSJJAoGuIYe.LXHArin2.kTsH2Y.VvW6和放大器; PAYER_EMAIL = zepipo_1362649981_per%40gmail.com和放大器; txn_id = 3064854848985250B和放大器; payment_type =即时和放大器;姓氏= malh%E3o和放大器; ADDRESS_STATE = CA&放; RECEIVER_EMAIL = admin_1362650103_biz%40gmail.com&安培; payment_fee = 0.04&安培; receiver_ ID = 4S4KP74V2695Q和放大器; txn_type = web_accept和放大器; ITEM_NAME = WPMP +订货%23 + 5138d0b85e6b5和放大器; mc_currency = USD和放大器; ITEM_NUMBER = 5138d0b85e6b5和放大器; residence_country = US&放大器;的test_ipn = 1&安培; handling_amount = 0.00和放大器; transaction_subject = 5138d0b85e6b5和放大器; payment_gross = 0.04安培;航运= 0.00&安培; ipn_track_id = 35c2de10de615&安培; CMD = _notify-验证