Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/273998-paypal-ipn-help/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/273998-paypal-ipn-help/#findComment-1410017
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.