#Glutch
1 messages · Page 1 of 1 (latest)
Hello! Not sure I understand, can you provide more detail?
you can provide metadata to a new session, but it would be extremely convenient to add metadata to a single line item
You mean a Checkout Session?
yes
The line items in a Checkout Session are not independent objects, so they don't have independent metadata. If you were using Invoices, where Invoice Items are separate objects, those do support metadata: https://stripe.com/docs/api/invoiceitems/create#create_invoiceitem-metadata
What's your use case for wanting metadata for the line items in Checkout?
i sell customized products, where the customer uploads their own image to print
so adding the image to the product would be great
otherwise ill have to add some JSON.stringify object to the checkout metadata etc
You can add metadata to the Product you're generating with product_data: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items-price_data-product_data-metadata
Wait, the image?
Stripe metadata only supports strings.
Yeah, what do you mean?
But you can specify an image: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items-price_data-product_data-images
JSON.stringify = string
You said image, which is not a string.
oh wait
i dont see the image provided there when using stripe.checkout.sessions.listLineItems
i want to use the image url in the backend for stuff
That's because everything inside product_data is being set on the Product created by Checkout.
If you want to fetch that data from the API you need to fetch the Product.
but im not creating a product here, it's just a one time product not saved
You are creating a Product. Using product_data when creating a Checkout Session creates a Product: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items-price_data-product_data
Data used to generate a new product object inline.
You can retrieve the Product you create there using this API: https://stripe.com/docs/api/products/retrieve
when i browse stripe -> products, it just says "add your first test product"
so no product is saved from stripe.checkout.sessions.create(payment_object)
Products created using product_data do not show up in the Dashboard.
When you create the Checkout Session expand the line_items and then you should see the Product ID in there.
nice, it worked
im currently passing the thumbnail to product_data.images: [db_item.thumbnail],
if i pass 2 images, will the source file be shown somewhere? Why can this be an array?
You can pass up to eight images which should show up when you fetch the Product, but I believe Checkout only uses the first image.
It's an array because we may support more than one image in the future.