#B33fb0n3YT-webhook
1 messages ยท Page 1 of 1 (latest)
@frosty ginkgo you say "it doesn't work" but without much more details. What event are you parsing? Does that event have lines? What is in the event right now, did you log all the details to compare? Do you have an event id evt_123?
yes. It have lines
I get an object with an id and an object "invoice".
you say "it doesn't work" but without much more details
the code inside the if statement should only be executed, when the statement is true. But it isn't when I buy another product.
What else do you need?
if (req.body.data.object.lines.data[0].plan.id === "price_myspecificpriceID") {
that is a complex if, deep into a nested structure. What does req.body.data.object.lines.data[0].plan.id return? what does req.body.data.object.lines.data[0].plan return? and also what does req.body.data.object.lines.data[0] return?
I dont know. You now I am normaly frontend developer. Normaly I would do something like this console.log(yourdata). How does it work if I want to check your values in the backend and where can I see the results?
yeah that's why I'm asking those questions. Right now you seem to assume you just access the json this way and that it's set but my guess is that req.body.data is null in the first place in your code here. That's usually not what the webhook handler looks like. Have you gone through our integration builder in this case: https://stripe.com/docs/webhooks/integration-builder ?
Overall for logs, you want to write to a file, that's the most common approach to debug this. You put a lot of logs to a file during your code to debug each step the way you would with console.log
Have you gone through our integration builder in this case:
No I dont. I rebuilded now my webhook handler.
If I just use console.log() for my logging, does the file creates itself?
It does not, that would output to wherever your console output is for your server-side code. It's hard to say without knowing your set up and more details. How do you usually debug your server-side code though?
I never code in backend. It's just for Stripe ๐
Because I never done it, I don't know, where my debug is going. I using aws amplify. Does this information help you?
I've never used it but it does make things more complex: https://stackoverflow.com/a/68584243/1606729 might help?
But yeah you're better off logging to a file I would say and looking at that file on your server, but I assume writing to a file is hard on that stack too
yes. I found this: https://docs.amplify.aws/lib/utilities/logger/q/platform/js/
It's just the same thing... i am trying it now...
no... does not see it. I think because stripe executes the webhook it's only in the stripe console?
Currently I checking the webhook calls and the result... I see there isn't any lines... but I cannot find any priceID as well ๐ค
sorry, you are trying to just make this work without really understanding the whole pipeline, in parts because you're not familiar with server-side code
You really need to go step by step:
1/ figure out how to receive the event and parse it.
2/ save/log the event
3/ slowly parse more complex information out of the event
yeah thats right
Step 1: finish.
Step 2: can I use the log of stripe?
Step 3: maybe call the invoice id and get trought this the priceid
what does "the log of stripe" mean? Stripe has not log function so I don't really understand.
I mean this:
You could try to send a response back instead of OK and have that response contain the relevant information, but I think you'd be better off spending an hour familiarizing yourself with accessing logs for AWS amplify honestly
why?
because, as a developer, you really need to understand this. It's impossible to write code that complex without being able to do simple log debugging. You haven't even started looking at signature verification which you might spend 3 days on
signature? ๐ค
oh well