I have a simple PayPal buy button on my site. The user goes to paypal, and when he is finished buying, he automatically redirects to my site (currently on the sandbox there is a screen before the redirect, saying “if with 10 seconds you are not redirected…”). Also, I’ve set up the notify_url with a url on my server to process the successfull payment.
I have 2 questions:
-
my site uses user login. so someone who clicked the buy button is an already logged in user. My question is what is the best way to figure out which user did the purchase when I’m processing the paypal IPN on the notify_url? I thought about setting a unique identifier based on the user id on the button form, but I just couldn’t find documentation how to do it.
-
when the user finishes the purchase he should be able to have access to certain content. So say the user lands in http://www.example.com/account after the purchase, I would like to check the database to see whether he really did successfully finished a purchase. So my question is, can I be certain that the notify_url callback will be executed before the user lands on /account?
I really don’t want to have angry customers who successfully purchased but still didn’t get access. What is the best way to ensure this situation will never happen?
Thank you.
If you look at the IPN and PDT variables page for Paypal, you’ll see that a field called “custom” can be used. Its description:
Form example:
And in your IPN response script: