user3181000
user3181000

Reputation: 43

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.

Upvotes: 3

Views: 2880

Answers (3)

dolmetscher
dolmetscher

Reputation: 31

I know this is old, but I was having the same problem and the only thing that worked for me was to use if (strpos($res, "VERIFIED") !== 0). Hope it helps.

Upvotes: 0

PayPal_Martin
PayPal_Martin

Reputation: 816

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

Upvotes: 3

user3182607
user3182607

Reputation: 29

I had the same issue and found a really easy work around I changed the function :

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

By

if (strpos($res,'VERIFIED') !== false) {

So anywhere you used strcmp must be changed to strpos.

I hope this will help some of you :)

Mouns

Upvotes: 2

Related Questions