PayPal Payment Callback
The callback function specified in the return and notify url variables are the programmer's responsibility. Why? Because each website has it's own table structure for orders. Try this as a guide:
On your Paypal profile set your preference to redirect automatically after an order. You will also need to set a default return url. this will be used if you forgot to specify a return url on your order form or query string sent to Paypal.
Next, set your rm field/variable to "2" (this will tell Paypal API to autoredirect to your return url after the order and pass the order info in POST format)
You can view the response from Paypal by doing a var_dump($_POST) or print_r($_POST).
One of the important variables from the response is $_POST['payment_status'] which will tell you the outcome of the order. A successful transaction is 'Completed'. A transaction that requires verification from Paypal or from the merchant's side is 'Pending'.
Lastly, don't forget to specify 'invoice' on your Paypal field/request so you can update the status of your order. Something like:
$status = $_POST['payment_status'];
$invoice = $_POST['invoice'];
mysql_query("UPDATE Orders SET status='$status' WHERE order_id='$invoice'");
I know this is bad and unsafe coding but at least you get the general idea in it's simplest form.
Again, don't rely on other's codes. Codes in the net exists for reference purposes and not as God's handwork. Only you have the power to create your own masterpiece :D
I hope that helps. Vote up if you like it. Ignore if not.