Node.js 未处理条纹Webhook案例
})) 服务器日志:2021-01-04T08:32:39.522281+00:00应用程序[web.1]:未处理的事件类型customer.subscription.updatedNode.js 未处理条纹Webhook案例,node.js,heroku,stripe-payments,Node.js,Heroku,Stripe Payments,})) 服务器日志:2021-01-04T08:32:39.522281+00:00应用程序[web.1]:未处理的事件类型customer.subscription.updated 这是当前在线的,为什么customer.subscription.updated不运行,而只运行默认值:run?我如何修复此问题?我的密钥是正确的(使用密钥和右webhook的端点密钥)。我不应该为已处理的事件获取未处理的事件类型。可能您缺少break语句?因此,匹配的案例和默认案例都在运行。也许您缺少break语
这是当前在线的,为什么customer.subscription.updated不运行,而只运行默认值:run?我如何修复此问题?我的密钥是正确的(使用密钥和右webhook的端点密钥)。我不应该为已处理的事件获取未处理的事件类型。可能您缺少
break
语句?因此,匹配的案例和默认案例都在运行。也许您缺少break
语句?因此,匹配的案例和默认案例都在运行。
app.post('/webhook', bodyParser.raw({type: 'application/json'}), async (request, response) => {
const sig = request.headers['stripe-signature'];
let event;
try {
event = stripe.webhooks.constructEvent(request.body, sig, endpointSecret);
}
catch (err) {
response.status(400).send(`Webhook Error: ${err.message}`);
}
// Handle the event
switch (event.type) {
case 'payment_intent.succeeded':
case 'customer.subscription.created':
case 'payment_method.attached':
case 'customer.subscription.updated':
console.log('this should run');
default:
console.log(`Unhandled event type ${event.type}`);
}
// Return a response to acknowledge receipt of the event
response.json({received: true});