Metadata which has been set on an object generally is not “inherited” by or copied to associated objects which are created at the same time. For example, a Balance Transaction will not inherit the metadata which has been previously set on the Charge that created the Balance Transaction.
There are some important exceptions. When a PaymentIntent is confirmed, Stripe will copy its metadata, along with some other fields, to the Charge that is created by the PaymentIntent. This is a one-time event, however, and subsequent updates to the PaymentIntent’s metadata will not update the metadata of the Charge, which must be updated separately.
Additionally, the metadata of an Invoice’s Line Items will be copied from the metadata of the Subscription the Invoice belongs to, for Invoice Line Items where type: ‘subscription.’
There are also some Stripe objects that have dedicated parameters for setting metadata of associated objects. Examples include:
You can set the metadata of a Subscription that is created for a Checkout Session in subscription mode by setting subscription_data.metadata. Any future updates to the Subscription’s metadata should be done directly on the Subscription object or by modifying the phases of a Subscription Schedule.
Subscription Schedules can be used to update metadata on the underlying Subscription by setting phases.metadata.[0] As the Schedule transitions to each phase Stripe will update the Subscription's metadata based on the content of phases.metadata . You can find more details on how this works in our guide in the documentation.