#rajput.abd_22
1 messages · Page 1 of 1 (latest)
yup
i am following this https://stripe.com/docs/webhooks/quickstart
As the error message suggests, it seems like your app is parsing the event payload.
You need to disable middleware that does that.
app.post('/webhook', express.raw({type: 'application/json'}), (request, response) => {
let event = request.body;
// Only verify the event if you have an endpoint secret defined.
// Otherwise use the basic event deserialized with JSON.parse
if (endpointSecret) {
// Get the signature sent by Stripe
const signature = request.headers['stripe-signature'];
try {
event = stripe.webhooks.constructEvent(
request.body,
signature,
endpointSecret
);
} catch (err) {
console.log(⚠️ Webhook signature verification failed., err.message);
return response.sendStatus(400);
}
}
// Handle the event
switch (event.type) {
case 'payment_intent.succeeded':
const paymentIntent = event.data.object;
console.log(`PaymentIntent for ${paymentIntent.amount} was successful!`);
// Then define and call a method to handle the successful payment intent.
// handlePaymentIntentSucceeded(paymentIntent);
break;
case 'payment_method.attached':
const paymentMethod = event.data.object;
// Then define and call a method to handle the successful attachment of a PaymentMethod.
// handlePaymentMethodAttached(paymentMethod);
break;
default:
// Unexpected event type
console.log(`Unhandled event type ${event.type}.`);
}
// Return a 200 response to acknowledge receipt of the event
response.send();
});
i get this from the docs provided by stripe
i didn't change anything
What about the rest of the app?
Are you using any other middleware?
yes i used bodyparser and cors
Where are you using the body parser?
my whole application is using body-parser
can i share my dummy application code
@vital mauve are you there
Yes please
You need to put the webhook in the beginning, before app.use(bodyParser.json());
but this things make issue in my main project
Webhook signature verification failed. No signatures found matching the expected signature for payload. Are you passing the raw request body you received from Stripe?
Learn more about webhook signing and explore webhook integration examples for various frameworks at https://github.com/stripe/stripe-node#webhook-signing
this issue is coming
This is the same issue you shared initailly.
But we are talking about a different problem right now.
i changes code
Could you please share the new code?
Hey! Taking over for my colleague. Let me catch up.
okay Please
What changes are you making n this Quickstart exactly ?
Did you try to download that sample and simply run it without updating any thing ?
yupp this is the copy code
ctrl + c , then ctrl + v
@whole nacelle are you there
Yes I'm here, please stop using mentions, we are monitoring all threads.
the code you've provided has changes.
First did you try to simply download the project code and run/test it ?
https://stripe.com/docs/webhooks/quickstart
Between, You need to remove bodyParser.