locked
listening to USB magnetic swipe card reader

    Question

  • I am working on a metro app that will serve as a Kiosk. One of the requirements is that it needs to accept credit card payments (just like a typical Kiosk). I have a USB credit card reader, and I have tested the input on a notepad. It's setup correctly and reads the card.

    Now, I don't know how I would listen to this kind of input while on the metro app. I've visited threads regarding USB HIDs and serial ports support, and unless I'm wrong, it seems that there's nothing built in to listen to such input events programmatically. 

    One cheap approach I attempted was that I put a textbox somewhere behind another control and applied focus to it. And as the card is swiped, the input goes to the textbox, and is sent away for validation. Obviously, that's not something I'd want to stick to.

    So can you folks suggest an elegant solution to this requirement?

    Much appreciated.

     


    • Edited by dgman Monday, May 14, 2012 6:23 PM
    Monday, May 14, 2012 6:21 PM

Answers

  • dgman,

    If sounds like your credit card reader emulates a keyboard which means that credit card numbers will show up as regular keyboard input.  Using Window.Current.CoreWindow.CharacterRecieved would work.

    i.e.
    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
    Window.Current.CoreWindow.CharacterReceived += CoreWindow_CharacterReceived;
    }

    void CoreWindow_CharacterReceived(Windows.UI.Core.CoreWindow sender, Windows.UI.Core.CharacterReceivedEventArgs args)
    {
    //Character is in args.keycode
    }


    If you have an actual keyboard attached (or another device that emulates keyboard input) you will need to disambiguate the input in your application as there is no way to identify the specific device associated with specific keyboard input.  Consider using explicit user action (such as a Pay Now button) to determine the kind of input you are expecting to receive.
     
    Best Wishes - Eric

    Friday, May 25, 2012 8:39 PM
    Moderator

All replies

  • dgman,

    I will look into this for you.

    Best Wishes - Eric

    Monday, May 14, 2012 8:54 PM
    Moderator
  • dgman,

    If sounds like your credit card reader emulates a keyboard which means that credit card numbers will show up as regular keyboard input.  Using Window.Current.CoreWindow.CharacterRecieved would work.

    i.e.
    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
    Window.Current.CoreWindow.CharacterReceived += CoreWindow_CharacterReceived;
    }

    void CoreWindow_CharacterReceived(Windows.UI.Core.CoreWindow sender, Windows.UI.Core.CharacterReceivedEventArgs args)
    {
    //Character is in args.keycode
    }


    If you have an actual keyboard attached (or another device that emulates keyboard input) you will need to disambiguate the input in your application as there is no way to identify the specific device associated with specific keyboard input.  Consider using explicit user action (such as a Pay Now button) to determine the kind of input you are expecting to receive.
     
    Best Wishes - Eric

    Friday, May 25, 2012 8:39 PM
    Moderator