#onkel_api

1 messages ยท Page 1 of 1 (latest)

river phoenixBOT
#

๐Ÿ‘‹ 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/1273269679875428382

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

hasty halo
#

What sort of data are you trying to map?

sacred turtle
#

so i have to do an additional api call?

#

I wanted to create an order listing in our system based on the checkout ession completed event

#

but mayby i'm going about the wrong way?

hasty halo
sacred turtle
#

Our app is based on "Click and Collect", so the consumer would go to the shop and pickup hes stuff. So we do "manual" fullfillment

#

The shop owner press a "Delivered" button on the order.

#

When the customer has pciked the item(s) up

#

arh, i see. i can use the same code. i think the example clarifies it. thanks ๐Ÿ‘

hasty halo
#

NP! ๐Ÿ™‚ Happy to help

sacred turtle
#

Can you provide an example of how to read and expanded object in Stripe.NET?

hasty halo
#

Not sure I follow, you mean looking at line items once you've expanded it? I don't know if we have any examples of that but if you change the example lauguage to .NET, it shows how you can access properties on checkoutSession object

#

The API ref shows, it'd be a StripeList<LineItem> object

sacred turtle
#

but how does the expand option work?
new SessionGetOptions
{
Expand = ["line_items"]
}

#

the object returned is still a Checkout Session with StripeList<LineItem> LineItems (still no metadata)

#

Sorry, if i'm slow ๐Ÿ˜„

hasty halo
#

All good, are you setting any metadata on the checkout session when you create it?

Where exactly are you setting it?

sacred turtle
#

give me 2 min

#

var checkoutSession = await sessionService.GetAsync(message.CheckoutSession.Id, new SessionGetOptions
{
Expand = ["line_items"]
});

    var lineItems = await sessionService.ListLineItemsAsync(checkoutSession.Id);

Should i call "ListLineItemsAsync" after calling "GetAsync". And if i understand the "Expand" option correct, this only results in one api call?

hasty halo
#

I don't believe you'd need ListLineItemsAsync call separately if you're already expanding line_items when you get a checkout session using sessionService

checkoutSession variable in should have an object that has line items included

sacred turtle
#

but there is not metadata per line_item? correct?

#

I would like to match line items to items in the original cart

hasty halo
#

correct there's no metadata per line item when you create checkout session..

An alternative could possibly be that you define metadata on the price object itself (where price.metadata.some_id == product id in your DB)

#

Then along with line_items, you also expand price

sacred turtle
#

yes, i already did that actually, like this for each line item:
return new SessionLineItemOptions
{
PriceData = new SessionLineItemPriceDataOptions
{
ProductData = new SessionLineItemPriceDataProductDataOptions
{
Name = product.Name,
Metadata = { ["OfferedProductId"] = x.OfferedProductId },
Images = [$"https://localhost:3399/{imageStore.GetImageUrl(product.Image)!}"] // TODO: absolute url
},
Currency = company.CurrencyCode,
TaxBehavior = "inclusive",
UnitAmountDecimal = product.Price * 100,
},
Quantity = x.Quantity,
AdjustableQuantity = new SessionLineItemAdjustableQuantityOptions { Enabled = true },
};

#

Where do i find the pricedata?

#

Is it "checkoutSession.LineItems.Data.Single().Price.Metadata"?

hasty halo
#

Price Data creates an inline price

#

yup

#

You seem to be passing the metadata on the product object though

#

So you'd need to expand product..

OR you can set metadata under price data on creation

sacred turtle
#

SessionLineItemPriceDataProductDataOptions doesnt seem to have a MetaData property

hasty halo
sacred turtle
#

Like this?
Expand = ["line_items", "line_items.data.price", "line_items.data.price.product"]

hasty halo
#

Yeah try it out?

sacred turtle
#

On it. Thanks ๐Ÿ™‚

river phoenixBOT