Capability Provider

Hi,
How do I use the CapabilityProvider to call my app from the Payment Fragment when my app icon is pressed?

From the sample gift card processor app’s code, I can see that the giftcard_capabilities.xml file is the one that has to be changed. It’s contents are:

<?xml version="1.0" encoding="utf-8"?>
<capability>
    <!-- Special App ID for Transaction Processing-->
    <appid>co.poynt.samplegiftcardprocessor</appid>

    <type>TRANSACTION</type>

    <!-- descriptive name of this capability -->
    <provider>GIFT CARD</provider>

    <!-- reserved to future use. This icon will show up on your CUSTOM button in Payment Fragment payment options in the future -->
    <logo>@drawable/ic_launcher</logo>

    <!-- entry method could be one of the following
        CARDREAD -> card data will be directly passed to this capability provider.
        CUSTOM -> other entry methods.
        each entry method can be additionally filtered with eval tag.
    -->
    <!-- value is a first6 digits of card number also referred to as binrange.
        value >=601056 && value <= 601056 -->
    <!-- for eval expression definition please refer to https://github.com/uklimaschewski/EvalEx -->
    <entry_method
        eval="value &lt;= 198000 &amp;&amp; value &gt;=  197000"
        type="CARDREAD" />
    <entry_method type="CUSTOM" />
</capability>

I have changed the appid, provider and logo values. Also, I have changed the Service class to call my app’s MainActivity:
Intent paymentActivity = new Intent("COLLECT_CUSTOM_PAYMENT"); paymentActivity.setComponent(new ComponentName(getPackageName(), MainActivity.class.getName())); paymentActivity.putExtra("transaction", transaction); listener.onLaunchActivity(paymentActivity, requestId);

After making these changes, I installed the app to the device. But when I press my app’s icon in the Payment Fragment while making a transaction, it launches the sample gift card processor app which I installed on the device.

Looks like there is a conflict as Capability Manager is unable to recognize my app. If I uninstall the sample app, my app is correctly called.

Please help.

Thank You,
Akilan Arasu

Hi Akilan,

Currently there is a limitation where only one CUSTOM provider can be installed on a device. So you will need to uninstall the sample app first.

Thanks @dennis :smiley:
Got it.