If you owed them money, they would have to accept it. But you don’t owe them money, you’re trying to make a purchase.
The business only needs to post a notice that they don’t take cash. If you continue to deal with the business, like a restaurant, then you are agreeing to their terms.