PayPal IPN for Digital Downloads

Posted in Code on Tuesday, March 30th, 2010 @ 12:43 pm (392 views)

Last week saw the release of PWA+PHP Pro for Wordpress, the big brother of PWA+PHP, with advanced functionality like thumbnail caching, integrated comments system and additional shortcodes for more functionality.  For the first week, I was manually sending out the code after the requisite donations started rolling in. Hassle.

I decided to automate the process using PayPal IPN, since I was already accepting donations via PayPal, so I just needed a way to fire off an email containing the code when someone made a donation.  Much of the sample code I found online was full of errors, so I decided to post the code I used to implement the solution, including the database schema, below.  Feel free to grab it and modify as necessary to setup something similar on your site.

Note: You’ll need a Business or Premier PayPal account for IPN to work.

Database Schema:

CREATE TABLE IF NOT EXISTS `donations` (
`invoice` int(10) unsigned NOT NULL AUTO_INCREMENT,
`receiver_email` varchar(60) DEFAULT NULL,
`payment_status` varchar(10) DEFAULT NULL,
`payment_date` datetime DEFAULT NULL,
`mc_gross` varchar(20) DEFAULT NULL,
`txn_id` varchar(20) DEFAULT NULL,
`first_name` varchar(30) DEFAULT NULL,
`last_name` varchar(40) DEFAULT NULL,
`payer_email` varchar(60) DEFAULT NULL,
PRIMARY KEY (`invoice`)
)

IPN Listener Package:
The attached bundle contains the IPN listener and a copy of the PHP Email Attachement Class from kavoir.com.

Get the code: http://code.google.com/p/ipnid/downloads/list

See Also: http://code.google.com/p/ipnid/

 

2 Responses to “PayPal IPN for Digital Downloads”

  1. KENT says:


    Medicamentspot.com. Canadian Health&Care.Special Internet Prices.No prescription online pharmacy.Best quality drugs. High quality pills. Order pills online

    Buy:Lasix.Aricept.Benicar.Advair.Nymphomax.Acomplia.Zetia.Buspar.Cozaar.Seroquel.Lipitor.Zocor.Prozac.Ventolin.Amoxicillin.Lipothin.Wellbutrin SR.Female Cialis.Female Pink Viagra.SleepWell….

Leave a Reply