> 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/secure-card-display/implement-secure-card-display/display-card-metadata.md).

# Display Card Metadata

## Overview

This section describes how to display the non-sensitive card data in the issuer application.

## User experience

<div align="left"><figure><img src="https://422423898-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdtyHvT2CJEJbb6gkHON7%2Fuploads%2FPle2AioiIRXiLW7U0L3h%2FGroup%2039915.png?alt=media&amp;token=10362f38-fb5d-4275-9450-76c490af6de4" alt="" width="336"><figcaption></figcaption></figure></div>

## Sequence diagram

#### Prerequisites:

* End user and cards are registered in D1 backend.
* D1 SDK is properly initialised.
* Issuer application called D1 SDK login API.

<figure><img src="https://422423898-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdtyHvT2CJEJbb6gkHON7%2Fuploads%2FjoJ5H45RyU5QMywPIOKw%2FSequence%20Diagram%20-%20Secure%20Card%20Display%20-%20Metadata.png?alt=media&amp;token=532649d0-25d2-47b0-af8f-4f6078af8a76" alt=""><figcaption></figcaption></figure>

Based on the `cardID` value, the issuer application can display the basic information of the card to the end user such as the last four PAN digits, the expiry date, the card image background, and so on.

D1 SDK exposes the public `getCardMetaData()` API to get the card information. The `CardMetadata.cardAssetArray()` API for iOS and the `CardMetadata.getAssetList()` API for Android retrieve card assets. On the first call, the D1 SDK fetches card assets from D1 backend and caches them locally. On subsequent calls, the D1 SDK returns card assets from the local cache.

For a card issued by D1, additional card information such as “State Reason” and “Ongoing Operation” can be obtained using the CardMetadata.getStateReason() and CardMetadata.getOngoingOperation() APIs.

{% hint style="info" %}
The list of cards can be obtained with the `getCardList()` operation.
{% endhint %}

{% tabs %}
{% tab title="Android >= 4.4.0" %}

```kotlin
fun getCardMetaData(d1Task: D1Task, cardID: String, activity: FragmentActivity) {
    activity.lifecycleScope.launch {
        try {
            val cardMetadata = d1Task.secureCardDisplayService.getCardMetadata(cardID).await()

            // Last 4 digits of PAN
            val last4Pan = cardMetadata.last4Pan

            // CardAsset is used to display Card Artwork
            val cardAssets = cardMetadata.getAssetList().await()
            // Proceeds with the application logic
        } catch (exception: D1Exception) {
            // Refer to D1 SDK Integration – Error Management section
        }
    }
}
```

{% endtab %}

{% tab title="Android < 4.4.0" %}

```kotlin
fun getCardMetaData(d1Task: D1Task) {
    var cardID = "" // Card ID received from backend.
    val callback = object : D1Task.Callback<CardMetadata> {
      override fun onSuccess(cardMetadata: CardMetadata) {
        // Last 4 digits of PAN.
        val last4Pan = cardMetadata.last4Pan

        // CardAsset is used to display Card Artwork.
        cardMetadata.getAssetList(object : D1Task.Callback<List<CardAsset>> {
          override fun onSuccess(cardAssets: List<CardAsset>) {
          // Proceeds with the application logic.
          }
  
          override fun onError(e: D1Exception) {
          // Handles the error. For example, log it, display it, and so on.
          }
        })
    }
      override fun onError(exception: D1Exception) {
        // Refer to D1 SDK Integration – Error Management section.
      }
    }

    d1Task.getCardMetadata(cardID, callback)
}
```

{% endtab %}

{% tab title="iOS >= 4.4.0" %}

```swift
let cardID = "" // obtained e.g. from server
do {
    let service = try d1Task.secureCardDisplayService()
    let cardMetadata = try await service.cardMetadata(cardID)
    // Proceed with subsequent flows e.g. update UI
    print("Scheme: \(cardMetadata.cardScheme.rawValue)")
    print("State: \(cardMetadata.cardState.rawValue)")
    print("Exp: \(cardMetadata.cardExpiry)")
    print("Last4: **** **** **** \(cardMetadata.cardLast4)")
    // e.g. show the first card art
    let assets = try await cardMetadata.cardAssetArray()
    if let cardAssetContent = assets.first?.contentArray.first,
       let cardImageData = Data(base64Encoded: cardAssetContent.encodedData, options: .ignoreUnknownCharacters) {
        let image = UIImage.init(data: cardImageData)
    }
} catch let d1Error as D1Error {
    // Refer to D1 SDK Integration – Error Management section
} catch let error {
    // Handle other error
}
```

{% endtab %}

{% tab title="iOS < 4.4.0" %}

```swift
let cardID = "" // Obtained for example, from server.
d1Task.cardMetadata(cardID) { cardMetadata, error in
    if let error = error {
        // Refer to D1 SDK Integration – Error Management section.
    } else if let cardMetadata = cardMetadata {
        // Proceeds with subsequent flows. For example, update UI.
        print("Scheme: \(cardMetadata.cardScheme.rawValue)")
        print("State: \(cardMetadata.cardState.rawValue)")
        print("Exp: \(cardMetadata.cardExpiry)")
        print("Last4: **** **** **** \(cardMetadata.cardLast4)")

        print("reason: \(cardMetadata.reason.rawValue)")
        print("Ongoing operation: \(cardMetadata.ongoingOperation.rawValue)")

        // For example, shows the first card artwork.
        cardMetadata.cardAssetArray { assets, error in
            if let cardAssetContent = assets?.first?.contentArray.first,
               let cardImageData = Data(base64Encoded: cardAssetContent.encodedData, options: .ignoreUnknownCharacters) {
                let image = UIImage.init(data: cardImageData)
            }
        }
    }
}
```

{% 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 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/secure-card-display/implement-secure-card-display/display-card-metadata.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.
