13
2013
Mobile Payment Using NFC – Near Field Communication
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.
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:
-
-
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.
-
-
- ACTION_NDEF_DISCOVERED
- ACTION_TECH_DISCOVERED
- 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
-
-
Sending messages from an Android phone using NFC
-
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.
-
-
Interpreting messages from the NFC reader
-
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:
On this Page