【问题标题】:paypal IPN suddenly failed (no HTTP response)paypal IPN 突然失败(没有 HTTP 响应)
【发布时间】:2017-03-14 11:58:11
【问题描述】:

我的 paypal IPN 脚本突然不再工作了。 在贝宝 IPN 历史记录中,IPN 现在失败了,HTTP 响应代码保持为空。什么可能导致这种情况以及如何解决? 我没有更改任何代码,它只是停止工作。

这是我的 php 代码:

<?php
   //Change these with your information
$paypalmode = ''; //Sandbox for testing or empty ''
$dbusername     = 'xxx'; //db username
$dbpassword     = 'xxx'; //db password
$dbhost     = 'xxx.com'; //db host
$dbname     = 'xxx'; //db name

if($_POST)
{
    if($paypalmode=='sandbox')
    {
        $paypalmode     =   '.sandbox';
    }
    $req = 'cmd=' . urlencode('_notify-validate');
    foreach ($_POST as $key => $value) {
        $value = urlencode(stripslashes($value));
        $req .= "&$key=$value";
    }
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'https://www'.$paypalmode.'.paypal.com/cgi-bin/webscr');
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host: www'.$paypalmode.'.sandbox.paypal.com'));
    $res = curl_exec($ch);
    curl_close($ch);

    if (strcmp ($res, "VERIFIED") == 0)
    {
        $transaction_id = $_POST['txn_id'];
        $ebaytxnid = $_POST['ebay_txn_id1'];
        $payerid = $_POST['payer_id'];
        $firstname = $_POST['first_name'];
        $lastname = $_POST['last_name'];
        $ebayname = $_POST['auction_buyer_id'];
        $email = $_POST['payer_email'];
        $shippingname = $_POST['address_name'];
        $shippingstreet = $_POST['address_street'];
        $shippingcity = $_POST['address_city'];
        $shippingstate = $_POST['address_state'];
        $shippingzip = $_POST['address_zip'];
        $shippingcountry = $_POST['address_country'];
        $shippingcountrycode = $_POST['address_country_code'];
        $currency = $_POST['mc_currency'];
        $paymentfee = $_POST['payment_fee'];
        $total = $_POST['payment_gross'];
        $mcfee = $_POST['mc_fee'];
        $mcgross = $_POST['mc_gross'];
        $ebayitemno = $_POST['item_number'];
        $ebayitemname = $_POST['item_name'];
        $quantity = $_POST['quantity1'];
        $paymentdate = $_POST['payment_date'];
        $mdate= date('Y-m-d h:i:s',strtotime($paymentdate));
        $paymentstatus = $_POST['payment_status'];
        $payerstatus = $_POST['payer_status'];
        $paymenttype = $_POST['payment_type'];
        $addressstatus = $_POST['address_status'];
        $forauction = $_POST['for_auction'];
        $protectioneligibility = $_POST['protection_eligibility'];
        $otherstuff = json_encode($_POST);

        $conn = mysql_connect($dbhost,$dbusername,$dbpassword);
        if (!$conn)
        {
         die('Could not connect: ' . mysql_error());
        }

        mysql_select_db($dbname, $conn);

        // insert in our IPN record table
        $query = "INSERT INTO ibn_table
        (itransaction_id,iebaytxnid,ipayerid,ifirstname,ilastname,iebayname,iemail,ishippingname,ishippingstreet,ishippingcity,ishippingstate,ishippingzip,ishippingcountry,ishippingcountrycode,icurrency,ipaymentfee,itotal,imcfee,imcgross,iebayitemno,iebayitemname,iquantity,itransaction_date,ipaymentstatus,ipayerstatus,ipaymenttype,iaddressstatus,iforauction,iprotectioneligibility,ieverything_else)
        VALUES
        ('$transaction_id','$ebaytxnid','$payerid','$firstname','$lastname','$ebayname','$email','$shippingname','$shippingstreet','$shippingcity','$shippingstate','$shippingzip','$shippingcountry','$shippingcountrycode','$currency','$paymentfee','$total','$mcfee','$mcgross','$ebayitemno','$ebayitemname','$quantity','$mdate','$paymentstatus','$payerstatus','$paymenttype','$addressstatus','$forauction','$protectioneligibility','$otherstuff')";

        if(!mysql_query($query))
        {
            //mysql error..!
        }
        mysql_close($conn);

    }
}
?>

【问题讨论】:

  • 请阅读为什么你不应该再使用 MySQL_* 函数stackoverflow.com/q/12859942/3664960
  • 也许某处有人更新了安全标准(尤其是在使用支付选项时),导致旧代码容易被杀死......
  • 我尝试搜索更新的安全标准,但没有找到任何东西。
  • 我遇到了同样的问题@DannyNetten。
  • 即使对 mysql DB 脚本进行简单的发布,也无法正常工作。 http 标头测试显示正确的响应“HTTP/1.1 200 OK”,但在贝宝中它一直失败。我的主机是godaddy 豪华Linux 主机,也许问题出在godaddy 主机上?你的主机@Stoud 是什么?

标签: php paypal paypal-ipn paypal-sandbox


【解决方案1】:

更新: 2017 年 3 月 15 日上午 11:47 PDT 突然再次工作

我在 Godaddy 上的几个托管帐户也遇到了问题。截至 2017 年 3 月 13 日,后端在太平洋夏令时间上午 10 点至 12 点左右停止从 Paypal 接收 IPN。

对不起,如果事情没有意义,我是一个自学成才的白痴。 我尝试过的事情: 删除 SSL 证书 添加 SSL 证书 手动检查 ipn url (Works) 将paypal ip列入白名单 将所有内容重命名为 https 将所有内容重命名为 http 四重检查以确保:IPN 未被禁用且 IPN url 正确

我发现的有趣的事情: 在所有托管帐户上,一切都运行良好 3 年。 Paypal 沙盒帐户发回 IPN 的一切正常。 在事务的 IPN 历史记录中,没有 HTTP 状态代码。 paypal根本没有IPN访问权限,我这边没有错误或访问日志。 问题是跨多个托管帐户,上个月只有一个帐户发生了变化。

让我知道您的想法和内容,希望 Paypal 可以回应或修复它,因为现在所有迹象都指向它们。厌倦了他们的复制粘贴回复。

【讨论】:

  • 我已经联系了 godaddy 和 paypal 的技术支持。 godaddy 运行所有检查并确认没有任何东西阻止 IPN 或其服务器。 Paypal 正在调查并收到更多关于相同问题的报告。到目前为止一切正常,我收到了我的旧 IPN
  • 从贝宝收到以下回复:GoDaddy 客户遇到了这个问题。他们是他们的安全障碍。我们联系了 GoDaddy,他们将我们的 IP 列入白名单。
猜你喜欢
  • 2016-04-04
  • 2012-04-09
  • 2014-07-31
  • 2011-04-25
  • 2016-11-16
  • 2017-08-05
  • 2021-06-21
  • 2012-08-14
  • 2016-08-17
相关资源
最近更新 更多