Cash has to be honored for debts. When you want to buy something, there is no debt, so no, a merchant doesn’t have to accept currency. Of course you are under no obligation to patronize such a merchant.
This is true except for the fact that you have taken possession of the items in your shopping cart and owe a dept to the store for their value. You have also taken possession of the meal you just ate with the implied promise that you will pay the debt of the value of the meal once you have consumed it. This is why it isn’t the same for online shopping.