* The seller does not state they do not take cash before the transaction happens,
* And the buyer attempts to pay for the transaction after the fact with cash in good faith,
* And the sold goods cannot be returned to their original condition prior to sale,
Then the buyer is okay (FSVO okay) to leave and go about his day because the seller refused to take money that was presented in good faith by the buyer. Because cash, at least in the US, is "legal tender for all debts public and private" and a transaction to which you owe money is a form of debt.
Obligatory not a lawyer and not an accountant disclaimer. I'm way too lazy to go and properly research and cite this.
In real life there's not a lot of cases where someone gives you goods before you pay, and anywhere i've been to that don't accept cash clearly posts "this is a cashless business" (sweetgreen and the like, SF/NYC, YMMV) so good luck making the argument that you're entitled to your free salad
Usually this isn't a problem because "We don't take cash." signs are prominently posted, but we are speaking in the hypothetical after all.