简体   繁体   English

PayPal IPN未插入数据库

[英]PayPal IPN not inserting into database

I tested a paypal donation button on localhost and it inserts the payment amount into the mysql database (verified on phpmyadmin) with the first time. 我在localhost上测试了一个paypal捐赠按钮,并在第一次将付款金额插入mysql数据库(在phpmyadmin中验证)。 but after that it just stops working 但是之后就停止工作

Is there anything below that could prevent it from working? 有什么下面的东西可能会阻止它工作?

config.php config.php文件

<?php

require "paypal_integration_class/paypal.class.php";
require "config.php";
require "connect.php";

$p = new paypal_class;
$p->paypal_url = $payPalURL;

if ($p->validate_ipn()) {
    if($p->ipn_data['payment_status']=='Completed')
    {
        $amount = $p->ipn_data['mc_gross'] - $p->ipn_data['mc_fee'];

        mysql_query("   INSERT INTO dc_donations (transaction_id,donor_email,amount,original_request)
                        VALUES (
                            '".esc($p->ipn_data['txn_id'])."',
                            '".esc($p->ipn_data['payer_email'])."',
                            ".(float)$amount.",
                            '".esc(http_build_query($_POST))."'
                        )");
    }
}

function esc($str)
{
    global $link;
    return mysql_real_escape_string($str,$link);
}
?>

donation button 捐赠按钮

<!-- The PayPal Donation Button -->



<form action="<?php echo $payPalURL?>" method="post" class="payPalForm">
<div>
    <input type="hidden" name="cmd" value="_donations" />
    <input type="hidden" name="item_name" value="Donation" />

    <!-- Your PayPal email: -->
    <input type="hidden" name="business" value="<?php echo $myPayPalEmail?>" />

    <!-- PayPal will send an IPN notification to this URL: -->
    <input type="hidden" name="notify_url" value="<?php echo $url.'/ipn.php'?>" /> 

    <!-- The return page to which the user is navigated after the donations is complete: -->
    <input type="hidden" name="return" value="<?php echo $url.'/thankyou.php'?>" /> 

    <!-- Signifies that the transaction data will be passed to the return page by POST -->
    <input type="hidden" name="rm" value="2" /> 


    <!--    General configuration variables for the paypal landing page. Consult 
            http://www.paypal.com/IntegrationCenter/ic_std-variable-ref-donate.html for more info  -->

    <input type="hidden" name="no_note" value="1" />
    <input type="hidden" name="cbt" value="Go Back To The Site" />
    <input type="hidden" name="no_shipping" value="1" />
    <input type="hidden" name="lc" value="US" />
    <input type="hidden" name="currency_code" value="USD" />




    <input type="double" name="amount">

    <input type="hidden" name="bn" value="PP-DonationsBF:btn_donate_LG.gif:NonHostedGuest" />

    <!-- You can change the image of the button: -->
    <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif" name="submit" alt="PayPal - The safer, easier way to pay online!" />

  <img alt="" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" />
</div>
</form>

The first thing I notice is that you're only running the DB update if the payment has a status of completed. 我注意到的第一件事是,如果付款状态为已完成,则仅在运行数据库更新。 It's possible your payments are pending and in those cases that code would be skipped, of course. 您的付款可能有待处理,在某些情况下,当然会跳过代码。

How exactly did you test locally? 您如何在本地测试? Did you use the IPN simulator or did you run an actual sandbox transaction so the system would trigger just like a real order? 您是使用IPN模拟器还是运行实际的沙箱交易,以便系统像真实订单一样触发? What is the actual value of your notify_url after the PHP is processed? 处理完PHP后,notify_url的实际值是多少? You're using $url, but what is the value of that? 您正在使用$ url,但是它的价值是什么? If it's "localhost" it won't work. 如果它是“ localhost”,它将无法工作。

Have you checked the PayPal IPN History to see if it shows the IPN's are getting sent and might be getting an error result? 您是否检查过PayPal IPN历史记录以查看是否显示IPN正在发送并且可能会收到错误结果? Have you checked your web server logs to see if that script is getting hit? 您是否检查过Web服务器日志以查看该脚本是否受到攻击?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM