They are not allowed to charge customers more for paying via credit card that for paying via cash. This is the law in some states, and in addition many merchant contracts stipulate it as well.
Sometimes you'll see merchants offer a "cash discount", which is technically prohibited too, but small merchants can sometimes fly under the radar if it's not too blatant.