Yes a business is legally allowed to charge a surcharge fee for customers to pay with a credit card as long as they alert the customer to the surcharge fee.
Whenever you use your credit card or debit card to pay for something the business is charged a percentage of the transaction to accept the credit or debit card.
So it's understandable why a business would charge a fee to use the credit or debit card.
They have to charge the fees to keep making their profit to stay in business.