The fees merchants pay to the credit card processors vary. There's a minimum. Reward cards charge higher acceptance and processing fees.
Example. The average annual profit margin for convenience stores, without fuel, is 7%. (From industry stats). So, if your acceptance fees are 3%, or higher, and your margin is 7% , well you do the math.
Some sales can go negative right at the register. One pack of cigarettes and one can of pop and the merchant probably doesn't break even.
The three 3% processing fee isn't the floor either on acceptance costs. The electronic network that actually transmits the transaction and then, one or two days later credits the merchants account with the proceeds also gets an additional fee. And the bank where the merchant banks charges a fee for each account deposit. Monthly commercial checking account fees are higher, much higher than individual/personal accounts.
Plus the merchant either has to buy or rent the card processing equipment.
Sometimes it can be free as part of the service, if you're a high volume account. Each time there's a change in card security features, like the recent change to chip cards, the merchant has to get all new equipment. It literally never ends. There's at least 5 or 6 different ways a merchant pays to accept a credit card.
Debit cards, if the customer actually runs it as a debit using a pin, are charged a flat fee that doesn't vary by card, but all other processing/deposit/handling fees are applied on top of that.