Dear All,
I am trying to implement a paypal payment system through their API. Do not ask why I don’t use braintree or stripe… it’s a client specification for some reasons that it goes through plain paypal and now I am struggling to implement the payment verification.
I implemented the paypal payment form with the sandbox that works. I mentioned a notify-url to get feedback and it is then that I have to do the paypal verification (to make sure the payment information I received is real) according to this documentation : https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNImplementation/ and this https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNIntro/#id08CKFJ00JYK
My code is as follow :
import { Meteor } from 'meteor/meteor';
import moment from 'moment';
import bodyParser from 'body-parser';
import { HTTP } from 'meteor/http'
Picker.middleware(bodyParser.urlencoded({ extended : false }));
// Picker.middleware(bodyParser.json());
let postRoutes = Picker.filter(function(req, res) {
return req.method === "POST"
});
postRoutes.route('/payment_received', function(params, request, response, next){
response.statusCode = 200;
response.end();
let convertAsyncToSync = Meteor.wrapAsync(HTTP.call);
let test = JSON.stringify(request.body);
let body2 = 'cmd=_notify-validate&' + test.slice(1, -1).replace(/"/g,'').replace(/:/g,"=").replace(/,/g,'&')
console.log('-------body2-----------')
console.log(body2)
let result2 = convertAsyncToSync('POST', "https://ipnpb.sandbox.paypal.com/cgi-bin/webscr", {
headers: {
'Connection': 'close'
},
body: body2
});
console.log('----------------result2------------')
console.log(result2);
console.log('----------------result2.BODY------------')
console.log(result2.body);
})
According to the doc I though I should get a “VERIFIED” or “INVALID” response, instead of this I get a full HTML page which I have no idea why.
Even if I test the post request with a simple REST client I do not get the good reply. No idea why and I am stuck there. Anyone with paypal experience ?