MiPassVerifyRequest

class MiPassVerifyRequest @JvmOverloads constructor(customerReferenceId: String? = null, enrollmentId: String)

Formats a request body to use with MiPass V2/V3 Verify API.

Samples

import android.content.Intent
import android.os.Bundle
import androidx.activity.result.ActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity
import com.miteksystems.misnap.apputil.LicenseFetcher
import com.miteksystems.misnap.R
import com.miteksystems.misnap.core.MiSnapSettings
import com.miteksystems.misnap.core.serverconnection.MiPassVerifyRequest
import com.miteksystems.misnap.core.serverconnection.MiSnapTransactionResult
import com.miteksystems.misnap.databinding.ExampleActivityIntegrationBinding
import com.miteksystems.misnap.workflow.MiSnapFinalResult
import com.miteksystems.misnap.workflow.MiSnapWorkflowActivity
import com.miteksystems.misnap.workflow.MiSnapWorkflowStep
import com.miteksystems.misnap.workflow.util.toServerResult
fun main() { 
   //sampleStart 
   /**
 * This example demonstrates how to handle the results from the MiSnap SDK to build an
 * HTTP request payload that can be used with the MiPass API for verification.
 *
 * NOTE: Ensure that the provided license has all the necessary features enabled for the target
 *  MiSnap session.
 *
 * @see [MiPassVerifyRequest] for the full list of properties used to build the payload.
 **/
class MiPassVerifyRequestActivity : AppCompatActivity() {

    /**
     * Fetch the Misnap SDK license.
     * Good practice: Handle the license in a way that it is remotely updatable.
     */
    private val license by lazy {  
        LicenseFetcher.fetch()
    }

    private lateinit var binding: ExampleActivityIntegrationBinding

    /**
     * Register a request to start an activity along with a callback to handle the results of
     * the launched activity once they're available to form the request payload.
     */
    private val registerForActivityResult =
        registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
            /**
             * ID returned as part of the response once enrollment request is sent to the MiPass Enroll V2/V3 API server.
             * It is needed to verify previous enrollment.
             */
            val enrollmentId = "98303-9393"
            val request = MiPassVerifyRequest(enrollmentId = enrollmentId)

            /**
             * Once the [ActivityResult] is available, get the available session results from
             * [MiSnapWorkflowActivity.Result.results] and handle them accordingly. To add the results
             * to the request payload builder first convert the [MiSnapWorkflowActivity.Result] into a
             * [MiSnapTransactionResult].
             */
            MiSnapWorkflowActivity.Result.results.iterator().forEach {
                when (it) {
                    is MiSnapWorkflowStep.Result.Success -> {
                        when (it.result) {
                            is MiSnapFinalResult.VoiceSession -> {
                                // Add the voice verification session result.
                                request.setVoiceResult(it.result.toServerResult() as MiSnapTransactionResult.VoiceResult)
                            }

                            is MiSnapFinalResult.FaceSession -> {
                                // Add the face session results.
                                request.setFaceResult(it.result.toServerResult() as MiSnapTransactionResult.FaceResult)
                            }
                            else -> {}
                        }
                    }
                    else -> {}
                }
            }

            /**
             * Prepare the Verify request payload once all the results are added, then use it in an HTTP
             * request and send it to MiPass Verify V2/V3 API server.
             */
            val verifyRequestString = request.getRequest()

            // Once you're done handling the results, clear them before calling for a new session.
            MiSnapWorkflowActivity.Result.clearResults()
        }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        binding = ExampleActivityIntegrationBinding.inflate(layoutInflater)
        setContentView(binding.root)
    }

    override fun onStart() {
        super.onStart()

        binding.startSession.setOnClickListener {
            /**
             * Create an [Intent] to launch the [MiSnapWorkflowActivity] by calling [MiSnapWorkflowActivity.buildIntent]
             * and passing the list of [MiSnapWorkflowStep]s with your custom [MiSnapSettings].
             *
             * If multiple steps are defined these will be handled in the order they were submitted.
             */
            registerForActivityResult.launch(
                MiSnapWorkflowActivity.buildIntent(
                    this,
                    MiSnapWorkflowStep(MiSnapSettings(MiSnapSettings.UseCase.VOICE, license).apply {
                        voice.flow = MiSnapSettings.Voice.Flow.VERIFICATION
                        voice.phrase =
                            resources.getStringArray(R.array.misnapWorkflowVoicePhraseSelectionFragmentPhrases)[0]
                    }),
                    MiSnapWorkflowStep(MiSnapSettings(MiSnapSettings.UseCase.FACE, license))
                )
            )
        }
    }
} 
   //sampleEnd
}

Constructors

Link copied to clipboard
constructor(customerReferenceId: String? = null, enrollmentId: String)

Functions

Link copied to clipboard

Generates a valid formatted request body from the added results.

Link copied to clipboard

Sets the data of a voice session result to format the request.

Link copied to clipboard

Sets the data of a voice session result to format the request.