#Pdot-checkout-custom-field
1 messages ยท Page 1 of 1 (latest)
Thank you
You can retrieve the line_items for a checkout session using the API if that works with your flow
https://stripe.com/docs/payments/checkout/custom-success-page
yes I am already sending the items to be purchased via line_items
whoops I pasted the wrong link.
https://stripe.com/docs/api/checkout/sessions/line_items?lang=node
my question is, if there is a field that can hold the type of product, so once I recieve it on the /success page I can perform logic based on if the product purchased had the type of "tech" or "digital tool"
oh actually I see there is a metadata that gets returnd in the link you just send
yup I was going to mention just that ๐
so directly in the line_items array of objects, I can pass in something like this?
line_items = [{"name": "test", "quantity": "1", "amount": 9999, "metadata": {"type": "tech"}}]
sounds good, I'll give it a go. Thanks for the help
NP! ๐ Good luck
I was able to create the checkout with the metadata but upon getting to the success page and calling the session, the meta data seems to be empty.
but that's the checkout session metadata though, you're setting metadata on the line items in the code
is there a way to grab the line items in the session potentially? applogies, its my first day with stripe
No worries at all. I believe you need to expand the line items here
An example: https://stripe.com/docs/expand#includable-properties
thanks, let me give that a go
ahhh I was able to expand the session to include Line items but metadata still seems empty.
just making sure the metadata goes inside the product_data and not outside?
yup I believe so. On the flip-side, I think you can also set metadata on the session object itself.
thank you, I am trying to save a few db calls and not place it on the session object. I would really prefer it to be on line_items. Really not sure why its not working.
do you have a request ID for the session creation?
I can take a look
it should look something like req_xxxxx
You'd find it under logs
https://dashboard.stripe.com/test/logs
thanks. looking
ah I see what happened there
the metadata is actually linked to the product since we're basically setting it as product_data[metadata]
I am assuming there is a way to expand product_data lol
you bet ๐
expand: ['line_items.data.price.product']
NP! ๐ Glad that worked
you have a great rest of the day