Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 942
user3181000 Avatar asked Apr 23 '26 09:04

user3181000


1 Answers

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

like image 117
PayPal_Martin Avatar answered Apr 24 '26 23:04

PayPal_Martin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!