Taking online payments with paypal and use the IPN system
Today I will try and guide you through creating a simple Payment system using Paypal and the IPN payment notifications system while using PHP as your scripting language and MYSQL as your database to store payments.
Ok. This may seem a little daunting but I swear! If you follow this, You will be able to do the following:
Say you have a website that talks to your database. Say you have a user with a userid of “SomeUser”
This user has a field in your database called “paid” and if its value = “1” then you will allow the user access to some kind of material.
I’m not going to be able to help you with your user system or how that user gets authenticated. What we WILL DO here is modify your database ( or whatever you want ) to show that a user has paid once Paypal has authenticated the payment.
This is a “basic” working example. You will need to modify it somewhat to be able to do what you may need. However it should be fairly straight forward once you understand what is going on here.
How the payment flows
1) You create a “Buy now button” with a special feild
2) You add it to your site
3) You then create an IPN “listener” that will be on your server
4) When a payment comes in, Paypal will talk to your PHP IPN listener
5) Your IPN script updates your backend systems based on the details sent via Paypal.
Lets get started
Create and add a “buy now” button to your site.
Create the PHP IPN server / listener.
Update the Paypal IPN URL
Test your IPN script
There are a few ways to test your IPN script.
1) Use the Paypal Sandbox ( Change the URL in the IPN script to the Sandbox url and then use the Paypal Sandbox website )
2) Set your price to something really low for testing. Something like 2pence / 2cents.
I think it works if you set it to Free / 0$ / £0 , so give that a try also.