#redbluesock_code

1 messages ยท Page 1 of 1 (latest)

torpid driftBOT
#

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

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

sleek bear
#
{
  "id": "evt_1RiZqXINxfzIe4TvCmIxQUvP",
  "object": "event",
  "api_version": "2025-06-30.basil",
  "created": 1751974680,
  "data": {
    "object": {
      "metadata": {}, <--- here we want the data to show up
      },
    }
broken hatch
sleek bear
#

Yes, correct.

broken hatch
#

Looking at your code:
.putMetadata(METADATA_INVOICE_ITEM_TYPE, METADATA_INVOICE_ITEM_TYPE_VALUE_SUBSCRIPTION)
You're setting the top-level metadata parameter. Those key/values aren't passed through to underlying objects: https://docs.stripe.com/metadata#set-indirectly

Learn how to use metadata to save additional information.

sleek bear
#

Yes, we call putMetadata(...) on the SessionCreateParams.SubscriptionData.Builder and successfully add out values to the /data/object/parent/subscription_details/metadata element.
But we're processing different types of of invoices (like one time payments) where we need to differentiate in further processing. Unfortunately it's not possible to do this based on the line items.
So we looked for a field that is always available in all invoice webhooks whether it's an subscription or something else and found the top-level metadata field.

sleek bear
broken hatch
#

Can you share an invoice (in_xxx) where the metadata isn't copied? Using that evt_xxx above I can see the metadata in the hash I shared

broken hatch
sleek bear
broken hatch
torpid driftBOT
solid sigil
#

๐Ÿ‘‹ taking over for my colleague. Let me know if there's any follow-up Qs I can answer!

sleek bear
#

And this data is also passed via webhook?

solid sigil
#

yes correct

sleek bear
#

But we expect this metadata to show up in the invoice.payment_succeded event but this can't be the case since SessionCreateParams.builder().putMetadata(...) doesn't add metadata to the invoice, right?

solid sigil
#

yes you can add metadata to the invoice object

#

when you're creating an invoice

#

but if you're creating a Checkout Session, the top level metadata is on the checkout session object

#

not the invoice object

sleek bear
#

Okay sorry to be unclear but I think I see the problem. We'll try to SessionCreateParams.builder().setInvoiceCreation(SessionCreateParams.builder().putMetadata(...)... and check wheterh we get our metadata in the invoice.payment_succeded event.

solid sigil
#

no

solid sigil
sleek bear
#

Yes okay, I'll get back to our developers since I see I am not sufficiently familiar with the subject to elaborate. They've told me they can't set the specific metadata field on the invoice but I think they can work with the suggested solution.
Thanks for your help!

solid sigil