Your 'Connection: close' header (which ends with \r\n
) is correctly followed by a blank line (i.e. another \r\n
), being the last header, but so is the previous header ('Content-Length'). So the 'Connection: close' header is being seen as part of the payload. Remove the blank line from the previous header, i.e. change the 2nd-last \r\n\r\n
to \r\n
. In fact I would change them both, and add another print of \r\n
after the last header, so you won't break it like this again.
Paypal IPN will just not work properly
-
03-07-2022 - |
Domanda
This is my code:
// post back to PayPal system to validate
$header .= "POST cgi-bin/webscr HTTP/1.1\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .="Host: www.paypal.com\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$header .="Connection: close\r\n\r\n";
$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
if (!$fp) { // HTTP ERROR
echo 'HTTP ERROR';
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) { $res = fgets ($fp, 2048); }
if (strpos ($res), "VERIFIED") !== false) {
switch ($transaction_type) {
case "subscr_payment":
if ($payment_status == "Completed" &&strtolower($receiver_email) == strtolower($receiverEmail)&&$currency=$payment_currency)
Earlier I had tried entering the trim
statement into this line:
if (strpos ($res, "VERIFIED") !== false)
I changed it to:
if (strcmp (trim($res), 'VERIFIED') == 0)
Soluzione
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow