The expression “to pay the piper” means: To pay the fiddler; to settle the score; hence, to suffer the consequences; to take one’s punishment, face the music, or take the rap.
This had the same allusion as “to pay the fiddler”; that is, to pay the musician who led a dance, and the piper was one of the earliest to supply such music.
Incidentally, until well into the nineteenth century, all such musicians, like the itinerant minstrels of earlier days, were considered to be scarcely a step above domestic menials.
Hence, any pay they were given, beyond food and all the wine they could drink, was through the bounty of the master of the house.