#simoneparis_code
1 messages ยท Page 1 of 1 (latest)
๐ 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/1225840995262922774
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
The first issue is most likely related to express.raw({ type: "application/json" })
Your code is parsing the incoming payload as JSON and the stripe SDK expects it to be raw
Try changing it to express.raw({ type: "*/*" })
Hi hanzo, i'm trying right now with your suggestion
Nothing, still got same errors :/
Do you have code similar to express.raw({ type: "application/json" }) anywhere else in your file?
Try printing request and see if it's JSON or buffer.
It should be a buffer unless you're parsing the incoming request somewhere else (globally)
it's a json. I tried looking in other places (even other files) but I don't use express.raw anywhere else
I mean it could be something else not just express.raw
i use only express.Router in each router file exept in index.js
app.use(express.json({ limit: '10mb' }));
could this be the problem?
Yep that'd be it
Uhm ok, it's a huge problem
You can do something like
app.use('/stripe/webhook', express.raw({ type: '*/*' }));
after app.use(express.json({ limit: '10mb' }));
Ok, it seems to work. Many thanks for this. but I still have this other problem:
Error retrieving user subscriptions: StripeInvalidRequestError: No customer 'cs_test_'
and honestly I don't understand if it comes from the webhook or from the initial POST call when I try to create the session with checkout.sessions.create
Based on the error:
Error retrieving user subscriptions: StripeInvalidRequestError: No customer 'cstest'
It is coming from your code that's trying to retrieve subscriptions
Customer object prefix is cus_xxx
Your code makes the API call for cstest which isn't a valid customer ID.. You'd need to debug your code to see what's being passed in to the API call and fix it to pass a valid customer ID
Ok that was a suspicion I had, thanks for confirming. Sooner or later I will find the correct path ๐
NP! ๐ Good luck