#matt-jones-siteglide-sitegurus_api

1 messages ยท Page 1 of 1 (latest)

wispy juniperBOT
#

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

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

sacred wren
#

hello! juggling a few other threads atm, gimme just a bit

hazy tulip
#

No problem! Take your time, thanks

sacred wren
#

aaand i'm back, reading up on your question now

#

ok just making sure i understand your end goal here, it would be to make it so the values you're currently passing in line_items[0].price_data.product_data.metadata are reflected in the invoice line item in that event, right? so you would expect to see it in lines.data[n].metadata or something?

#

the way you're currently passing it is setting it on the product, so if you retrieved the invoice and expanded lines.data.price.product you should see it

hazy tulip
#

Thanks, checking that

#

Yes, I'm setting on line_items[0].price_data.product_data.metadata.siteglide_cart_item_id

and looking for the result on data.object.lines.data[0].metadata.siteglide_cart_item_id

I think you might be saying if I put it a bit higher it might work without an extra API call, or if I make an extra API call to expand the webhook.

#

On line_items[0].metadata.siteglide_cart_item_id

#

Actually it looks like I am already also setting metadata on line_items[0].metadata.cart_item_id I must have done that on a previous attempt.

#

Yet the webhook sends data.object.lines.data[0].metadata to be {}

#

Do I just need to do an API call to expand that?

wispy juniperBOT
hazy tulip
#

Sorry I just thought I had solved the issue, but I was looking at the request, not the webhook, so it remains unsolved.

sacred wren
#

FYI we're still looking at this, will get back to you with more details soon

dense harbor
#

๐Ÿ‘‹ taking over for @sacred wren

hazy tulip
#

Hi,

#

https://dashboard.stripe.com/acct_1SytRpJNiKvHd4vK/test/products/prod_UT40nbO5wKH10I Looking at this link, the metadata does exist against the archived product.

I also have successfully set metadata against the root of the invoice, since that was an easy option in the invoice creation object. https://dashboard.stripe.com/acct_1SytRpJNiKvHd4vK/test/invoices/in_1TU7tjJNiKvHd4vKh8dGhpwO

There is no metadata stored against the price of the archived product: https://dashboard.stripe.com/acct_1SytRpJNiKvHd4vK/test/prices/price_1TU7suJNiKvHd4vKyh4xHuEx|

I am not sure where in the dashboard I can check the invoice line item and its current metadata. il_1TU7IdJNiKvHd4vKgRxM9Zrx doesn't seem to find anything in dashboard with search. I can try an API request next.

dense harbor
#

My understanding of your problem is that you're passing metadat on your Checkout Session's line items and are unclear why this is not populated on your Invoice Line Item's metadata. There are very few cases where metadata is copied from one object to another (exceptions are outlined here). Unfortunately, metadata isn't copied from a Checkout Session Line Item to an Invoice Line item. As a workaround, you can listen for checkout.session.completed Events, pull the metadata from the Event's data, and update your Invoice Line Item's metadata with an API call.

hazy tulip
#

I see. The original problem I'm trying to solve is to accurately identify which invoice line item refers to which original line item.

If I am confident enough to know which is which to update the metadata, then I already know which is which. This is a chicken and the egg problem.

I suppose the index of the line item is a safe way to refer to it? The invoice will never show line items in a different order from the original line items?

#

I didn't want to assume that originally

dense harbor
#

If you pass reusable price objects instead of price_data when creating your Checkout Session's line_items, that could help with reconciling your Invoice's line items

hazy tulip
#

How would that behave differently?

#

It is not ideal, as it would require a lot of extra work to handle prices being updated on the platform. So would need to be sure it was the best way before starting ideally.

rugged narwhal
#

Hey there, sorry for the wait - taking over for Janet here

#

I think they were just pointing out that if you used reusable prices then the mapping from the Checkout Session's line items to the Invoice's line items would be more reliable because you have an id you could reference, but I see your point

hazy tulip
#

Ah because both would refer to a common price_id automatically? Because while metadata is not copied across from session lines to invoice lines, everything else is?

#

Do the invoice line item and the checkout line items not refer to each other's IDs at all then?

rugged narwhal
#

I think the Invoice Item would reference the specific Price id but I would recommend testing it to vet that, which I can do in a few minutes

#

Do the invoice line item and the checkout line items not refer to each other's IDs at all then?

No, they are completely different things. It is a sort of unfortunate semantic overlap with respect to the terms "line items" / "invoice items"

hazy tulip
#

I see...

#

I think either "Description" or index of the line item seems like the best option to me for now. It seems like there is a chance it is not a reliable method, but it's easy enough to test that.

#

Is it possible to make this into a feature request for a future improvement? Either to copy the metadata across or store an ID to the original checkout session li? It seems to be a feature for subscriptions, so perhaps makes sense to store some reference for payments as well?

#

Thanks for explaining

rugged narwhal
#

Yeah, we've had a lot of feedback over the years about this and similar instances, which is sort of generally against the way Stripe works, as the doc that janet sent you sort of discusses