View on GitHub

sensibill-android-documentation

Sample Sensibill Integration

Last updated for v1.14.6.2
CompileSdkVersion => 27
BuildToolsVersion => 26.0.2
TargetSdkVersion => 27
MinSdkVersion => 18
supportLibraryVersion => 27.0.2

This project is a application demonstrating how to integrate with Sensibill SDK. Sample initialization of SDK is done in the SensibillManager class. Launching of Sensibill Functionality is done in the SensibillActionsActivity.

Environment Setup

Install Gradle

Installing Demo Repo via GitHub Desktop

Installing Demo Repo via Git command line


Integration Steps

Import SDK into the project
dependencies {
    compile "com.getsensibill:sensibill-auth:X.X.X"
    compile "com.getsensibill:sensibill-sdk-all:X.X.X"
    // Optional - For Transaction matching
    compile "com.getsensibill:sensibill-transaction-matcher:X.X.X"
    //Please ask for latest value of X.X.X from Sensibill
}

Pre SDK Initialization

IMPORTANT: Make sure that client credentials provided are for the chosen DefaultEnvironment

SDK Initialization

Initialization Extension: SDK Lifecycle Listener
Initialization Extension: Token Provider
Initialization Extension: Event Listener

###### Initialization Extension: Token Provider #####

- Transaction created in SDK, ie. Receipt Creation, can be monitored by providing a **TransactionDataObserver** during initialization.

InitializationBuilder builder = new InitializationBuilder(getApplicationContext(), DefaultEnvironment.BETA_SANDBOX) .transactionDataObserver(new TransactionDataObserver() { @Override public void notify(Transaction transaction) { // Monitor transaction } })


###### Initialization Extension: SDK Customization #####

- Additional SDK functional customizations can be made via SBSDKConfiguration. Set desired functionality, and pass to initialization builder.

InitializationBuilder builder = new InitializationBuilder(getApplicationContext(), DefaultEnvironment.BETA_SANDBOX) .configuration(new SBSDKConfiguration());


##### Build and Initialize #####

- Once InitializationBuilder object is created and optional extensions are added, SDK can be initialized by calling the following:

SensibillSDK.getInstance().initialize(builder.build());


**Example:** Initialization example can be found in [SensibillManager.java]

### Signing in User

- Once SDK is initialization, users can now sign in and use SDK. There are two flows that can be used to sign users into SDK

###### Access Token Sign in #####

- In the case where a token is coming from an external source, ie. a integration server, said token can be used to sign into SDK
- Before attempting to sign in with token, verify that token is valid using **SensibillSDK.getInstance().verifyToken()**

SensibillSDK.getInstance().verifyToken(username, access_token, new SessionVerificationListener() { @Override public void onValidSession() { // Valid Token }

@Override
public void onInvalidSession(@NotNull SBError sbError) {
    // Invalid Token
} }); ``` - If token is valid, attempt to sign in using **SensibillSDK.getInstance().login()**
SensibillSDK.getInstance().login(getApplicationContext(), access_token, username, new SDKStartup() {
    @Override
    public void onSDKStarted() {
        // SDK Logged in
    }

    @Override
    public void onSDKFailed(LoginError sdkLoginError, String message) {
        // SDK failed to login
    }
});
Username - Password
auth.signIn(username, password, new SensibillAuth.SessionListener() {
@Override
      public void onFailure(@NotNull SensibillAuth.AuthError error) {
        // Authorization Error
      }

      @Override
      public void onSuccess(@NotNull final OauthUser user) {
        // Sign in Successful
      }
}

Example: Login example can be found in [SensibillManager.java]


Using Sensibill SDK Activities

Launching Capture Activity

Launching Receipt Detail Activity

Using SDK Fragment

There are couple of fragments that you can embed in your app’s activities for seamless integration between SDK and your app.

All these fragments can also be embedded directly in the layout file(except SBMainTabsFragment).


> **IMPORTANT** Make sure that Theme.Sensibill or a style extending Theme.Sensibill is applied to any activity hosting a Sensibill Fragment in the Android Manifest

***

### Customize Sensibill Colours
To style SDK with brand colors, extend the Sensibill external theme **Theme.Sensibill**:
<style name="Theme.Sensibill" parent="Base.Theme.Sensibill">
    ...
</style> ```

The SDK has 16 colours which can be overridden in the Theme.Sensibill style. All elements in the SDK map to one of the 16 colours. For further details on the sensibill branding strategy please refer to the provided style guide. The following is an example of a full re-branding of the Sensibill SDK:

    <style name="Theme.Sensibill" parent="Base.Theme.Sensibill">
        <item name="sb__brandBackground">@color/myBank_brandBackground</item>
        <item name="sb__brandForeground">@color/white</item>
        <item name="sb__brandForegroundDisabled">@color/myBank_brandBackground</item>
        <item name="sb__actionBackground">@color/myBank_actionBackground</item>
        <item name="sb__actionForeground">@color/white</item>
        <item name="sb__accentBackground">@color/myBank_accentBackground</item>
        <item name="sb__accentForeground">@color/black</item>
        <item name="sb__alternateBackground">@color/myBank_alternateBackground</item>
        <item name="sb__alternateForeground">@color/white</item>
        <item name="sb__errorBackground">@color/myBank_errorBackground</item>
        <item name="sb__errorForeground">@color/white</item>
        <item name="sb__disabledBackground">@color/myBank_disabledBackground</item>
        <item name="sb__disabledForeground">@color/white</item>
        <item name="sb__primaryBackground">@color/myBank_primaryBackground</item>
        <item name="sb__offPrimaryBackground">@color/white</item>
        <item name="sb__primaryForeground">@color/black</item>
        <item name="sb__primaryForegroundTwo">@color/myBank_primaryForegroundTwo</item>
        <item name="sb__primaryForegroundThree">@color/myBank_primaryForegroundThree</item>
        <item name="sb__primaryForegroundFour">@color/myBank_primaryForegroundFour</item>
    </style>

To brand SDK for android versions less than 23, override the following colors to get the same affect:

    <color name="sb__brand_background">@color/myBank_brandBackground</color>
    <color name="sb__action_background">@color/myBank_actionBackground</color>
    <color name="sb__accent_background">@color/myBank_accentBackground</color>
    <color name="sb__accent_foreground">@color/black</color>
    <color name="sb__alternate_foreground">@color/myBank_alternateBackground</color>
    <color name="sb__error_background">@color/myBank_errorBackground</color>
    <color name="sb__disabled_background">@color/myBank_disabledBackground</color>
    <color name="sb__primary_background">@color/myBank_primaryBackground</color>
    <color name="sb__primary_off_background">@color/white</color>
    <color name="sb__primary_foreground">@color/black</color>
    <color name="sb__primary_foreground_two">@color/myBank_primaryForegroundTwo</color>
    <color name="sb__primary_foreground_three">@color/myBank_primaryForegroundThree</color>
    <color name="sb__primary_foreground_four">@color/myBank_primaryForegroundFour</color>
    ...

Customize Sensibill Font

To customize font of SDK, create a resource folder called assets with subfolder fonts.

Asset Folder

Add a bold, italic and regular version of desired font to the fonts folder. Create three string resources of the path to each font starting from the assets folder, for example:

    <string name="brand_font_regular">fonts/RNHouseSans-Regular.ttf</string>
    <string name="brand_font_bold">fonts/RNHouseSans-Bold.ttf</string>
    <string name="brand_font_italic">fonts/RNHouseSans-Italic.ttf</string>

Override the sb__font_regular, sb__font_italic, sb__font_bold properties of Theme.Sensibill with your string resources pointing to your desired fonts. For example:

    <style name="Theme.Sensibill" parent="Base.Theme.Sensibill">
        ...
        <item name="sb__font_regular">@string/brand_font_regular</item>
        <item name="sb__font_italic">@string/brand_font_italic</item>
        <item name="sb__font_bold">@string/brand_font_bold</item>
        ...
    </style>