This was litigated, as I recall all the way to the United States Supreme Court, and the merchants lost at every turn because these practices were a patent violation of the contracts the merchants had/have with the credit card companies.
That's quite shocking....that two parties can have a contract between them that works against the financial interest of a third party - the person who chooses to pay cash. That person is paying for a service they do not receive when the cost of credit cards is built into the retail price.