> 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="https://2211683957-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9XBN1F9dv7Dl1ggilGWC%2Fuploads%2FgMYP2MS3ngOcxoihi90B%2F%7BBA31E7F3-9182-412E-99F1-4D271E111E29%7D.png?alt=media&amp;token=a53d7fe7-eaf5-4c31-948a-48a5bc89904a" 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 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/integracion-del-sdk/integration/android.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.
