#shubhamjha

1 messages · Page 1 of 1 (latest)

kindred raftBOT
dawn crow
#

Hi there!

#

I'm not sure I understand your question. Can you clarify what you are trying to do?

neat whale
#

i am making the event of upcoming invoice but i cant pass the reqest body in stripe.webhooks.constructEvent(request.body, sig, endpointSecret)

dawn crow
#

What do you mean by "you can't pass"? Do you get an error message? Can you share it here?

neat whale
#

it givees me error

dawn crow
#

Can you copy-paste the exact error here?

neat whale
#

it says no timestamp and signature is found

dawn crow
#

Can you copy-paste the exact error here?

#

And also share your full code?

neat whale
#

ok wait

#

const { AuthDisabledRouter } = require('../../../shared/route-builder')
const config = require('../../../config')

const _get = require('get-value')

const stripe = require('stripe')(config.STRIPE_KEY.STRIPE_SECRET_KEY)
let endpointSecret = config.STRIPE_KEY.WEBHOOK_KEY
let session = ''
const webhook = async (request, response) => {
const sig = _get(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})
return
}
switch (event.type) {
case 'invoice.upcoming':
session = event.data.object
const c = await stripe.customers.retrieve(session.customer)
console.log(c)
break

default:
  console.log(`Unhandled event type ${event.type}`)

}
response.send()
}
const webhookRouter = new AuthDisabledRouter()
webhookRouter.post('/webhook-check', webhook)

module.exports = { webhookRouter }

#

not working for me please help

dawn crow
#

Thanks, now can you copy-past the exact error message you see in your logs?

#

Also when exactly do you see this error message? When you trigger a specific Stripe event, or when you visit the webhook page, or something else?

neat whale
#

when i trigger the test clock

dawn crow
#

Can you share the event ID (evt_xxx) you are trying to recieve?

neat whale
#

'invoice.upcoming':