> 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/authenticate-a-transaction.md).

# Autenticar una transacción

Una vez que el dispositivo está vinculado, puedes autenticar una transacción sin presencia de tarjeta usando Visa Cloud Token Framework (CTF) y Digital Authentication Framework (DAF).

## Flujo

<figure><img src="https://2211683957-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9XBN1F9dv7Dl1ggilGWC%2Fuploads%2FiOUXIbJk6Bg2leTG0iwN%2FFlow%20-%20Authenticate%20a%20transaction.svg?alt=media&amp;token=56927190-9f38-4952-909f-d7581970397b" alt=""><figcaption><p>Flujo de autenticación de transacciones CTF y DAF.</p></figcaption></figure>

<table><thead><tr><th width="100">Paso</th><th>Descripción</th></tr></thead><tbody><tr><td>1</td><td>Durante la transacción, la aplicación del comercio activa el SDK de Thales para autenticar al usuario final.</td></tr><tr><td>2</td><td>Después de una autenticación exitosa, el SDK de Thales genera una carga útil definida por Visa.</td></tr><tr><td>3</td><td>El comercio o PSP llama al backend de Thales con el <code>tokenId</code>, la carga útil de Visa y los detalles de la transacción.</td></tr><tr><td>4</td><td>El backend de Thales solicita detalles del token y un criptograma a VTS (el TSP de Visa).</td></tr><tr><td>5</td><td>El backend de Thales devuelve un <code>transactionId</code>, los detalles del token y el criptograma TAF/CTF.</td></tr><tr><td>6-10</td><td>El comercio o PSP construye la solicitud de autorización, la envía al adquirente y finaliza el pago.</td></tr></tbody></table>

## Integración del SDK

### Autenticar la transacción

Llamar `authenticateTransaction` desde `VisaCTFHelper`.

Esta llamada requiere la presencia del usuario final. Activa la autenticación en el dispositivo.

{% tabs %}
{% tab title="Android" %}
Autenticar la transacción requiere la presencia del usuario final. Para ello, llama a `startAuthentication` para iniciar la autenticación en el dispositivo.

Esta función se puede encontrar en el `DeviceAuthentication` objeto de la `onDeviceAuthentication` devolución de llamada que forma parte de `TransactionListener`.

Se pueden pasar algunas cadenas de texto personalizadas a la `startAuthentication` función para la visualización en la interfaz de usuario de la autenticación biométrica.

```java
visaCTFHelper.authenticateTransaction(vProvisionedTokenId,
                                        new TransactionListener() {
                @Override
                public void onDeviceAuthentication(DeviceAuthentication deviceAuthentication) {
                    FragmentActivity fragmentActivity;
                    CharSequence title;
                    CharSequence subTitle;
                    CharSequence description;
                    CharSequence negativeButtonText;
                    deviceAuthentication.startAuthentication(fragmentActivity, 
                                                            title, 
                                                            subTitle, 
                                                            description, 
                                                            negativeButtonText);
                }

                @Override
                public void onError(TMGClientException exception) {
                    // Comprobar error
                    int errorCode = exception.getErrorCode();
                    int errorMessage = exception.getMessage();
                }

                @Override
                public void onSuccess(String visaPayload) {
                    // Carga útil de Visa recuperada
                }
            });
```

El SDK devuelve el resultado en `onSuccess` o `onError`.

Si tiene éxito, `onSuccess` devuelve una carga útil de Visa. Úsala en tu llamada del lado del servidor al backend de Thales.
{% endtab %}

{% tab title="iOS" %}
Autenticar la transacción requiere la presencia del usuario final. Para ello, llama a `startAuthentication` para iniciar la autenticación en el dispositivo.

Esta función se puede encontrar en el `DeviceAuthentication` objeto de la `deviceAuthenticationHandler` devolución de llamada que forma parte de `authenticateTransaction`.

```swift
let vProvisionedTokenID: String = ""
            
// 1. Iniciar la autenticación de la transacción
visaCTFHelper.authenticateTransaction(forVProvisionedTokenID: vProvisionedTokenID,
                                      deviceAuthenticationHandler: { auth in
        // 2. Iniciar la autenticación del usuario
        let customMessage = "" // Pasa el mensaje personalizado. p. ej.: "Autenticar con Face ID"
        auth.startAuthentication(withMessage: customMessage)
    }, completionHandler: { (visaPayload, error) in
        // 3. Éxito: generar carga útil
        if error == nil {
            
        } else {
            // Manejar el error
        }
})
```

{% endtab %}
{% endtabs %}

## API

Usa la misma operación del backend de Thales que en otros flujos de transacción.

* Referencia de API: [Crear transacción](broken://pages/08156055f53c693bbf24bc8205632ecabbd96544#post-v2-transactions)


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.payments.thalescloud.io/merchant-tokenization/es/ctf-y-daf-de-visa/implement-ctf-and-daf/authenticate-a-transaction.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
