#good-node-env

1 messages · Page 1 of 1 (latest)

unborn jackalBOT
trim summit
lunar mist
#

what do you mean "into the command for Stripe". What's a "command?

#

good-node-env

trim summit
#

sorry normally when I type in manually the string, my webhook will run, but when I try to substitute it using the code above, it gives me a

Error message: No signatures found matching the expected signature for payload. Are you passing the raw request body you received from Stripe?

#

By command, I means stripe trigger invoice.paid

#

in the cli command line

lunar mist
#

you can share real code here, no need for pictures (way better no picture)

trim summit
#

oh okay got it

lunar mist
#

Still unclear what that could mean. The Stripe CLI happens is just a command line tool, this has nothing to do with your Typescript code

#

Overall though the problem likely means that you haven't set your environment variable properly right?

#

The first step would be to log that value to make sure it's what you expect

trim summit
#

yea I did console.log it and it's the exact same value I expected

#

I logged it and it gave me back the exact same key word I needed in the .env.local I have. But for some reason whenever I pair it with any stripe declarations like declaring my secret key or my webhook, it'll run into an issue where it won't connect to the stripe server

const webhookHandler = async (req: NextApiRequest, res : NextApiResponse) => {
if (req.method === 'POST') {
const buf = await buffer(req)
const sig = req.headers['stripe-signature']!

    let event : Stripe.Event;

    try {
        event = stripe.webhooks.constructEvent(buf.toString(), sig, webhookSecret)
    } catch (err : any)  {
        console.log(`Error message: ${err.message}`)
        res.status (400).send(`Webhook Error: ${err.message}`)
        return
    }
lunar mist
#

I'm sorry I don't really understand this right now

#

the fact that you use a hardcoded value or something from your environment is not relevant to Stripe

#

as long as you have the correct value

unborn jackalBOT
tender walrus
#

it'll run into an issue where it won't connect to the stripe server
I'm similarly unsure of what this means, exactly, and how it relates to the No signatures found error you're seeing when verifying webhook signatures

trim summit
#

yea I think the value was wrong. My environment is giving undefined when I log it to the page