Permalink
Browse files

Added README

  • Loading branch information...
1 parent 41e7932 commit b0a20631e2805a843dbe64146de66f1b49551885 @andzdroid committed May 30, 2011
Showing with 47 additions and 0 deletions.
  1. +46 −0 README.md
  2. +1 −0 tests/ipn.js
View
@@ -0,0 +1,46 @@
+# Paypal IPN Verification
+
+A simple NodeJS package for verifying Paypal IPN messages.
+
+## Installation
+`npm install paypal-ipn`
+
+## Usage
+There is only one function, `verify`, which is used to verify any IPN messages you receive:
+
+ ipn.verify(ipn_params, callback);
+
+`ipn_params` is the dictionary of POST values sent to your IPN script by Paypal. Don't modify the dict in any way, just pass it directly to `ipn.verify` to check if the IPN message is valid.
+
+
+Example code:
+
+ var ipn = require('paypal-ipn');
+
+ ipn.verify(params, function callback(err, msg) {
+ if (err) {
+ console.error(msg);
+ } else {
+ //Do stuff with original params here
+
+ if (params.payment_status == 'Completed') {
+ //Payment has been confirmed as completed
+ }
+ }
+ });
+
+### The callback
+The callback has two parameters, `err` and `msg`.
+
+`err` will be set to true if the IPN was invalid or the request could not be made. If it is false, then the IPN was valid and you can continue to process the payment.
+
+If `err` was set to true, you can check `msg` for the exact error message.
+
+If `err` was false, then `msg` will always be `VERIFIED`.
+
+### ExpressJS
+`paypal-ipn` works fine with [ExpressJS](http://expressjs.com/) or any other web framework.
+
+All you need to do is pass in the request parameters to `ipn.verify`.
+
+In ExpressJS, the request parameters are in `req.body`.
View
@@ -1,6 +1,7 @@
var ipn = require('../index');
var qs = require('querystring');
+//Run the test with nodeunit
module.exports['Fake IPN request'] = function(test) {
var message = 'mc_gross=19.95&protection_eligibility=Eligible&address_status=confirmed&payer_id=LPLWNMTBWMFAY&tax=0.00&address_street=1+Main+St&payment_date=20%3A12%3A59+Jan+13%2C+2009+PST&payment_status=Completed&charset=windows-1252&address_zip=95131&first_name=Test&mc_fee=0.88&address_country_code=US&address_name=Test+User&notify_version=2.6&custom=&payer_status=verified&address_country=United+States&address_city=San+Jose&quantity=1&verify_sign=AtkOfCXbDm2hu0ZELryHFjY-Vb7PAUvS6nMXgysbElEn9v-1XcmSoGtf&payer_email=gpmac_1231902590_per%40paypal.com&txn_id=61E67681CH3238416&payment_type=instant&last_name=User&address_state=CA&receiver_email=gpmac_1231902686_biz%40paypal.com&payment_fee=0.88&receiver_id=S8XGHLYDW9T3S&txn_type=express_checkout&item_name=&mc_currency=USD&item_number=&residence_country=US&test_ipn=1&handling_amount=0.00&transaction_subject=&payment_gross=19.95&shipping=0.00';

0 comments on commit b0a2063

Please sign in to comment.