#BarefootDev
1 messages ยท Page 1 of 1 (latest)
Hi ๐ what's your question?
Based on the error message, it could be a few things. What have you tried so far?
im using the endpointSecret provided in the node.js sample, and the raw request body. only difference is im doing it in a serverless function (emulated locally), not an express app
I havent come up with any ideas to try fix
Are you able to log the raw response body you received from Stripe and manually confirm that the signature matches what you provided in the request?
umm to trigger the webhook im just using stripe trigger checkout.session.completed
so i dont know what sig is being provided in the req
when i run stripe listen it does log the webhook signing secret it's using, which matches the endpointSecret im using in my code
but not sure about the sig
Ah, okay. I didn't realize you were using the CLI to do this. Let me dig a bit more and circle back
Thanks
Do you have a request ID for the request that raises the error?
Here's how you can find a request ID: https://support.stripe.com/questions/finding-the-id-for-an-api-request
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
Yep here's one: req_thuDTBix56CZwT
๐
Can you share your Webhook code?
Also have you logged out the request body?
Usually the issue here is that your framework is manipulating the raw body and that causes signature verification to fail
oh okay that sounds possible, im using a firebase function and have the handler wrapped in a cors thing
exports.stripeWebhookHandler = functions.https.onRequest((req, res) => {
cors(req, res, async () => {
await stripeWebhookHandler(req, res);
return res.status(200).send("Webhook received");
});
});
That might do it. If you log out the raw body it should be a buffer that looks like binary
If you see JSON then your framework is likely the issue
Oftentimes the framework "helps you" with this... but this is one case where you have to force it to not do anything to the raw body
Yeah try that
๐
just one quick q: is it possible to send some kind of metadata (e.g. a user id) when i initially create the checkout session, so that the webhook receives it?
ah awesome
You can also set the metadata at the PaymentIntent level using https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-payment_intent_data-metadata
thanks a bunch
If you prefer the metadata to get carried down to the PaymentIntent
Instead of the metadata being associated to the Checkout Session
not entirely sure what the diff is between payment intend and checkout sess tbh
ill do some digging
A PaymentIntent is created due to the Checkout Session
It is a state machine for the payment attempt
But yeah, mostly I would recommend just testing the flow out
And look at what is created and what is sent to your Webhook