There are a lot of questions in stackoverflow similar to this topic and I have tried everyone of them, but to no avail. It might be my server configuration or something, so posting if anyone has any clue.
This is my code:-
$this->gateway['submit_url'] = 'https://www.paypal.com/cgi-bin/webscr';
$this->gateway['callback_url'] = 'ssl://ipnpb.paypal.com:443';
//headers
$header = "POST /cgi-bin/webscr HTTP/1.1\r\n";
$header .= "Host www.ipnpb.paypal.com\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: ".strlen($req)."\r\n\r\n";
$fp= fsockopen($this->gateway['callback_url'], 443, $error_no, $error_msg, 60);
$req is defined above somewhere in the code.
Here fp returns null. My OpenSSL version is: OpenSSL 1.0.1i 6 Aug 2014
I have windows IIS server
Can you try removing port number :443
from $this->gateway['callback_url']
?
$this->gateway['callback_url'] = 'ssl://ipnpb.paypal.com';
Port 443
is already passed in fsockopen
function call.
$fp= fsockopen($this->gateway['callback_url'], 443, $error_no, $error_msg, 60);
Edit: ( Editing answer as new lines are now allowed in comments )
Is there anything else around this part of this code?
Same code wrapped in a class with 3 changes suggested above is working for me. ( returns a resource of type stream )
<?php
class abc {
public $gateway;
public function __construct() {
$req = 'ABCD';
$this->gateway['submit_url'] = 'https://www.paypal.com/cgi-bin/webscr';
$this->gateway['callback_url'] = 'ssl://ipnpb.paypal.com';
//headers
$header = "POST /cgi-bin/webscr HTTP/1.1\r\n";
$header .= "Host www.ipnpb.paypal.com\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: ".strlen($req)."\r\n\r\n";
$fp= fsockopen($this->gateway['callback_url'], 443, $error_no, $error_msg, 60);
var_dump($fp);
}
}
$a = new abc();