PHP - Paypal Ipn Help Needed Urgently
I have set up my PayPal IPN and it works perfectly when sending test IPN's using the IPN Simulator on the PayPal developer website.
When I change the ssl in this line Code: [Select] $fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);to Code: [Select] www.paypal.com It no longer works. It comes back as INVALID, not VERIFIED. Anyone know what the problem could be? My IPN is below. You'll see there is entries into the log table, this is just for testing purposes, and how I found out that it's coming back as INVALID and not VERIFIED. Thanks Denno <?php //connect to the database here include "../scripts/connect_to_mysql.php"; //------------------------------- // 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 $team_name = $_POST['item_name']; $item_number = $_POST['item_number']; $payment_status = $_POST['payment_status']; $payment_amount = $_POST['mc_gross']; $payment_currency = $_POST['mc_currency']; $txn_id = $_POST['txn_id']; $receiver_email = $_POST['receiver_email']; $payer_email = $_POST['payer_email']; $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $associated_club = $_POST['custom']; $contact_number = $_POST['invoice']; if (!$fp) { // HTTP ERROR } else { fputs ($fp, $header . $req); while (!feof($fp)) { $res = fgets ($fp, 1024); if (strcmp ($res, "VERIFIED") == 0) { //User code is added below here $dateField=date("Y-m-d H:i:s"); $sqlCommand = "INSERT INTO log VALUES('','$dateField','$payment_status','$payment_amount','$payment_currency','1','0')"; $update = mysql_query($sqlCommand, $myConnection); if($payment_status == "Completed"){ if($payment_amount == '40.00' && $payment_currency == "AUD"){ //process payment and enter information into database $sqlCommand = "INSERT INTO teams VALUES ('','$first_name','$last_name','$associated_club','$team_name','$contact_number','1')"; $update = mysql_query($sqlCommand, $myConnection); } } //User code is added above here } else if (strcmp ($res, "INVALID") == 0) { // log for manual investigation $dateField=date("Y-m-d H:i:s"); $sqlCommand = "INSERT INTO log VALUES('','$dateField','$payment_status','$payment_amount','$payment_currency','0','1')"; $update = mysql_query($sqlCommand, $myConnection); } } fclose ($fp); } echo "$sqlCommand"; ?> Similar TutorialsI have purchased a ad manager type script and have put so much work in to the site but i cannot get the cron file to execute properly due to errors. The makers of the script arent answering my emails so I am left to find the answer myself im hoping some experts can shine a light on this for me
I have the cron running once daily as required
the error messages are as follows:
/home2/net2you/public_html/2xx.co.uk/include/CronStats.php: line 1: ?php: No such file or directory /home2/net2you/public_html/2xx.co.uk/include/CronStats.php: line 2: syntax error near unexpected token `;' /home2/net2you/public_html/2xx.co.uk/include/CronStats.php: line 2: `ob_start();' I have installed the script on two different hosts and get the exact same errors. any help would be much appriciated the contents of the cron file are below ______________________________________________ <?php I want to implement PayPal in my website. I'll be using ExpressCheckout method. I know there are following steps: 1. Cart page on a website 1a. Provide custom IPN URL in PayPal form (notify_url). 2. Redirect to PayPal payment page. 3a. On success redirect to my "payment confirmation" page. 3b. On false redirect to payment cancelled page. 4. Enable IPN in PayPal account. 5. Prepare payment handler page. PayPal response will be sent to this page. Everything above has been tested and it's working perfectly. Anyway, I have few questions. I need to log transactions in database 'transactions' table. So..on checkout page, I insert a row with user data, date. Now I'm wondering about one small thing. What about transaction ID? I was never implementing PayPal before, more I'm reading, I'm know less I'm testing payments in sandbox. When payment is done, it returns to provided URL with following $_GET data: ?token=EC-8JP09047FK347153S&PayerID=C9UCCD3968V52. But when I test IPN in my sandbox it return a field called txn_id. Now time for my questions: 1. Is this the same as token? 2. How transactions are usually logged in into database? What is used as 'key' when 3. Is it possible to define token and payer_id before redirecting user to PayPal checkout? 4. When checking transaction on IPN response handler, is txn_id the most important transaction field? My biggest issue is to handle IPN response. How could I know transaction ID when I do not have any key to compare? Any help will be appreciated. Hi Guys, I am a bit of a PHP noob and I am hoping for a bit of help. My deadline to have this working is tomorrow. Basically I want to display a table which shows all the events I have signed upto. However, my code is creating windows within itself and separate tables which are all over the place. Here is my code: <?php session_start(); $email = $_SESSION['email']; include '../dbconn.php'; include '../includes/functions2.php'; $query2 = "SELECT * FROM billing where email='$email'"; $result2 = mysql_query($query2); $num_rows = mysql_num_rows($result2); while($row2 = mysql_fetch_array($result2, MYSQL_ASSOC)) { $query3 = "SELECT * FROM events where id='$row2[eventid]'"; $result3 = mysql_query($query3); while($row3 = mysql_fetch_array($result3, MYSQL_ASSOC)) { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <link rel="shortcut icon" href="../images/favicon.ico"> <meta http-equiv="Content-Type" content="text/html; charset=iso8859-1" /> <meta name="keywords" content="Ghost Hunts, Ghost Hunting, Ghost Hunt Suppers, Overnight Ghost Hunt, Haunted Nights, Ghost Hunting Weekends, Paranormal Events, Most Haunted Tours, Most Haunted, Haunted Places, Anyone There?, Fright Nights, Haunted Happenings, Haunted Gatherings, The Hoff, Scott Mills, Yvette Fielding" /> <meta name="description" content=" Paranormal team, organising ghost hunts accross the UK. With many famous guests, only at Anyone There?" /> <link href="style.css" rel="stylesheet" type="text/css" /> <title>Anyone There :. Haunted Experiences</title> </head> <script LANGUAGE="JavaScript" SRC="overlib.js"></script> <body> <div id="container"> <div id="header"> </div> <div id="nav"> <ul> <li><a href="cprotected.php" class="selected" title="Events">My Events</a></li> <li><a href="feedback.php">Feedback</a></li> <li><a href="index.php">Logout</a></li> </ul> </div> <div id="content"> <div id="page"> <h2><?php echo "Welcome $row1[fname] $row1[sname]"; ?></h2> <br> <h2> <?php echo "Showing $num_rows events. . ."; ?> </h2> <center> <p> <?php $deposit=$row2[quantity]*10; $total=$row2[quantity]*$row2[ticketprice]; $cancel='http://www.anyonethere.co.uk/main/cprotected.php'; $paid='http://www.anyonethere.co.uk/main/paid.php'; echo " <center> <table width='800' class='reference'> <tr> <th>Venue</th> <th>Date</th> <th>Total Price</th> <th>Deposit</th> <th>Remaining</th> <th>Ticket Quantity</th> <th>Status</th> </tr> "; if ($row2[status]=='0') { echo "<tr>"; echo "<td>$row3[venue]</td> "; echo "<td>$row3[date]</td> "; echo "<td>£$total</td> "; echo "<td>£$deposit</td> "; echo "<td>£$row2[owe]</td> "; echo "<td>$row2[quantity]</td> "; echo "<td>Pay Deposit</td></tr>"; } elseif ($row2[status]=='1') { echo "<td>$row3[venue]</td> "; echo "<td>$row3[date]</td> "; echo "<td>£$total</td> "; echo "<td>£$deposit</td> "; echo "<td>£$row2[owe]</td> "; echo "<td>$row2[quantity]</td> "; echo "<td bgcolor='orange'>PAY OUTSTANDING BALANCE</td></tr>"; } elseif ($row2[status]=='2') { echo "<td>$row3[venue]</td> "; echo "<td>$row3[date]</td> "; echo "<td>£$total</td> "; echo "<td>£$deposit</td> "; echo "<td>£$row2[owe]</td> "; echo "<td>$row2[quantity]</td> "; echo "<td bgcolor='green'>Paid</td></tr>"; }}} echo "</table>"; ?> </p> </div> <div class="clear"></div> </div> <div id="footer"> <p>© 2011 Anyone The The UK's #1 for Haunted Events</p> </div> </div> </body> </html> Please can somebody give me a pointer in the right direction, it will be a life saver? Thanks in Advance, Dan Hi guys, I am not a coder, but more a graphic designer and I am currently designing a ccbill affiliate program in which I urgently need to find a way to code the following: When people visit the affiliate page, affiliates are able to log in by entering their 6 digit ccbill affiliate ID. Once they log in, they are redirected to the affiliate area, where all affiliate links are embedded with their unique ID. I have seen many affiliate sites using this simple "set cookie" script but for the life of me, can I find it online!! .. absolutly no chance. I have been looking for a way to do this for around 6 months now. Here are some examples I found on google of affiliates that are using this type of code: [links to sexually oriented sites removed.] < this is the layout I want to follow, ie three steps at the bottom of the page, with the third being the login It seems they are all using a pho file to do this. Can anyone please, please help me with this, as I think this forum is my last resort after 6 months of searching for a way to do this. Many thanks! import java.util.Scanner; public class bijele { public static void main (String[] args) { Scanner in = new Scanner(System.in); int[] neededPieces = {1,1,2,2,2,8}; String[] currentPieces = in.nextLine().split(" "); for (int i = 0; i < 6; i++) { neededPieces[i] -= Integer.parseInt(currentPieces[i]); System.out.print("" + neededPieces[i] + " "); } } }
Hi guys, my code below works with sanbox for paypal IPN but since it has gone live it doesnt do anything, so i made emails to send me where the issue is and it keep sending me $req = 'cmd=_notify-validate'; could you please tell me what im doing wrong here? my db connection should be fine as it does update the users on sanbox. the account im paying with in paypal keep saying payment status unclaimed. it means the reciever has not recieved the money. I checked the paypal account where i recieve the moeny and looked into my ipn history, nothing there. the same ipn address is used for my account when i tested it on sanbox, thanks <?php $email="princeofpersia@hotmail.co.uk"; include 'global.php'; // 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); //$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);//Live // assign posted variables to local variables if (!$fp)// failed to connect to url { //write to file $fh = fopen("logipn.txt", 'a');//open file and create if does not exist fwrite($fh, "\r\n/////////////////////////////////////////\r\n HTTP ERROR \r\n");//Just for spacing in log file fwrite($fh, $errstr);//write data fclose($fh);//close file $mail_From = "From: IPN@tester.com"; $mail_To = $email; $mail_Subject = "HTTP ERROR"; $mail_Body = $errstr;//error string from fsockopen mail($mail_To, $mail_Subject, $mail_Body, $mail_From); } else//successful connect to url { fputs ($fp, $header . $req);//send request while (!feof($fp)) //while not end of file { $res = fgets ($fp, 1024);//get response if (strcmp ($res, "VERIFIED") == 0) { //write to file $fh = fopen("logipn.txt", 'a');//open file and create if does not exist fwrite($fh, "\r\n/////////////////////////////////////////\r\n Verified \r\n");//Just for spacing in log file fwrite($fh, $req);//write data fclose($fh);//close file $mail_From = "From: IPN@tester.com"; $mail_To = $email; $mail_Subject = "VERIFIED IPN"; $mail_Body = $req; mail($mail_To, $mail_Subject, $mail_Body, $mail_From); } else if (strcmp ($res, "INVALID") == 0) { //write to file $fh = fopen("logipn.txt", 'a');//open file and create if does not exist fwrite($fh, "\r\n/////////////////////////////////////////\r\n Invalid \r\n");//Just for spacing in log file fwrite($fh, $req);//write data fclose($fh);//close file $mail_From = "From: IPN@tester.com"; $mail_To = $email; $mail_Subject = "INVALID IPN"; $mail_Body = $req; mail($mail_To, $mail_Subject, $mail_Body, $mail_From); } } fclose ($fp);//close file pointer } $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']; $txn_id = $_POST['txn_id']; $receiver_email = $_POST['receiver_email']; $payer_email = $_POST['payer_email']; //$username=$_POST['username']; if (!$fp) { // HTTP ERROR } else { fputs ($fp, $header . $req); while (!feof($fp)) { $res = fgets ($fp, 1024); if (strcmp ($res, "VERIFIED") == 0) { if (strtolower($payment_status)=="completed") { if ($payment_amount==0.01&&$payment_currency=="GBP") { $update = mysql_query("UPDATE users SET credit= credit+5 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); } ?> Hey Guys, i have another problem, i am using paypal IPN, and i want the details of the order to be stored in my orders table of the databse as well as sending me an email. Im pretty sure the code is ok, but it is not working. Can some one please take a look? <?php include('db_fns.php'); // change these to your paypal settings $paypal_email = "benmunns@gmail.com"; $paypal_currency = 'USD'; $shipping = 10.00; /** * checks if paypal trans id is already in database * @param int $trans_id * @return bool */ function no_paypal_trans_id($trans_id) { $connection = db_connect(); $query = sprintf("SELECT id from orders WHERE paypal_trans_id = '%s'", mysql_real_escape_string($trans_id)); $result = mysql_query($query); $num_results = mysql_num_rows($result); if($num_results == 0) { return true; } return false; } /** * checks to make sure that paypal payment amount is correct * @param int $shipping * @param array $params * @return bool */ function payment_amount_correct($shipping, $params) { $amount = 0.00; for ($i=1; $i <= $params['num_cart_items']; $i++) { $query = sprintf("SELECT price from products where id='%s'", mysql_real_escape_string($params["item_number{$i}"])); $result = mysql_query($query); if($result) { $item_price = mysql_result($result, 0, 'price'); $amount += $item_price * $params["quantity{$i}"]; } } if(($amount+$shipping) == $params['mc_gross']) { return true; } else { return false; } } /** * creates order and adds items * @param array $params * @return bool */ function create_order($params) { db_connect(); $query = sprintf("INSERT INTO orders set orders.firstname = '%s', orders.lastname = '%s', orders.email = '%s', orders.country = '%s', orders.address = '%s', orders.city = '%s', orders.zip_code = '%s', orders.state = '%s', orders.status = '%s', orders.amount = '%s', orders.paypal_trans_id = '%s', created_at = NOW() ", mysql_real_escape_string($params['first_name']), mysql_real_escape_string($params['last_name']), mysql_real_escape_string($params['payer_email']), mysql_real_escape_string($params['address_country']), mysql_real_escape_string($params['address_street']), mysql_real_escape_string($params['address_city']), mysql_real_escape_string($params['address_zip']), mysql_real_escape_string($params['address_state']), mysql_real_escape_string($params['payment_status']), mysql_real_escape_string($params['mc_gross']), mysql_real_escape_string($params['txn_id']) ); $result = mysql_query($query); if(!$result) { return false; } $order_id = mysql_insert_id(); for ($i=1; $i <= $params['num_cart_items'] ; $i++) { $product = find_product($params["item_number{$i}"]); $query = sprintf("INSERT INTO items set order_id = '%s', product_id = '%s', title = '%s', price = '%s', qty = '%s' ", mysql_real_escape_string($order_id), mysql_real_escape_string($product['id']), mysql_real_escape_string($product['title']), mysql_real_escape_string($product['price']), mysql_real_escape_string($params["quantity{$i}"]) ); $result = mysql_query($query); if(!$result) { return false; } } return true; } // 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 ('www.paypal.com', 80, $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']; $txn_id = $_POST['txn_id']; $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) { if ($_POST['payment_status'] == 'Completed' && no_paypal_trans_id($_POST['txn_id']) && $paypal_email == $_POST['receiver_email'] && $paypal_currency == $_POST['mc_currency'] && payment_amount_correct($shipping, $_POST) ) { // process payment create_order($_POST); } } else if (strcmp ($res, "INVALID") == 0) { // log for manual investigation } } fclose ($fp); } ?> Hey guys i have created a paypal IPN script and it takes various info from users via paypal. Anyways i store their info into a database along with their email however i dont want them to be able to purchase again with the same email (long story) anways by the time i receive the info from paypal the payments already gone through so its too late for me to do the checking against the database. Is there anyway i can auto refund the payment do paypal allow this? Hope someone can help. Thanks! Hi Does any one know of any good tutorials for paypal web payments pro, or recommend books Thanks in advance Hi, I am new here, so hello everyone. I really need some help with getting Paypal IPN working correctly. This is what I am trying to do. I have a user database, when the user logs in, they have the option to upgrade/subscribe to our website. So when they subscribe and payment is validated, I want a specific field in a specific table updated based on the user's unique ID, not based on [payer_email], so how do I pass on that parameter using IPN? right now I added the "userId" to a hidden field in the Paypal subscription form named "on1".... I hope this isn't confusing - would really appreciate your help - I added code below. Code: [Select] <?php DB info -- // 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.sandbox.paypal.com', 443, $errno, $errstr, 30); if (!$fp) { // HTTP ERROR } else { fputs ($fp, $header . $req); while (!feof($fp)) { $res = fgets ($fp, 1024); if (strcmp ($res, "VERIFIED") == 0) { // PAYMENT VALIDATED & VERIFIED! $email = $_POST['payer_email']; $userId=$_POST['on1']; $membership = '2'; mysql_query("UPDATE users SET membership=".$membership." WHERE userId=".$userId) or die(mysql_error()); $to = $email; $subject = 'subject line'; $message = ' message here '; mail($to, $subject, $message, $headers); } else if (strcmp ($res, "INVALID") == 0) { // PAYMENT INVALID & INVESTIGATE MANUALY! $to = 'my_email'; $subject = 'subject lin'; $message = ' Dear Administrator, A payment has been made but is flagged as INVALID. Please verify the payment manualy and contact the buyer. Buyer Email: '.$email.' '; $headers = 'From:my_email' . "\r\n"; mail($to, $subject, $message, $headers); } } fclose ($fp); } ?> Hey All, I have setup a Paypal API to handle the recurring payments on my website, once the payment is completed I get a token id and ba_token id return. I am storing this in a database, but wondered how people link this with a user table? I could use a cookie to store the user's id before payment and then get it once the payment is complete, but this would not work with the subsequent recurring payments. How do you go about sending the user id when a recurring payment happens? Any advise would be appreciated. Edd Hi all I have a quick PayPal IPN question, is this the right group to post the message and does anyone know much about the PayPal IPN? Thanks I just did the ipn page to store paypal transactions into my database but it doesnt seem to be working. Is there anything else that i need to do other than creating the ipn page? <?php mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("pbstore") or die(mysql_error()); // 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.sandbox.paypal.com', 443, $errno, $errstr, 30); if (!$fp) { // HTTP ERROR } else { fputs ($fp, $header . $req); while (!feof($fp)) { $res = fgets ($fp, 1024); if (strcmp ($res, "VERIFIED") == 0) { // PAYMENT VALIDATED & VERIFIED! $email = $_POST['payer_email']; $name = $_POST['item_name']; mysql_query("INSERT into sales (name, email) VALUES('".$name."', '".$email."')")or die(mysql_error()); mysql_query("INSERT INTO users (email, password) VALUES('". mysql_escape_string($email) ."', '".md5($password)."' ) ") or die(mysql_error()); } else if (strcmp ($res, "INVALID") == 0) { // PAYMENT INVALID & INVESTIGATE MANUALY! } } fclose ($fp); } ?> I am trying to get a Paypal IPN working using PHP. I have attached the code I have written that is not working. I have no real way to test it other than nothing is being posted to the databases. The transactions seem to complete with paypal, but I get no information and no emails are generated. Any help would be much appreciated. Hi, I've integrated paypal payment pro over my website. I don't know how can i test it. can any one help me out? my site address is : http://pacific-labs.com/paymybill.php Please help Hi me need to implement echeck system in my site with paypal using php script with ipn can any one help me out regarding code for paypal echeck payment system. Thanks I am writing a listener to handle IPN notifications from paypal, and one thing I cant seemt o find anywhere - How does IPN handle pending payments, that are then completed/denied? For example, if paypal invokes my IPN once the payment is made, but pending, with a particular transaction ID, when the payment completes, does it then invoke my IPN again, with the payment status as 'completed'? If so, will this second IPN have the same transaction ID? It would seem logical that the same transaction ID is sent again, as it is actually the same customer transaction, however reading this on thepaypal website suggests otherwise: "Avoid duplicate IPN messages. Check that you have not already processed the transaction identified by the transaction ID returned in the IPN message. You may need to store transaction IDs returned by IPN messages in a file or database so that you can check for duplicates. If the transaction ID sent by PayPal is a duplicate, you should not process it again. " Help would be appreciated!! Hi, I am about to incorporate some PayPal functions to my site and am just asking for some advice before I start. Basically a user is going to enter some data into a form and then be passed to PayPal to pay an X amount, once the payment has been verified I want the information entered in the form (before going to PayPal), to be added to a database. But it seems that PayPal does not allow you to pass multiple (about 13) variables through their system. Is this correct? So what I was going to do is just before the customer goes to the PayPal site, I was going to insert all the data into the database and set a payment status, then once the payment is confirmed re-setting the payment status to paid or non-paid. Is that a good way to do what I want? If not is there a better way? Any help would be great. Lee I am trying to write a Paypal IPN Listener that will create a confirmation key in the order database I have on the server. Upon completing the order it will then send a email to the buyer with a link to a file upload page with the confirmation code embedding so that when the buyer goes to the upload page it can authenicate based on that code prior to allowing the person to upload a file. I has been a pain and is still not working. Similar to an email confirmation when some one signs up as a user on a site, but using the Paypal order information and the listener to generate the confirmation and authentication. IS THIS POSSIBLE? For some reason I can't get this script working for my IPN. Please help. <?php include("init.inc.php"); $send = 'cmd=_notify-validate&' . http_build_query($_POST); $head = 'POST /cgi-bin/webscr HTTP/1.0' . "\r\n"; $head .= 'Content-Type: application/x-www-form-urlencoded' . "\r\n"; $head .= 'Content-Length: ' . strlen($send) . "\r\n\r\n"; $fp = fsockopen('sandbox.paypal.com', 80); if ($fp !== false){ fwrite($fp, $head . $send); $response = stream_get_contents($fp); $response = trim(end(explode("\n", $response))); if ($response === 'VERIFIED' && $_POST['payment_status'] === "Completed" && $_POST['mc_gross'] === "10.00" && $_POST['mc_currency'] === "USD") { $payer_email = $_POST['payer_email']; $q = mysql_query("UPDATE `users` SET `test` = '1' WHERE `email` = '$payer_email'"); } } fclose($fp); ?> |