Working with the New Point Of Service APIs in Windows 8.1


Smart Devices are increasingly being used at Point of Service (POS) terminals.

Increasingly, we are seeing tablets being used as checkout devices. To capitalize on the potential, Microsoft has introduced first class support for Point of Service devices with new APIs that specialize for these devices. These APIs will work with barcode scanners and magnetic stripe readers and do not rely on manufacturer-specific solutions. Instead, Microsoft has provided manufacturer-neutral APIs, which can be used in Windows Store applications to interact with the POS devices.

Point of Service APIs

These APIs reside in the Windows.Device.PointOfService namespace and are available for both XAML developers as well as web developers (JavaScript).

The barcode scanner is represented by the BarcodeScanner class, which resides in the Windows.Device.PointOfService.

You can get a BarcodeScanner object in one of two ways:

1. Call Windows.Device.PointOfService.BarcodeScanner.GetDefaultAsync static method, which will return the first barcode scanner attached to the device on which the application will be running.

2. Call Windows.Device.PointOfService.BarcodeScanner.FromIdAsync method, which will return a specific BarcodeScanner object depending on the DeviceInformationId parameter.

To get exclusive access to the scanner device, call the ClaimScannerAsync API.

The magnetic strip reader resides in the Windows.Device.PointOfService namespace as MagneticStripeReader class. The methods on this class are similar to the ones on BarcodeScanner class except one difference; to get exclusive access, you would call the ClaimReaderAsync API.

Hands On

In our demo application, we will create a simple Windows Store application, which will connect to a magnetic stripe reader and receive data from it.

Create a new Windows Store application titled WindowsPointOfServiceDemo.

New Project
New Project

Add three Button controls. The first button, buttonGetReader, will be to get a handle to a Magnetic Stripe Reader and claim exclusive access to the magnetic stripe reader. The second button, buttonStartReadingMagneticData, will begin processing data received from the magnetic stripe reader. The last button, buttonStopReading, will release exclusive access to the magnetic stripe reader.

Since we will be working with PointOfService APIs, we need to include the Windows.Devices.PointOfService namespace  in the code-behind file.

using Windows.Devices.PointOfService;
Next, we will add a MagneticStripeReader instance.
public sealed partial class MainPage : Page
        MagneticStripeReader myReader = null;
 ClaimedMagneticStripeReader myClaimedReader = null;
        public MainPage()

In the event handler for the buttonGetReader click event, we will invoke the static API Windows.Device.PointOfService.MagneticStripeReader.GetDefaultAsync to get the handle to the first available strip reader.

        private async void buttonGetReader_Click(object sender, RoutedEventArgs e)


            myReader = await MagneticStripeReader.GetDefaultAsync();

            if (myReader != null)

                myClaimedReader = await myReader.ClaimReaderAsync();


Next, we will enable the magnetic strip reader to receive data, and also specify the callback to be invoked when a Bank Card Data Received event occurs (when a bank card is swiped).

private async void buttonStartReadingMagneticData_Click(object sender, RoutedEventArgs e)
            await myClaimedReader.EnableAsync();
myClaimedReader.BankCardDataReceived += myClaimedReader_BankCardDataReceived;

Now, our magnetic strip reader will be receiving data. To listen to the data, we add code in the myClaimedReader_BankCardDataReceived event handler.

void myClaimedReader_BankCardDataReceived(ClaimedMagneticStripeReader sender, MagneticStripeReaderBankCardDataReceivedEventArgs args)
            textBoxAccountNumber.Text = args.AccountNumber;

Finally, we implement the buttonStopReading button’s click event handler. In this method, we will release the exclusive access and also unregister event handlers for BankCardDataReceived event.

private async void buttonStopReading_Click(object sender, RoutedEventArgs e)
            await myClaimedReader.DisableAsync();
            myClaimedReader.BankCardDataReceived -= myClaimedReader_BankCardDataReceived;

We are now ready to test our code. If you have trouble following along, you can download a copy of this sample below.

If you have a POS device and attach it to a Windows machine running Windows 8.1 and run this application, you can test out the application we have built.


In this article, we learned about the built-in API support for Point of Service devices like barcode scanner and magnetic strip reader. I hope you have found this information useful.

About the author

Vipul Patel is a Program Manager currently working at Amazon Corporation. He has formerly worked at Microsoft in the Lync team and in the .NET team (in the Base Class libraries and the Debugging and Profiling team). He can be reached at

Related Articles



  • Work with Camera API for Barcode Scanner - Windows 8.1 project

    Posted by Robert Hellestrae on 05/20/2014 12:22pm

    Fabulous sample on working Windows 8.1 Point of Service API's; I am writing to ask if there are any code samples working with the Windows 8.1 Camera API for scanning bar codes; Best regards - Rob

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: October 29, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you interested in building a cognitive application using the power of IBM Watson? Need a platform that provides speed and ease for rapidly deploying this application? Join Chris Madison, Watson Solution Architect, as he walks through the process of building a Watson powered application on IBM Bluemix. Chris will talk about the new Watson Services just released on IBM bluemix, but more importantly he will do a step by step cognitive …

  • Live Event Date: October 29, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT It's well understood how critical version control is for code. However, its importance to DevOps isn't always recognized. The 2014 DevOps Survey of Practice shows that one of the key predictors of DevOps success is putting all production environment artifacts into version control. In this eSeminar, Gene Kim will discuss these survey findings and will share woeful tales of artifact management gone wrong! Gene will also share examples of how …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds