#simoneparis_code

1 messages ยท Page 1 of 1 (latest)

radiant raftBOT
#

๐Ÿ‘‹ 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.

blazing domeBOT
vivid gulch
#

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: "*/*" })

midnight bolt
#

Hi hanzo, i'm trying right now with your suggestion

#

Nothing, still got same errors :/

vivid gulch
#

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)

midnight bolt
#

it's a json. I tried looking in other places (even other files) but I don't use express.raw anywhere else

vivid gulch
#

I mean it could be something else not just express.raw

midnight bolt
#

i use only express.Router in each router file exept in index.js
app.use(express.json({ limit: '10mb' }));

#

could this be the problem?

vivid gulch
#

Yep that'd be it

midnight bolt
#

Uhm ok, it's a huge problem

vivid gulch
#

You can do something like
app.use('/stripe/webhook', express.raw({ type: '*/*' }));

after app.use(express.json({ limit: '10mb' }));

midnight bolt
#

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

vivid gulch
#

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

midnight bolt
#

Ok that was a suspicion I had, thanks for confirming. Sooner or later I will find the correct path ๐Ÿ™‚

vivid gulch
#

NP! ๐Ÿ™‚ Good luck