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

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

问题描述

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

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

我检查了PayPal的变量列表,并且在那里列出了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.

推荐答案

如何/在何处接收数据?向我们显示您的HTML.

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

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

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.

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

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.

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

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

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

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

选项3)如果显示成功.php或页面,您可以看到

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发布变量"txn_id";没有设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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