Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Changed request method to POST, added check to make sure params is no…

…t undefined
  • Loading branch information...
commit 931390681ac74502948f785dda1da051f9f65338 1 parent 36aac28
@andzdroid authored
Showing with 13 additions and 2 deletions.
  1. +13 −2 lib/paypal-ipn.js
View
15 lib/paypal-ipn.js
@@ -6,13 +6,20 @@ var REGULAR_URL = 'www.paypal.com';
exports.verify = function verify(params, callback) {
+ if (typeof params === "undefined") {
+ return callback(true, 'No params were passed to ipn.verify');
+ }
+
params.cmd = '_notify-validate';
+ var body = qs.stringify(params);
+
//Set up the request to paypal
var req_options = {
host: (params.test_ipn) ? SANDBOX_URL : REGULAR_URL,
- method: 'GET',
- path: '/cgi-bin/webscr?' + qs.stringify(params)
+ method: 'POST',
+ path: '/cgi-bin/webscr',
+ headers: {'Content-Length': body.length}
}
@@ -24,6 +31,10 @@ exports.verify = function verify(params, callback) {
callback(response != 'VERIFIED', response);
});
});
+
+ //Add the post parameters to the request body
+ req.write(body);
+
req.end();
//Request error
Please sign in to comment.
Something went wrong with that request. Please try again.