They did - in fact, it was a standard feature of Medieval warfare that captured combatants of means could arrange for a ransom to buy their freedom from captivity. Though as you'll see, the practicalities depend on whether it's a common soldier or an aristocrat who's doing the capturing. More can always be said on the matter, of course, but since warfare of all stripes is ever popular on the sub, the following previous posts may interest you:
A few more relevant threads in next post because argh tag limit.