#arrow-pricingtable-product
1 messages ยท Page 1 of 1 (latest)
hey @static citrus. The line_items property on Checkout Session is documented here: https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-line_items
It's marked as Expandable which means it's not returned by default or in the Event. What you need to do instead if retrieve those explicitly. This is documented here: https://stripe.com/docs/expand#includable-properties
@gritty ferry Thank you for the quick response but this is for custom retrival I am using webhook ... so when checkout session success event is fire i get response and it does not show meta data for the product bought I don't know how to know for which product the complete session event is for. The document you shared is for retriving the session info and I am not doing that I am using webhook
Sure but what you want to do is impossible. So you need to do what I said instead. When you get the Event on your webhook endpoint, retrieve the Session and get the line_items at the same time and other related data like the Price and the Product. Use the Expand feature I mentioned: https://stripe.com/docs/expand
cool thx
hello sorry to ping you again it's not that metadata key is not present in the response but it's empty for expand does it come empty ?
@gritty ferry
Hi there ๐ taking over for @gritty ferry as they had to step away
Give me a couple minutes to get caught up.
What are you wanting to do with metadata? That field is used to set arbitrary key/value pairs on different Stripe objects and has nothing to do with Product or Price
just to clarify: you said you put the metadata on the **Product so you have to look on the Product object, not the Checkout Session's metadata
yes
meta is product not checkout session I don't have control over checkout bcz i am using price table
You'll want to expand line_items.data.price.product to get metadata from the Product then.
I have no information about for which product a user paid for in the current session success event reponse ... I am using price table feature no custom implemenation of anything
You'll want to expand
line_items.data.price.productto getmetadatafrom the Product then.
Can you try expanding the Product object and looking there?
line_items.data is array will it be alway 1 element in array ?
even in there meatadata is empty
my product does have metadata
@arctic spoke
also everything is in test mode if needed I can share eventID
Not necessarily. It could be multiple, depending on if you have other Prices included for payment on the Checkout Session
Where are you setting metadata? Also, maybe more importantly, when are you setting metadata in the lifecycle of the charge?
Yes, those are safe to share here. Pretty much all Stripe object IDs are safe to share here
ok I have wrote 0 code for doing any of this. I created 3 products from the dashboard using UI then i created pricing table which contains this 3 products then I created a html file and rendered the price table using the embaded code
Then i created webhook to view the events and know when the payment is completed by user. Then I views the webhook event "checkout.session.completed" and it gave me a response "id": "cs_test_a1jaxsWfcEQW4zK90RFcVbe6BRVsEBiR96tyMchXin7fqGhGJqsxfNFwlv",
this is the ID I don't mind using another event webhook I used this bcz it has custom client ref id so i know which user paid and now I want to know what the used paid for @arctic spoke
Okay, but where/when are you setting metadata? It's not implicit on the object. You have to set it yourself either manually from the Dashboard or via the API in order for anything to populate it
yes I shared the screenshot already see here while I am creating product they ask for metadata and I created it there in dashboard
@arctic spoke
@arctic spoke
@static citrus please be patient. The server is busy and I'm juggling a few other threads.
The screenshots you sent did't show Product getting expanded. Can you share (a) the Event ID where you expanded Product and (b) copy/paste the Product ID for me to look at?
no worries take your time I have shared everything there are 3 screen shorts 1st the lineItem the 2nd with product expand and 3rd which shows metadata is set a dashboard view I am re-replyting in here and I also shared event ID but here it is again
"id": "cs_test_a1jaxsWfcEQW4zK90RFcVbe6BRVsEBiR96tyMchXin7fqGhGJqsxfNFwlv",
and product ID is "prod_MViAugbLD0TmKA" priceID is price_1LmgkGEyoRNqUErOtnRdPzho
1st Screenshot
2nd screen show with product expand
3rd screensort of the dashboard showing the metadata is set
@arctic spoke
Right, but Product is not expanded int he 2nd screenshot. It only shows Price object and the ID of the Product
the second screenshot is output of line_items.data.price and I don't know what you mean by product is not expanded ... I added product is expand as well which give error it can't be expand
@arctic spoke
Product should be expandable: https://stripe.com/docs/api/checkout/sessions/object?event_types-payment_intent.payment_failed#checkout_session_object-line_items-data-price-product
You need to make sure you're expanding line_items.data.price.product not product
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.