Php IPN VERIFIED 和 strcmp 不再工作



我在 IPN 系统中PayPal收到的 VERIFIED 字符串有一个奇怪的问题。我使用php来检查付款的有效性。直到昨天下午5点都很好。但是对于最后 2 次付款,我的脚本无法再拯救"已验证"字符串。这里是我的脚本:

[...]
$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!
         [...]
        }
   [...]
  }

它一直工作到昨天,当我们从PayPal那里收到这些数据时:

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

通过最后两次付款,我们收到了这个:

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

并且脚本将此付款标记为无效。我用这个更改了"strcmp"if语句:

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

谁能告诉我这个脚本是否有效?提前谢谢。

请检查 IPN 发回PayPal已验证但前后有数字

此外,评估应该通过包含 trim() 来工作

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

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

我遇到了同样的问题,并找到了一个非常简单的解决方法,我更改了函数:

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

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

因此,无论您使用strcmp的任何地方都必须更改为strpos。

我希望这对你们中的一些人有所帮助:)

土坟

我知道

这很旧,但我遇到了同样的问题,唯一对我有用的就是使用 if (strpos($res, "VERIFIED") !== 0) .希望对您有所帮助。

最新更新