#li_webhooks
1 messages · Page 1 of 1 (latest)
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.
- li_api, 1 day ago, 10 messages
👋 Welcome to your new thread!
⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1233001320353632337
📝 Have more to share? Add more details, code, screenshots, videos, etc. below.
This is the result returned :Webhook signature verification failed. c [Error]: 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
at l (/var/task/.next/server/chunks/539.js:1:46036)
at Object.verifyHeader (/var/task/.next/server/chunks/539.js:1:44939)
at Object.constructEvent (/var/task/.next/server/chunks/539.js:1:44183)
at p (/var/task/.next/server/app/api/webhook/route.js:1:1073)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async /var/task/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:42484
at async eI.execute (/var/task/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:32486)
at async eI.handle (/var/task/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:43737)
at async Y (/var/task/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:16:24659)
at async Q.responseCache.get.routeKind (/var/task/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:17:1025) {
type: 'c',
raw: {
message: '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',
?
hi! I'd suggest starting by using the example projects from the github repo in the error message and getting those working in isolation, and then start adding your own code to them later.
我并不是完全使用了 node 进行开发的 所以我对比了示例项目的代码,没有头绪,所以才请求帮助的
I did not completely use node for development, so I compared the code of the sample project and had no clue, so I asked for help. The project uses nextjs.
english only please
I did not completely use node for development, so I compared the code of the sample project and had no clue, so I asked for help. The project uses nextjs
ok. So how can I help you?
we have an example project for webhook signing in nextjs https://github.com/stripe/stripe-node/tree/master/examples/webhook-signing/nextjs
the recommendation is to get that working first as the webhook signing can be difficult, and then start augmenting it with your own code
I've taken a screenshot of the code I wrote and I think I didn't write it wrong
yep but clearly something is wrong, so now you start debugging 🙂
for example clearly log all the paramters passed to constructEvent and start from there, comparing them to what they should be
I currently cannot reproduce it during testing because the results returned on my working machine are correct.😫
maybe you deployed the live code with the wrong webhook signing secret?
like you deployed with the whsec_xxx from stripe-cli or your testmode endpoint, and not the one from the actual livmeode endpoint you created for this service in production.
you don't need to reproduce it, you can add logs and then check your server logs.
OK I'll try it
Just to confirm, can I still use the local webhook key in the deployed test environment?
what exactly is "the local webhook key"? do you mean the key that is printed in the output of stripe listen using stripe-cli?
yes exactly
then no, you can't use that. When you deploy your code somehere, you create an endpoint on https://dashboard.stripe.com/test/webhooks for the URL where your code is running, and that will give you a separate signing secret whsec_xxxx, which is what you then configure the code running at that URL to use.
Are you referring to this key?
I modified the key and it works fine, but if I have an endpoint how do I add it? I'm confused.
but if I have an endpoint how do I add it?
not sure I understand, can you explain in more detail? add what, to where?
抱歉我的问题让您没有听懂
not sure what you mean.
you have some code and you host it at example.com/webhook_A . Your code knows it's at webhook_A. Your enter that URL in the Stripe Dashboard and get a secret. You add that secret to the database/YAML file/whatever you to use to configure your code and load the value of the string to pass to constructEvent(you don't hardcode this stuff as strings in the actual code of course, in reality 🙂 )
you have some code and you host it at example.com/webhook_B . Your code knows it's at webhook_B. Your enter that URL in the Stripe Dashboard and get a secret. You add that secret to the database/YAML file/whatever you to use to configure your code
Let's put it this way, one endpoint corresponds to one request, right?
Example: I have set up webhookA and webhook B in the cli. Then I must write webhookA and webhookB in the code to process the two requests. Is this the case?
one endpoint corresponds to one request, right?
wrong
an endpoint is a URL, like https://example.com/webhook_A . At that URL you run a web server. That web server runs some code like that Javascript you have screenshots above. When something happens on your Stripe account, we create an Event object and we send you a webhook (a HTTP request) to your URl and your server runs that code to handle it. When something else happens on your account, we send you another HTTP request