Feature Manager

interface FeatureManager {
    fun verify(
        activity: Activity,
        request: FeatureRequest,
        credentialReceiver: CredentialReceiver,
        callback: FeatureCallback<VerifyResult>
    )
}

interface FeatureCallback<T> {
    fun onComplete(result: T, data: Map<String, Any?> = emptyMap())
    fun onError(error: GoPayEnterpriseError)
}

TerminologyDescription
requestIdRequest identifier generated by the client before initiating any flow via Enterprise SDK.
userCorrelationIdIdentifier linking the client user to GoPay, obtained from the credential exchange.
tokenThe linking token for the user — short-term when an exchange is required, long-term when it is not.

verify

Launches the GoPay verify flow. Validates the request internally and invokes FeatureCallback.onError (code GPE-2206) if required fields are missing rather than throwing.

Field NameField TypeField Description
activityActivityThe Android activity context used to launch the SDK UI.
requestFeatureRequestBuilt via FeatureRequest.Builder. Contains requestId, featureId, userCorrelationId, and token.
credentialReceiverCredentialReceiverSealed class controlling how the SDK delivers an auth-code credential. Use CredentialReceiver.Exchange to handle the handshake, or CredentialReceiver.None to skip it.
callbackFeatureCallback<VerifyResult>Receives onComplete(result, data) with a VerifyResult on completion, or onError(error) on failure.

FeatureRequest

FeatureRequest is constructed via its Builder. requestId and userCorrelationId are validated inside verify() — if either is blank, FeatureCallback.onError is called with GPE-2206 rather than throwing an exception.

class FeatureRequest private constructor(
    val requestId: String?,
    val featureId: String?,
    val userCorrelationId: String?,
    val token: String?
) {
    data class Builder(
        var requestId: String? = null,
        var featureId: String? = null,
        var userCorrelationId: String? = null,
        var token: String? = null
    ) {
        fun requestId(id: String): Builder
        fun featureId(id: String?): Builder
        fun userCorrelationId(id: String?): Builder
        fun token(t: String?): Builder
        fun build(): FeatureRequest
    }

    companion object {
        fun fromJson(obj: JSONObject): FeatureRequest
    }
}

Fields

Field nameTypeRequiredDescription
requestIdString?YesUnique identifier for the request, generated by the client (e.g. a UUID). Validated inside verify(); error returned if blank.
featureIdString?NoReserved for internal use. Do not set this field for the verify flow.
userCorrelationIdString?YesIdentifier linking the client user to GoPay. Validated inside verify(); error returned if blank.
tokenString?YesThe linking token for the user. Pass a short-term linking token when using CredentialReceiver.Exchange, or a long-term token when using CredentialReceiver.None.

Usage Notes

  • build() performs no validation — a request with blank requestId or userCorrelationId will build successfully but trigger FeatureCallback.onError(GPE-2206) when passed to verify().
  • Use FeatureRequest.fromJson(JSONObject) when constructing from a deserialised payload.
  • requestId must be unique per flow and is used for handshake and state correlation.

Example — Building from JSON

val jsonObj = JSONObject().apply {
    put("requestId", "unique-request-123")
    put("userCorrelationId", "user-correlation-456")
    put("token", "linking-token-xyz")
}

val request = FeatureRequest.fromJson(jsonObj)

featureManager.verify(
    activity = activity,
    request = request,
    credentialReceiver = credentialReceiver,
    callback = callback
)

GoPayCredential

Represents the authentication credential issued by the SDK to the client during a flow that requires a handshake.

sealed class GoPayCredential {
    data class AuthCode(val code: String) : GoPayCredential()
}
GoPayCredential typeDescription
AuthCodeThe one-time authentication code to exchange server-side for a user correlation ID.

CredentialReceiver

Sealed class that determines how the SDK delivers a GoPayCredential to the client during a flow requiring an auth-code handshake.

sealed class CredentialReceiver {
    data class Exchange(
        val handler: suspend (credential: GoPayCredential, requestId: String) -> ExchangeResult
    ) : CredentialReceiver()

    object None : CredentialReceiver()
}
VariantDescription
ExchangeUse when the user has a short-term linking token. The SDK invokes the handler with an auth code; the client exchanges it server-side and returns an ExchangeResult.
NoneUse when the user has a long-term token that is still valid. No auth-code exchange is required.

Usage Notes

  • Use CredentialReceiver.Exchange when the user has a short-term linking token that requires a backend exchange.
  • Use CredentialReceiver.None when the user has a long-term token that is still valid.
  • The handler lambda is invoked on a background coroutine dispatcher — do not perform UI operations directly inside it.

ExchangeResult

Sealed class returned by the CredentialReceiver.Exchange handler to signal the outcome of the backend credential exchange.

sealed class ExchangeResult {
    data class Success(val userCorrelationId: String) : ExchangeResult()
    data class Failure(val reason: String) : ExchangeResult()
}
VariantFieldDescription
SuccessuserCorrelationIdThe unique user identifier returned from the client's backend after exchanging the auth code.
FailurereasonA human-readable description of why the exchange failed. The SDK propagates this as GPE-2208.

Usage Notes

  • Return ExchangeResult.Success after successfully calling your backend and obtaining the userCorrelationId.
  • Return ExchangeResult.Failure if your backend call fails. The SDK stops the flow and invokes FeatureCallback.onError with code GPE-2208.
  • Do not throw exceptions from the handler; always return an ExchangeResult.

FeatureCallback

Interface implemented by the client to receive the result of a verify flow.

interface FeatureCallback<T> {
    fun onComplete(result: T, data: Map<String, Any?> = emptyMap())
    fun onError(error: GoPayEnterpriseError)
}

Function

Description

onComplete

Called when the flow completes.
result is the typed result (e.g. VerifyResult) data carries any additional metadata from the SDK.

onError

Called when the flow fails for any reason. See GoPayEnterpriseError for error codes.

VerifyResult

Result returned to FeatureCallback.onComplete after a successful verify flow.

data class VerifyResult(val submissionId: String)
FieldDescription
submissionIdSubmission identifier for the KYC flow, returned by the backend.

Example Usage

val request = FeatureRequest.Builder()
    .requestId("REQ-${System.currentTimeMillis()}")
    .userCorrelationId("user-correlation-id")
    .token("short-term-linking-token")
    .build()

val credentialReceiver = CredentialReceiver.Exchange { credential, requestId ->
    if (credential is GoPayCredential.AuthCode) {
        val correlationId = myBackend.exchangeAuthCode(credential.code, requestId)
        ExchangeResult.Success(userCorrelationId = correlationId)
    } else {
        ExchangeResult.Failure(reason = "Unexpected credential type")
    }
}

sdk.getFeatureManager().verify(
    activity = this,
    request = request,
    credentialReceiver = credentialReceiver,
    callback = object : FeatureCallback<VerifyResult> {
        override fun onComplete(result: VerifyResult, data: Map<String, Any?>) {
            Log.d(TAG, "Submission ID: ${result.submissionId}")
        }
        override fun onError(error: GoPayEnterpriseError) {
            Log.e(TAG, "Error ${error.code}: ${error.message}")
        }
    }
)