4

I'm trying to get some information about how to add my app as a tap and pay option for Android devices.

Apps like PayPal and Android Pay can be set as the default app to launch when NFC contact is detected. I would like for my payment app to be an option to launch when someone does NFC tap.

Currently my app can take advantage of NFC by the Android Beam functionality, but I was curious to see how I can get my app included as a tap-to-pay default option so that an NFC tap would launch the app directly.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Jake
  • 41
  • 3
  • I have the exact same requirement, did you get some solution or workaround for your problem? – Sagar Mody Nov 23 '17 at 01:48
  • @SagarMody I also need an answer for this one - do you have any info that you can share please? – Janet Todorova Nov 30 '17 at 12:44
  • @Jake is your app a payment (HCE) app? If so then I think the moment you register ```Service``` with a ```metadata``` for ```android.nfc.cardemulation.host_apdu_service```, it'll become an option in the settings. I've never seen a case where user gets to choose the payment app when doing a tap-to-pay. Usually the default is set ahead of time and android uses it immediately (without user interaction) when it detects a tap-to-pay to make the experience quick. Usually the first payment app found on device is set as default payment. User could change it after installing another one – ahasbini Dec 15 '17 at 07:06
  • @ahasbini yes we know that so here what we need is how user could change our app to default payment app, please if you have done this before share with us?thanks – abdullahicyc Feb 27 '18 at 14:16
  • @abdullahicyc here's an answer that prompts the user to set the app as default payment app: https://stackoverflow.com/a/24167039/2949966. Note that app cannot set itself as the default without asking the user first. – ahasbini Feb 27 '18 at 15:48
  • @ahasbini thanks man, but my app is not shown in the settings where nfc payment apps are listed. how can i make it visible? – abdullahicyc Feb 27 '18 at 16:16
  • It should be once you register a `Service` with an `intent-filter` for `android.nfc.cardemulation.action.HOST_APDU_SERVICE` and `metadata` with `android.nfc.cardemulation.host_apdu_service` file in `AndroidManifest.xml`, check this link https://developer.android.com/guide/topics/connectivity/nfc/hce.html section **Service manifest declaration and AID registration** for more info – ahasbini Feb 27 '18 at 16:21

1 Answers1

0

I am trying to do the same like you and I found this question which ables you to show your app as payment method.

Application not visible in Tap and Pay

add this lines within application tag in your android manifest...

 <service android:exported="true" android:name="my.package.MyPaymentService" android:permission="android.permission.BIND_NFC_SERVICE">
        <intent-filter>
            <action android:name="android.nfc.cardemulation.action.HOST_APDU_SERVICE" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
        <meta-data android:name="android.nfc.cardemulation.host_apdu_service" android:resource="@xml/apduservice" />
    </service>

and then create a file named apdusehvices.xml in your xml folder with this content...

<host-apdu-service xmlns:android="http://schemas.android.com/apk/res/android"
    android:requireDeviceUnlock="true"
    android:apduServiceBanner="@drawable/ic_fingerprint_error">

    <aid-group
        android:category="payment"
        android:description="@string/app_name" >
        <aid-filter
            android:name="325041592E5359532E4444463031"
            android:description="@string/ppse" />
        <aid-filter
            android:name="A0000000041010"
            android:description="@string/mastercard" />
        <aid-filter
            android:name="A0000000031010"
            android:description="@string/visa" />
        <aid-filter
            android:name="A000000003101001"
            android:description="@string/visa" />
        <aid-filter
            android:name="A0000002771010"
            android:description="@string/interac" />
    </aid-group>

you will need to set the string variables in your values => strings and the background image in your drawable folder.

Now I can select my app as Tap & Pay app but when I select it the app crashes and I suppose it's because I haven't created there Service class and the manifest is pointing to my.package.MyPaymentService.

Pablo R.
  • 711
  • 2
  • 10
  • 31