#danilabagroff
1 messages ยท Page 1 of 1 (latest)
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.
- danila-list-pagination, 1 day ago, 11 messages
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...
you want to have the metadata on the invoice rather than on the subscription?
...metadata is empty
no, i need both
what object are you looking at in the last screenshot?
would you mind sharing its ID
in_1MPPuREPcSoIRKCHG0Hgukpq
taking a look
so basically the metadata of the subscription won't be copied to the invoice but rather to the invoice line items
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 = [])
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
but what do you think: is this a bug or by design?
no it's by design
I'm not sure what the reason behind it is. but I double checked and it is by design
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
you can, they will get aggregated
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 ๐
๐
Stepping in
Is the confusion here about how to see Subscription metadata on Invoices?
metadata passed to stripe.Subscription.create(...) used as metadata for all items instead of using metadata passed to Product.create() or Price.create()
and yes, I reckon that this metadata should be used like Invoice.create() uses same argument
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.
Then you didn't set metadata at the top level of that Subscription
This is how I am trying to achieve this
Yeah that looks fine
but this metadata goes here
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
as I said earlier - not a big deal, I can modify metadata straight after Subscription.create(...)
Can you share that Subscription Id from your screenshot?
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?
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?
Yes
No
Root of Subscription and in subscription_details.metadata of the Invoice
The lines metadata comes from metadata you set on your Price objects
no, eventually this metadata used in all il_objects, root metadata of subscription_details is empty
Have a glance, please
Have you created a fresh test-mode Subscription today to test it out?
Since you don't believe me, that is the next step
no, this how this code works for a year or somthing
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
no, the question is not about trust, I just see my code and I'm using different format of metadata for different type of objects
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
That sounds good. A fresh test that we can look at together is the best way to go.