That used to be the case, but changed in 2013 when a lawsuit settlement was reached that more or less did away with these sorts of contract terms[0]. That's why (at least where I live) gas stations that charge different prices for CCs and cash/debit are everywhere, some restaurants will offer some percentage off if you pay in cash, and some online services, even, pass credit card fees on to customers.
I believe there are a few states in the US left where merchants can still be required to charge the same, but in most places in the US that's not the case.
The no-surcharge terms are plainly anticompetive and should have been reigned in a long time ago. But customers get really mad about extra fees and think it's the merchant that is ripping them off and not Visa/Mastercard.
I believe there are a few states in the US left where merchants can still be required to charge the same, but in most places in the US that's not the case.
[0] https://smartpay.gsa.gov/content/surcharges