1

My paypal IPN script suddenly does not works anymore. in paypal IPN history the IPN's are failing now and the HTTP response code stays empty. what could be causing this and how to fix it? I have not changed any code, it just stopped working.

here is my php code:

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

    }
}
?>

davejal
  • 6,009
  • 10
  • 39
  • 82
  • Please read why you shouldn't be using MySQL_* functions anymore http://stackoverflow.com/q/12859942/3664960 – davejal Mar 14 '17 at 12:07
  • Maybe somewhere someone updated the security standards (especially when using payments options), resulting in old code that is vulnerable to be killed.... – davejal Mar 14 '17 at 12:09
  • i tried searching for updated security standard but did not find anything. – Danny Netten Mar 14 '17 at 13:16
  • I've been having the same problem @DannyNetten. – Stoud Mar 14 '17 at 20:40
  • even with a simple post to mysql DB script it wont work. http header test shows a correct response "HTTP/1.1 200 OK" but in paypal it keeps failing. my host is godaddy deluxe linux hosting, maybe the problem is in the godaddy host? what is your hosting @Stoud ? – Danny Netten Mar 14 '17 at 21:22
  • @DannyNetten I'm using godaddy as well. – Stoud Mar 14 '17 at 21:23
  • is your domain HTTPS enabled? – Martin Mar 15 '17 at 18:52
  • As of now it works again, i do not use HTTPS on my IPN url, only to validate to paypal i use HTTPS – Danny Netten Mar 15 '17 at 23:12

1 Answers1

0

UPDATE: Working again all of a sudden as of 11:47am PDT March 15, 2017

I'm having issues as well with several hosting accounts on Godaddy. Back end stopped receiving IPN from Paypal around 10-12 am PDT as of the 13th of March, 2017.

Sorry if things don't make sense, I'm a self taught idiot. Things I've tried: Deleting SSL certificates Adding SSL certificates Checking ipn url manually (Works) whitelisting paypal ip Renaming everything to https renaming everything to http Quadruple checked to make sure: IPN not disabled and IPN url is correct

Interesting things I found: Everything was working fine for 3 years on all hosting accounts. Paypal Sandbox Account sends back IPN's perfectly fine everything works. In IPN history in transactions, there is no HTTP status code. There is no IPN access by paypal at all, no error or access logs on my end. Problem is across multiple hosting accounts only one has had changed in last month.

Let me know your thoughts and stuff, hopefully Paypal can respond or fix it because all signs point to them right now. Tired of copy paste responses from them.

  • i have had contact with technical support from both godaddy and paypal. godaddy run all the checks and confirmed nothing was blocking the IPN or their servers. Paypal was investigating and had more reports with the same problem. as of now everything works again and i receive my old IPN's – Danny Netten Mar 15 '17 at 23:10
  • Got the following response from paypal: GoDaddy customers faced this issue. Their was a security block on their end. We contacted GoDaddy, and they white listed our IPs. – Danny Netten Mar 16 '17 at 10:12