0

我正在使用 Paypal IPN

我编写了一个脚本,在与模拟器一起使用时可以很好地与 Web Accept 事务类型一起使用。我取回变量并处理它们等但是当我将事务类型切换为快速结帐时,它停止工作。谁能帮我弄清楚为什么?

我的代码是 PHP

4

1 回答 1

0

这个问题有点老了,但万一其他人在这个页面上遇到同样的问题......如果你使用的是来自官方 PayPal 开发者网站的 IPN 监听器代码,你可能仍然有一些代码需要特定的形式POST 项目,这就是问题所在。IPN 模拟器的 Express Checkout 消息中不存在这些项目。这是有问题的代码:

   // assign posted variables to local variables
   $item_name = $_POST['item_name'];
   $item_number = $_POST['item_number'];

Express Checkout 表单帖子不会有 item_name 和 item_number,但会有 item_name1 和 item_number1。因此,一个好的解决方案是在该部分中删除所有那些指定表单字段名称的代码行,而是遍历所有表单字段。在循环中,如果需要,您可以测试预期项目的存在。或者,如果您只想对完整的表单项做一些事情,您可以这样做,如下所示:

    foreach($_POST as $key => $value) {
       $strOutput .= $key . " = " . $value . "|";
    }

仅供参考...有问题的代码在这里找到: https ://developer.paypal.com/docs/classic/ipn/ht_ipn/ ...在这里: https ://gist.github.com/xcommerce-gists/3440401 #file-completelistener-php

于 2013-11-25T04:07:21.090 回答