> 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/implement-nfc-wallet/tokenize-a-card/digitize-a-card.md).

# Digitize a card

## Overview

After the card passes eligibility checks, and the end user accepts the terms and conditions (T\&C) when required, start digitization.

During the digitization:

* The issuer backend returns the **Tokenization** decision (green flow, yellow flow, or red flow) to the digital wallet application via NFC Wallet.
* If the issuer backend approves (green flow or yellow flow):
  * The Token Service Provider (TSP) creates the digital card and its assets (profile and payment keys).
  * NFC Wallet securely provisions the digital card profile and payment keys in the digital wallet application.

In the yellow flow, the digital wallet application performs ID\&V (step-up authentication) before the card can be provisioned.

In the red flow, digitization is declined and the SDK returns an error callback.

Implement the green flow, the yellow flow, or both, based on your program.

{% hint style="info" %}
Depending on your program, **T\&C** might not be required. If so, the digital wallet application can accept the T\&C without end user interaction.
{% endhint %}

## SDK integration

Start **card digitization** by calling `MGCardEnrollmentService.digitizeCard(...)`.

You shall first implement `MGDigitizationListener` to track the digitization progress by handling callbacks according to the enrollment color flow:

* In the **Green flow (approved, no step-up)** the SDK calls these callbacks:

  * `onCPSActivationCodeAcquired`
  * `onComplete`

  For details, see [Green flow digitization](/nfc-wallet-sdk-android/implement-nfc-wallet/tokenize-a-card/digitize-a-card/green-flow-digitization.md).
* In the **yellow flow (approved with step-up)** the SDK also calls:

  * `onSelectIDVMethod`
  * `onActivationRequired`

  For details, see [Yellow flow digitization](/nfc-wallet-sdk-android/implement-nfc-wallet/tokenize-a-card/digitize-a-card/yellow-flow-digitization.md).

In case of digization error, NFC Wallet SDK emits the callback:

* `onError`: Digitization failed. Use `error.getCode()` to decide whether to retry, ask the end user to take action, or route to support.

### `MGDigitizationListener` implementation example

See code snipet below to implement `MGDigitizationListener`

{% code expandable="true" %}

```java
// build your Digitization listener
public class MyDigitizationListener implements MGDigitizationListener {

    @Override
    public void onCPSActivationCodeAcquired(String digitalCardId, byte[] activationCode) {
        // Receive activationCode to start provisioning for this digitalCardId.
        // See "Trigger a provisioning session".
    }

    @Override
    public void onSelectIDVMethod(IDVMethodSelector idvMethodSelector) {
        // Yellow flow only - Receive the list of ID&V methods
        // See "Yellow flow digization"
    }

    @Override
    public void onActivationRequired(PendingCardActivation pendingCardActivation) {
        // Yellow flow only - selected ID&V method requiring activation
        // See "Yellow flow digization"
   }

    @Override
    public void onComplete(String digitalCardId) {
        // Digitization completed successfully.
    }

    @Override
    public void onError(String digitalCardId, MobileGatewayError error) {
        // Digitization failed.
        // Parse error.getCode() and apply the right retry / recovery logic.
    }
});
```

{% endcode %}

### Digitize card example

In the example below you can find the code to start digitization.

* In case of green flow, you have to provide an **authentication token**.

{% code expandable="true" %}

```java
// reference to your Card Digitization listener
// - to track digitization progress using callback
MyDigitizationListener digitizationListener = new MyDigitizationListener();

// Get the enrollment service.
MGCardEnrollmentService enrollmentService =
        MobileGatewayManager.INSTANCE.getCardEnrollmentService();

// From eligibility: retrieve TermsAndConditions.
// See "Check card eligibility".
TermsAndConditionSession tncSession = termsAndConditions.accept();

// Provide the authentication in case of green flow
byte[] authenticationToken = null;

enrollmentService.digitizeCard(tncSession, authenticationToken, digitizationListener);
```

{% endcode %}


---

# 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-wallet-sdk-android/implement-nfc-wallet/tokenize-a-card/digitize-a-card.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.
