无法在 IPN 上获得 paypal "VERIFIED" 或 "INVALID"

Cannot get paypal "VERIFIED" or "INVALID" on IPN

我正在尝试通过他们的 API 实施贝宝支付系统。不要问我为什么不使用 braintree 或 stripe...由于某些原因,它是一个客户端规范,它通过普通的 paypal,现在我正在努力实施支付验证。

我使用有效的沙箱实现了贝宝付款表格。我提到了一个 notify-url 以获得反馈,然后我必须根据此文档进行贝宝验证(以确保我收到的付款信息是真实的):https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNImplementation/ and this https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNIntro/#id08CKFJ00JYK

我的代码如下:

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);

})

根据文档,我虽然应该得到 "VERIFIED" 或 "INVALID" 响应,但我得到的不是这个,而是完整的 HTML 页面,我不知道为什么。

即使我用一个简单的 REST 客户端测试 post 请求,我也没有得到好的答复。不知道为什么,我被困在那里。有人有过 paypal 经验吗?

试试这个包,它对我来说轻而易举。 https://github.com/mbreuer23/meteor-ipn-listener/