Welcome to our new developer portal! Use the "Ask" button to chat with our AI Agent.

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.

D1PayWallet.getCachedCardMetadata() does not require the login API.

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 for details.

SDK

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
                }
            }
        }
    })
}

Last updated

Was this helpful?