#Parthian
1 messages · Page 1 of 1 (latest)
So here, the metadata would be set on the product itself. Even when you are creating products inline like that, there is a product object created by Stripe. If you want to get this, you will likely need to retrieve your Checkout Session's line items and expand the product field on them.
Or you can put the metadata at a higher up level on the Checkout Session itself, in which case it will be included as part of that initial webhook event
I've found Retrieve line-items on Postman. And through that I've realised that product: "prod_blahblah" isn't the same as List all Products - which only shows the 'fixed' products in https://dashboard.stripe.com/test/products?active=true. Which is why I could never see my dynamic products metadata. That's a great help. Magic.
I don't think I can raise up to the higher metadata as there will be more than one line-item each needing it's own metadata. I've a feeling that none of the Events will transfer over the product directly. Maybe a series of API call from endpoint code?
@meager nest sorry for the confusion
the problem here is that you are putting the metadata on the Product itself and not the Session
If you put it on the Product, you have to get to that object to see the metadata. A Checkout Session has LineItems in line_items, each LineItem has a Price in price and each Price has a Product in product. It's like a long list of connections/hierarchy
So when you retrieve the Checkout Session you can use our Expand feature https://stripe.com/docs/expand to then retrieve all linked objects at once. We document it here https://stripe.com/docs/expand#includable-properties and you can basically expand line_items.data.price.product and then you can access line_items.data[0].price.product.metadata
Found this - Using Expand with Webhooks
You can’t receive webhook events with properties auto-expanded. Objects sent in events are always in their minimal form. To access nested values in expandable properties, you must retrieve the object in a separate call within your webhook handler.
correct you need the extra API request