#briskdev1-webhook

1 messages · Page 1 of 1 (latest)

old vapor
#

@wispy kayak I don't fully grasp what you are asking

wispy kayak
#

the example doesn't include anything about resolving/rejecting promises but my example webhook endpoint gives me errors saying im not handling the unresolved promises properly

old vapor
#

Do you have code example you can share?

wispy kayak
#

const testWebhook = async (request, response) => {

const endpointSecret = "whsec_oopsBl3Fw2tip1zBVQXzeVQOvKX"

const sig = request.headers['stripe-signature'];
console.log(sig = ${sig})

const event = stripe.webhooks.constructEvent(request.body, sig, endpointSecret).then((event) => {

// Handle the event
switch (event.type) {
  case 'payment_intent.succeeded':
    const paymentIntent = event.data.object;
    // Then define and call a function to handle the event payment_intent.succeeded
    break;
  // ... handle other event types
  default:
    console.log(`Unhandled event type ${event.type}`);
}

// Return a 200 response to acknowledge receipt of the event
response.status(200).send("success");

}).catch((error) => {
response.status(400).send(Webhook Error: ${error});
return;
})
}

#

I still get the events printed out to the terminal using the CLI but a few seconds later i get errors saying "[ERROR] Failed to POST: Post "http://localhost:3000/api/testWebhook": context deadline exceeded (Client.Timeout exceeded while awaiting headers)"

old vapor
#

I'm not entirely sure I follow. Do you get to the response.status(200)?

wispy kayak
#

im not sure

#

should that be logged in my console too?

#

2021-11-01 08:59:15 --> payment_intent.created [evt_3Jr2ukJZYU3zUqpI08Jun5Ik]
2021-11-01 08:59:15 --> invoice.created [evt_1Jr2ulJZYU3zUqpI4M2Yzo4K]
2021-11-01 08:59:15 --> invoice.finalized [evt_1Jr2ulJZYU3zUqpIRaTWOcZI]
2021-11-01 08:59:15 --> customer.subscription.created [evt_1Jr2ulJZYU3zUqpIVNubxNIB]
2021-11-01 08:59:18 --> payment_intent.succeeded [evt_3Jr2ukJZYU3zUqpI0UkstWsl]
2021-11-01 08:59:18 --> charge.succeeded [evt_3Jr2ukJZYU3zUqpI0FQrUD2K]
2021-11-01 08:59:18 --> invoice.updated [evt_1Jr2uoJZYU3zUqpITs8xeZtd]
2021-11-01 08:59:18 --> customer.subscription.updated [evt_1Jr2uoJZYU3zUqpIXv5zVotE]
2021-11-01 08:59:18 --> invoice.paid [evt_1Jr2uoJZYU3zUqpI93eJ4hSz]
2021-11-01 08:59:19 --> invoice.payment_succeeded [evt_1Jr2uoJZYU3zUqpIIs78UuSP]

old vapor
#

I'm sorry I don't really know what you're doing and what's errorring

wispy kayak
#

this is what i get back when i create and pay a subscription

#

thats ok. I'll look into it some more

old vapor
#

The error looks more like a connection error

#

Does your endpoint work without the CLI? Like if you curl it yourself?