Package for verifying Paypal IPN messages
A simple NodeJS package for verifying PayPal IPN messages.
$ npm install paypal-ipn
There is only one function,
verify, which is used to verify any IPN messages you receive:
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.
// Must respond to PayPal IPN request with an empty 200 first// If using Express, uncomment the following:// res.send(200);var ipn = ;ipn;//You can also pass a settings object to the verify function:ipn;
Note that all the package does is confirm that the IPN message is valid. After this, you will still need to make some more checks:
Confirm that the
Use the transaction ID to verify that the transaction has not already been processed, which prevents duplicate transactions from being processed.
Validate that the receiver's email address is registered to you.
Verify that the price, item description, and so on, match the transaction on your website.
You can find more information on the PayPal documentation for IPN.
If this is true, the library will attempt to verify sandbox requests at PayPal's sandbox URL.
If this is false, the library will callback with an error without checking PayPal. (This is the default value.)
You should set this to false on production servers.
The callback has two parameters,
err is null then the IPN is valid and you can continue processing the payment.
msg is always
In case IPN was invalid or the http request failed
err holds the Error object.
paypal-ipn works fine with Express or any other web framework.
All you need to do is pass in the request parameters to
In Express, the request parameters are in