> 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/merchant-tokenization/ja/visa-ctf-to-daf/implement-ctf-and-daf/create-device-binding-yellow-flow/activate-binding-with-app-to-app.md).

# アプリ間でバインディングを有効化

その **加盟店アプリケーション** リダイレクトする **エンドユーザー** へ **イシュアアプリケーション** でバインディングリクエストを承認します。承認の決定は **イシュアバックエンド** 経由で **VTS**.

{% hint style="info" %}
デバイスバインディングは加盟店アプリケーションで開始されますが、最終的な承認はイシュアバックエンドから行われます。

デバイスとサーバーの非同期を避けてください。トークンリクエスタに成功が通知されてからローカルでバインディングを有効化してください。
{% endhint %}

## フロー

<figure><img src="/files/ef191f733e87da0240d1a1e31c969fb4142b163f" alt=""><figcaption><p>アプリ間（アプリ間）デバイスバインディングフロー。</p></figcaption></figure>

<table><thead><tr><th width="100">ステップ</th><th>説明</th></tr></thead><tbody><tr><td>1</td><td>エンドユーザーがアプリ間オプションを選択します。</td></tr><tr><td>2</td><td>その決定はThalesバックエンドに転送されます。</td></tr><tr><td>3</td><td>加盟店アプリケーションがエンドユーザーをイシュアアプリケーションにリダイレクトします。</td></tr><tr><td>4</td><td>エンドユーザーがイシュアアプリケーションで認証し、バインディングリクエストを検証します。</td></tr><tr><td>5</td><td>イシュアがバインディングリクエストを受け入れ、VTSに通知します。</td></tr><tr><td>6-7</td><td>VTSがThalesバックエンドに通知し、加盟店/PSPバックエンドに知らせます。</td></tr><tr><td>8</td><td>加盟店/PSPバックエンドが結果を加盟店アプリケーションに伝えます。</td></tr><tr><td>9</td><td>加盟店アプリケーションがThales SDKで保留中のバインディングセッションを終了します。</td></tr></tbody></table>

## SDK統合

このページは、次のフローの続きを示します： [デバイスバインディングの作成（黄色のフロー）](/merchant-tokenization/ja/visa-ctf-to-daf/implement-ctf-and-daf/create-device-binding-yellow-flow.md).

### 1. アプリ間のID\&V方式を選択

の間に `createBinding` または `resumeBinding`、アプリ間のID\&V方式を選択します。

{% tabs %}
{% tab title="Android" %}
アプリケーションが選択した `ID&V` 方式を正常に送信すると、 `onIssuerAuthenticationReady` コールバックがアプリケーションに返されます。そうでない場合は、 `onError` コールバックが返されます。

```java
@Override
public void onIssuerAuthenticationRequired(IDVSession idvSession) { 
    // APP_TO_APP の ID&V 方法を送信
    for (IDVMethod idvMethod : idvSession.getIdvMethods()) {
        if (idvMethod.getType().equals(IDVType.APP_TO_APP)) {
            idvSession.selectIdvMethod(idvMethod);
        }
    }
}

@Override
public void onIssuerAuthenticationReady(IDVSession idvSession, 
                                        @Nullable OtpActivationStatus status) {
    
}

@Override
public void onError(TMGClientException exception) { 
    // エラーがあるか確認する
    int errorCode = exception.getErrorCode();
    int errorMessage = exception.getMessage();
}
```

{% endtab %}

{% tab title="iOS" %}

```swift
guard let idvSession = VisaService.shared.idvSession else {
    // IDVセッションがありません。
    return
}
// 1. IDV方法の一覧を表示します。
do {
    let idvMethods = try idvSession.idvMethods
    let selectedIdvMethod = idvMethods[0] // ユーザーがアプリ間IDV方法を選択する
    
    // 2. IDV方法を送信します。
    idvSession.selectIDVMethod(selectedIdvMethod) { (result) in
        if let otpActivationStatus = result {
        
        } else {
            if selectedIdvMethod.type == .appToApp {
                let idvType = selectedIdvMethod.type
                let requestPayload = selectedIdvMethod.requestPayload
                let source = selectedIdvMethod.source
                let value = selectedIdvMethod.value
                // 3. アプリを起動します。
            }
        }
    }
} catch let error {
    // エラーを処理します。
}

// 4. ステップ2（selectIDVMethod）の失敗は completionHandler で処理されます。
VisaService.shared.completionHandler = { (session, error) in
    // 5. それが selectIDVMethod のエラーか確認します。
    if let session = session,
        let error = error,
        error.description == TMGError.invalidIdvMethod.description {
        VisaService.shared.idvSession = session
        // 6. IDVフローを再試行します。
    }
}
```

{% endtab %}
{% endtabs %}

### 2. アプリ間リダイレクトデータを取得する

{% hint style="info" %}
マーチャントアプリケーションはアプリ間リダイレクトを処理する必要があります。これはThales SDKの範囲外です。
{% endhint %}

{% tabs %}
{% tab title="Android" %}
マーチャントアプリケーションは [ディープリンク](https://developer.android.com/training/app-links/deep-linking) 機能を使用してイシュアアプリケーションを起動できます。バインディングアクティベーションに必要なデータは `IDVMethod` オブジェクトから取得できます。

```java
// アプリ間用の追加データを取得します。
IDVType idvType = idvMethod.getType();
String requestPayload = idvMethod.getRequestPayload();
String source = idvMethod.getSource();
String value = idvMethod.getValue();
```

{% endtab %}

{% tab title="iOS" %}
マーチャントアプリケーションは次を使用できます [URLスキーム](https://developer.apple.com/documentation/xcode/defining-a-custom-url-scheme-for-your-app) または [ユニバーサルリンク](https://developer.apple.com/ios/universal-links) でイシュアアプリケーションを起動できます。バインディングアクティベーションに必要なデータはから取得できます `IDVMethod` オブジェクトから取得できます。

```swift
let idvType = selectedIdvMethod.type
let requestPayload = selectedIdvMethod.requestPayload
let source = selectedIdvMethod.source
let value = selectedIdvMethod.value
```

{% endtab %}
{% endtabs %}

### 3. バインディングをアクティベートする

エンドユーザーがイシュアアプリケーションから戻った後、マーチャントまたはPSPのバックエンドが承認を確認するのを待ちます。その後、ローカルでバインディングを有効化するために次を呼び出します `activateBinding` 上の `IDVSession` オブジェクトから取得できます。

パス `null` フローが完了したことを示すため。

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

```java
@Override
public void onIssuerAuthenticationReady(IDVSession idvSession, 
                                        @Nullable OtpActivationStatus status) { 
    // ローカルでバインディングを有効化する
    idvSession.activateBinding(null);
}

@Override
public void onError(TMGClientException exception) { 
    // エラーがないか確認する
    int errorCode = exception.getErrorCode();
    int errorMessage = exception.getMessage();
}
```

バインディング有効化プロセスの結果は、経由で返されます `onSuccess` コールバック関数または `onError` エラーがある場合。
{% endtab %}

{% tab title="iOS" %}

```swift
guard let idvSession = VisaService.shared.idvSession else {
    // IDVセッションがありません。
    return
}
// 1. エンドユーザーがアプリから戻った後に activate を呼び出す
idvSession.activateBinding(withValue: nil)

VisaService.shared.completionHandler = { (session, error) in
    // 2. activateBinding が成功したか確認する。
    if error == nil {
        
    }
}
```

バインディング有効化プロセスの結果は、経由で返されます `completionHandler` コールバック関数。バインディング有効化が失敗した場合、 `completionHandler` が呼び出され、 `IDVSession` オブジェクトとともに `error` オブジェクトがエンドユーザーに渡され、処理を再試行する。
{% 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 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/merchant-tokenization/ja/visa-ctf-to-daf/implement-ctf-and-daf/create-device-binding-yellow-flow/activate-binding-with-app-to-app.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.
