Hi there, I've been having some trouble getting my ipn script to run. I have auto return and data transfer activated, and I have a premier account. The URL to the ipn script is correct, it all works fine on sandbox. I've made it so as soon as the ipn script is read, it inserts a test entry into the database. This is the button I'm trying to use: <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="receiver_email" value='myemail'> <input type="hidden" name="item_name" value="2 Token Donation"> <input type="hidden" name="payer_email" value="<?php echo $email; ?>"> <input type="hidden" name="currency_code" value="GBP"> <input type="hidden" name="amount" value="1.50"> <input type="image" src="https://www.paypal.com/en_US/GB/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online."> <img alt="" border="0" src="https://www.paypal.com/en_GB/i/scr/pixel.gif" width="1" height="1"> </form> And this is my IPN script: <?php //connect to database $server connect stuff // PHP 4.1 read the post from PayPal system and add 'cmd' $req = 'cmd=_notify-validate'; foreach ($_POST as $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&$key=$value"; } // post back to PayPal system to validate $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30); // assign posted variables to local variables $item_name = $_POST['item_name']; $item_number = $_POST['item_number']; $payment_status = $_POST['payment_status']; $payment_amount = $_POST['mc_gross']; $payment_currency = $_POST['mc_currency']; $payment_currency = $_POST['currency_code']; $txn_id = $_POST['txn_id']; $receiver_email = $_POST['business']; $receiver_email = $_POST['receiver_email']; $payer_email = $_POST['payer_email']; if (!$fp) { // HTTP ERROR } else { fputs ($fp, $header . $req); while (!feof($fp)) { $res = fgets ($fp, 1024); if (strcmp ($res, "VERIFIED") == 0) { $queryuser = "SELECT * FROM user WHERE email='$payer_email'"; $resultuser = mysql_query($queryuser) or die(mysql_error()); $rowuser = mysql_fetch_array($resultuser) or die(mysql_error()); $username = $rowuser['username']; $donatehistoryadd = mysql_query("INSERT INTO donatehistory VALUES ('','$username','$payer_email','$payment_currency','$payment_amount','$payment_status')"); if ($payment_status == "Completed") { if ($payment_amount == '1.50') { $update = mysql_query("UPDATE user SET points=points+'2' WHERE email='$payer_email'"); } elseif ($payment_amount == '5.00' && $payment_currency == 'GBP') { $update = mysql_query("UPDATE user SET points=points+'11' WHERE email='$payer_email'"); } elseif ($payment_amount == '10.00' && $payment_currency == 'GBP') { $update = mysql_query("UPDATE user SET points=points+'22' WHERE email='$payer_email'"); } elseif ($payment_amount == '20.00' && $payment_currency == 'GBP') { $update = mysql_query("UPDATE user SET points=points+'45' WHERE email='$payer_email'"); } elseif ($payment_amount == '50.00' && $payment_currency == 'GBP') { $update = mysql_query("UPDATE user SET points=points+'110' WHERE email='$payer_email'"); } } // check the payment_status is Completed // check that txn_id has not been previously processed // check that receiver_email is your Primary PayPal email // check that payment_amount/payment_currency are correct // process payment } else if (strcmp ($res, "INVALID") == 0) { // log for manual investigation } } fclose ($fp); } ?> I'd greatly appreciate any help you folk can offer! 🙂 - Diagon
... View more