#c6llb

1 messages · Page 1 of 1 (latest)

plush martenBOT
#

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.

  • c6llb, 8 minutes ago, 45 messages
  • c6llb, 7 hours ago, 19 messages
unkempt forum
#

What's your question

vital hearth
#

app.use((req, res, next) => {
if (req.path === '/api/v1/orders') console.log(req);
next();
});

The signature passed by the test env for checkout complete webhook is not correct

#

and this middleware logs the request

#

which have the header stripe-signature

#

and it is like this:
t=NUMBER,v1=NUMBER,v0=NUMBER

#

And none of these starts with whsec

#

so none of these is actually a signature, and there is no middlewares before this middleware who logged the stripe-signature header

#

what would be the problem?

unkempt forum
#

I don't understand the problem

#

Webhook secret isn't sent in the request ever...

#

You store webhook secret in an env variable and verify the signature with that

vital hearth
#

i meant the signature

unkempt forum
#

You won't get it in a request

vital hearth
#

so the request can be verified

unkempt forum
#

That's expected

vital hearth
unkempt forum
#

yes

#

But not recommended to verify manually ^

vital hearth
#

exports.saveOrder = catchAsync(async (req, res, next) => {
const payload = req.body;
const sig = req.headers['stripe-signature'];
console.log(sig);

try {
const event = stripe.webhooks.constructEvent(
JSON.stringify(payload),
sig,
process.env.STRIPE_WEBHOOK.trim()
);
} catch (e) {
// console.log('fail');
// console.log(e.message);
return res.status(400).json({});
}

res.status(204).json({});
});

#

yes, i'm using your libraries

#

and it displays the error:

fail
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

fail
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

fail
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

fail
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

#

each error is for some request
one for session.created, completed...etc

unkempt forum
#

Does process.env.STRIPE_WEBHOOK.trim() start with wsec_?

vital hearth
#

yes

#

it is the webhook secret

unkempt forum
#

Why do you pass JSON.stringify(payload),

#

I don't think it accepts a string

#

I think you need to pass a buffer from what I remember in node

#

And building on top of that

vital hearth
#

still, not working

unkempt forum
#

What's not working

#

What did you change

vital hearth
#

const event = stripe.webhooks.constructEvent(
payload,
sig,
process.env.STRIPE_WEBHOOK.trim()
);

unkempt forum
#

And building off of that

#

Is there a reason you're not doing that?

vital hearth
#

I've already used it, and did some edits

unkempt forum
#

Your snippet looks very different

vital hearth
#

Ok, I will try to copy-paste it

unkempt forum
#

Signature verification issues are extremely common in Node because often folks install various middlewares that mess with the inbound request body. They can be hard to debug

#

That's why we generally recommend you explicitly download the above quickstart app and use that as a base

#

You can click the "download full app" button

vital hearth
#

thanks

#

Stripe is not even supported in Jordan😂

#

My whole work is gone

#

I will try to find another

#

thanks