Note that there are some explanatory texts on larger screens.

plurals
  1. POPayPal sends multiple IPN's
    primarykey
    data
    text
    <p>I have this code, everything works fine. It's just that <a href="http://en.wikipedia.org/wiki/PayPal" rel="nofollow">PayPal</a> keeps resending multiple <a href="http://en.wikipedia.org/wiki/Instant_payment_notification" rel="nofollow">IPNs</a>. I have read the forum of PayPal and they say that PayPal isn't getting a HTTP/1.1 200 OK from me, so it keeps resending the IPN. How would I go about this?</p> <pre><code>function sql_execute($sql){ $sql_connect = @mysql_connect($_SERVER['HTTP_HOST'].':3306','root', '****') or die('Could not connect: ' . mysql_error()); mysql_select_db('4bkk'); mysql_query($sql); $rows = mysql_affected_rows($sql_connect); //mysql_insert_id(); mysql_close(); return $rows; } function sql_query($sql){ // echo $sql; $sql_connect = @mysql_connect($_SERVER['HTTP_HOST'].':3306','****', 'zzz111') or die('Could not connect: ' . mysql_error()); mysql_select_db('4bkk'); $rs = mysql_query($sql) or die(mysql_error()); mysql_close(); return $rs; } function logtrace($o){ $q = "INSERT INTO log (trace, trace_time) VALUES ('$o', NOW() )"; sql_query($q); } function send_email($t,$s,$m,$h){ //mail($t, $s, $m, $h); $fh = fopen('result_ipn_test.txt', 'w'); fwrite($fh, $t.' '.$s.' '.$m.' '.$h); fclose($fh); logtrace('Mail is sent and exit called'); exit(); } logtrace('__________NEW SESSION__________'); $url = 'https://www.sandbox.paypal.com/cgi-bin/webscr'; $postFields = 'cmd=_notify-validate'; foreach($_POST as $key =&gt; $value) { $postFields .= "&amp;$key=".urlencode($value); } $ch = curl_init(); curl_setopt_array($ch, array( CURLOPT_URL =&gt; $url, CURLOPT_RETURNTRANSFER =&gt; true, CURLOPT_SSL_VERIFYPEER =&gt; false, CURLOPT_POST =&gt; true, CURLOPT_POSTFIELDS =&gt; $postFields )); $result = curl_exec($ch); $info = curl_getinfo($ch); logtrace($info['url']); curl_close($ch); //get buyers information from PAYPAL checkout $email = $_POST['payer_email']; $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $amount = $_POST['amount3']; $plan = $_POST['option_selection1']; logtrace($email.' -- '.$active); $q = "SELECT * FROM users WHERE email='$email' AND user_level='' AND active='unverified'"; //Unprocessed record = no user_level and active = 'unverified' $ex = sql_execute($q); //logtrace("THIS ".$q." =&gt; ".$ex); if(sql_execute($q)){ logtrace('IT IS TRUE'); $flag = TRUE; } else{ logtrace('FALSE'); $flag = FALSE; } logtrace($result.' RESPONSE FROM PAYPAL'); if(($result=='VERIFIED') &amp;&amp; $flag){ //Checks first if PayPal is valid, email address exists in //records and checks if user_level='' and active='unverified', //if not enters. logtrace('USER IS READY FOR VERIFICATION'); $q = "SELECT * FROM users WHERE email='$email'"; $data = sql_query($q); $con = mysql_fetch_array($data); //Get buyers information from the database $email2 = $con['email']; $first_name = $con['first_name']; $last_name = $con['last_name']; $active = $con['active']; $user_level = $con['user_level']; logtrace('Emails match'); $u = "UPDATE users SET active='verified', user_level='$plan' WHERE email='$email' LIMIT 1"; if (sql_query($u)) { //Successful verification logtrace('|| Update was sucessful'); } else{ // Unsuccessful verification. logtrace('|| Something went wrong with update.'); } } else{ // The user doesn't have any record in the database. $q = "SELECT * FROM users WHERE email='$email' AND (user_level='Monthly' OR user_level='Quarterly' OR user_level='Yearly')"; if(sql_execute($q)){ // The user is already verified logtrace('THE USER IS ALREADY VERIFIED'); } else{ // The user does not exist. logtrace('THE USER HAS NO RECORD ON DATABASE'); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload