Handle the Centinel Lookup Response and SDK Handle the Challenge UI - Android

After the completion of the cmpi_lookup request, check the CMPI_Lookup_Response for the following fields : 

  • ThreeDSVersion = 2.X ( 2.0, 2.1, etc)
  • Enrolled = Y
  • PAResStatus = C

Upon validating the above fields, you will call cardinal.cca_continue to hand control to SDK for performing the challenge between the user and the issuing bank. Use the code snippet below for completing the cardinal.continue()

2.2.7-4 Update to cca_continue()

With the 2.2.7-4 release, we introduced a new way to display the challenge screen which will help avoid app crashes due to Android System killing the app while it is in background.

The new, overloaded ‘cca_continue()’ method takes in the following parameters:

  • String: transactionId
  • String: payload
  • CardinalChallengeObserver: challengeObserver
    • This is a new class that the App will have to instantiate in their onCreate() method and pass on the new cca_continue method.
    • The CardinalChallengeObserver takes in two parameters:
      • FragmentActivity
      • CardinalValidateReceiver: this was previously passed in the old cca_continue method directly. 

All the functionality of the older version of cca_continue() will function as before, but moving to this new method is recommended in order to help avoid the scenario where your app may be killed while in the background and the SDK then being unable to return control back to the app.

Java
  // This version of cca_continue is available in Cardinal SDK 2.2.7-4 for Android

  public void cca_continue(String transactionId, String payload, CardinalChallengeObserver challengeObserver) throws InvalidInputException {
    ccaProcessor.cca_continue(transactionId, payload, challengeObserver);
}

// The new CardinalChallengeObserver class is required in using the new version of cca_continue shown above

 
public CardinalChallengeObserver(@NonNull FragmentActivity activity, @NonNull CardinalValidateReceiver cardinalValidateReceiver) throws InvalidInputException {
    super(activity, cardinalValidateReceiver);
}


// Put together, it would look something like this:

CardinalChallengeObserver challengeObserver;
challengeObserver = new CardinalChallengeObserver(this, new CardinalValidateReceiver() {
    @Override
    public void onValidated(Context context, ValidateResponse validateResponse, String s) {
        //your code here to handle onValidate result
    }
});


Java
 /**
  * Cca continue
  *
  * @param transactionId     the transaction id
  * @param payload           the payload
  * @param currentActivity   the current activity
  * @throws InvalidInputException        the invalid input exception
  * @throws JSONException                the json exception
  * @throws UnsupportedEncodingException the unsupported encoding exception
  */
 try {
     cardinal.cca_continue("[TRANSACTION ID ]", "[PAYLOAD]", this, new CardinalValidateReceiver() {
            /**
             * This method is triggered when the transaction has been terminated. This is how SDK hands back
             * control to the merchant's application. This method will
             * include data on how the transaction attempt ended and
             * you should have your logic for reviewing the results of
             * the transaction and making decisions regarding next steps.
             * JWT will be empty if validate was not successful.
             *
             * @param validateResponse
             * @param serverJWT
             */
            @Override
            public void onValidated(Context currentContext, ValidateResponse validateResponse, String serverJWT) {

            }
        });
  }
 catch (Exception e) {
    // Handle exception
  }
Kotlin
 /**
  * Cca continue.
  *
  * @param transactionId     the transaction id
  * @param payload           the payload
  * @param currentActivity   the current activity
  * @throws InvalidInputException        the invalid input exception
  * @throws JSONException                the json exception
  * @throws UnsupportedEncodingException the unsupported encoding exception
  */
 try {
     cardinal.cca_continue("[TRANSACTION ID ]", "[PAYLOAD]", this, object: CardinalValidateReceiver {
            /**
             * This method is triggered when the transaction has been terminated.This is how SDK hands back
             * control to the merchant's application. This method will
             * include data on how the transaction attempt ended and
             * you should have your logic for reviewing the results of
             * the transaction and making decisions regarding next steps.
             * JWT will be empty if validate was not successful.
             *
             * @param validateResponse
             * @param serverJWT
             */
            override fun onValidated(currentContext: Context?, validateResponse: ValidateResponse, serverJWT: String?) {

            }
        });
  }
 catch (e: Exception) {
    // Handle exception
  }

onValidated() is triggered when the transaction has been terminated. This is how the Cardinal Mobile SDK hands back control to the merchant's application. This event will include data on how the transaction attempt ended and should be where you review the results of the transaction and make decisions regarding the next steps. The field ActionCode should be used to determine the overall state of the transaction. On the first pass, we recommend that on an ActionCode of 'SUCCESS' or 'NOACTION' you send the response JWT to your backend for verification. There is more information on verifying JWT's in the next section.

Java
@Override
   public void onValidated(Context currentContext, ValidateResponse validateResponse, String serverJWT) {
 
       switch (validateResponse.getActionCode()){
 
           case SUCCESS:
               // Handle successful transaction, send JWT to backend to verify
               break;
           case NOACTION:
               // Handle no actionable outcome
               break;
           case FAILURE:
               // Handle failed transaction attempt
               break;
 		   case CANCEL:
               // Handle cancel transaction 
               break;
           case ERROR:
               // Handle service level error
               break;
		   case TIMEOUT:
               // Handle timeout 
               break;
       }
   }

Kotlin
override fun onValidated(currentContext: Context?, validateResponse: ValidateResponse, serverJWT: String?) {
 
       when (validateResponse.getActionCode()!!) {
 
           CardinalActionCode.SUCCESS -> {
               // Handle successful transaction, send JWT to backend to verify
		   }

           CardinalActionCode.NOACTION -> {
               // Handle no actionable outcome
           }
 
           CardinalActionCode.FAILURE -> {
               // Handle failed transaction attempt
           }

 		   CardinalActionCode.CANCEL -> {
               // Handle cancel transaction 
           }

           CardinalActionCode.ERROR -> {
               // Handle service level error
           }

		   CardinalActionCode.TIMEOUT -> {
               // Handle timeout
           }
       }
   }

ValidateResponse Object 

Validate Response 

Modifier and TypeField and Description
com.cardinalcommerce.cardinalmobilesdk.models.CardinalActionCode
actionCode 
java.lang.StringconsumerSessionId 
java.lang.StringerrorDescription 
interrorNumber 
com.cardinalcommerce.cardinalmobilesdk.models.Payment
payment 
booleanvalidated 

Action Code

Enum Constant and Description
ERROR 
FAILURE 
NOACTION 
SUCCESS 
CANCEL
TIMEOUT

Payment

Modifier and TypeField and Description
com.cardinalcommerce.cardinalmobilesdk.models.ExtendedData
extendedData
The Extended data.
java.lang.StringprocessorTransactionId
The Processor transaction id.
java.lang.Stringtype
The Type.

Extended Data

Modifier and TypeField and Description
java.lang.Stringcavv
The Cavv.
java.lang.StringeciFlag
The Eci flag.
java.lang.Stringenrolled
Status of Authentication eligibility.
java.lang.StringpaResStatus
Transaction status result identifier.
java.lang.StringsignatureVerification
Transaction status result identifier.
java.lang.Stringxid
The Xid.