What is causing my PayPal IPN script to fail?

此生再无相见时 提交于 2019-12-04 10:02:41

Have you tried the IPN test tool to investigate the problem?

You can use it to reproduce the form you're submitting and see if you get consistent results.

You might get better answers if you specify exactly in which context it is failing.

Dominik Späte

Anyone using the PHP Paypal IPN Integration Class by Micah Carrick and having the same problem: The IPN variables and values have to be preceded with cmd=_notify-validate. In the paypal.class.php file it's just the opposite.

So, just replace $post_string = ''; in line 179 by
$post_string="cmd=_notify-validate";
replace
$post_string .= $field.'='.urlencode(stripslashes($value)).'&';

in line 181 by $post_string .= '&' . $field.'='.urlencode(stripslashes($value));

then delete $post_string.="cmd=_notify-validate"; in line 184 and your problem should be solved.

Nono

For connect to sandbox Paypal use this line :

$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30); 

and not : $fp = fsockopen($url_parsed['host'],"80",$err_num,$err_str,30);

and the response IPN send the word "VERIFIED"

If you're testing Paypal IPN over SSL, you will have to use ssl://www.sandbox.paypal.com on the port 443

@ Dominik , that seems to fix my problems too ! I happened to be using Md Emran Hasan's PHP class. And done tearing my hair out for about a week with this issue!

So my edit looked like this... where $postString .="cmd=_notify-validate"; // used to be after the while loop! This code was wrapped in a validateIPN function.

    $postString .= "cmd=_notify-validate"; // append ipn command

    foreach ($_POST as $field=>$value)
    {
        $this->ipnData["$field"] = $value;
        $postString .= '&' . $field .'=' . urlencode(stripslashes($value));
    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!