PayPal发送相同 webhook(节点)的许多倍数



更新:代码现在可以工作了,我认为在我添加"res.send('on')到代码后,有大量未经验证的交易必须通过系统工作。

编辑:添加res.send('on')修复了502网关错误,但重新发送仍在继续。

我已成功配置网络钩子,并正在我的听众处接收它们。有关如何验证的文档不是很清楚,但我正在运行节点 SDK 文档中给出的get_and_ verify.js代码。PayPal发送的每个 Webhook 都通过此代码运行,该代码始终返回 true

我的问题是,PayPal一遍又一遍地重新发送相同的 webhook,似乎无休止。配置中是否有我没有做过的事情,或者这就是这些工作方式?

侦听器代码:

app.post('/paymentauthed', (req,res) => {
        res.status(200);
        console.log(req.body);
paypal.configure({
  mode: "sandbox", //sandbox or live
  client_id:
    "...",
  client_secret:
    "..."
});
const eventBody = `{"id": "${req.body.id}"}`
paypal.notification.webhookEvent.getAndVerify(eventBody, function (error, response) {
   if (error) {
        console.log(error);
        throw error;
    } else {
        console.log(response);
    }
});
});
app.listen(3000, () => console.log('Server Started'))

此响应也可能相关,它说有一个 502 错误的网关,不知道为什么......

"transmissions": [
        {
            "webhook_url": "https://cloudhookstester.net/paymentauthed",
            "response_headers": {
                "SERVER_INFO": "",
                "Strict-Transport-Security": "“max-age=15768000”",
                "HTTP/1.1 502 Bad Gateway": "",
                "Server": "nginx/1.14.2",
                "Connection": "keep-alive",
                "Content-Length": "173",
                "Date": "Tue, 15 Jan 2019 03:38:43 GMT",
                "Content-Type": "text/html"
            },
            "transmission_id": "74323070-1874-11e9-8941-d953a11868e8",
            "status": "PENDING",
            "timestamp": "2019-01-15T03:20:05Z"
        }
    ],

任何帮助,不胜感激。

我在 django 应用程序中实现接收 webhook 时遇到了同样的问题PayPal这个问题,这在通过服务器为返回 HttpResponse 的网络钩子调用提供有效的工作 URL 后得到解决。

希望它对您有用,其他人也会遇到这个问题。

最新更新