> 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-payment/implement-nfc-payment/support-replenishment/replenish-payment-keys.md).

# Replenish payment keys

### Overview

Visa uses Limited Use Key (LUK) credentials that remain valid for a limited period, such as 10 days or 1 month.

If a LUK expires before any payment, the D1 SDK cannot replenish it without end user authentication. The LUK value is protected in the Android Keystore. Visa also requires the previous LUK data during replenishment to authorize retrieval of new credentials.

Mastercard uses Single Use Key (SUK) credentials for each transaction. Replenish SUK credentials when the remaining number is low.

{% hint style="info" %}
Although this scenario is rare, the issuer application must handle it for end users who rarely open the application. Implement this check during issuer application startup, after the D1 SDK is initialized and before displaying the digital card list.
{% endhint %}

### Flow

#### Replenishment with push notification

Push notifications are data messages handled silently by the issuer application. When the issuer application receives a push notification, it must forward it to the D1 SDK.

The D1 SDK processes the message and returns the message type `PushResponseKey.TYPE_REPLENISHMENT` and the related `cardId` when no error occurs. This indicates that the card requires replenishment.

The issuer application should then call the `replenish` API with `isForced` set to `true`.

See [Message Handling](/nfc-payment/integrate-d1-sdk/getting-started/configuration/4.-push-notifications/message-handling.md).

#### Digital card list

`D1PayDigitalCard` provides the `isReplenishmentNeeded()` flag to indicate whether the issuer application must call the `replenish` API. If this method returns `true`, call `replenish` with `isForced` set to `false`.

See [Digital card list](/nfc-payment/implement-nfc-payment/manage-digital-card/display-digital-card.md).

#### SDK

This example shows how to trigger replenishment.

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

```java
private void replenishment(String cardIdToReplenish, boolean isForced) {
    /**
     * Visa may require device authentication during replenishment.
     * The issuer application may need to check whether it is in the
     * background or foreground.
     */
    DeviceAuthenticationCallback cvmCallback = new DeviceAuthenticationCallback() {
        @Override
        public void onSuccess() {
            // User authentication succeeded.
        }

        @Override
        public void onFailed() {
            // User authentication failed. The issuer application may ask the
            // end user to retry.
        }

        @Override
        public void onHelp(int fpCode, @NonNull CharSequence fpDetail) {
            // For biometric only.

            // The issuer application may show the fpDetail message to the
            // end user.
        }

        @Override
        public void onError(int fpErrorCode) {
            // For biometric only.

            // An error occurred during biometric authentication, for example
            // if the wrong finger is used too many times and the sensor locks.
            // Depending on fpErrorCode, the issuer application should guide
            // the end user.
        }
    };

    if (cardIdToReplenish != null) {
        D1PayWallet d1PayWallet = d1Task.getD1PayWallet();
        d1PayWallet.replenish(cardIdToReplenish, isForced, cvmCallback,
            new D1Task.Callback<Void>() {
                @Override
                public void onSuccess(Void ignored) {
                    // Replenishment completed.
                }

                @Override
                public void onError(@NonNull D1Exception exception) {
                    // Refer to the D1 SDK error management section.
                }
            });
    }
}
```

{% 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/nfc-payment/implement-nfc-payment/support-replenishment/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.
