Square does it. How do they do it? More importantly, you want to do it. How should it be done?
Here's Project Hijack out of the University of Michigan. As of this post, you can buy the hardware from Seeed Studio.
If you're on Android, use their Open Accessory API.
Or, you can knock one together yourself with a few dollars worth of components following Johnathan C. Hall's advice.
Leave a comment if you try any of these and like them.