我正在使用Sandpal版本的Paypal,在每次交易中,我都会得到相同的HTTP响应代码200作为输出。
mc_gross=4.99&protection_eligibility=Eligible&address_status=confirmed&payer_id=89DUDR3H8QUZ6&tax=0.00&address_street=1 Maire-Victorin&payment_date=23:57:24 Sep 11, 2015 PDT&payment_status=Completed&charset=windows-1252&address_zip=M5A 1E1&first_name=test&mc_fee=0.44&address_country_code=CA&address_name=test buyer¬ify_version=3.8&custom=&payer_status=verified&business=billing-facilitator@REMOVED.REOMVED&address_country=Canada&address_city=Toronto&quantity=1&verify_sign=AtzgbXK1X.9xdTmY4kIxKn.3Mc4LA0AZU0o3yoMH-W9PB0pDU-ial8ml&payer_email=billing-buyer@ctstudios.ca&txn_id=91220841NA400993W&payment_type=instant&last_name=buyer&address_state=Ontario&receiver_email=billing-facilitator@ctstudios.ca&payment_fee=&receiver_id=2EEUCVJ5AHKJS&txn_type=web_accept&item_name=Bronze Package&mc_currency=CAD&item_number=WP01&residence_country=CA&test_ipn=1&handling_amount=0.00&transaction_subject=&payment_gross=&shipping=0.00&ipn_track_id=cfe9b900ce627
当它重定向到页面时,它会回显
The response from IPN was: INVALID
这是检查标题的代码。
if ($_GET['page'] == "order_completed") {
$raw_post_data = file_get_contents('php://input');
$raw_post_array = explode('&', $raw_post_data);
$myPost = array();
foreach ($raw_post_array as $keyval) {
$keyval = explode ('=', $keyval);
if (count($keyval) == 2)
$myPost[$keyval[0]] = urldecode($keyval[1]);
}
$req = 'cmd=_notify-validate';
if(function_exists('get_magic_quotes_gpc')) {
$get_magic_quotes_exists = true;
}
foreach ($myPost as $key => $value) {
if($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) {
$value = urlencode(stripslashes($value));
} else {
$value = urlencode($value);
}
$req .= "&$key=$value";
}
$ch = curl_init('https://www.sandbox.paypal.com/cgi-bin/webscr');
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));
curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem');
if( !($res = curl_exec($ch)) ) {
curl_close($ch);
exit;
}
if (strcmp ($res, "VERIFIED") == 0) {
$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'];
foreach($_POST as $key => $value) {
echo $key." = ". $value."<br>";
}
} else if (strcmp ($res, "INVALID") == 0) {
echo "The response from IPN was: <b>" .$res ."</b>";
}
curl_close($ch);
}
我的问题是,为什么我会收到响应代码200,但它说响应是无效的?