#luizcarlosfx-checkout-product

1 messages ยท Page 1 of 1 (latest)

runic flax
#

Hi ๐Ÿ‘‹ can you elaborate?

quiet basin
#

yeah, I was just waiting for the thread lmao

#
Stripe.Checkout.SessionService service = new Stripe.Checkout.SessionService();
            var lineOptions = new SessionListLineItemsOptions();
            lineOptions.AddExpand("data.product");
            StripeList<LineItem> lineItems = await service.ListLineItemsAsync(session.Id, lineOptions);
            Console.WriteLine(lineItems.Data[0].Product.Name);
#

this is my code, I want to get the lineItems product name

#

but I'm getting an error saying that I can't expand data.product

#

btw I forgot to add the expand in this code snippet

#

I basically want to be able to know witch product the user just purchased

#

This property cannot be expanded (data.product).

#

I can get the product id from the pricing though, but I'd have to make another request to get the product name

runic flax
#

Apologies for the delay, can you share the ID of a request where you received that message? It'll help me see exactly what you're doing.

quiet basin
#

the session id?

#

cs_test_b1qvdqyfS7Wj7LVEp2fu9TGMUR9FRrWXRt3kILgWggWsTidVzzqUyOMYzMl

#

this is the session id

#

I'm not sure if that's what you need

runic flax
#

No, that won't be too helpful here. Are you retrieving a single Checkout Session, or listing multiple?

quiet basin
#

I'm listening to the events

#

then when I get the checkout complete event I try to list the line items for that specific checkout

runic flax
#

Directly from the event?

quiet basin
#

I can successfully list the line items, but I can't get the product expanded

quiet basin
#

I get the session Id and make a new request to list the line items

#

StripeList<LineItem> lineItems = await service.ListLineItemsAsync(session.Id, lineOptions);

runic flax
#

Oohh, okay, that was the piece that hadn't clicked for me (you're making a request to retrieve the line items for a session).

quiet basin
#

list the items with this api

runic flax
#

The Product information is contained inside of the price hash in those results, so you'll want to expand data.price.product

quiet basin
#

let me try that

runic flax
#

๐Ÿ‘

quiet basin
#

that works, thank you

#

I tried expanding data.product because the LineItem class also have a "product" property