A couple of hundred years ago it was common practice in the British army for officers to buy their rank. You paid a certain sum and you became a lieutenant. And you could pay some more and get promoted.
Who was the money being paid to? The commander of the regiment? The higher officers? The regiment as a whole? The army as a whole? Parliament? The king?
Usually you bought the rank from the person who had it. Some officers who encountered financial difficulties had to sell their commissions to pay their debts. See Purchase of commissions in the British Army - Wikipedia for more complete info.
Generally the officer selling it. It was his property to sell when he wished, so if he was promoted from - say - Captain to Major he could get back the cost of his Captain’s commission.
Lots of complications where commissions were sold directly by the Crown but that was the general principle. As always start with wikibut this siteis pretty informitive.
The money would be paid to the officer who’s selling the promotion. So, lets say I, Captain Amazing, have done my thirty years and am retiring, or for whatever other army, I have to get out of the army. So I tell the powers that be that I’m retiring, and my captaincy goes on the promotion list as “available for sale”. Then you, as a Lieutenant with more seniority than anyone else who wants to buy the rank, pay your money, I get it, and now you’re Captain and I’ve got some extra money to pad my pension. You can then sell your Lieutenancy to make back some of the money you spent.
Now if you want a free promotion, you pretty much have to wait for somebody to die (hence the toast “Here’s to bloody wars and sickly seasons”), for someone to be promoted to Major General, for someone to take a staff post, or for the size of the officer corps to be increased.
Suppose an officer left the service suddenly for reasons involving a cannonball. Would his estate inherit his commission and be able to sell it?
From MarcusF’s link:
*Non-purchase vacancies arose because of:
Death (“A bloody war or a sickly season”). After 1856 the value of the commission of an officer killed in battle or dying of his wounds within six months was paid to his family;*