In the EU (whole EEA actually) the merchants are not allowed to charge a different amount for cash and personal cards (debit or credit cards). They can charge the transaction fee they pay for business (company) cards and they need to inform the consumer in advance.
In the US, there are legally few limitations as long as you inform the customer. However all of the major credit cards have "most favored nation" clauses in their service agreements that prohibit charging any less for competing payment systems.
As a side note, many government services aren't allowed to eat the transaction cost, so they actually do pass the cost to the consumer (e.g. when I pay my annual car registration, an ACH (electronic check) payment is the same as paying cash in person, but a credit card has an additional fee tacked on.