/android-sdk

FIDEL Android SDK

Primary LanguageJavaMIT LicenseMIT

FIDEL Android SDK

Setup

You can manually download FidelSDK.aar and import it as a new .jar/.aar module with File / New Module / Import .JAR/.AAR package command.

And add the following dependencies:

compile 'io.card:android-sdk:5.5.1'
compile 'com.afollestad.material-dialogs:core:0.9.4.5'
compile 'com.koushikdutta.ion:ion:2.+'

Alternatively, add jitpack.io to your root build.gradle at the end of repositories:

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

And finally add Fidel dependency

dependencies {
    compile 'com.github.FidelLimited:android-sdk:1.0.3'
}

Sample code

First, set up a programId and an apiKey (can be found in your dashboard):

Fidel.programId = "your program id";
Fidel.apiKey = "your api key";

You can pass additional data with com.google.gson.JsonObject:

JsonObject jsonMeta = new JsonObject();

jsonMeta.addProperty("id", "this-is-the-metadata-id");
jsonMeta.addProperty("customKey1", "customValue1");
jsonMeta.addProperty("customKey2", "customValue2");

Then, present the Fidel activity:

Fidel.present(YourActivityClass.this);

To automatically start credit card scanning, use:

Fidel.autoScan = true;

You can retrieve a card object, in case a card is successfully added:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if(requestCode == Fidel.FIDEL_LINK_CARD_REQUEST_CODE) {
        if(data != null && data.hasExtra(Fidel.FIDEL_LINK_CARD_RESULT_CARD)) {
            LinkResult card = (LinkResult)data.getParcelableExtra(Fidel.FIDEL_LINK_CARD_RESULT_CARD);

            Log.d("d", "CARD ID = " + card.id);
        }
    }
}

You can customize the topmost banner image:

Fidel.bannerImage = Bitmap(...);