#naway_code
1 messages · Page 1 of 1 (latest)
đź‘‹ Welcome to your new thread!
⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
đź”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1407411077687414794
📝 Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi there. I'll be with you in just a moment
fyi i'm taking over for palamedes! looking into your question now
okok !!
ok, just to summarize, you're listening to an event which is returning a checkout ID, and you want to use that to retrieve the product name?
yes i'm listening checkout.session.completed
the expansion you've provided looks correct to me
can you share an example checkout session you've tried this with?
ok yeah, i just tried this on a few API versions just to make sure it isn't something that changed recently and it looks like it works on the most recent version as well as a few I tried from 2024 at least
cs_test_a1VSy1OZg6kn3kkSIYnUQgEnBfGKww7TrPxme3rNl7KKZgbR0HNFGE7fdd
i did that bc its the name of the product i need but doesn't work
session = stripe.checkout.Session.retrieve(
obj["id"],
expand=["line_items"]
)
items = session.line_items.data
product = ""
if items:
product = items[0].description or ""
it looks like you're creating these via a payment link right?
what happens if you just log out the session you retrieve from this?
obj["id"],
expand=["line_items.data.price.product"]
)```
not sure what you mean by that?
I initially thought the issue was on Stripe’s side (the session not returning the name), so I hadn’t tried pulling it manually and inspecting it end‑to‑end. I just checked and the session payload does include it.
So it’s on my side: my webhook code must not be reading the field correctly in the code path that builds the email. I’ll add logs around session.line_items.data[0].price.product.name (and fallback to line_items.data[0].description) to see where it’s getting lost.
ty for ur help anyway
makes sense. i did test your code real quick (in a slightly different form) and it actually works just fine for me
session = stripe.checkout.Session.create(
line_items=[
{
'price_data': {
'product_data': {
'name': 'Test Product'
},
'unit_amount': 1000,
'currency': 'usd'
},
'quantity': 1
}
],
mode='payment',
success_url='https://google.com/success',
cancel_url='https://google.com/cancel',
expand=['line_items.data.price.product']
)
items = session.line_items.data
product = ""
if items:
prod = items[0].price.product
product = prod.name
print(product)```
okay good it works ty!!