Search code examples
phppaypalpaypal-ipn

Php IPN VERIFIED and strcmp doesn't work anymore


I have a strange problem with VERIFIED string received by PayPal in IPN system. I use php to check the validity of the payment. Up to yesterday at 5 pm all worked fine. But with the last 2 payments, my script can not rescue the "VERIFIED" string anymore. Here you are my script:

[...]
$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
[...]
if (!$fp)
  {[...]
  }
else
  {fputs ($fp, $header . $req);
   while (!feof($fp))
     {$res = fgets ($fp, 1024);
      $ResTotale .= $res;
      if (strcmp ($res, "VERIFIED") == 0)
        {// Payment ok!
         [...]
        }
   [...]
  }

It worked till yesterday, when we received those data from PayPal:

[...]
domain=.paypal.com VERIFIED
[...]

With last two payment, we received this:

[...]
8
VERIFIED
0
[...]

And the script mark this payment as INVALID. I changed the "strcmp" if statement with this:

if ((strcmp ($res, "VERIFIED") == 0) || (strcmp (trim($res), "VERIFIED") == 0) || (trim($res) == "VERIFIED"))

Can anyone tell me if this script will work? Thanks in advance.


Solution

  • Please check Paypal IPN sends back VERIFIED but with numbers before and after

    Furthermore, the evaluation should work by including trim()

    if (strcmp (trim($res), "VERIFIED") == 0)

    See: https://ppmts.custhelp.com/app/answers/detail/a_id/926/kw/http%201.1