Stripe webhooks 的错误率为 92%,响应不可预测
我是第一次设置 Stripe webhooks。我已经发出了数十次测试请求,错误率为 92%。失败发生的原因是不可预测的。
仪表板上的失败响应是:
Timed out connecting to remote host
或
Failed to connect to remote host
我的 webhook(我已将其简化以进行测试)。 8% 的情况下,我会收到带有 {received: true}
的 200 响应:
expressRouter.route('/hooks').post( async (req, res) => {
const event = req.body;
console.log("Event:");
console.log(event);
// Handle the event
switch (event.type) {
case 'payment_intent.succeeded':
const paymentIntent = event.data.object;
// Then define and call a method to handle the successful payment intent.
// handlePaymentIntentSucceeded(paymentIntent);
break;
case 'payment_method.attached':
const paymentMethod = event.data.object;
// Then define and call a method to handle the successful attachment of a PaymentMethod.
// handlePaymentMethodAttached(paymentMethod);
break;
// ... handle other event types
default:
console.log(`Unhandled event type ${event.type}`);
}
// Return a response to acknowledge receipt of the event
res.json({received: true});
})
我已将 Stripe 的 IP 添加到 iptables。我在 Ubuntu 18.04 上使用 Caddy 运行我的服务器。非常感谢任何建议。
I'm setting up Stripe webhooks for the first time. I've made dozens of test requests and I've had an error rate of 92%. It's unpredictable as to why the failures occur.
The failure responses on the dashboard are either:
Timed out connecting to remote host
or
Failed to connect to remote host
My webhook (I've simplified it for testing). 8% of the time, I get a 200 response with {received: true}
:
expressRouter.route('/hooks').post( async (req, res) => {
const event = req.body;
console.log("Event:");
console.log(event);
// Handle the event
switch (event.type) {
case 'payment_intent.succeeded':
const paymentIntent = event.data.object;
// Then define and call a method to handle the successful payment intent.
// handlePaymentIntentSucceeded(paymentIntent);
break;
case 'payment_method.attached':
const paymentMethod = event.data.object;
// Then define and call a method to handle the successful attachment of a PaymentMethod.
// handlePaymentMethodAttached(paymentMethod);
break;
// ... handle other event types
default:
console.log(`Unhandled event type ${event.type}`);
}
// Return a response to acknowledge receipt of the event
res.json({received: true});
})
I have added Stripe's IPs to iptables. I'm running my server with Caddy on Ubuntu 18.04. Any advice is greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论