#saucecode_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/1272990579751518354
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
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.
- saucecode_code, 17 hours ago, 11 messages
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?
Yes please. I am setting the JSON string that way as i currently do not know any other approach
What happens if you only pass cartItems without JSON.stringify() ?
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"}}
Hmm okay.. Thinking..
Are you using ruby? If so, try cartItems.to_s?
I am using next.js
oh interesting.. your metadata has symbols as keys.. I didn't know next.js uses symbols too
Yeah
I am really stressed out here
how exactly are you creating your cartItems?
I am creating the cart items according to this schema:
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
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"},
that's still not a javascript object?
hmm
I guess so
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.
Hmm
Alright
according to this: https://stackoverflow.com/questions/7503450/how-do-you-turn-a-mongoose-document-into-a-plain-object
There's a toObject() function you can use..