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