Both sentences are fine. "me" makes it explicit that the speaker paid for the sandwich. The first sentence can be used regardless of who paid for it.
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.