#bobo00011
1 messages · Page 1 of 1 (latest)
Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
Link the doc you're referring to
What's the error you're getting
I need info to be able to help you
Right now you're just saying vague statements
look at link which I attached, I have written 2 times ...
error
event = stripe.webhooks.constructEvent(payload, sig, endpointSecret);
Still not enough info
What is the error you're getting
See the message at the top of the thread
If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
We don't have time to read through all old threads
This is a public server and we help many people
If you want 1:1 support, you can reach out to Stripe Support team
Otherwise, you'll need to play by the rules of this server
as
what?
wait
...
you have closed my topic every time
import { Router } from "express";
import stripe from "./payments";
import prisma from "./db";
import bodyParser from "body-parser";
console.log(bodyParser);
const router_webhooks = Router();
/**
* Webhook Stripe payment
*/
router_webhooks.post("/payments", bodyParser.raw({type: "application/json"}), (req, res, next) => {
const payload = req.body;
const sig = req.headers["stripe-signature"];
let event = null;
console.log(payload);
try {
event = stripe.webhooks.constructEvent(payload, sig, process.env.STRIPE_WEBHOOK_SECRET);
} catch (err) {
console.log("Webhook signature verification failed.")
return res.status(400).send(`Webhook Error: ${err.message}`);
We close threads when the user stops responding
error Webhook signature verification failed.
error is that I have to pass buffer, not object
but I parse
using body-parse, AS YOU HAVE IN DOC
Ok and what have you tried so far?
Recommend trying the example in the quickstart instead: https://stripe.com/docs/webhooks/quickstart
asf
man it doesnt work
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);
}
}```
i get error
webhook signature veritifaction
failed
test it and you will see
...
let event = request.body;
this is object
but it shouldnt be
you just downloaded the example and ran it directly or you copied code into your project? because it could be some package in your project that's causing the issue
I just ran the code and it worked completely fine
Click the "download full app" button here: https://stripe.com/docs/webhooks/quickstart
And use that app as your project base. It works fine for me
You'll obviously need to replace the endpointSecret variable though with your endpoint secret
Did you do as suggested?
Download the sample app rather than copy/paste into your project?
app.use(express.urlencoded({extended: true}));```
maybe it cause
problem
but how can I make it
?
Oh yeah those likely are. Try removing
The point of me having you try the quickstart example exactly was to get a version working
That's why I suggest using that as a base and running as-is so you know you have a minimal version working
Then you can add to that quickstart if need be