#Abhi ->
1 messages · Page 1 of 1 (latest)
Can you share your code please
const sig = req.headers['stripe-signature'];
let event;
console.log(req.body,sig,stripeWebhookSecret);
try {
event = stripe.webhooks.constructEvent(req.body, sig, stripeWebhookSecret);
} catch (err) {
console.log( ^}^l STRIPE KYC Error message: ${err.message});
return res.status(400).send(Webhook Error: ${err.message});
}
console.log('STRIPE EVENT>>',event.type);
you need req body
The full webhook route/handler please
router.post('/identityWebhook',)
i'm getting below errr at first catch
❌ STRIPE KYC Error message: No signatures found matching the expected signature for payload. Are you passing the raw request body you received from Stripe? https://github.com/stripe/stripe-node#webhook-signing
What framework is this?
express js
that file function handles that webhook endpoint that is connected to stripe acc
i got the err in this section
const sig = req.headers['stripe-signature'];
let event;
console.log(req.body,sig,stripeWebhookSecret);
try {
event = stripe.webhooks.constructEvent(req.body, sig, stripeWebhookSecret);
} catch (err) {
// On error, log and return the error message
console.log(`❌ STRIPE KYC Error message: ${err.message}`);
return res.status(400).send(`Webhook Error: ${err.message}`);
}
console.log('STRIPE EVENT>>',event.type);
you need any req body or header data?
Express.js is likely parsing the Request object so its not the raw object as the constructEvents expects:
app.post('/webhook', express.raw({type: 'application/json'}), (req, res) =>
Did you look at the example I just shared?
yes applied and get same as previous
Updated:
router.post('/identityWebhook',express.raw({type: 'application/json'}),ctrl.identityWebhook)
sorry to create a problem for u but can you help me to solve this.
You haven't shared your full code with me in its current state
And what's the exact error?
❌ STRIPE KYC Error message: No signatures found matching the expected signature for payload. Are you passing the raw request body you received from Stripe? https://github.com/stripe/stripe-node#webhook-signin
raw body
{
id: 'evt_1NYPHbGYQpSlp3uiTYqciO1p',
object: 'event',
api_version: '2019-09-09',
created: 1690445451,
data: {
object: {
id: 'vs_1NYPHbGYQpSlp3uiMU4bwcal',
object: 'identity.verification_session',
client_secret: 'xxx',
created: 1690445451,
last_error: null,
last_verification_report: null,
livemode: true,
metadata: [Object],
options: [Object],
redaction: null,
status: 'requires_input',
type: 'document',
url: 'https://verify.stripe.com/start/live_YWNjdF8xRkoxZ2hHWVFwU2xwM3VpLF9PTDVTS3VaM3ZpeHc0YmhYeUF5elJUazVVOEk2elZJ01007iaQnYJs'
}
},
livemode: true,
pending_webhooks: 1,
request: {
id: 'req_07CtPeNOwmUmk7',
idempotency_key: '5ac161cb-ac2b-47a1-b7be-2f2480b168fc'
},
type: 'identity.verification_session.created'
}
Stripe helps you securely verify your identity online
Where did you log that in your code? That's not the raw body
so which raw body expects can u help me in that
req.body. If you're doing console.log(req.body) somewhere then that'll parse it and it'll no longer be 'raw'
still getting err
Are you doing a console.log(req.body)?
not at all now
async (req, res, next) => {
const sig = req.headers['stripe-signature'];
let event;
try {
event = stripe.webhooks.constructEvent(req.body, sig, stripeWebhookSecret);
} catch (err) {
now direct call constructEvents
Where's the express.raw() middleware gone?
budy after that raw this will be called
router.post('/identityWebhook',express.raw({type: 'application/json'}),async (req, res, next) => {
const sig = req.headers['stripe-signature'];
let event;
try {
event = stripe.webhooks.constructEvent(req.body, sig, stripeWebhookSecret);
} catch (err) {
I'm confused, why do you have 2 different async functions that call constructEvent?
why you think both are diff upper one is a part of second one
I've asked you to share your full code, yet you keep sharing smaller parts of it which is seemingly different every time
yes
still same err
❌ STRIPE KYC Error message: No signatures found matching the expected signature for payload. Are you passing the raw request body you received from Stripe? https://github.com/stripe/stripe-node#webhook-signing
?
I don't see it in your code
let stripeKey =
process.env.STRIPE_SANDBOX === 'true'
? process.env.STRIPE_SANDBOX_SK
: process.env.STRIPE_PRODUCTION_SK;
const stripe = require('stripe')(stripeKey);
const stripeWebhookSecret = process.env.STRIPE_SANDBOX === 'true'
? process.env.STRIPE_SANDBOX_WEBHOOK_SEC
: process.env.STRIPE_PRODUCTION_WEBHOOK_SEC;
buddy i have more wbhook rather then stripe so that's why i can not give you full file,
This is why I asked to see the full code
How am I meant to help you without the full context of your code?
Is this running locally, or hosted?
Ok, hosted where?
sorry but for now i'm checking in local
hello can we just finish this here
thanks for try to help me
What was the issue?
still not found buddy but i'll try
Does it work locally?
i tried in test mode
not in live mode
that's all is now in local and try to test in live mode
Yes, but can you run the code locally on your machine? You can use the CLI to trigger an event
Please don't test in live mode
not like that we have staging env so i can test in that and set the webhook in stripe
Hi! I'm taking over this thread.
hello soma
Can you console.log the stripeWebhookSecret, and check that it matches the one you see in your Stripe dashboard? It should start with whsec_.
yes i check previously, above i loged those details
Can you tripe check just to make sure? This is a very common mistake.
Also can you share your webhook endpoint ID (we_xxx)?
ok