Paypal is pretty easy, the system works as follows:
1) Your Website takes payment amount and item that the user is buying and post's these to paypal (usually using cURL)
2) Paypal takes details and process's orders
3) Paypal sends $_POST data back to a url script of your choice (Example: Send: Userid, ProductId, Amount to
http://www.somesite.com/finalise_payment.php)
4) You update everything and process the data in the url script you provided (in this example that would be finalise_payment.php
Other notes:
Make SURE you verify that the url requesting the script (finalise_payment.php) is from Paypal, a simple way to test this is to find the url that paypal uses to post the request to your script and then to use:
Please note i have not tested this code so it may not work and may need debugging
Code: Select all
$host = $_HTTP['REMOTE_HOST'];
if ($host != "http://www.paypal.com") {
header( 'Location: 'http://www.somesite.com/error.php';
}
To verify that it's Paypal that is sending you payment information and not just some random person
Paypal, as you will find, is a breeze once you've done it once, like riding a bike

My software never has bugs. It just develops random features.