#naway_code

1 messages · Page 1 of 1 (latest)

sage veldtBOT
#

đź‘‹ 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.

rustic gazelle
#

Hi there. I'll be with you in just a moment

formal radish
#

fyi i'm taking over for palamedes! looking into your question now

silent berry
#

okok !!

formal radish
#

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?

silent berry
#

yes i'm listening checkout.session.completed

formal radish
#

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

silent berry
formal radish
#

it looks like you're creating these via a payment link right?

formal radish
#

what happens if you just log out the session you retrieve from this?

                obj["id"],
                expand=["line_items.data.price.product"]
            )```
silent berry
formal radish
#

it looks like the name is in there!

#

i think the issue is maybe with your code

silent berry
#

a ye i checked i

#

sorry i thinking it was the retrieve

formal radish
#

not sure what you mean by that?

silent berry
#

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

formal radish
#

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)```
silent berry
#

okay good it works ty!!