Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
286 views
in Technique[技术] by (71.8m points)

node.js - Stripe Webhook Cases not being handled

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

});

Server Logs: 2021-01-04T08:32:39.522281+00:00 app[web.1]: Unhandled event type customer.subscription.updated

This is live currently, why doesn't the customer.subscription.updated run and only the default: run and how do I fix this? My keys are correct (Using secret key, and endpoint key for right webhook). I shouldn't be getting unhandled event type for an event that is handled.

question from:https://stackoverflow.com/questions/65560005/stripe-webhook-cases-not-being-handled

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...