Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build a paypal donation system that gives points

Tags:

php

mysql

paypal

Am trying to create a way to setup the following:

  1. User sends donation to paypal with info from donation site (name, email)
  2. Paypal receives the donation and using the 2 variables it received (name, email) it sends them back to the donation site
  3. Donation site receives variables and donation amount and changes some variables in the website to show that the user has donated some amount.

The site shows a list of users that have donated and how much they have donated which shows as points. How can I do this with paypal and php and mysql.

like image 317
Luis Alvarado Avatar asked Nov 22 '11 00:11

Luis Alvarado


2 Answers

I'd suggest looking into using PayPal Instant Payment Notifications (IPN). PayPal IPN allows you to (asynchronously) process order information while not having to depend on the buyer to return to your website to complete the order (which would be the case with PDT).

You can use IPN by setting up a script which receives this (POST) data from PayPal. In addition, you must include the following code in your button and/or API call(s):

For Website Payments Standard (where "xxxxxxxx" is the full URL to your IPN script):
<input type="hidden" name="notify_url" value="xxxxxxxx">

For Express Checkout:
Include NOTIFYURL=xxxxxxxx in your SetExpressCheckout and DoExpressCheckoutPayment API call

For Website Payments Pro
Include NOTIFYURL=xxxxxxxx in your DoDirectPayment API call

Once set up, you will receive POST data from PayPal with every transaction.
Take this data, and send it back to https://www.paypal.com/cgi-bin/webscr?cmd=_notify-validate (Live) or https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_notify-validate (Sandbox) to validate the data. If PayPal responds with VERIFIED (in the body of the page), you're sure the data is genuine IPN data coming from PayPal.

You can find sample code, documentation and further information on PayPal IPN at https://www.paypal.com/ipn

See also some IPN security best practices at https://www.x.com/developers/community/blogs/ppmtsrobertg/securing-your-instant-payment-notification-ipn-script

like image 90
Robert Avatar answered Oct 27 '22 21:10

Robert


I found this tutorial, looks like what you're after.

http://tutorialzine.com/2010/05/donation-center-php-mysql-paypal-api/

like image 23
afro360 Avatar answered Oct 27 '22 19:10

afro360