#shubhamjha
1 messages · Page 1 of 1 (latest)
Hi there!
I'm not sure I understand your question. Can you clarify what you are trying to do?
i am making the event of upcoming invoice but i cant pass the reqest body in stripe.webhooks.constructEvent(request.body, sig, endpointSecret)
What do you mean by "you can't pass"? Do you get an error message? Can you share it here?
it givees me error
Can you copy-paste the exact error here?
it says no timestamp and signature is found
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
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?
when i trigger the test clock
Can you share the event ID (evt_xxx) you are trying to recieve?
'invoice.upcoming':