How to track when a payment is done using a payment link in stripe

I have created a payment link object with custom metadata, which includes the product ID:

      Metadata = new Dictionary<string, string> { { "product_id", productID } },

When a payment is successfully made, I want to filter the payment intents that have a status of ‘succeeded’ and retrieve the product ID associated with those payment intents. However, when the payment is completed, the payment link object does not pass the metadata into the payment intent. Therefore, I am unable to track whether a payment has been successfully made through a particular payment link or not. Additionally, there is no payment link ID in the payment intent where I can track the payments.

If anyone has any ideas on how to accomplish this, please let me know. (Please provide step-by-step instructions)