Android SDK Integration

Documentation detailing how to integrate PIdg Android SDK in an Android App

Adding Equal PIdg Plugin as Dependency

Add Equal maven Repositiory URL

allprojects { 
    repositories { 
        google() 
        mavenCentral() 
        maven { 
           url "https://android-gateway-plugin.s3.ap-south-1.amazonaws.com"
        }
    } 
}

Add dependency on PIdg Plugin

android {
  ...
  buildFeatures {
    viewBinding true
    ...
  }
  ...
}
  ... 
dependencies{ 
  ... 
  implementation group: 'com.equal.gatewaysdk', name: 'gatewaysdk', version: '1.2.3', ext: 'aar', classifier: 'release'
  ... 
}

Initialising SDK

To optimise latency and improve user experience, EqualPIdgSdk requires initialisation to prefetch required assets, register global contexts, request for required permissions etc. At the start of your main Activity initialise the plugin.


public class MainActivity extends AppCompatActivity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ..
        ..
        ..
        //Init SDK should be in side the onCreate.
        PIdgPlugin.initSDK(this, SDKEnvironment.STAGE);
      	..
        ..

    }
}

Initialising SDK with Transaction & Token

When user initiates verification at your end, initialise an ID Exchange transaction at Equal end by invoking our /transaction/init API. Init API returns, ie_transaction_id and token in response. Pass these details to SDK and SDK will be ready to serve execute requests.

PIdgPlugin.registerTransaction(new PluginTransaction.Builder()
                               .clientId(client_id) //client_id -> Will be given during onboarding.
                               .token(token)
                               .transaction(transaction_id)
                               .build());

Executing Verification Journey

private void verifyPan(final String panNumber) {
     PluginExecuteReq pluginExecuteReq = new PluginExecuteReq();
     pluginExecuteReq.setJourneyId("pan_digital");
  	 pluginExecuteReq.setRequestId("<request_id>");
     Map<String, String> inputValue = new HashMap<>();
     inputValue.put("pan_no", panNumber);
     pluginExecuteReq.setData(inputValue);
     //Execute SDK
     try {
       PIdgPlugin.execute(this,
                          pluginExecuteReq,
                          new PIdgSuccessHandler() {
                          	 @Override
                          	 public void onSuccess(final PIdgSuccessEvent event) {
         											 //handle Success cases here
       											 }
                          },
                          new PIdgFailureHandler() {
                            @Override
                          	 public void onFailure(final PIdgFailureEvent event) {
         											 //handle Failure cases here
       											 }
                          },
                           
                          new PIdgEventHandler() {
                            @Override
                          	 public void onEvent(final PIdgEvent event) {
         											 //handle Failure cases here
       											 }
                          },
                         
     		});
      } catch (final PIDGException e) {
        throw new RuntimeException(e);
      }
}

SDK Events


VERIFICATION_STARTED

onEvent

This event is sent to the business when the verification journey got started.

Unless there is wrong journey id or other configuration related issues, this will be the first event that the business gets.

In-progress

Business can continue to show their loader indicating to the user that their verification is still in progress

VERIFICATION_UI_LAUNCHED

onEvent

This event is sent to the business indicating that Equal UI will be rendered. This might happen when

Correct the provided input

Handle the POO checks

Collect additional input

Take the user to fallback options

Completed

VERIFICATION_USER_CANCELLED

onError

VERIFICATION_HARD_FAILURE

onError

CONFIGURATION_ERROR

onError

VERIFICATION_BUSINESS_CANCELLED

onError

VERIFICATION_FALLBACK_STARTED

onEvent

INTERNAL_SERVER_ERROR

onError