> 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/tokenization/ja/implement-tokenization/mobairusdknotkun/visa-ctf-noapuri.md). Agents can also search and read this documentation through its [MCP server](https://docs.payments.thalescloud.io/~gitbook/mcp).

# Visa CTF のアプリ内認証

{% hint style="danger" %}
このセクションは非推奨です。新たに導入された API については、セクション「[eコマースのトークン検証](https://docs.payments.thalescloud.io/tokenization/ja/implement-tokenization/mobairusdknotkun/ekomsunotkun.md)".
{% endhint %}

Visa Cloud Token Framework (CTF) は、トークン化後の eコマース向けデジタルカードへの信頼を高めるために設計された Visa のフレームワークです。

CTF では 2 つのフローが定義されています: デバイスバインディングとカード所有者確認です。

これらのフローにより、加盟店はイシュアによるカード所有者のステップアップ認証フローをトリガーして、デジタルカードへの信頼を高めることができます。

フルフローおよび Visa Cloud Token Framework (CTF) の詳細については、セクションをご覧ください。 [Visa Cloud Token Framework](https://docs.payments.thalescloud.io/tokenization/implement-tokenization/post-tokenization-requests/visa-cloud-token-framework-ctf) Tokenization のドキュメント内の

Visa CTF のアプリ内認証フローは、次に説明するフローと非常によく似ています。 [アプリ内認証](https://docs.payments.thalescloud.io/tokenization/ja/implement-tokenization/mobairusdknotkun/apuri.md).

手順 \[01] から \[10] は基本的に同じです。

主な違いはペイロード形式であり、次の表に示されています:

<table><thead><tr><th>デバイスバインディング - ペイロード</th><th>カード所有者認証 - ペイロード</th></tr></thead><tbody><tr><td><pre><code>{
  "panReferenceID": "V-3815023863409817870482",
  "tokenRequestorID": "42301999123",
  "tokenReferenceID": "DNITHE381502386342002358",
  "panLast4": "1234",
  "deviceID": "DEiOiJBMjU2R_0NNS1-ciLCJiI",
  "walletAccountID": "AiJBMjU-2_R0NNS1ciLCJiI6",
  "deviceIndex": "1",
  "reasonCode": "TOKEN_DEVICE_BINDING"
}
</code></pre></td><td><pre><code>{
  "panReferenceID": "V-3815023863409817870482",
  "tokenRequestorID": "42301999123",
  "tokenReferenceID": "DNITHE381502386342002358",
  "panLast4": "1234",
  "deviceID": "null",
  "walletAccountID": "AiJBMjU-2_R0NNS1ciLCJiI6",
  "deviceIndex": "null",
  "reasonCode": "カード所有者_STEPUP"
}
</code></pre></td></tr></tbody></table>

標準のトークン化認証と比較して、イシュアアプリケーションは次を確認する必要があります:

* **理由コード**：CTF 認証の理由を特定します。
  * `トークンデバイスバインディング`：デバイスバインディングのフロー。
  * `カード所有者_STEPUP`: カード所有者の認証フロー。
* **deviceIndex**: デバイスバインディングフローで使用されます。これは Visa のデバイス参照です。D1 SDK では、これは次にマップされます `bindingReference`.

次のシーケンス図を参照する場合 [アプリ内認証](https://docs.payments.thalescloud.io/tokenization/ja/implement-tokenization/mobairusdknotkun/apuri.md)、手順 \[11] と \[12] を新しい API 呼び出しに置き換えてください。

この場合、デジタルカードの有効化はありません。代わりに、認証結果を Visa VTS に伝播する必要があります。

D1 SDK は、イシュアのアプリケーションが結果を報告できるように、以下の API を公開しています：

1. 次の場合 `トークンデバイスバインディング`、次を呼び出します `DigitalCardService.approveBinding` を使用して `digitalCardID` と `deviceIndex`.
2. 次の場合 `カード所有者_STEPUP`、次を呼び出します `DigitalCardService.approveCardholderVerification` を使用して `digitalCardID`.

D1 SDK では、次のこともできます：

1. バインドされたデバイスの一覧を次のように取得します `deviceBindingList` when `getDigitalCardList()` が呼び出されます。詳細は次を参照してください [デジタルカードの表示と制御](https://docs.payments.thalescloud.io/tokenization/ja/implement-tokenization/mobairusdknotkun/dejitarukdowosuru.md).
2. 呼び出してデバイスのバインドを解除します `DigitalCardService.unbindDevice`。次を参照してください [デバイスのバインド解除](https://docs.payments.thalescloud.io/tokenization/ja/implement-tokenization/mobairusdknotkun/visa-ctf-noapuri/debaisunobaindowosuru.md).

次の例では、ペイロードを解析し、バインド要求を承認する方法を示します。

{% hint style="info" %}
注意

次のフィールドマッピングが適用されます:

* `tokenReferenceID` = `digitalCardID`
* `deviceIndex` = `bindingReference`
  {% endhint %}

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

```kotlin
private const val VISA_STEPUP_RESULT_RESPONSE = "STEP_UP_RESPONSE"
private const val STEPUP_RESULT_APPROVED = "approved"
private const val STEPUP_RESULT_DECLINED = "declined"
private const val STEPUP_RESULT_FAILED = "failure"

val visaPayload = intent.getStringExtra(Intent.EXTRA_TEXT) ?: return

val payloadJson = try {
    val decodedPayload = String(Base64.decode(visaPayload, Base64.DEFAULT), Charsets.UTF_8)
    JSONObject(decodedPayload)
} catch (_: IllegalArgumentException) {
    // 無効な base64 ペイロード
    return
} catch (_: JSONException) {
    // 無効な JSON ペイロード
    return
}

val reasonCode = payloadJson.optString("reasonCode", "")
val digitalCardID = payloadJson.optString("tokenReferenceID", "") // tokenReferenceID -> digitalCardID
val bindingReference = payloadJson.optString("deviceIndex", "") // deviceIndex -> bindingReference

if ("TOKEN_DEVICE_BINDING" == reasonCode &&
    digitalCardID.isNotEmpty() &&
    bindingReference.isNotEmpty()) {

    d1Task.digitalCardService().approveBinding(
        digitalCardID,
        bindingReference,
        DigitalCardService.BindingApprovalReason.USER_DECISION,
        object : D1Task.Callback<Void> {
            override fun onSuccess(data: Void?) {
                sendResultToTokenRequestorApp(activity, null)
            }

            override fun onError(e: D1Exception) {
                sendResultToTokenRequestorApp(activity, e)
            }
        }
    )
} else {
    // その他のフロー（例: アクティベーション）
}

private fun sendResultToTokenRequestorApp(activity: Activity, exception: D1Exception?) {
    val result = Intent()
    // 取りうる値: "approved"、"declined"、または "failure"
    val stepupResult = if (exception == null) STEPUP_RESULT_APPROVED else STEPUP_RESULT_FAILED
    result.putExtra(VISA_STEPUP_RESULT_RESPONSE, stepupResult)
    // 発行者が認証コードによるアクティベーションを使用している場合に適用
    activity.setResult(Activity.RESULT_OK, result)
    activity.finish()
}
```

```java
private static final String VISA_STEPUP_RESULT_RESPONSE = "STEP_UP_RESPONSE";
private static final String STEPUP_RESULT_APPROVED = "approved";
private static final String STEPUP_RESULT_DECLINED = "declined";
private static final String STEPUP_RESULT_FAILED = "failure";

String visaPayload = getIntent().getStringExtra(Intent.EXTRA_TEXT);
if (visaPayload == null) {
    return;
}

JSONObject payloadJson;
try {
    byte[] decodedPayloadBytes = Base64.decode(visaPayload, Base64.DEFAULT);
    String decodedPayload = new String(decodedPayloadBytes, StandardCharsets.UTF_8);
    payloadJson = new JSONObject(decodedPayload);
} catch (IllegalArgumentException | JSONException e) {
    // 無効な base64/JSON ペイロード
    return;
}

String reasonCode = payloadJson.optString("reasonCode", "");
String digitalCardID = payloadJson.optString("tokenReferenceID", ""); // tokenReferenceID -> digitalCardID
String bindingReference = payloadJson.optString("deviceIndex", ""); // deviceIndex -> bindingReference

if ("TOKEN_DEVICE_BINDING".equals(reasonCode) &&
        !digitalCardID.isEmpty() &&
        !bindingReference.isEmpty()) {

    d1Task.digitalCardService().approveBinding(
            digitalCardID,
            bindingReference,
            DigitalCardService.BindingApprovalReason.USER_DECISION,
            new D1Task.Callback<Void>() {
                @Override
                public void onSuccess(Void data) {
                    sendResultToTokenRequestorApp(activity, null);
                }

                @Override
                public void onError(@NonNull D1Exception exception) {
                    sendResultToTokenRequestorApp(activity, exception);
                }
            });
} else {
    // その他のフロー（例: アクティベーション）
}

private void sendResultToTokenRequestorApp(Activity activity, D1Exception exception) {
    Intent result = new Intent ();
    // 取りうる値: "approved"、"declined"、または "failure"
    String stepupResult = (exception == null) ? STEPUP_RESULT_APPROVED : STEPUP_RESULT_FAILED;
    result.putExtra(VISA_STEPUP_RESULT_RESPONSE, stepupResult);
    // 発行者が認証コードによるアクティベーションを使用している場合に適用
    activity.setResult(RESULT_OK, result);
    activity.finish();
}
```

{% endtab %}

{% tab title="iOS" %}

```swift
// Walletアプリからのアプリリダイレクトをサポートするため。
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
    guard let components = URLComponents(url: url, resolvingAgainstBaseURL: true) else { return false }

    let queryDict = components.queryItems?.reduce(into: [String: String]()) { dict, item in
        dict[item.name] = item.value
    } ?? [:]

    switch components.host {
    // Visaのアプリ間連携を処理するサービス名の例
    case "visaCTF":
        guard let wpCallback = queryDict["wpcallback"]?.removingPercentEncoding,
              let encodedPayload = queryDict["a2apayload"],
              let payloadData = Data(base64Encoded: encodedPayload.replacingOccurrences(of: " ", with: "+")),
              let json = try? JSONSerialization.jsonObject(with: payloadData) as? [String: Any],
              let reasonCode = json["reasonCode"] as? String else {
            return false
        }

        switch reasonCode {
        case "TOKEN_DEVICE_BINDING":
            guard let digitalCardID = json["tokenReferenceID"] as? String,
                  let bindingReference = json["deviceIndex"] as? String else {
                return false
            }

            Task {
                do {
                    try await d1Task.digitalCardService().approveBinding(
                        digitalCardID,
                        bindingReference: bindingReference,
                        reason: nil
                    )
                    sendResultToApp(wpCallback: wpCallback, stepupResult: "承認")
                } catch {
                    sendResultToApp(wpCallback: wpCallback, stepupResult: "失敗")
                }
            }

        default:
            return false
        }

        return true
    default:
        return false
    }
}

private func sendResultToApp(wpCallback: String, stepupResult: String) {
    guard var components = URLComponents(string: wpCallback) else { return }

    var items = components.queryItems ?? []
    items.append(URLQueryItem(name: "stepupresponse", value: stepupResult))
    components.queryItems = items

    if let callbackURL = components.url {
        UIApplication.shared.open(callbackURL)
    }
}
```

{% endtab %}
{% endtabs %}

D1 SDKへの完全なアクセスについては、以下を確認してください [API リファレンス](https://docs.payments.thalescloud.io/push-provisioning/integrate-the-d1-sdk/api-reference).


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.payments.thalescloud.io/tokenization/ja/implement-tokenization/mobairusdknotkun/visa-ctf-noapuri.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
