#danilabagroff

1 messages ยท Page 1 of 1 (latest)

arctic nicheBOT
#

Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

potent tundra
#

๐Ÿ‘‹ happy to help

#

I'm not sure I follow, would you mind sharing some examples?

ruby crag
#

Hi! Thank you for joining me.

#

first example - everything works as expected

#

I can see crn in the root metadata

#

but if i create a subscription with Subscription.create...

potent tundra
#

you want to have the metadata on the invoice rather than on the subscription?

ruby crag
#

...metadata is empty

potent tundra
#

what object are you looking at in the last screenshot?

#

would you mind sharing its ID

ruby crag
#

in_1MPPuREPcSoIRKCHG0Hgukpq

potent tundra
#

taking a look

#

so basically the metadata of the subscription won't be copied to the invoice but rather to the invoice line items

ruby crag
#

yes, which is confusing a bit, because lines passing separately and each line supposed to have its own metadata as far as I understand

#

so, we supposed to call

#

stripe.Subscription.create(metadata = {}, items = [])

potent tundra
#

what you can do is basically listen to the invoice.created event and if subscription on the invoice object isn't null you can retrieve the subscription object and manually copy the metadata to the invoice

ruby crag
#

but what do you think: is this a bug or by design?

potent tundra
#

no it's by design

#

I'm not sure what the reason behind it is. but I double checked and it is by design

ruby crag
#

this means that I cannot pass metadata for each line in the items list

#

... but just one common metadata will be used for all items

potent tundra
#

you can, they will get aggregated

arctic nicheBOT
ruby crag
#

honestly speaking, I cannot agree with such design, but it costs to me just one extra call to API - not a critcal issue but not so comfortable as I am used to working with Stripe ๐Ÿ™‚

summer ivy
#

๐Ÿ‘‹

#

Stepping in

#

Is the confusion here about how to see Subscription metadata on Invoices?

ruby crag
#

and yes, I reckon that this metadata should be used like Invoice.create() uses same argument

summer ivy
#

Yeah metadata passed at the top level of a Subscription object won't appear within items. However, when looking at an Invoice you can look at the subscription_details.metadata to see metadata set at the Subscription's top level.

ruby crag
#

in my case both metadatas are empty

summer ivy
#

Then you didn't set metadata at the top level of that Subscription

ruby crag
#

This is how I am trying to achieve this

summer ivy
#

Yeah that looks fine

ruby crag
#

but this metadata goes here

summer ivy
#

Let's back up.

#

What are you trying to do?

#

Why do you care about this metadata

ruby crag
# summer ivy Why do you care about this metadata

because separate business logic depends on this metadata and I need to keep this key in the root metadata or root subscription_details.metadata but not as a metadata of each line within il_object what have no sense

ruby crag
summer ivy
#

Can you share that Subscription Id from your screenshot?

ruby crag
#

sub_1MPPuQEPcSoIRKCHAmmaWIgz

summer ivy
#

Okay yeah so you have the metadata you are talking about set on your Price. So if you don't want that you just remove it from your Price object?

ruby crag
#

I don't bother you with this, anyway I am trying now to modify invoice straight after. Just final recap:

#

Where this metadata will be used?

#
  • In the root of in_object, right?
summer ivy
#

Yes

ruby crag
#

same question about this metadata?

#
  • in all items of lines, right?
summer ivy
#

No

#

Root of Subscription and in subscription_details.metadata of the Invoice

#

The lines metadata comes from metadata you set on your Price objects

ruby crag
ruby crag
summer ivy
#

Have you created a fresh test-mode Subscription today to test it out?

#

Since you don't believe me, that is the next step

ruby crag
summer ivy
#

Well, subscription_details.metadata was added in the past year

#

So yeah that won't show up on old Invoices

#

It was specifically added in July of last year

ruby crag
#

anyway, I need to fix metadata of all subscriptions and I will come back with minimal reproducible example if you need one, but a bit later

summer ivy
#

That sounds good. A fresh test that we can look at together is the best way to go.