I understand how IPN works, and the basic idea of the sending of information, verifying etc. But for the life of me I cannot get it to work!!
This is what I'm trying to do...
A user selects a certain part of a product to purchase, once they click it, they are linked to a paypal button which I've added 2 text fields to. First is there User ID and the second the name of their selected part - both of which the value is added in automatically. That all works fine.
They then press Buy Now and fill out their card details and it is purchased and redirected to a success page.
However, I want it so it updates their profile in my database to show they have purchased that product.
I understand that using PayPal's IPN I can send information to a page on my site to check it, and if the payment is complete then take whatever action needed.
I have tried the scripts from the PayPal site itself and I get no response at all. Can someone give me a really, REALLY simple method of achieving what I'm after? Because every tutorial out there is overly complicated or doesn't work, and the examples don't help me in the slightest and they talk to you as if you should know how it's done already.
I've even read the whole PDF and still I'm clueless about how to get this working. Any help?
This really depends on how you have your users stored in a database.
Basically, you would want to look at the IPN Variables and see what you could use to associate the data with your databases when the IPN message is received by your script.
Lets say you have the following Databases:
Users: ID, email, etc.. etc..
Transactions: ID, emailofUser, invoiceID, Success/Fail(bool)
You want to store information to the database before you send the data to PayPal - "Hey, this guy was sent to PayPal to purchase this".
Then, IPN comes in when you want to ensure that the item was actually purchased. You don't want to offer someone the benefits of purchasing an item just for being sent to PayPal, you want to make sure they actually completed payment. Going off of the IPN variables, you could easily use the 'invoice' variable (as long as you define it appropriately when you send the data to PayPal).
So lets say you send a buyer to PayPal, he completes checkout, and your script gets an IPN message. You'll want to do something like the following:
Check what invoice this is for
mysql_query("SELECT * FROM Transactions WHERE invoiceID=$_POST['invoice']");
See if the transaction is successful or not.
if ($_POST['payment_status'] == 'completed')
{
//update whatever information you need to
}
else
{
//something else happened with this transaction, put a flag on it for review by
//an admin
}
You should check out the links below which describe a little more about managing your orders
Order Management Automation Order Management Guide
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With