> 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/manage-digital-card/display-card-metadata.md).

# Display card metadata

### Overview

Retrieve cached metadata for a digital card.

This metadata can include card art, the last four digits of the PAN, and the expiry date.

### Flow

Use `D1PayWallet.getCachedCardMetadata()` to retrieve card metadata stored in the local cache.

{% hint style="info" %}
`D1PayWallet.getCachedCardMetadata()` does not require the `login` API.
{% endhint %}

This API helps the issuer application display card metadata in offline mode.

The cache updates automatically when:

* the end user digitizes a new card with `D1PayWallet.addCard()`
* the issuer application calls `D1Task.getCardMetadata()`

This keeps the cached `CardMetadata` synchronized with the latest data from the D1 backend.

When card renewal occurs, the cached metadata updates as well. See [Review card LCM](/nfc-payment/implement-nfc-payment/manage-digital-card/review-card-lcm.md) for details.

{% hint style="warning" %}
If the local cache is not synchronized with the D1 backend, `state`, `expiryDate`, and card art may be missing or outdated.
{% endhint %}

### SDK

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

```kotlin
fun getCachedCardMetadata(d1Task: D1Task, cardID: String) { // cardID: Digitised card ID
    val d1PayWallet : D1PayWallet = d1Task.d1PayWallet

    d1PayWallet.getCachedCardMetadata(cardID, object : D1Task.Callback<CardMetadata?> {
        override fun onSuccess(data: CardMetadata?) {
            data?.let {
                val last4: String = it.last4Pan
                val scheme: Scheme = it.scheme

                // If the cached card metadata is not synchronized with the D1 backend,
                // this API may not return `state`, `expiryDate`, or card art.
                val expiryDate: String = it.expiryDate
                val state: State = it.state
                getCardAssets(it)
            }
        }

        override fun onError(exception: D1Exception) {
            // Refer to D1 SDK Integration – Error Management section
        }
    })
}

fun getCardAssets(cardMetadata: CardMetadata) {
    cardMetadata.getAssetList(object : D1Task.Callback<List<CardAsset>> {
        override fun onSuccess(data: List<CardAsset>) {
            // Update the UI based on the card asset.
        }

        override fun onError(exception: D1Exception) {
            // If card art is not available in the local cache,
            // `cardMetadata.getAssetList()` returns `D1Exception.ErrorCode.ERROR_D1PAY_NO_CARD_ART_CACHE`.
            // The issuer application can use this error code to display a local template image
            // based on the payment network (`VISA`, `MASTERCARD`).
            if (exception.errorCode == D1Exception.ErrorCode.ERROR_D1PAY_NO_CARD_ART_CACHE) {
                if (cardMetadata.scheme == Scheme.MASTERCARD) {
                    // Update UI using MASTERCARD template image
                } else if (cardMetadata.scheme == Scheme.VISA) {
                    // Update UI using VISA template image
                }
            }
        }
    })
}
```

{% endtab %}

{% tab title="Android Java" %}

```java
public void getCachedCardMetadata(@NonNull D1Task d1Task, @NonNull String cardID) { // cardID: Digitised card ID
    D1PayWallet d1PayWallet = d1Task.getD1PayWallet();

    d1PayWallet.getCachedCardMetadata(cardID, new D1Task.Callback<CardMetadata>() {
        @Override
        public void onSuccess(CardMetadata data) {
            @NonNull String last4 = data.getLast4Pan();
            @NonNull Scheme scheme = data.getScheme();

            // If the cached card metadata is not synchronized with the D1 backend,
            // this API may not return `state`, `expiryDate`, or card art.
            @Nullable String expiryDate = data.getExpiryDate();
            @Nullable State state = data.getState();
            getCardAssets(data);
        }

        @Override
        public void onError(@NonNull D1Exception exception) {
            // Refer to D1 SDK Integration – Error Management section.
        }
    });
}

public void getCardAssets(@NonNull CardMetadata cardMetadata) {
    cardMetadata.getAssetList(new D1Task.Callback<List<CardAsset>>() {
        @Override
        public void onSuccess(List<CardAsset> data) {
            // Update the UI based on the card asset.
        }

        @Override
        public void onError(@NonNull D1Exception exception) {
            // If card art is not available in the local cache,
            // `cardMetadata.getAssetList()` returns `D1Exception.ErrorCode.ERROR_D1PAY_NO_CARD_ART_CACHE`.
            // The issuer application can use this error code to display a local template image
            // based on the payment network (`VISA`, `MASTERCARD`).
            if(exception.getErrorCode() == D1Exception.ErrorCode.ERROR_D1PAY_NO_CARD_ART_CACHE) {
                if(cardMetadata.getScheme() == Scheme.MASTERCARD) {
                    // Update UI using local MASTERCARD template image
                } else if(cardMetadata.getScheme() == Scheme.VISA) {
                    // Update UI using local VISA template image
                }
            }
        }
    });
}
```

{% 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:

```
GET https://docs.payments.thalescloud.io/nfc-payment/implement-nfc-payment/manage-digital-card/display-card-metadata.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
