Pay the piper is a popular idiomatic phrase in English, used for warning people that their actions have consequences, which must be bore by everyone.
The idiom is a reference to the tale “The Pied Piper of Hamelin”.
The story tells of a Piper who saves the town from a rat infestation, using his pipe.
When the town doesn’t want to pay him for his deed, he uses his pipe to lure away the children of the settlement.
The idiom didn’t appear until the late 1600’s, even though the story is set in the 13th century.
The expression saw rise in the 19th century, with its popularity peaking 1895, according to Google Ngram Viewer.
“Pay the piper” would remain a common expression in English, appearing in literary works, as well as parents’ life lessons to their children.