@gollum,
It varies.
There are super delegates which are decided by holding certain offices.
The regular delegates are decided by caucuses in some states which means they are decided at the state convention. It is a convoluted process. Delegates to the state convention can decide to stand for election to the national convention. In other states the delegates are on the primary ballot and are voted on as supporting a certain candidate.
My understanding is each delegate has to pay their own way. Of course, that is pretty much only the travel and hotel as drinks, food are found at the numerous events held by candidates, lobbyists etc