0
我就简单的购物车的工作,一个问题是推动我疯了IPN监听器不工作IPN监听贝宝
当我付款我重定向回到感谢页面和打印这些值出。
thankyou.php
下面的这些帖子打印出来,还有很多帖子变量。
[address_status] => confirmed
[payment_status] => Completed
[payer_status] => verified
问题是我的IPN监听器不工作。
<input type="hidden" name="notify_url" value="http://mysqlphp.uphero.com/paypal_ipn.php">
这是我的paypal_ipn.php下面的脚本了下来:
// Check to see there are posted variables coming into the script
if ($_SERVER['REQUEST_METHOD'] != "POST")
die ("No Post Variables"); ------>
// Initialize the $req variable and add CMD key value pair
$req = 'cmd=_notify-validate';
// Read the post from PayPal
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
$url = "https://www.sandbox.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, 30);
$curl_result = @curl_exec($ch);
$curl_err = curl_error($ch);
curl_close($ch);
$req = str_replace("&", "\n", $req);
// Check that the result verifies and sending email before doing anything i just wanted to make sure that this script is working but i don't receive an email
if (strpos($curl_result, "VERIFIED") !== false) {
$req .= "\n\nPaypal Verified OK";
mail("[email protected]mail.com", "IPN interaction verified", "$req", "[email protected]");
}
当你说“不工作”时,你可以告诉脚本是否被调用过,或者脚本本身存在问题吗?您是否在服务器错误日志中看到任何错误? – 2013-02-21 16:12:42
(这不是一个答案,顺便说一句,只是一个评论)贝宝可以混淆,他们的文档是一团糟!我即将与IPN合作,如果我学到了任何东西,我会回来查看你的问题。就目前而言,我不了解有关诊断问题的过程。 – 2013-02-21 16:31:05
好的,谢谢兄弟,我真的很感激,如果我找到我会回复给你的东西..再次感谢你 – 2013-02-21 16:52:47