when a user pays for purchasing our product then how we can know that which user paid through information sended by paypal to our ipn.
(1) For both Paypal IPN and PDT, after creating your button in Paypal, you can customize it by adding fields like below:
<input type="hidden" name="item_name" value="Name of the Item" /> <input type="hidden" name="amount" value="49.95" /> <input type="hidden" name="custom" value="User ID" /> <input type="hidden" name="return" value="A Link for handling" /> <input type="hidden" name="cancel_return" value="A link for handling cancel" /> <input type="hidden" name="notify_url" value="IPN link that user will return to" />
to specify which info you'd like to have returned back to you after the transaction goes through.
(2) In Paypal, you'll need to set up IPN (and PDT is also a good idea). If using PDT, you'll receive and record the unique token Paypal creates for you.
(3) You'll need a script that uses this unique token and "catches" the transaction info sent to it. You can write one using PHP and curl or you can use one wrapped in a class. If you'd like a link to a good one or an example, just let me know.
Once the user pays for the item(s), s/he will be returned to your IPN url which will handle the verification and then can record the transaction status in a database or by sending an email to you (depends how you write your script). If the user closes the browser or does not return to your url handling the IPN, then the transaction won't be recorded outside of Paypal. So, it would be a good idea to implement PDT and then put a condition specifying that if IPN worked first, don't do PDT and/or if PDT worked first, don't do IPN. Or you could just mark your transactions as IPN and PDT respectively.
Edited by kamili: Incorrect word used