> 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/push-provisioning/ja/implement-push-provisioning/implement-push-to-scheme/push-to-token-requestors-token-connect.md).

# トークンリクエスタへのプッシュ（Token Connect）

## トークンリクエスタへのプッシュ（Token Connect）

このガイドを使用して、イシュアアプリケーションから **トークンリクエスタ** を使用して **Mastercard MDES Token Connect**.

トークンリクエスタには、eコマース加盟店やウォレットプロバイダーが含まれる場合があります。

Mastercardの製品ドキュメントについては、次を参照してください。 [MDES Token Connectの概要](https://developer.mastercard.com/mdes-token-connect/documentation/#overview).

### 概要

Token Connectを使用すると、イシュアアプリケーションは次のことを行います。

1. カードに対して対象のトークンリクエスタ一覧を取得します。
2. 要求します。 **プッシュ URL** 選択したトークンリクエスタ用に。
3. エンドユーザーをトークンリクエスタの体験画面にリダイレクトして、 **トークン化**.

{% hint style="info" %}
**前提条件**

* エンドユーザーはイシュアアプリケーションで認証されます。
* イシュアアプリケーションはD1 SDKを初期化し、ログインを完了しています。
* 消費者とカードはD1に登録されています。
  {% endhint %}

### エンドユーザー体験

以下の図は、代表的なToken Connectフローを示しています。同じパターンは、Token Connect準拠の任意のトークンリクエスタに適用されます。

<figure><img src="https://1486457345-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWDlYTPaq4dNHuiWtf8ux%2Fuploads%2FsVuMgQC38BtKGrjgtZA7%2FUX%20-%20Push%20to%20Wallet.svg?alt=media&amp;token=51d9e105-acd8-4f44-a09d-67fb1ca57145" alt=""><figcaption><p>Token Connectを使用してカードをトークンリクエスタにプッシュするエンドユーザー体験の例。</p></figcaption></figure>

### フロー

#### 対象のトークンリクエスタを取得

<figure><img src="https://1486457345-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWDlYTPaq4dNHuiWtf8ux%2Fuploads%2FZExA7WRfN1glX8viYJ9h%2FFlow%20-%20Push%20to%20token%20requestors%20(Token%20Connect).svg?alt=media&amp;token=46566394-9e5e-474b-8374-c0b09b535f18" alt=""><figcaption><p>カードの対象トークンリクエスタを取得します。</p></figcaption></figure>

#### トークンリクエスタにプッシュする

<figure><img src="https://1486457345-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWDlYTPaq4dNHuiWtf8ux%2Fuploads%2FJaYE8VfMvniOex4o6Xj1%2FFlow%20-%20Push%20to%20token%20requestors%20(Token%20Connect)%20-2.svg?alt=media&amp;token=905d5af4-09c8-4850-b3ac-cda2a75b49bc" alt=""><figcaption><p>選択したトークンリクエスタ用のプッシュ URLを生成し、エンドユーザーをリダイレクトします。</p></figcaption></figure>

### シーケンス図

{% stepper %}
{% step %}

#### 対象のトークンリクエスタを取得

イシュアアプリケーションはD1 SDKを使用して、指定したカードでToken Connectをサポートするトークンリクエスタ一覧を取得します。

各トークンリクエスタには次が含まれます。

* 表示名。
* ブランドロゴ。
* 1つ以上の対応プロビジョニング方法（例: Android、iOS、またはWeb）。

<figure><img src="https://1486457345-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWDlYTPaq4dNHuiWtf8ux%2Fuploads%2FWpceTQPa0ZNlxHiRQwnv%2FSequence%20Diagram%20-%20Get%20eligible%20token%20requestors.svg?alt=media&amp;token=874b73b9-71ae-4d28-8821-7ece9e7f9a8a" alt=""><figcaption></figcaption></figure>

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

```kotlin
fun getEligibleTokenRequestors(d1Task: D1Task, cardID: String) {
    activity.lifecycleScope.launch(Dispatchers.Main) {
        try {
            val tkRequestorList = withContext(Dispatchers.IO) {
                d1Task.pushProvisioningService.getTokenRequestorList(
                    cardID
                ).await()
            }

            // サーバーからの tkRequestorList オブジェクトを処理
            // 例: 上のサンプル画像のようにUIに表示する
            for (tkRequestor : TokenRequestor in tkRequestorList) {
                val tkRequestorID : String = tkRequestor.id
                val tkRequestorName : String = tkRequestor.name
                val tkRequestorAssets : MutableList<AssetContent>? = tkRequestor.assets // トークンリクエスタのロゴ
                val tkrProvisioningMethods : MutableList<ProvisioningMethod> = tkRequestor.provisioningMethods // トークンリクエスタのプロビジョニング方法
            }
        } catch (exception: D1Exception) {
            // D1 SDK 統合 – エラー管理のセクションを参照してください
        }
    }
}
```

{% endtab %}

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

```kotlin
fun getEligibleTokenRequestors(d1Task: D1Task, cardID: String) {
    val callback: D1Task.Callback<List<TokenRequestor>> = object : D1Task.Callback<List<TokenRequestor>> {

        override fun onSuccess(tkRequestorList: List<TokenRequestor>) {
            // サーバーからの tkRequestorList オブジェクトを処理します。
            // 例: 上のサンプル画像のようにUIに表示します。
            for (tkRequestor : TokenRequestor in tkRequestorList) {
                val tkRequestorID : String = tkRequestor.id
                val tkRequestorName : String = tkRequestor.name
                val tkRequestorAssets : MutableList<AssetContent>? = tkRequestor.assets // トークンリクエスタのロゴ。
                val tkrProvisioningMethods : MutableList<ProvisioningMethod> = tkRequestor.provisioningMethods // トークンリクエスタのプロビジョニング方法。
            }
        }

        override fun onError(exception: D1Exception) {
            // D1 SDK 統合 – エラー管理のセクションを参照してください。
        }
    }

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

{% endtab %}

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

```swift
let cardID = "" // 例: サーバーから取得
        
do {
    let service = try d1Task.pushProvisioningService()
    let tokenRequestors = try await service.tokenRequestorList(cardID)
    // tokenRequestors をUIに表示します
    for tokenRequestor in tokenRequestors {
        print("ID: \(tokenRequestor.id ?? \"\")")
        print("Name: \(tokenRequestor.name ?? \"\")")

        if let asset = tokenRequestor.asset?.first,
           let imageData = Data(base64Encoded: asset.encodedData) {
            let image = UIImage(data: imageData)
            _ = image
        }
    }
} catch let d1Error as D1Error {
    // D1 SDK 統合 – エラー管理のセクションを参照してください
} catch let error {
    // その他のエラーを処理します
}
```

{% endtab %}

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

```swift
let cardID = "" // 取得元は、例えばバックエンドなど

d1Task.tokenRequestorList(cardID) { tokenRequestors, error in
    if let error = error {
        // D1 SDK の統合エラー管理のセクションを参照してください
    } else if let tokenRequestors = tokenRequestors {
        // tokenRequestors をUIに表示します
        for tokenRequestor in tokenRequestors {
            print("ID: \(tokenRequestor.id ?? \"\")")
            print("Name: \(tokenRequestor.name ?? \"\")")

            if let asset = tokenRequestor.asset?.first,
               let imageData = Data(base64Encoded: asset.encodedData) {
                let image = UIImage(data: imageData)
                _ = image
            }
        }
    }
}
```

{% endtab %}
{% endtabs %}
{% endstep %}

{% step %}

#### カードをトークンリクエスタにプッシュする

エンドユーザーがトークンリクエスタを選択すると、イシュアアプリケーションは **プッシュ URL** を呼び出して `addDigitalCardToScheme()`.

その後、イシュアアプリケーションは返されたプッシュ URLを使用して、エンドユーザーをトークンリクエスタにリダイレクトします。

<figure><img src="https://1486457345-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWDlYTPaq4dNHuiWtf8ux%2Fuploads%2Fgit-blob-7ce5dff88d091310a8adff27be0a29acd22a2b8e%2FSequence%20Diagram%20-%20%20Push%20a%20card%20to%20a%20token%20requestor.svg?alt=media" alt=""><figcaption></figcaption></figure>

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

```kotlin
fun pushCardToTokenRequestor(d1Task: D1Task, cardID: String, tokenRequestor: TokenRequestor) {
    val appURL = "d1demoapp://com.thalesgroup.gemalto.d1.validation/PushToSchemeResult" // イシュアアプリのカスタムURL。トークンリクエスタは、デジタル化フローの完了時にこれをコールバックします
    val tcsAccepted = true

    // Click to Payでは、MastercardのtokenRequester.id属性値は50123197928です。
    activity.lifecycleScope.launch(Dispatchers.Main) {
        try {
            val pushUrl = withContext(Dispatchers.IO) {
                d1Task.pushProvisioningService.addDigitalCardToScheme(
                    cardID,
                    tokenRequestor,
                    appURL,
                    tcsAccepted
                ).await()
            }
            // トークンリクエスタアプリケーションを起動
            activity.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(pushUrl)))
        } catch (exception: D1Exception) {
            // D1 SDK 統合 – エラー管理のセクションを参照してください
        }
    }
}
```

{% endtab %}

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

```kotlin
//cardID: getConsumerDetails APIで取得。
//tokenRequestor: ユーザーが選択。
fun pushCardToTokenRequestor(d1Task: D1Task, cardID: String, tokenRequestor: TokenRequestor) {
    val appURL = "d1demoapp://com.thalesgroup.gemalto.d1.validation/PushToSchemeResult" // イシュアアプリのカスタムURL。トークンリクエスタは、デジタル化フローの完了時にこれをコールバックします。
    val tcsAccepted = true

    val callback: D1Task.Callback<String> = object : D1Task.Callback<String> {

        override fun onSuccess(pushUrl: String) {
            // トークンリクエスタアプリケーションを起動します。
            getActivity().startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(pushUrl)))
        }

        override fun onError(exception: D1Exception) {
            // D1 SDK 統合 – エラー管理のセクションを参照してください。
        }
    }

    // Click to Payでは、MastercardのtokenRequestor.id属性値は50123197928です。
    d1Task.addDigitalCardToScheme(
        cardID,
        tokenRequestor,
        appURL,
        tcsAccepted,
        callback
    )
}
```

{% endtab %}

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

```swift
let provisionMethod = PushProvisioningService.ProvisioningMethod(pushHandler: "pushHandler", platformType: "iOS")
let tokenRequestor = PushProvisioningService.TokenRequestor(id: "test", name: "test", asset: nil, provisioningMethods: [provisionMethod])
let cardID = "" // 例: サーバーから取得
let appURL = "test://sample.com.demo/tokenRequestorsPage"
// ディープリンク機構を使用して設定されたイシュアのappURL。
// トークンリクエスタアプリは、このURLにコールバックしてカードプッシュ情報の結果を渡します。
do {
    let service = try d1Task.pushProvisioningService()
    let provisionString = try await service.addDigitalCardToScheme(cardID,
                                                                   tokenRequestor: tokenRequestor,
                                                                   appURL: appURL,
                                                                   termsAndConditionsAccepted: true)
    if let provisionURL = URL(string: provisionString) {
        if await UIApplication.shared.canOpenURL(provisionURL) {
            await UIApplication.shared.open(provisionURL)
        }
    }
} catch let d1Error as D1Error {
    // D1 SDK 統合 – エラー管理のセクションを参照してください
} catch let error {
    // その他のエラーを処理します
}
```

{% endtab %}

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

```swift
let cardID = "" // 取得元は、例えばバックエンドなど

// トークン化フロー後にトークンリクエスタが呼び出すイシュアアプリケーションのディープリンクURL。
let appURL = "test://sample.com.demo/tokenRequestorsPage"

// tokenRequestorはエンドユーザーによって選択され、tokenRequestorList()によって返されます。

d1Task.addDigitalCardToScheme(
    cardID,
    tokenRequestor: tokenRequestor,
    appURL: appURL,
    termsAndConditionsAccepted: true
) { provisionString, error in
    if let error = error {
        // D1 SDK の統合エラー管理のセクションを参照してください
    } else if let provisionString = provisionString,
              let pushUrl = URL(string: provisionString),
              UIApplication.shared.canOpenURL(pushUrl) {
        UIApplication.shared.open(pushUrl)
    }
}
```

{% endtab %}
{% endtabs %}

**次に起こること**

* D1 SDKはプッシュ URLを返します。
* イシュアアプリケーションは、プッシュ URLをトークンリクエスタアプリケーションまたはWebビューで開きます。
* トークンリクエスタがトークン化フローを実行します。
* フローが完了すると、トークンリクエスタはエンドユーザーをイシュアアプリケーションに戻します。 `appURL`.
  {% endstep %}
  {% endstepper %}

{% hint style="info" %}

* 設定するには `appURL`、イシュアアプリケーションにディープリンクを実装します: [Android](https://developer.android.com/training/app-links/deep-linking), [iOS](https://developer.apple.com/documentation/xcode/defining-a-custom-url-scheme-for-your-app).
* トークンリクエスタは、トークン化結果をイシュアアプリケーションに返します。詳細は、Mastercardガイドを参照してください: [トークンリクエスタからの応答を受け取る](https://developer.mastercard.com/mdes-token-connect/documentation/tutorials-and-guides/issuer-implementation-guide/#receive-response-from-token-requestor).
  {% endhint %}

{% hint style="warning" %}
Mastercard **簡素化されたアクティベーション** はサポートされていません。
{% endhint %}

D1 SDK への完全なアクセスについては、ご確認ください [API リファレンス](/push-provisioning/ja/integrate-the-d1-sdk/api-reference.md).


---

# 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/push-provisioning/ja/implement-push-provisioning/implement-push-to-scheme/push-to-token-requestors-token-connect.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.
