#coldrain-checkout
1 messages · Page 1 of 1 (latest)
Can you share the error that you're facing when using metadata?
It works when it's outside line items
now I'll map, wait a second and show u error
"Invalid value type: {:item=>{:name=>"Amira", :_createdAt=>"2022-08-29T13:29:25Z", :quantity=>"1", :_type=>"product", :_updatedAt=>"2022-08-29T13:36:44Z", :image=>{:"0"=>{:_type=>"image", :_key=>"60cb05945adb", :asset=>{:_type=>"reference", :_ref=>"image-22ce77c63db11e3e482e73bd086f5d744d3c69d2-1500x2250-jpg"}}}, :price=>"672", :_rev=>"jmTP3LYrZrN0wRtRCwXwwl", :dress=>{:height=>"123", :waistToEnd=>"123", :shoulderToEnd=>"0", :bustSize=>"123", :shoulderToWaist=>"123", :sleeveLength=>"123", :waistVolume=>"123", :dressLength=>"123"}, :details=>"fdsfsdf", :_id=>"11bc0914-e593-411e-8305-8ffa0033d4c1", :slug=>{:_type=>"slug", :current=>"amira"}}} must be a string"
I'm trying to map my object
with my metadata
Thanks for sharing
It looks like you're passing metadata value an object
Metadata value accepts string, not object
You should convert it into into string from object before setting into metadata
You can convert it into json string
Why do you want to store dress object with Stripe?
The metadata value has 500 characters limit: https://stripe.com/docs/api/metadata
I need those parameters
It can potentially be trimmed off if the final string is more than 500 characters
it's not
so how can I convert it in JSON ?
I've made it
but why I don't see any info here?
The page you are in is Payment Intent metadata, not Checkout Session metadata
To set Payment Intent metadata, you should also set metadata in payment_intent_data.metadata: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-payment_intent_data-metadata
You can refer to the doc here: https://support.stripe.com/questions/using-metadata-with-checkout-sessions
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
I was reading it, but I dont get why your api dont let to pass an object, it would be much easier
Is there a better solution to make it more beatiful?
it can't be object because other languages like Java and C# require typing
on the backend?
yup. the object type is defined by user's server and stripe doesn't know, so we can't store as an object, but the universal string that accepts by different languages
the intention of metadata is also not to store to object
but the reference to the object such as order ID
nope
so if I want to make it more beautiful I need to make my own server and req my metadata and JSON it. Right?
Two last questions. What happen if metadata exceeds 500 char limit?
If I get 501, 502 etc error from stripe API it will cause my app to crash? Do I need to add more?
What happen if metadata exceeds 500 char limit?
Stripe will return 400 error
If I get 501, 502 etc error from stripe API it will cause my app to crash? Do I need to add more?
From the code, this seems to fine, but it'll depend how your frontend handles 500 error from your server
its next js server
Ok. Thank you so much for your help.
No problem! Happy to help
And last one. Do I need to enter a color of a dress in a metadata?
That's up to you since metadata is for your own reference and Stripe doesn't use information from metadata
I think I cannot make color visible in a checkout page?
What are you trying to achieve? Metadata is for your reference and not visible to checkout page
I'm not talking about metadata. I'm asking about a color selected by user in a stripe checkout page
I don't understand question. Do you mean you want to display the dress color in text somewhere in the checkout page?
y
Is this possible?
One possible way I think of is to add the color in the product description, line_items.price_data.product_data.description: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items-price_data-product_data-description