germany
This is... complicated.
What you describe would be illegal, because
Bürgerliches Gesetzbuch (BGB)
§ 270a Vereinbarungen über Entgelte für die Nutzung bargeldloser Zahlungsmittel
Eine Vereinbarung, durch die der Schuldner verpflichtet wird, ein Entgelt für die Nutzung einer SEPA-Basislastschrift, einer SEPA-Firmenlastschrift, einer SEPA-Überweisung oder einer Zahlungskarte zu entrichten, ist unwirksam
Translation:
Civil Code (BGB)
§ Section 270a Agreements on charges for the use of cashless means of payment
An agreement obliging the debtor to pay a fee for the use of a SEPA core direct debit, a SEPA business-to-business direct debit, a SEPA credit transfer or a payment card is invalid
Bascially says that I can pay with my German Debit Card and no business is allowed to charge a fee for that. They do not have to accept my card, but if they do, they cannot charge extra.
However
It is legal to charge extra for services that in turn charge your account by the same (SEPA) means. So for example if you put your card as a payment option into Paypal or SofortÜberweisung, services that charge the seller an extra fee over what a SEPA transaction would cost, it is legal for the seller to charge the buyer/consumer extra for usage of those services.
I say it is complicated, because the highest court ruled on it, after lower instances went back and forth on it:
https://www.bundesgerichtshof.de/SharedDocs/Pressemitteilungen/DE/2021/2021067.html