Australia has exactly this rule.
One influence in the setting of this rule was that payment card processors had been throwing their weight around requiring that merchants not pass on cost, which was fairly clearly an abuse of their position of power. (For most in-person business, which was largely what was being dealt with at the time, cash is essentially costless, and so for some small businesses being forced to swallow payment card fees was genuinely an unreasonable burden.)