node.js - Node express bodyParser for Paypal IPN -
i'm trying paypal ipn working node.js express app , have validate ipn message once receive "send[ing] contents in exact order received , precede command _notify-validate". example give query string this:
https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_notify-validate&mc_gross=19.95&protection_eligibility=eligible&address_status=confirmed&payer_id=lplwnmtbwmfay&tax=0.00&...&payment_gross=19.95&shipping=0.00
however, because i'm using bodyparser, request.body json object. if append "cmd=_notify-validate" , send back, how receive simple querystring , send simple querystring without getting rid of bodyparser? still need json-parsed version on route interpreting data. also, sending post on server-side like? (do res.send(str)?)
i used paypal-ipn module node , turns out json parsed body fine. main problem had using module making sure respond res.send(200), otherwise paypal's ipn keeps sending message minute @ intervals. here's code help:
exports.ipn = function(req,res){ var params = req.body res.send(200); ipn.verify(params, function callback(err, msg) { if (err) { console.log(err); return false } if (params.payment_status == 'completed') { // payment has been confirmed completed // stuff, save transaction, etc. } }); }
Comments
Post a Comment