Paypal IPN

Sample code for Paypal IPN using WebDNA.
By Dan Strong -
Free to use, no strings attached.


1) Log Into your PayPal acct.
2) Go to "Profile", and under "Selling Preferences" click "Instant Payment Notification"
3) Click "Edit Settings" button
4) Enter your "Notification URL" (doesn't need to be https) where your IPN code will live
5) Choose "IPN messages - Receive IPN messages (Enabled)" and Save.

1) When a payment is made to your PayPal account your IPN Notification URL page expects to receive a string very similar to this:

2) You must echo this string back to paypal along with an additional name/value pair "cmd=_notify-validate"
3) You can either save this string directly to a .db for later or break out the vars via [formvariables], whichever works best for you.


[/!][TCPsend skipheader=T]POST /cgi-bin/webscr HTTP/1.0[unurl]%0D%0A[/unURL][!]
[/!]USER-AGENT: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)[unurl]%0D%0A[/unURL][!]
[/!]Content-Type: application/x-www-form-urlencoded[unurl]%0D%0A[/unURL][!]
[/!]Content-Length: [countchars][content][/countChars][unurl]%0D%0A[/unURL][!]

Your IPN Notification URL will receive a [response] from PayPal of simply VERIFIED or INVALID.
Process your data accordingly.

To prevent fraud, Paypal suggests that you
1) Check the "payment_status" is "Completed"
2) Check that "txn_id" has not been previously processed
3) Check that "receiver_email" is your Primary PayPal email
4) Check that "payment_amount"/"payment_currency" are correct
Dan Strong


Top Articles:

Tips and Tricks

A list of user-submitted tips ...

WebDNA Modules

A list of the currently available modules...

Technical Change History

This Technical Change History provides a reverse chronological list of WebDNA changes...

WebDNA Libraries

A list of available libraries for WebDNA...

AWS Raw WebDNA LAMP-Plus WebServer

Amazon Web Services (AWS) README for Machine Image ID...

WebDNA reference

A list of all WebDNA instructions...

Related Readings:

Check the Federal Government's Social Security database

The script on the page will check the federal government's social security database...

reCAPTCHA code

reCAPTCHA helps prevent automated abuse of your site (such as comment spam or bogus registrations) by using a CAPTCHA to ensure that only humans perform certain actions...

Formatting a long list in a table

How to show the result of a search as a table...

Database backup

How to make a backup of your databases...

Removing whitespace

How can I remove all whitespace entered by a user from an input box (ie card number)...

Spaghetti code

How to get rid of very long search strings...