> 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/nfc-wallet-sdk-android/es/implement-nfc-wallet/make-payment/replenish-payment-keys.md).

# Reponer las claves de pago

## Descripción general

Se requieren claves de pago (SUK o LUK) para calcular criptogramas EMV para pagos sin contacto.

En un modelo de emulación de tarjeta en el host (HCE), las claves de pago son temporales. Repóngalas antes de que se agoten. Esto evita interrupciones en los pagos.

Esta guía cubre cuándo reponer y cómo activarlo.

{% hint style="info" %}
El NFC Wallet SDK admite estos tipos de claves de pago:

* **SUK (clave de un solo uso)**: Use una clave por transacción. Se usa para Mastercard y PURE (EMV de marca blanca).
* **LUK (clave de uso limitado)**: Use una clave para varias transacciones. Se usa para Visa.
  {% endhint %}

## Requisitos previos

### Configurar umbrales de reposición (incorporación)

Configure los umbrales de reposición durante la incorporación con el **equipo de entrega de Thales**.

{% hint style="info" %}
Al definir los umbrales, tenga en cuenta:

* **SUK**: Cantidad restante de SUK que activa la reposición.
* **LUK**: Cantidad restante de transacciones y tiempo de vencimiento de la LUK.
  {% endhint %}

## Integración del SDK

### Detectar cuándo se requiere reposición

Use una (o ambas) de estas señales:

* **Comprobación proactiva**: Lea el estado de la tarjeta digital.
* **Empuje reactivo (activado por TSP)**: Procese `MG:ReplenishmentNeededNotification` del **TSP**.

Para la entrega y el enrutamiento de push, consulte [Gestionar notificaciones push](/nfc-wallet-sdk-android/es/get-started/configuration/5.-push-notifications/handle-push-notifications.md).

#### Comprobación proactiva

Ejecute esta comprobación para cada tarjeta digital. Ejecútela al iniciar la aplicación o después de un pago.

1. Obtener `DigitalizedCardStatus` de `DigitalizedCard`.
2. Llamar a `DigitalizedCardStatus.needsReplenishment()`.

Consulte [Mostrar tarjetas digitales](/nfc-wallet-sdk-android/es/implement-nfc-wallet/manage-digital-cards/display-digital-cards.md).

{% code title="Comprobar si una tarjeta digital necesita reposición" %}

```java
public static boolean needsReplenishment(final DigitalizedCard card) {
    AsyncResult<DigitalizedCardStatus> result =
            card.getCardState(null).waitToComplete();

    if (!result.isSuccessful()) {
        // TODO: manejar error
        return false;
    }

    DigitalizedCardStatus status = result.getResult();
    return status != null && status.needsReplenishment();
}
```

{% endcode %}

Realice esta comprobación proactiva:

* Al iniciar regularmente la aplicación
  * No realice la comprobación si la aplicación se inicia para un pago; consulte la advertencia a continuación
* Después de un pago
  * En el evento `onNextTransactionReady` - consulte [implementar devoluciones de llamada de pago sin contacto](/nfc-wallet-sdk-android/es/implement-nfc-wallet/make-payment/implement-contactless-payments/2.-implement-contactless-payment-callbacks.md).
* Cuando la tarjeta se establece como predeterminada.
* Después de que se restablezca la conectividad (sin conexión → en línea).

{% hint style="warning" %}
Ejecute esta comprobación al iniciar la aplicación, después de **NFC Wallet SDK** la inicialización.

No ejecute esta comprobación cuando el usuario final inicie la aplicación para realizar un pago sin contacto. Puede retrasar la ejecución del pago.
{% endhint %}

### Activar la reposición

Llamar a `ProvisioningBusinessService.sendRequestForReplenishment(...)` para solicitar nuevas claves de pago.

1. Obtenga el identificador de la tarjeta.

   Use el **ID de la tarjeta tokenizada** - consulte [Mostrar tarjeta digital](/nfc-wallet-sdk-android/es/implement-nfc-wallet/manage-digital-cards/display-digital-cards.md#tokenized-card-id-versus-digital-card-id).
2. Envíe la solicitud de reposición.

   Llamar a `sendRequestForReplenishment(...)` e implemente `PushServiceListener`:

   * `onComplete`: La solicitud es aceptada.
   * `onError`: El SDK no puede enviar la solicitud. Inspeccione `ProvisioningServiceError`.

   <pre class="language-java" data-title="Enviar una solicitud de reposición"><code class="lang-java">public void replenish(final String tokenizedCardId, final boolean forced) {
       ProvisioningBusinessService service =
               ProvisioningServiceManager.getProvisioningBusinessService();

       service.sendRequestForReplenishment(
               tokenizedCardId,
               new ReplenishmentListener(),
               forced
       );
   }

   private static class ReplenishmentListener implements PushServiceListener {
       @Override
       public void onComplete() {
           // TODO: registrar éxito
       }

       @Override
       public void onError(final ProvisioningServiceError error) {
           // TODO: registrar error
       }

       @Override
       public void onUnsupportedPushContent(final Bundle bundle) {
           // No se usa para esta llamada.
       }

       @Override
       public void onServerMessage(final String tokenizedCardId,
                                   final ProvisioningServiceMessage message) {
           // No se usa para esta llamada.
       }
   }
   </code></pre>
3. Procese el push de reposición.

   Después de enviar la solicitud, el backend de NFC Wallet envía una notificación push. Su **aplicación de billetera digital** debe procesarla. Luego, el SDK recupera las nuevas claves de pago.

{% hint style="info" %}
Evite terminar la **aplicación de billetera digital** mientras la reposición está en curso.
{% endhint %}

{% hint style="info" %}
**Reposición activada por TSP**

Cuando reciba `MG:ReplenishmentNeededNotification`, active la reposición con `forced = true`.

Consulte [Procesar notificaciones MG (reposición)](/nfc-wallet-sdk-android/es/get-started/configuration/5.-push-notifications/handle-push-notifications.md#process-mg-notifications-replenishment).
{% endhint %}


---

# 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/nfc-wallet-sdk-android/es/implement-nfc-wallet/make-payment/replenish-payment-keys.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.
