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)
}| Terminology | Description |
|---|---|
| requestId | Request identifier generated by the client before initiating any flow via Enterprise SDK. |
| userCorrelationId | Identifier linking the client user to GoPay, obtained from the credential exchange. |
| token | The 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 Name | Field Type | Field Description |
|---|---|---|
| activity | Activity | The Android activity context used to launch the SDK UI. |
| request | FeatureRequest | Built via FeatureRequest.Builder. Contains requestId, featureId, userCorrelationId, and token. |
| credentialReceiver | CredentialReceiver | Sealed class controlling how the SDK delivers an auth-code credential. Use CredentialReceiver.Exchange to handle the handshake, or CredentialReceiver.None to skip it. |
| callback | FeatureCallback<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 name | Type | Required | Description |
|---|---|---|---|
| requestId | String? | Yes | Unique identifier for the request, generated by the client (e.g. a UUID). Validated inside verify(); error returned if blank. |
| featureId | String? | No | Reserved for internal use. Do not set this field for the verify flow. |
| userCorrelationId | String? | Yes | Identifier linking the client user to GoPay. Validated inside verify(); error returned if blank. |
| token | String? | Yes | The 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 blankrequestIdoruserCorrelationIdwill build successfully but triggerFeatureCallback.onError(GPE-2206)when passed toverify().- Use
FeatureRequest.fromJson(JSONObject)when constructing from a deserialised payload. requestIdmust 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 type | Description |
|---|---|
| AuthCode | The 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()
}| Variant | Description |
|---|---|
| Exchange | Use 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. |
| None | Use when the user has a long-term token that is still valid. No auth-code exchange is required. |
Usage Notes
- Use
CredentialReceiver.Exchangewhen the user has a short-term linking token that requires a backend exchange. - Use
CredentialReceiver.Nonewhen the user has a long-term token that is still valid. - The
handlerlambda 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()
}| Variant | Field | Description |
|---|---|---|
| Success | userCorrelationId | The unique user identifier returned from the client's backend after exchanging the auth code. |
| Failure | reason | A human-readable description of why the exchange failed. The SDK propagates this as GPE-2208. |
Usage Notes
- Return
ExchangeResult.Successafter successfully calling your backend and obtaining theuserCorrelationId. - Return
ExchangeResult.Failureif your backend call fails. The SDK stops the flow and invokesFeatureCallback.onErrorwith codeGPE-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. |
onError | Called when the flow fails for any reason. See |
VerifyResult
Result returned to FeatureCallback.onComplete after a successful verify flow.
data class VerifyResult(val submissionId: String)| Field | Description |
|---|---|
| submissionId | Submission 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}")
}
}
)Updated about 13 hours ago