It’s been mostly legal to charge credit card surcharge fees since 2013. https://www.lexology.com/library/detail.aspx?g=5c6e1264-42a8...
The real reason that most merchants don’t charge surcharges is that they don’t want to lose the sale, calculating the actual interchange is wildly complex and in general they prefer cards to cash.