PHP MYSQL and Paypal IPN

Hi

I am trying to get my head round IPN and how (and when) to record payment details in my MYSQL database. What I require is:

  • Someone registers on my site
  • They then pay for this registration using paypal
  • payment confirmation page is shown on my website
  • Their registration details and payment details are saved into a MYSQL database using PHP

That is my preferred order although not sure how to achieve this with IPN or PHP forms.

Has anyone got any scripts they have used to do this in this order? I have the MYSQL database setup and the forms it is just how to pass the data between forms in the right order I am not sure of.

I found that the simplest way of matching up data is to generate the invoice number myself and give that to Paypal. Everything Paypal passes to the IPN then has the appropriate invoice number to match what I have already saved.

Sorry hadnt heard of this before, but just registered looks like it might be useful. I was just making small payments with my own credit card to test functionaility!

I’ve done something like this last year, except I had an other order.
The user ordered “something”, then I made an IPN call to get the PayPal identifier, redirected the user to PayPal, he submitted his payment details, PayPal redirected him back to the site, I checked if the payment was done and that’s it.
After the user submitted the payment details PayPal sends a request to a “hidden” script on the server so I can flag the transaction as done - this way I only have those details in the database that are really interesting, no “half-baked” orders or so.

I’m not 100% sure but I believe I’ve gotten this workflow from the PayPal API docs, if not it’s from one of the other developer tutorials from the PayPal DevCenter.

I already have a form that collects registration details and writes them to a database. Just need to work out how I integrate paypal into this using IPN so that for example another field is completed in the table for payment made or similar. I guess someone out there must have integrated paypal with their php mysql site in order to record in the database that a certain user has paid. Also to disallow membership priveleges for that user until they have paid.

I believe the only data you need from PayPal is the transaction number. Given that number and authentication details you can make a request for all the associated order details except the credit card number. I don’t believe there is any way to get the credit card number. So if you want to store the credit number you will need to do that on your side and go through all proper encryption requirements by law.

Do you have a PayPal sandbox account? That would be the first step.