Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

135
Visualizações
Stripe webhooks - checking request from Stripe

I want to check if request on my endpoint is from Stripe. I can do this, I can check this but the problem is - my code after try catch blocks is not triggering.

Even if I write all this console logs in try block AFTER I assing response from Promise to event variable. All of my code AFTER event = await stripe.webhooks.constructEvent(payload, sig, endpointSecret); is not working. Also I dont have any errors...

I want to send response 200 and continue with more complicated code on server but it stops working after checking req from stripe.

    pixelRouter.post("/payments", async (req, res) => {
  //Checking if request is from STRIPE
  const payload = req.body;
  const sig = req.headers["stripe-signature"];
  const endpointSecret =
    "my secret endpoint here";
  let event;
  try {
    event = await stripe.webhooks.constructEvent(payload, sig, endpointSecret);
  } catch (err) {
    return res.status(400).send(`Webhook Error: ${err.message}`);
    console.log(err.message);
  }
  //********************************* */
  switch (event.type) {
    case "checkout.session.completed":
      console.log("Code for checkout session completed");
      break;
    case "payment_intent.succeeded":
      console.log("Payment succeeeded");
      break;
    default:
      console.log("???");
  }
  console.log("ndkndnn");
  res.json({ success: true });
});
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda