Hello Malik,
You didn't give much context in your ask either in what you do in your code or what isn't working unfortunately. You mentioned `subscription_data` though so I'm going to assume you are using Checkout and its Sessions API. That API does let you configure the metadata that should be set on the resulting primary object depending on the Session's `mode`:
* For `payment` you would pass `payment_intent_data[metadata]` and the resulting PaymentIntent would have its `metadata` property set from it.
* For `subscription` you would pass `subscription_data[metadata]` and the resulting Subscription would have its `metadata` property set from it.
* For `setup` you would pass `setup_intent_data[metadata]` and the resulting Subscription would have its `metadata` property set from it.
In each case, you then have to go through Checkout and complete the Session. After that you will either get a redirect or the `checkout.session.completed` Event. In both cases, you won't see the metadata there since the underlying primary object created would not be returned in the payload, just its id. So for example you will see `subscription: 'sub_123456'` which is the id of that Subscription that was created as a result. Then, you can use the Retrieve Subscription API to retrieve the entire resource and confirm the `metadata` on it is set properly.
Alternatively, you can make use of our Expand feature (
https://stripe.com/docs/expand) which lets you retrieve multiple separate objects at the same time. For example you can call the Retrieve Checkout Session API and also expand the underlying Subscription, SetupIntent or PaymentIntent that was created after the Session completed successfully.
It is also important to note that metadata does not propagate between objects except in really specific cases. If you set `metadata` on the Checkout Session itself, it will only be on the Session object, nothing else. That's why you need to explicitly use `payment_intent_data[metadata]` for example for the `metadata` to appear on the PaymentIntent, but in turn it's not reflected back on the Session itself.
Overall, this definitely works as expected and is widely used by developers working with Checkout! If you have a follow up question, I'd recommend working with our support team directly and providing clear examples where it isn't working and they will be able to help you narrow it down. You can contact them here:
https://support.stripe.com/contact
Best,
Remi