I believe either VISA or MasterCard - likely both - have rules against charging any additional fees when paying with their cards as a merchant, with the implicit threat of them pulling their services and leaving you unable to process cards if you don't follow said rules.
The typical workaround, which isn't against their rules, is to offer a discount for paying in cash - I can't recall the last gas station I saw that didn't do this (for gas at least), and a number of restaurants also offer cash discounts.
The reason for offering a discount for paying in cash is probably that most clients would get angry if merchants tried to charge them more for using a credit card while they are always happy when they get a discount for paying in cash. I think the credit card processors are smart enough to realise that this is happening, so if they wanted & could do anything about it, they would probably write their terms differently (cca. "prices for payments in cash and with cards must be equal").
The typical workaround, which isn't against their rules, is to offer a discount for paying in cash - I can't recall the last gas station I saw that didn't do this (for gas at least), and a number of restaurants also offer cash discounts.