Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use android pay api with nfc?

I am trying to implement "Tap and Pay(for payment transaction)" with NFC and Android Pay API.

I did not find any tutorials or examples regarding this.

I looked at developer.android.com but did not get it.

The above documentation talks about communicating with NFC using Host-based Card Emulation (I might be wrong)

How can this be achieved? Are there other APIs or do I have to integrate a payment protocol with a Host-based Card Emulation Service?

public class MyHostApduService extends HostApduService {
    @Override
    public byte[] processCommandApdu(byte[] apdu, Bundle extras) {

       //Implement PAYMENT protocol here
    }
    @Override
    public void onDeactivated(int reason) {
       ...
    }
}
like image 923
user3371398 Avatar asked Feb 02 '16 10:02

user3371398


People also ask

Can Android emulate NFC card?

Many Android-powered devices that offer NFC functionality already support NFC card emulation. In most cases, the card is emulated by a separate chip in the device, called a secure element. Many SIM cards provided by wireless carriers also contain a secure element.


2 Answers

Like the other commenters have noted.

As for Android Pay API - it is designed to pay without any NFC terminal ...

answered Aug 16 at 11:42 Jehy

However, you may want to look into something like Square, they make NFC readers that accept Android Pay. They cost about $50.00, which I personally feel is inexpensive for a small business or individual.

You should also look at their APIs and in particular

In-person commerce. Custom iOS and Android point-of-sale apps can use the Square Register API to process payments securely with Square hardware.

Armed with the $50 NFC reader and a custom built point-of-sale app you can in a round about way achieve a reasonable solution. Though your users will be using Android Pay or Apple Pay for contact-less payments(no point reinventing the wheel).

Disclaimer

As of the time of this answer Square APIs are not offered everywhere.

Important: Square APIs are currently available only in the United States and Canada. We are working to make them available in additional countries soon.

like image 24
chewpoclypse Avatar answered Oct 16 '22 18:10

chewpoclypse


Comment from icyerasor is completely right. If you want to pay for something with Android pay and NFC, you should use Android Pay application. You can't implement custom payment application because of security issues (for example, google doesn't allow Android pay on rooted devices or on devices with custom screen locks).

As for Android Pay API - it is designed to pay without any NFC terminal - only from your application. You can see typical payment flows here - those can't include any NFC contacts.

If you wonder, what is NFC card emulation designed for - it can be used for person identification instead of cards, for storing bus tickets and etc. I think that it is possible to make a custom payment system - but it will require creating custom bank processing and NFC terminals (card readers) at least (I repeat once again that you can't use Android Pay). That's almost impossible for a little company which business isn't in this field (very expensive, requires lots of licensing work and time). And even after it, your application will be banned in google play.

like image 104
Jehy Avatar answered Oct 16 '22 18:10

Jehy