As for the costs, the varying factors to make a cup at home holds true as well. A retailer had me pay the varies fees, fixed and variable, both bean and machine, to make a profit.
About the only conflict that exists to producing a cheap cup of coffee (or, for my for urbane friends, 'latte') is the rent. Here, you are competing with the various retail options that a landlord could also sell in that location. So, that coffee shop could also be an Apple Store which commands both high margins and high revenue per transaction.
At that point, it becomes the market's choice as to what best serves the community's interest. Do we pay for a coffee shop or an Apple store?
I know my choice. Coffee shop.
As a side note, credit card processing fees as a variable cost should vary indirectly to sales.