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

# カードをデジタル化する

## 概要

カードが有効性チェックを通過し、必要に応じてエンドユーザーが利用規約 (T\&C) に同意した後、デジタル化を開始します。

デジタル化中:

* イシュアのバックエンドが返します。 **トークン化** 決定（グリーンフロー、イエローフロー、またはレッドフロー）を NFC Wallet 経由でデジタルウォレットアプリケーションに送ります。
* イシュアのバックエンドが承認する場合（グリーンフローまたはイエローフロー）:
  * Token Service Provider (TSP) がデジタルカードとそのアセット（プロファイルと支払いキー）を作成します。
  * NFC Wallet がデジタルウォレットアプリケーション内にデジタルカードのプロファイルと支払いキーを安全にプロビジョニングします。

イエローフローでは、カードをプロビジョニングできるようになる前に、デジタルウォレットアプリケーションが ID\&V（ステップアップ認証）を実行します。

レッドフローでは、デジタル化は拒否され、SDK はエラーコールバックを返します。

ご利用のプログラムに応じて、グリーンフロー、イエローフロー、またはその両方を実装してください。

{% hint style="info" %}
お使いのプログラムによっては、 **利用規約** 必要ない場合があります。その場合、デジタルウォレットアプリケーションはエンドユーザーの操作なしで T\&C を受け入れることができます。
{% endhint %}

## SDK 連携

開始 **カードのデジタル化** を呼び出すことで `MGCardEnrollmentService.digitizeCard(...)`.

まず実装する必要があります `MGDigitizationListener` 登録のカラー フローに従ってコールバックを処理し、デジタル化の進行状況を追跡するために:

* 次の **グリーンフロー（承認済み、ステップアップなし）** SDK は次のコールバックを呼び出します:

  * `onCPSActivationCodeAcquired`
  * `onComplete`

  詳細については、次を参照してください: [Green flow のデジタル化](/nfc-wallet-sdk-android/ja/implement-nfc-wallet/tokenize-a-card/digitize-a-card/green-flow-digitization.md).
* 次の **イエローフロー（ステップアップ付きで承認）** SDK はさらに次を呼び出します:

  * `onSelectIDVMethod`
  * `onActivationRequired`

  詳細については、次を参照してください: [Yellow flow のデジタル化](/nfc-wallet-sdk-android/ja/implement-nfc-wallet/tokenize-a-card/digitize-a-card/yellow-flow-digitization.md).

デジタル化エラーが発生した場合、NFC Wallet SDK は次のコールバックを発行します:

* `onError`: デジタル化に失敗しました。次を使用します: `error.getCode()` 再試行するか、エンドユーザーに対応を依頼するか、またはサポートに回すかを判断します。

### `MGDigitizationListener` 実装例

実装方法については、以下のコードスニペットを参照してください `MGDigitizationListener`

{% code expandable="true" %}

```java
// デジタル化リスナーを作成します
public class MyDigitizationListener implements MGDigitizationListener {

    @Override
    public void onCPSActivationCodeAcquired(String digitalCardId, byte[] activationCode) {
        // activationCode を受け取り、この digitalCardId のプロビジョニングを開始します。
        // 「プロビジョニングセッションをトリガーする」を参照してください。
    }

    @Override
    public void onSelectIDVMethod(IDVMethodSelector idvMethodSelector) {
        // イエローフローのみ - ID&V メソッドの一覧を受け取ります
        // 「イエローフローのデジタル化」を参照してください
    }

    @Override
    public void onActivationRequired(PendingCardActivation pendingCardActivation) {
        // イエローフローのみ - アクティベーションが必要な選択済み ID&V メソッド
        // 「イエローフローのデジタル化」を参照してください
   }

    @Override
    public void onComplete(String digitalCardId) {
        // デジタル化が正常に完了しました。
    }

    @Override
    public void onError(String digitalCardId, MobileGatewayError error) {
        // デジタル化に失敗しました。
        // error.getCode() を解析し、適切な再試行／復旧ロジックを適用します。
    }
});
```

{% endcode %}

### カードのデジタル化の例

以下の例では、デジタル化を開始するためのコードを確認できます。

* グリーンフローの場合は、次を提供する必要があります: **認証トークン**.

{% code expandable="true" %}

```java
// Card Digitization listener への参照
// - コールバックを使用してデジタル化の進行状況を追跡するため
MyDigitizationListener digitizationListener = new MyDigitizationListener();

// 登録サービスを取得します。
MGCardEnrollmentService enrollmentService =
        MobileGatewayManager.INSTANCE.getCardEnrollmentService();

// 有効性から TermsAndConditions を取得します。
// 「カードの有効性を確認する」を参照してください。
TermsAndConditionSession tncSession = termsAndConditions.accept();

// グリーンフローの場合は認証を提供します
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, and the optional `goal` query parameter:

```
GET https://docs.payments.thalescloud.io/nfc-wallet-sdk-android/ja/implement-nfc-wallet/tokenize-a-card/digitize-a-card.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.
