【问题标题】:PayPal IPN post variable ''txn_id" not being set未设置 PayPal IPN 发布变量“txn_id”
【发布时间】:2018-02-11 09:28:21
【问题描述】:

当 IPN 被验证为已完成时,我的代码会将 txn_id 放入数据库中,但它没有被设置。我正在使用的所有其他 PayPal 变量均已设置,但此变量未设置。我需要一种唯一标识交易的方法,这就是我使用该变量的原因,这是我用来获取 id 的代码:

$txn_id = $_POST['txn_id'];

我检查了 PayPal 的变量列表,其中列出了 txn_id,但我没有收到任何东西/它没有设置。

付款不是订阅付款,只是普通的一次性购买付款。

【问题讨论】:

    标签: php paypal paypal-ipn


    【解决方案1】:

    您如何/在哪里接收数据?向我们展示您的 HTML。

    我最近在接收来自 PayPal 的 POST 数据时遇到了问题。但是,IPN.php 仍然有效。您可以在您的 IPN/返回页面上进行一些调试。

    将此添加到您的 PayPal 文件中,以准确查看您收到的内容。如果 POST 部分为空,那将是您的问题,您可能需要改用 GET 数据。

    选项 1) 将收到的所有内容转储到文件中

                        function test_file_dump2( $msg ) {
                            $filename = dirname(__FILE__).'-IPN-dump.log';
                            $f = fopen( $filename, 'a' );
                            fwrite( $f, var_export( $msg, true ) . "\n" );
                            fclose( $f );
                        }
                        test_file_dump2($_POST); 
                        test_file_dump2($_GET); 
    

    选项 2) 将所有错误记录到此目录中

                          ini_set('error_reporting', E_ALL); // everything.  Change to E_ALL & ~E_NOTICE); to remove notices
                          error_reporting(E_ALL );
                          ini_set('html_errors',TRUE);
                          ini_set('log_errors', TRUE);
                          ini_set('display_errors',TRUE);
                          ini_set('error_log', dirname(__FILE__) . '/-errors-ipn.log');
    

    选项3)如果在success.php或页面中可以看到

            echo "<pre> GET contents<br><br>"; print_r($_GET); echo "</pre>"; 
            echo "<pre> POST contents<br><br>"; print_r($_POST); echo "</pre>"; 
    

    【讨论】:

      猜你喜欢
      • 2012-02-23
      • 2019-09-12
      • 2015-06-09
      • 2019-05-02
      • 2011-07-21
      • 2012-01-17
      • 2012-06-19
      • 2012-12-05
      • 2011-06-21
      相关资源
      最近更新 更多