Earlier quoted context omitted.
Actually, if the restaurant only accepts payment by credit card, you are free to not pay. That's the concept of legal tender - if they want to demand payment of a debt (i.e. after you finish the meal) from you with backing by law, they _must_ accept legal tender. If they only accept credit card payments, they can't use the law to make you pay.
I would be surprised if this is true.
So, merchants can reject cash for purchases[1] because cash is legal tender for all debts, public charges, taxes, and dues, and a purchase is not one of these.
The Wikipedia page [2] for dining and dashing states that ordering a meal is a contract debt, since you are given the food before the transaction occurs, with the understanding that you'll pay for it afterwards. Thus, if the merchant, after giving you the food, informed you that they only accept credit card, that would not be allowed.
Also some good discussion on this SE post [3]
1. https://www.federalreserve.gov/faqs/currency_12772.htm 2. https://en.wikipedia.org/wiki/Dine_and_dash 3. http://skeptics.stackexchange.com/questions/7701/is-it-illeg...