IPN on sandbox is always failing. The sandbox requires now ssl connection to correctly validate back IPN
Making an ssl connection in validate_ipn() solved the issue for me (line 162):
//$fp = fsockopen($url_parsed[host],"80",$err_num,$err_str,30);
$fp = fsockopen('ssl://'.$url_parsed[host],"443",$err_num,$err_str,30);
I found the solution here:
stackoverflow.com/questions/8046690
...
I have not yet tested this solution in production environments, I'll post results asap.