Deepzone Posted February 4, 2013 Share Posted February 4, 2013 I use the following IPN code from Paypal to trigger my database update. if (!$fp) { // HTTP ERROR } else { fputs ($fp, $header . $req); while (!feof($fp)) { $res = fgets ($fp, 1024); // $res=stream_get_contents($fp, 1024); $res = trim($res); if (strcmp($res, "VERIFIED") == 0) { if ($payment_status === 'Completed') { $txn_id_check = mysql_query("SELECT txn_id FROM log WHERE txn_id = '".$txn_id."'"); if (mysql_num_rows($txn_id_check) != 1) { if ($receiver_email=='seller_999@me.com') { if ($payment_amount == '0.09' && $payment_currency == 'CAD') { // add txn to database $log_query = mysql_query("INSERT INTO log (txn_id, email) VALUES ('".$txn_id."', '".$payer_email."')"); // update premium to 1 $update_premium = mysql_query("UPDATE users SET premium = 1 WHERE user_id = '".$user_id."' "); } } } } } else if (strcmp ($res, "INVALID") == 0) { // log for manual investigation } } fclose ($fp); } The updating has never kicked in. I tried to debug it and found it has been blocked at if (strcmp($res, "VERIFIED") == 0) . From other post of this forum I learned to trace the IPN return script and found $res doesn't exist. Does anyone know how to fix it? Quote Link to comment https://forums.phpfreaks.com/topic/273998-paypal-ipn-help/ Share on other sites More sharing options...
Christian F. Posted February 4, 2013 Share Posted February 4, 2013 What, specifically, do you mean with "$res doesn't exist"? Also, have you checked your error logs for errors/warnings that this snippet may be producing? I don't see any error handling in here, so it's quite possible that it silently fails at numerous points. Checking the error logs, or turning on error reporting, should give you some pointers. Quote Link to comment https://forums.phpfreaks.com/topic/273998-paypal-ipn-help/#findComment-1410017 Share on other sites More sharing options...
Deepzone Posted February 5, 2013 Author Share Posted February 5, 2013 Thanks for reply. I ran this chunk of code and database update didn't occur until I commented out if (strcmp($res, "VERIFIED") == 0). And I trace the output return from Paypal but don't see anything like $res. Quote Link to comment https://forums.phpfreaks.com/topic/273998-paypal-ipn-help/#findComment-1410320 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.