It's not a great system but it's what we have so using debit instead of credit does mean losing out.
Especially service companies. They tend to quote out "cash" (aka check/bank transfer) price and then add another 5% or so if you want to pay via card. There of course is very often an even cheaper "actual cash" price too you need to ask for if you are so inclined.
This is no longer a thing, there was a settlement with Visa/MC that removed this provision from their merchant contracts. You are now allowed to pass on transaction fees if you feel like it as a merchant.
It was also never illegal. It simply was part of the contract to do accept Visa/MC/Amex and they'd close your merchant account if you got caught doing it.