Sorry I haven't had time to look through this in more detail. I have some time now. Since you're still having problems with this and you haven't checked the contents of $res. I tested IPN with a bad verification to see what came back because my memory is faulty:
https://www.paypal.com/cgi-bin/webscr?c ... y-validate
And unlike what I remember the response is a single word "INVALID". So I decided to
read the instructions (which I suggest you do too) and found a successful verification produces only the word "VERIFIED". Thus strcmp will work. It's not robust, but it should work. This means the problem is elsewhere.
Since you're saying "it seems nothing is in the database" I think you should look at that code. Also you should confirm that nothing is happening in your database.
I don't quite understand your database code. On the surface it appears that when a new transaction comes in, you try to select a paypal transaction id. When was this ID put into the database because it has to come from PayPal? Does this code in notify.php return any results?
Code: Select all
mysql_select_db($database_lachic, $lachic); // find Txn ID
$query_rsTxnId = "SELECT transactID FROM lachic_Orders WHERE transactID = '" . $txnID . "'";
$rsTxnId = mysql_query($query_rsTxnId, $lachic) or die(mysql_error());
$row_rsTxnId = mysql_fetch_assoc($rsTxnId);
$totalRows_rsTxnId = mysql_num_rows($rsTxnId);
As pseudo code you should be doing something like this:
*(optional) shopping cart can preconfigure database with unverified/unpaid order -- but it can not know the paypal transaction id
*paypal calls your IPN listener (notify.php) with $_POST data
*your code verifies $_POST data
*if valid add purchase information into database (using INSERT, or update to the shopping cart's initial information)
*Let the user know the status of their purchase (via email and/or return to merchant link like success.php which waits for the database to show successful)
*Perform any tasks relevant to their purchase
Also I'm not sure if PayPal guarantees the IPN will be fully processed before the user can click "Return to Vendor". This could cause a problem if success.php tries to access the database before the IPN data is complete. I've never tried to use the IPN this way. I did a search and couldn't find any information on that subject.
Is your shopping cart trying to preconfigure the order? Where did you get the code for using the XCart? It's possible there's a problem with how you've configured that to work with your database too.