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 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…