• Blog Home
  • Tech Talk
    • Best Practices
    • Java
    • .NET
    • Mobile
    • UI/ UX
    • Systems Engineering
    • Quality Assurance
  • ClubM

Sign in

  • Mazarin Corporate Site »
Mazarin Blog
stay connected
Join us on Facebbook! Follow Us on Twitter! Subscribe to our RSS Feed!
Nov
13
2013
Mobile

Mobile Payment Using NFC – Near Field Communication

Author Article by Admin editor    Comments No Comments

NFC – Near Field Communication is a technology used to express short messages with the help of changing a magnetic field. As its name suggests, it works within very close proximity like few centimeters.

NFC tags or cards have NFC magnetic fields embedded inside them. These tags are reprogrammable and can be manipulated to store some information at one time. NFC comes with mobile devices which have the ability to read NFC tags/cards or simulate a NFC magnetic field within the device to enable sending NFC messages. NFC has been used in many applications and its implementations are growing. Some examples are ticketing operations, access authentication, contact cards, smart posters and mobile payment.

NFC mobile payment process

NFC mobile payment process

Mazarin was requested to implement a mobile payment feature using this NFC technology for a Swedish customer. In this feature, the Android mobile app would get a unique code via a web service that would be passed to a NFC reading device through Android BeamTM technology, which is a technology that uses NFC to send short messages to other NFC enabled Android devices or NFC readers. Once the NFC reader gets this code it will validate the code and pass it to another web service to submit the transaction.

NFC mobile payment process

Implementations:

    1. Reading NFC tag from a mobile device

Reading the NFC tag was part of the implementation. The mobile application is able to respond when the mobile device detects a certain kind of NFC tag. The application also manages to extract the data from that scanned NFC tag.

There are several kinds of NFC tags. The mobile app responds mainly to the Mifare tags (Mifare Ultralight, Mifare Classic etc.). In Android, there is an Intent dispatch system. Intent is a type of notification that certain activities (application component) can be registered to respond. There are 3 main intents related to NFC communication.

      1. ACTION_NDEF_DISCOVERED
      2. ACTION_TECH_DISCOVERED
      3. ACTION_TAG_DISCOVERED

The mobile application is registered to respond to ACTION_TECH_DISCOVERED intent. The intent filter can be programmed to respond to certain NFC tag technologies in a tech-list resource xml file. In the tech-list you can include all the Mifare tag technologies the application should work with using the ACTION_TECH_DISCOVERED intent. Some information of the payment receiver is programmed into the NFC tag. After scanning the tag that information is shown in the mobile application and it is used in the payment code generation process.

<activity
   android:name="lk.mazarin.activity.nfc.NFCActivity"
   android:screenOrientation="portrait"
   android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >

   <intent-filter>
      <action android:name="android.nfc.action.TECH_DISCOVERED"/>
      <category android:name="android.intent.category.DEFAULT"/>
   </intent-filter>

   <meta-data
      android:name="android.nfc.action.TECH_DISCOVERED"
      android:resource="@xml/nfctech" />
</activity>

AndroidManifest.xml

<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">

    <tech-list>
        <tech>android.nfc.tech.MifareUltralight</tech>
    </tech-list>

    <tech-list>
        <tech>android.nfc.tech.MifareClassic</tech>
    </tech-list>

    <tech-list>
         <tech>android.nfc.tech.IsoDep</tech>
    </tech-list>

    <tech-list>
	    <tech>android.nfc.tech.Ndef</tech>
    </tech-list>

</resources>

nfctech.xml

    1. Sending messages from an Android phone using NFC

      NFC – Near Field Communication

Android BeamTM is used to pass messages using NFC in order to establish communication with a NFC reader. An Android activity is implemented with the interface CreateNdefMessageCallback. Then in the createNdefMessage method implementation, the NDEF message was created. A unique payment code is embedded in this NDEF message.

@Override
     public NdefMessage createNdefMessage(NfcEvent event) {
	NdefMessage msg = new NdefMessage(new NdefRecord[]{
                     common.newTextRecord(Locale.ENGLISH, true)}
                                                          );
       //newTextRecord returns the payment code fetched from web
       //service in the form of a NDefRecord object
	 return msg;
	}

This activity can implement the onNdefPushCompleteCallback to do some action when the NDEF message push is completed. On the onNDefPushComplete method implementation, ‘information sent’ message is shown in the application. When the activity with these implementations is on the foreground, the phone will prompt the user to send the NDEF message once it comes in contact with the NFC reader. Then the user can touch the screen to send the NDEF message to the NFC reader.

    1. Interpreting messages from the NFC reader

      NFC – Near Field Communication

A Java application was built to interface the NFC reader to retrieve the payment code. This application also acts as the client of the POS (Point Of Sale) terminal. The ACS ACR122U NFC reader was used for this feature implementation. This application was able to extract the data from the NDEF record received from the NFC reader. The reader was operated by the application, which was implemented using a third party library named NFC Tools. This library has different methods to work with different types of NFC readers using different protocols. It can be used to send or read a NFC message from the reader.

In this Java application, the payment selection would be done in the POS terminal and the selection is combined with the payment code information received from the reader. Thereafter, a web service was used to submit that combined object (Data Transfer Object) in order to complete the transaction. Upon completion of the transaction, a success message is sent back to the mobile application user via email. Additionally, the Java application sends a NDEF message from the reader, so that it can simulate a NFC tag to initiate the payment code generation process in the phone. This allows the users to place the phone on the reader to perform immediate transactions.

Another alternative to mobile payment is the use of QR codes. The logic of using QR codes is rather similar to the NFC technology. The advantage of NFC – Near Field Communication is its simplicity and the speed/ quickness. It requires minimal involvement of the application user. The mobile payment process can be completed with just one touch of the device and therefore will reduce queue time.

References:

    1. http://developer.android.com/guide/topics/connectivity/nfc/index.html
    2. http://en.wikipedia.org/wiki/Near_field_communication

Related Post

What Power BI Can Do – Major Benefits
Outbound Training 2013
Mazarin Kite Masters embellished Colombo Galle Face Sky
What is Docker ? Getting Started with Docker
MS SQL Server BI (Business Intelligence)
An Introduction to Node.js – Kickstarter
5 Principles: How To Use Lean Startup Towards A Successful Project
Spring OAuth 2 Token Based Authentication

On this Page

  • Implementations:
    • Reading NFC tag from a mobile device
    • Sending messages from an Android phone using NFC
    • Interpreting messages from the NFC reader
      • References:
    • Related Post
Tags: ACS ACR122., Android Development, Java development, Mazarin, Mobile Payment, NFC, NFC reader
Did you enjoy reading this article? Share it! Share on Facebook Tweet this! Bookmark on Delicious StumbleUpon Digg This!

Related Posts

  • Serverless Architecture with AWS Lambda
  • Let’s move to NoSQL Databases with MongoDB – Mazarin
  • Without Redux and with Redux application state behaviorProductive Development With React Redux
  • Elements of CultureCompany Culture
avatar

About the Author:

Leave a comment

Click here to cancel reply.

CAPTCHA
Refresh

*

Follow Us on Twitter!

On this Page

  • Implementations:
    • Reading NFC tag from a mobile device
    • Sending messages from an Android phone using NFC
    • Interpreting messages from the NFC reader
      • References:

Related Post

Sass and LESS: An Introduction to CSS Preprocessor...
Azure Functions – Learn more about it
Firebase – Mobile Application Development &#...
Serverless Architecture with AWS Lambda
Let’s move to NoSQL Databases with MongoDB &...
Productive Development With React Redux
Beginners’ Guide to CSS (CSS for dummies)
Company Culture
What is Docker ? Getting Started with Docker
Hybrid Mobile App Development with Ionic and Angul...
Test Automation of Mobile Applications using Appiu...
What Power BI Can Do – Major Benefits
Data Mining using SQL Server Analysis Server
Learn Cucumber Test Automation with Ruby Core Fram...
How to Succeed With Designing Scalable Web Apps
Importance of Big Data and Managing Data with Elas...
An Introduction to Node.js – Kickstarter
MS SQL Server BI (Business Intelligence)
How To Start Cloud Computing with AWS
What is NFC – The Ultimate Guide
Avatars by Sterling Adventures

Team Mazarin

A team of individuals dedicated to share common goals and vision of the company. Mazarin's endowed team consists of Managers, Software Engineers, User Interface Engineers, Business Analysts, Finance and Administration. We are a blend of quality people. We strive to maintain the open culture and work in close association. The way we work enables everyone to contribute while feeling contented sharing opinions and ideas to deliver the best software solutions.

Read More

Mazarin © 2022. All Rights Reserved.