No one is obligated to accept cash. Most apartments refuse cash payments because they don't want to deal with having thousands of dollars in cash on-hand at predictable times. Major airlines don't accept cash for purchases during flights. Several restaurants in New York are cashless, and the trend has been expanding slowly to other locations. Some stay cashless, some allow cash later.
A place not accepting cash doesn't mean that you can just walk out with the merchandise, though. Your perception that you've created a debt by attempting to purchase something is off. There's no debt because the transaction hasn't been completed, and there's no contract, verbal or written, setting up payment at a later time. What you're talking about is theft, and the police can arrest you for that. The judge will find you guilty of theft. The only thing you can do is leave your coffee behind and walk out to find a place that does accept cash.