PayPal IPN 发布变量 ''txn_id"未设置 [英] PayPal IPN post variable ''txn_id" not being set

查看:81
本文介绍了PayPal IPN 发布变量 ''txn_id"未设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

$txn_id = $_POST['txn_id'];

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

该付款不是订阅付款,而是正常的一次性购买付款.

解决方案

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

我最近无法从 PayPal 接收 POST 数据.但是,IPN.php 仍然有效.您可以在您的 IPN/返回页面上进行一些调试.

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

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

 函数 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);//一切.更改为 E_ALL &~E_NOTICE);删除通知错误报告(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 "

 GET 内容

";打印_r($_GET);echo "</pre>";echo "<pre> POST 内容<br><br>";打印_r($_POST);echo "</pre>";

When an IPN is verified as completed my code puts the txn_id in a database but it is not being set. All other PayPal variables that I am using are set but this one is not. I need a way to uniquely identity the transaction so that's why I am using that variable, here is my code that I use to grab the id:

$txn_id = $_POST['txn_id'];

I checked PayPal's list of variables and txn_id is listed on there but I'm not receiving anything/it's not set.

The payment is not a subscription payment, it's just a normal one time buy payment.

解决方案

How / where are you receiving the data? Shows us your HTML.

I recently had trouble receiving POST data from PayPal. However, the IPN.php still works. You can do some debugging on your IPN/return page.

Add this to your PayPal file to see exactly what you are receiving. If the POST section is empty, that will be your issue and you might need to work with GET data instead.

Option 1) Dump everything received into a file

                    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); 

Option 2) Log all errors to in this directory

                      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');

Option 3) if in success.php or a page you can see

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

这篇关于PayPal IPN 发布变量 &amp;#39;&amp;#39;txn_id&amp;quot;未设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆