Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 未处理条纹Webhook案例_Node.js_Heroku_Stripe Payments - Fatal编程技术网

Node.js 未处理条纹Webhook案例

Node.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语

}))

服务器日志:2021-01-04T08:32:39.522281+00:00应用程序[web.1]:未处理的事件类型customer.subscription.updated


这是当前在线的,为什么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});