You can usually pay ransom if the prisoner is your character's courtier or vassal. if you right-click, the option should be there.
If it's not there... huh...
The only way I could imagine it breaking is if your heir's spouse does not belong to your court. Like if she's landed in a different realm, or belongs to a vassal's court rather than yours. in fact... now that i think of it... is your heir landed? Because if so, that would make her his courtier which... would complicate things.
It might (with a big question mark, if it works, please let me know I'm really curious) be possible to get her transferred under your custody, or just released, if you revoke the titles of the vassal holding her.