php paypal iPN 奇怪的回调值
我正在尝试使用 paypal iPN 让我网站上的会员使用“立即购买”按钮购买高级会员资格。当我第一次尝试时,它根本不起作用。经过一些更改后,我能够成功收到付款。唯一的问题是本应通过 iPN 进入我的数据库的数据......不知何故不正确。电子邮件地址是正确的,但 txn_id 错误,并且没有插入日期。事务结束时给出的事务 ID 与插入到我的数据库中的事务 ID 不匹配。
此外,即使交易已完成,它仍然会将我发送到 return_cancel url。
表列 - id(自动递增)、txn_id(paypal 交易 ID)、电子邮件(买家)
// assign posted variables to local variables
$txn_id = $_POST['txn_id'];
$payer_email = $_POST['payer_email'];
$user_id = mss($_POST['custom']); //user id
$curdate = date("Y-m-d H:i:s");
if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
$update_prem = mysql_query("UPDATE `users` SET `accountype` = '2' WHERE `users`.`id` ='".$user_id."'");
$log_query=mysql_query("INSERT INTO `log` (`id`, `txn_id`, `date`, `email`) VALUES ('','".$txn_id."', '".$curdate."','1".$payer_email."')");
}
else if (strcmp ($res, "INVALID") == 0) {
// log for manual investigation
$log_query=mysql_query("INSERT INTO `pplog` (`lid`, `txn_id`, `date`, `email`) VALUES ('','".$txn_id."', '".$curdate."','000".$payer_email."')");
}
}
fclose ($fp);
}
也在代码中显示“1”.$payer_email.“”和“000”.$payer_email.“”,我使用让我知道记录的值是有效还是无效日志。前几次,它被记录了两次,然后我明白了为什么这样做,但现在它记录了一次,但只是'“.$payer_email。”'???
我现在解决了电子邮件问题。唯一剩下的问题是为什么当交易完成时paypal返回INVALID?是因为它是贝宝沙盒吗?
有谁知道这可能是什么原因,或者有人自己遇到过这个问题吗?
I am trying to use paypal ipn to have members on my site buy a premium membership using the buy now button. When I first tried it it didn't work at all. After some changes I was able to successfully receive payments. The only problem was the data that was suppose to go into my database through the ipn was... somehow not right. The email address was right, but the txn_id was wrong, and no date was inserted. The transaction id given at the end of a transaction does not match the one inserted into my database.
Also even though a transaction is complete, it still sends me to the return_cancel url.
Table columns- id(auto incremented), txn_id (paypal transaction ID), email (of buyer)
// assign posted variables to local variables
$txn_id = $_POST['txn_id'];
$payer_email = $_POST['payer_email'];
$user_id = mss($_POST['custom']); //user id
$curdate = date("Y-m-d H:i:s");
if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
$update_prem = mysql_query("UPDATE `users` SET `accountype` = '2' WHERE `users`.`id` ='".$user_id."'");
$log_query=mysql_query("INSERT INTO `log` (`id`, `txn_id`, `date`, `email`) VALUES ('','".$txn_id."', '".$curdate."','1".$payer_email."')");
}
else if (strcmp ($res, "INVALID") == 0) {
// log for manual investigation
$log_query=mysql_query("INSERT INTO `pplog` (`lid`, `txn_id`, `date`, `email`) VALUES ('','".$txn_id."', '".$curdate."','000".$payer_email."')");
}
}
fclose ($fp);
}
Also in the code where it says '1".$payer_email."' and '000".$payer_email."', I used to let me know if the logged value was a VALID or INVALID log. The first few times, it was logged twice, then I figured out why it did that, but now it logges it once but just '".$payer_email."'???
I got the email problem working now. the only thing left is why does paypal return INVALID when the transaction was complete? Is it because its a paypal sandbox thing?
Does anyone know what could be the cause of this, or has anyone had this problem themselves??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
或者,互联网上有一些 PHP Paypal IPN 集成类,您尝试过其中的任何一个吗?我已经链接了其中两个,看看是否有帮助。
http://www.micahcarrick.com/php-paypal-ipn-integration -class.html
http://www.geniegate.com/other/paypal/
我希望这有帮助。
Alternatively there are a few PHP Paypal IPN Integration Class available on internet, have you tried any of those? I have linked 2 of them, see if that helps.
http://www.micahcarrick.com/php-paypal-ipn-integration-class.html
http://www.geniegate.com/other/paypal/
I hope this helps.