> 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/integracion-del-sdk/integration/android.md).

# Android

Use esta guía para integrar el **SDK de Thales** en una aplicación de comerciante para Android.

### Paquete de entrega <a href="#delivery-packages" id="delivery-packages"></a>

El paquete de entrega del SDK incluye:

| Nombre                                                  | Descripción                                                  |
| ------------------------------------------------------- | ------------------------------------------------------------ |
| tmgsdk-debug-`<versión>`-`<fecha_de_lanzamiento>`.aar   | AAR de depuración para el SDK de Thales.                     |
| tmgsdk-release-`<versión>`-`<fecha_de_lanzamiento>`.aar | AAR de lanzamiento para el SDK de Thales.                    |
| demo                                                    | Proyecto de ejemplo que muestra cómo integrar y usar el SDK. |
| javadoc                                                 | Documentación de la API del SDK.                             |

### Dependencias <a href="#dependencies" id="dependencies"></a>

<table><thead><tr><th width="100">Nombre de la dependencia</th><th width="100">Versión</th><th>Descripción</th></tr></thead><tbody><tr><td>JNA</td><td>5.5.0</td><td>Esta biblioteca se utiliza para acceder a las bibliotecas nativas que se incluyen con el SDK de Thales.</td></tr><tr><td>AndroidX Biometric</td><td>1.1.0</td><td>Esta biblioteca se utiliza para la autenticación biométrica en dispositivos Android.</td></tr></tbody></table>

{% hint style="warning" %}
Desde la versión v2.0.0 del SDK, OkHttp ya no es obligatorio.
{% endhint %}

### Integrar el SDK <a href="#application-integration" id="application-integration"></a>

1. Cree una carpeta llamada `libs` bajo el directorio del proyecto.

<figure><img src="/files/e7abbdc50ef1ab491d5f47ad793c506a7f2a1917" alt=""><figcaption><p>Ejemplo <code>libs</code> carpeta que contiene el AAR del SDK.</p></figcaption></figure>

2. Copiar `tmgsdk-<variant>-<version>-<release_date>.aar` en la `libs` carpeta.

   `variant` es `debug` o `lanzamiento`.
3. Abra el `archivo app/build.gradle` y agregue las siguientes dependencias:

```java
implementation 'androidx.biometric:biometric:1.1.0'
implementation 'net.java.dev.jna:jna:5.5.0@aar'
implementation fileTree(dir: 'libs', include: ['*.aar'])
```

### Configurar el SDK <a href="#sdk-configuration" id="sdk-configuration"></a>

{% hint style="warning" %}

* Desde la versión v2.0.0 del SDK, la aplicación ya no está obligada a proporcionar el valor PIN del certificado.
* Desde la versión v3.0.0 del SDK, el SDK ya no es compatible con Android Keyguard.
  {% endhint %}

Configure Thales SDK antes de llamar a cualquier API del SDK.

Construya un `TMGClientConfiguration` con los parámetros requeridos:

* Contexto de la aplicación
* URL del servidor
* Certificado del servidor
* Identificador de clave

#### 1. Cree un `TMGClientConfiguration`

Obtenga la URL del servidor, el certificado del servidor y el identificador de clave durante el registro.

```java
Activity activity;
String serverUrl;
byte[] serverCertificate;
String keyIdentifier;
TMGClientConfiguration tmgClientConfiguration = new TMGClientConfiguration(activity, 
                                                                           serverUrl, 
                                                                           serverCertificate, 
                                                                           keyIdentifier);
```

#### 2. Comprobar compatibilidad biométrica

Compruebe si el dispositivo admite la autenticación biométrica.

```java
int biometricSupport = DeviceAuthenticationChecker.getBiometricsSupport(activity);
if (biometricSupport == BiometricsSupport.SUPPORTED) {
    // El dispositivo actual admite biometría.
}
```

#### 3. Cree un `VisaCTFHelper`

Cree el asistente para iniciar el emparejamiento del dispositivo y autenticar transacciones para Visa CTF y DAF.

```java
public void initVisaCTFHelper(@NonNull TMGClientConfiguration tmgClientConfiguration) {
    try {
        VisaCTFHelper visaCTFHelper = TMGClient.getInstance().createVisaCTFHelper(tmgClientConfiguration);
    } catch (TMGClientException e) {
        // Manejar error.
    }
}
```

#### 4. Cree un `MastercardTAFHelper`

Cree el asistente para iniciar el emparejamiento del dispositivo y autenticar transacciones para Mastercard TAF.

```java
public void initMastercardTAFHelper(@NonNull TMGClientConfiguration tmgClientConfiguration) {
   try {
       MastercardTAFHelper mastercardTAFHelper = TMGClient.getInstance().createMastercardTAFHelper(tmgClientConfiguration);
   } catch (TMGClientException e) {
       // Manejar error.
   }
}
```


---

# 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/integracion-del-sdk/integration/android.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.
