#saucecode_code

1 messages ¡ Page 1 of 1 (latest)

median heartBOT
#

👋 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/1272990579751518354

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

austere vaporBOT
#

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.

glass valley
#

Hello
Are you setting the whole JSON string as the value to cartItems ? In that case, the error may be expected as we have 500 character limit for value

#

Is there a reason you're converting it to JSON instead of passing cartItems as object?

glass rain
#

Yes please. I am setting the JSON string that way as i currently do not know any other approach

glass valley
#

What happens if you only pass cartItems without JSON.stringify() ?

glass rain
#

I get this error:
StripeInvalidRequestError: Metadata values must be strings, but for key cartItems you passed in a value of type hash. Invalid value: {:"0"=>{:quantity=>"1", :customizationData=>{:prim=>"#FF5733", :frontT=>"Custom Logo", :backT=>"Player Name"}, :_id=>"6672c9de1203b7a9f63f38be"}, :"1"=>{:quantity=>"1", :customizationData=>{:prim=>"#FF5733", :frontT=>"Custom Logo", :backT=>"Player Name"}, :_id=>"66686bc3b88e0eb0848bc0f0"}}

glass valley
#

Hmm okay.. Thinking..

Are you using ruby? If so, try cartItems.to_s?

glass rain
#

I am using next.js

glass valley
#

oh interesting.. your metadata has symbols as keys.. I didn't know next.js uses symbols too

glass rain
#

Yeah
I am really stressed out here

glass valley
#

how exactly are you creating your cartItems?

glass rain
#

I am creating the cart items according to this schema:

glass valley
#

can you try printing JSON.parse(JSON.stringify(cartItems)) ?

#

so what you'd need to do is basically convert mongoose object to a javascript object and pass that as metadata

glass rain
#

Trying it now

#

Same error:
StripeInvalidRequestError: Metadata values must be strings, but for key cartItems you passed in a value of type hash. Invalid value: {:"0"=>{:quantity=>"1", :customizationData=>{:prim=>"#FF5733", :frontT=>"Custom Logo", :backT=>"Player Name"},

glass valley
#

that's still not a javascript object?

glass rain
#

hmm
I guess so

glass valley
#

I'd recommend referring to mongoose docs and checking how you can convert it to Javascript.

This isn't something we'd be able to help with since we mainly just focus on Stripe API/SDK.

glass rain
#

Hmm
Alright

glass valley