> For the complete documentation index, see [llms.txt](https://docs.payments.thalescloud.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.payments.thalescloud.io/merchant-tokenization/es/ctf-y-daf-de-visa/implement-ctf-and-daf/create-device-binding-yellow-flow/activate-binding-with-otp.md).

# Activar la vinculación con OTP

La contraseña de un solo uso (OTP) se utiliza como el **ID\&V** método para activar un enlace de dispositivo pendiente.

Esta página continúa el flujo después de [Crear enlace de dispositivo (flujo amarillo)](/merchant-tokenization/es/ctf-y-daf-de-visa/implement-ctf-and-daf/create-device-binding-yellow-flow.md).

Prerrequisitos:

* Ya has iniciado `createBinding` o `resumeBinding`.
* El emisor seleccionó un método ID\&V basado en OTP (por ejemplo, `OTP_SMS`).
* Tu aplicación de comerciante puede recopilar un OTP del usuario final.

## Flujo

<figure><img src="/files/13f3ce48e404700f8712eb13fb9edc7eadad2abd" alt=""><figcaption><p>Flujo de enlace de dispositivo OTP.</p></figcaption></figure>

<table><thead><tr><th width="100">Paso</th><th>Descripción</th></tr></thead><tbody><tr><td>1</td><td>El usuario final selecciona una opción OTP (SMS, correo electrónico o banca en línea).</td></tr><tr><td>2</td><td>La aplicación del comerciante reenvía la selección al backend de Thales.</td></tr><tr><td>3–5</td><td>El backend de Thales solicita <strong>VTS</strong> y el <strong>emisor</strong> que entregue el OTP por el canal seleccionado.</td></tr><tr><td>6</td><td>El usuario final introduce el OTP en la aplicación del comerciante. La aplicación del comerciante posee la interfaz de usuario.</td></tr><tr><td>7–8</td><td>El backend de Thales valida el OTP con VTS y el emisor.</td></tr><tr><td>9</td><td>El SDK de Thales recibe el resultado y activa el enlace localmente.</td></tr><tr><td>10</td><td>El backend de Thales notifica al backend del comerciante/PSP que el enlace está activo.</td></tr></tbody></table>

## Integración del SDK

### 1. Seleccionar un método ID\&V OTP

Durante `createBinding` o `resumeBinding`, selecciona uno de los métodos ID\&V OTP:

* `OTP_SMS`
* `OTP_EMAIL`
* `OTP_ONLINE_BANKING`

{% tabs %}
{% tab title="Android" %}
Una vez que la aplicación envíe el `ID&V` método seleccionado con éxito, el `onIssuerAuthenticationReady` callback será devuelto a la aplicación. De lo contrario, un `onError` callback será devuelto.

```java
@Override
public void onIssuerAuthenticationRequired(PendingBindingSession pendingBindingSession) { 
    // Enviar método ID&V OTP_SMS
    for (IDVMethod idvMethod : pendingBindingSession.getIdvMethods()) {
        if (idvMethod.getType().equals(IDVType.OTP_SMS)) {
            pendingBindingSession.submitIdvMethod(idvMethod);
        }
    }
}

@Override
public void onIssuerAuthenticationReady(PendingBindingSession pendingBindingSession, 
                                        @Nullable OtpActivationStatus status) {
    
}

@Override
public void onError(TMGClientException exception) { 
    // Comprobar si hay algún error
    int errorCode = exception.getErrorCode();
    int errorMessage = exception.getMessage();
}
```

{% endtab %}

{% tab title="iOS" %}

```swift
guard let idvSession = VisaService.shared.idvSession else {
    // no hay sesión idv
    return
}
// 1. Mostrar la lista de métodos idv
do {
    let idvMethods = try idvSession.idvMethods
    let selectedIdvMethod = idvMethods[0] // el usuario selecciona un método idv OTP (OTP_SMS)
    
    // 2. enviar el método idv
    idvSession.selectIDVMethod(selectedIdvMethod) { (result) in
        if let otpActivationStatus = result {
            let maxOtpVerificationAllowed = otpActivationStatus.maxOTPVerificationAllowed
            let maxOtpRequestsAllowed = otpActivationStatus.maxOTPRequestsAllowed
            let otpExpiration = otpActivationStatus.otpExpiration
            
            // 3. Mostrar página para introducir el OTP
        }
    }
} catch let error {
    // manejar error
}

// 4. El fallo en el paso 2, selectIDVMethod, se manejará en completionHandler.
VisaService.shared.completionHandler = { (session, error) in
    // 5. Comprobar si es un error de selectIDVMethod.
    if let session = session,
        let error = error,
        error.description == TMGError.invalidIdvMethod.description {
        VisaService.shared.idvSession = session
        // 6. Reintentar el flujo IDV.
    }
}
```

{% endtab %}
{% endtabs %}

### 2. Activar el enlace

Recopila el OTP en tu aplicación de comerciante, luego llama a `activateBinding` en el `IDVSession`.

{% tabs %}
{% tab title="Android" %}

```java
@Override
public void onIssuerAuthenticationReady(IDVSession idvSession, 
                                        @Nullable OtpActivationStatus status) { 
    // Activar enlace
    String otp;
    idvSession.activateBinding(otp);
}

@Override
public void onIssuerAuthenticationError(@Nullable IDVSession idvSession, 
                                        TMGClientException tmgClientException) {
    // Comprobar el error o reintentar
}
```

El resultado se devuelve a través de `onSuccess` o `onIssuerAuthenticationError`.

Si la activación falla, utiliza el `IDVSession` devuelto en `onIssuerAuthenticationError` para reintentar.
{% endtab %}

{% tab title="iOS" %}

```swift
// 1. Valor OTP de la entrada del usuario
let otp = ""

guard let idvSession = VisaService.shared.idvSession else {
    // no hay sesión idv
    return
}
// 2. Llamar a activar
idvSession.activateBinding(withValue: otp)

VisaService.shared.completionHandler = { (session, error) in
    // 2. Enlace exitoso
    if error == nil {
        
    } else if let error = error,
                let session = session,
                error.description == TMGError.serverErrorWrongOTP.description {
        VisaService.shared.idvSession = session
        // 3. Reintentar la entrada OTP y mostrar mensaje de error
    }
}
```

El resultado se devuelve en `completionHandler`.

Si la activación falla, `completionHandler` devuelve un `IDVSession` y un error para reintentar.
{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.payments.thalescloud.io/merchant-tokenization/es/ctf-y-daf-de-visa/implement-ctf-and-daf/create-device-binding-yellow-flow/activate-binding-with-otp.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
