E. Cobham Brewer 18101897. Dictionary of Phrase and Fable. 1898.
To discharge a debt. (French, payer.)
Whos to pay the piper? Who is to stand Sam? who is to pay the score? The phrase comes from the tradition about the Pied Piper of Hameln, who agreed to cure the town of rats and mice; when he had done so, the people of Hameln refused to pay him, whereupon he piped again, and led all the children to Koppelberg Hill, which closed over them.
From the corresponding French phrase, payer les violons, it would seem to mean who is to pay the fiddler or piper if we have a dance [on the green]; who is going to stand Sam?