It depends on where you live. 10 states have laws that prohibit or restrict discounts for cash transactions: California, Colorado, Connecticut, Florida, Kansas, Maine, Massachusetts, New York, Oklahoma and Texas. Some of those restrictions have been invalidated by federal courts, but I was somewhat confused about which states were affected.
Perhaps this is explicitly allowed (you did say restrictions) but in Kansas it isn't uncommon to see gas station signs displaying a cash price and a card price.
I have definitely personally seen many instances in which you get a discount paying in cash in California. Maybe they get away with it because they technically frame it as charging extra for paying with a card?
All three of those states I believe had their surcharge bans invalidated by federal courts. Texas' law was declared unconstitutional in summer 2018: https://faq.sll.texas.gov/questions/9631
https://en.wikipedia.org/wiki/Durbin_amendment