If you are planning to write an Android App that would accept payments using NFC, here are some tips to get started. NFC reading data from Credit Card isn’t that simple, but isn’t that complicated either. I hope this article helps you understand the basics.
Let’s start with some terms and their meaning.
What is NFC?
NFC stands for Near Field Communication, is a type of technology that allows wireless communication between devices that are a few centimeters apart. It doesn’t require an Internet connection. It transmits data via shortwave radio frequencies.When one NFC-enabled device is close enough to another NFC device, a connection can be established and data shared between them.
NFC Settings on Android
This is where you find NFC Settings on Android.You need to enable this to allow data exchange.
Does my credit card support NFC payments?
The side-ways wifi logo tells me that my credit card supports NFC. So I would be able to accept payments using NFC.
Android Support for NFC Android provides support for
NFC allows you to share small payloads of data between an NFC tag and an Android-powered device, or between two Android-powered devices.
“android.nfc” package provides access to NFC functionality, allowing applications to read NDEF (NFC Data Exchange Format) message in NFC tags( in this case a contactless credit/debit card)
API also provides access to ISO-DEP ( based on ISO 14443–4 standard) properties and I/O operations on a Tag.
Primary methods used are
public void connect () : Enable I/O operations to the tag
public byte[] transceive (byte[] data) : Send raw ISO-DEP data to the tag and receive the response.
The APDU (Application Protocol Data Unit) is the communication unit between a reader and a card. The structure of an APDU is defined by the ISO 7816 standards.
There are two categories of APDUs: command APDUs and response APDUs.
APDU Command and response: Below are the basic 5 steps to read to connect to NFC device and read the card number.
Few useful links:
https://developer.android.com/guide/topics/connectivity/nfc?source=post_page—–b60d496d43ba——————————–
https://github.com/pro100svitlo/Credit-Card-NFC-Reader?source=post_page—–b60d496d43ba——————————–
Security with NFC
Since the devices must be in very close range (within 4 cm) to send signals, it is much more difficult to intercept these signals.
The NFC chips in devices aren’t always active. When your phone is locked and not in use, the NFC device isn’t actively sending any data. It doesn’t become active until you want it to, for example when you are checking out at a store using a contactless terminal.