> 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-otp.md).

# OTPでバインディングを有効化

ワンタイムパスワード（OTP）は、 **ID\&V** 保留中のデバイスバインディングを有効化するための方法として使用されます。

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

前提条件：

* すでに開始しています `createBinding` または `resumeBinding`.
* イシュアはOTPベースのID\&V方法（例： `OTP_SMS`).
* あなたの加盟店アプリはエンドユーザーからOTPを収集できます。

## フロー

<figure><img src="/files/22a5d68a54de7690303433b0999567320b382a21" alt=""><figcaption><p>OTPデバイスバインディングフロー。</p></figcaption></figure>

<table><thead><tr><th width="100">ステップ</th><th>説明</th></tr></thead><tbody><tr><td>1</td><td>エンドユーザーはOTPオプション（SMS、メールまたはオンラインバンキング）を選択します。</td></tr><tr><td>2</td><td>加盟店アプリは選択をThalesバックエンドに転送します。</td></tr><tr><td>3–5</td><td>Thalesバックエンドは <strong>VTS</strong> および <strong>イシュア</strong> に選択されたチャネルでOTPを配信するよう要求します。</td></tr><tr><td>6</td><td>エンドユーザーは加盟店アプリにOTPを入力します。加盟店アプリがUIを所有します。</td></tr><tr><td>7–8</td><td>ThalesバックエンドはVTSおよびイシュアとOTPを検証します。</td></tr><tr><td>9</td><td>Thales SDKは結果を受け取り、ローカルでバインディングを有効化します。</td></tr><tr><td>10</td><td>Thalesバックエンドは加盟店/PSPバックエンドにバインディングが有効であることを通知します。</td></tr></tbody></table>

## SDK統合

### 1. OTPのID\&V方法を選択する

の間に `createBinding` または `resumeBinding`、次のOTP ID\&V方法のいずれかを選択します：

* `OTP_SMS`
* `OTP_EMAIL`
* `OTP_ONLINE_BANKING`

{% tabs %}
{% tab title="Android" %}
アプリケーションが選択した `ID&V` メソッドを正常に送信すると、 `onIssuerAuthenticationReady` コールバックがアプリケーションに返されます。さもなければ、 `onError` コールバックが返されます。

```java
@Override
public void onIssuerAuthenticationRequired(PendingBindingSession pendingBindingSession) { 
    // OTP_SMS ID&Vメソッドを送信する
    for (IDVMethod idvMethod : pendingBindingSession.getIdvMethods()) {
        if (idvMethod.getType().equals(IDVType.OTP_SMS)) {
            pendingBindingSession.submitIdvMethod(idvMethod);
        }
    }
}

@Override
public void onIssuerAuthenticationReady(PendingBindingSession pendingBindingSession, 
                                        @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] // ユーザーがOTP idvメソッド（OTP_SMS）を選択
    
    // 2. idvメソッドを送信する
    idvSession.selectIDVMethod(selectedIdvMethod) { (result) in
        if let otpActivationStatus = result {
            let maxOtpVerificationAllowed = otpActivationStatus.maxOTPVerificationAllowed
            let maxOtpRequestsAllowed = otpActivationStatus.maxOTPRequestsAllowed
            let otpExpiration = otpActivationStatus.otpExpiration
            
            // 3. OTPを入力するページを表示する
        }
    }
} 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. バインディングを有効化する

加盟店アプリでOTPを収集し、次に `activateBinding` を呼び出します `IDVSession`.

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

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

@Override
public void onIssuerAuthenticationError(@Nullable IDVSession idvSession, 
                                        TMGClientException tmgClientException) {
    // エラーを確認するか再試行する
}
```

結果は次で返されます `onSuccess` または `onIssuerAuthenticationError`.

有効化に失敗した場合、 `IDVSession` で返される `onIssuerAuthenticationError` を使って再試行してください。
{% endtab %}

{% tab title="iOS" %}

```swift
// 1. ユーザー入力からのOTP値
let otp = ""

guard let idvSession = VisaService.shared.idvSession else {
    // idvセッションがない
    return
}
// 2. activateを呼ぶ
idvSession.activateBinding(withValue: otp)

VisaService.shared.completionHandler = { (session, error) in
    // 2. バインディング成功
    if error == nil {
        
    } else if let error = error,
                let session = session,
                error.description == TMGError.serverErrorWrongOTP.description {
        VisaService.shared.idvSession = session
        // 3. OTP入力を再試行し、エラーメッセージを表示する
    }
}
```

結果は次で返されます `completionHandler`.

有効化に失敗した場合、 `completionHandler` は `IDVSession` を返し、再試行のためのエラーを返します。
{% 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-otp.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.
