This one, oddly enough, is only possible because of the government: in states where it's possible for gas stations to give cash discounts, this is only because state law overrides merchant agreements that otherwise prohibit it. Otherwise, credit-card merchant agreements (i.e. corporate policy, not government policy) generally prohibit differential gas/card pricing. As a merchant you could choose not to do business with Visa at all, but if you do business with Visa, you aren't allow to give cash discounts by the contract terms.
As of January 27, 2013, Visa and Mastercard allow credit card surcharges. Prior to this I believe merchant agreements did allow for cash payment discounts, just not "surcharges", even though they are practically the same thing.
It was a long time ago that I worked a register, but at one point merchant agreements definitely disallowed cash discounts. I knew because on a slow day I actually read the fine print. The boss, correctly, didn't care that their discount for cash was forbidden, but I was young enough to be a little scandalized.
This one, oddly enough, is only possible because of the government: in states where it's possible for gas stations to give cash discounts, this is only because state law overrides merchant agreements that otherwise prohibit it. Otherwise, credit-card merchant agreements (i.e. corporate policy, not government policy) generally prohibit differential gas/card pricing. As a merchant you could choose not to do business with Visa at all, but if you do business with Visa, you aren't allow to give cash discounts by the contract terms.