#onkel_api
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/1273269679875428382
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hello
You can retreive the checkout session's line items using checkout session ID: https://docs.stripe.com/api/checkout/sessions/line_items
What sort of data are you trying to map?
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?
No, that's expected. See: https://docs.stripe.com/checkout/fulfillment?lang=node
The doc above has step by step guidance on fulfillment with checkout
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 ๐
NP! ๐ Happy to help
Can you provide an example of how to read and expanded object in Stripe.NET?
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
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 ๐
All good, are you setting any metadata on the checkout session when you create it?
Where exactly are you setting it?
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?
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
but there is not metadata per line_item? correct?
I would like to match line items to items in the original cart
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
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"?
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
SessionLineItemPriceDataProductDataOptions doesnt seem to have a MetaData property
If you look at the API ref: https://docs.stripe.com/api/checkout/sessions/object#checkout_session_object-line_items-data-price-product
The product is expandable. So you'd need to expand a bit deeper for product data to show up..
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Like this?
Expand = ["line_items", "line_items.data.price", "line_items.data.price.product"]
Yeah try it out?
On it. Thanks ๐