Sometimes that is actually the business charging slightly less for cash transactions rather than charging slightly more for credit card transactions.
What's the difference? If the business advertises both a cash price and a credit card price, then there is effectively no difference I believe whether you characterize it is a discount for cash or a surcharge for credit cards.
However, if you only advertise one price, then its a surcharge if that is the cash price and you add extra for credit cards at the register. If the one price is the credit card price, and you take off some for cash at the register, then it is a cash discount.
Doing a cash discount was a common trick at gas stations to work around terms in their contracts that said they would not have credit card surcharges. There was a lawsuit against such contract terms by merchants who wanted to do a surcharge, and in a settlement in 2013 Visa and Mastercard agreed to allow them (with some restrictions, like no more than 4%, must be a sign disclosing them at the point of sale, had to be included on the receipt, and had to apply to all cards), reducing the need for such tricks in many areas.
There are some states that have laws prohibiting credit card surcharges, so the cash discount trick may still be in use there. California, Colorado, Connecticut, Florida, Kansas, Maine, Massachusetts, New York, Oklahoma, and Texas. These have been challenged on Free Speech grounds. The Supreme Court has said that they are (well, New York's version, but others are similar) is a regulation of speech, but did not rule whether it was an unconstitutional regulation (the lower courts had not reached that issue) [1]. I don't happen to know what happened to that case after that.
[1] https://www.supremecourt.gov/opinions/16pdf/15-1391_g31i.pdf