--- eshop-paypal.class.php Wed Jun 06 13:11:32 2012 +++ fix.php Wed Jun 06 13:12:27 2012 @@ -196,17 +196,30 @@ } $post_string.="cmd=_notify-validate"; // append ipn command - // open the connection to paypal was: - //$fp = fsockopen($url_parsed[host],"80",$err_num,$err_str,30); - //try uncommenting that line if the following doesn't work. - $fp = fsockopen ('ssl://'.$url_parsed[host], "443", $err_no, $err_str, 30); - if(!$fp) { - // could not open the connection. If loggin is on, the error message - // will be in the log. - $this->last_error = "fsockopen error no. $errnum: $errstr"; - $this->log_ipn_results(false); - return false; - + $ipnhost= $url_parsed['host']; + $ipnport= 80; + + if (function_exists('stream_get_transports')) { + $transports= stream_get_transports(); + if (in_array('ssl', $transports)) { + $ipnport= 443; + } + } + + if ($ipnport == 443) { + $ipnhost= "ssl://$ipnhost"; + } + + $fp = fsockopen($ipnhost, $ipnport, $err_no, $err_str, 30); + + if(!$fp) { + // could not open the connection. If loggin is on, the error message + // will be in the log. // TYPO FIXES: + $this->last_error = "fsockopen error no. $err_no: $err_str"; + $this->last_error .= "\n host= $ipnhost, port= $ipnport"; + $this->log_ipn_results(false); + return false; + } else { // Post the data back to paypal @@ -236,6 +249,7 @@ // Invalid IPN transaction. Check the log for details. $this->last_error = 'IPN Validation Failed.'; + $this->last_error .= "\n host= $ipnhost, port= $ipnport"; $this->log_ipn_results(false); return false;