> 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/click-to-pay/ja/implement-click-to-pay-issuers/opt-out-cards-from-click-to-pay/opt-out-by-d1-sdk.md).

# D1 SDK によるオプトアウト

## 概要

このページでは、イシュアアプリケーションが D1 SDK を使用して Click to Pay からオプトアウトする方法を説明します。

D1 SDK には、2 つのオプトアウト API があります:

* `optOutCard` Click to Pay から 1 枚のカードを削除します。
* `optOutConsumer` エンドユーザーの Click to Pay からすべてのカードを削除します。

D1 が Click to Pay ディレクトリおよび決済ネットワークとのバックエンド連携をオーケストレーションしている間に、エンドユーザーがイシュアアプリケーションから直接オプトアウトを開始したい場合は、これらの SDK フローを使用します。

{% hint style="info" %}
**クイックリンク**

* [Click to Pay からカードをオプトアウト](/click-to-pay/ja/implement-click-to-pay-issuers/opt-out-cards-from-click-to-pay.md)
* [D1 SDK によるプロファイル取得](/click-to-pay/ja/implement-click-to-pay-issuers/retrieve-click-to-pay-profiles/retrieve-profiles-by-d1-sdk.md)
* [D1 SDK によるカード登録](/click-to-pay/ja/implement-click-to-pay-issuers/enroll-cards-in-click-to-pay/enroll-cards-by-d1-sdk.md)
* [D1 SDK によるプロファイル更新](/click-to-pay/ja/implement-click-to-pay-issuers/update-click-to-pay-profiles/update-profiles-by-d1-sdk.md)
  {% endhint %}

## 適切な SDK API を選択する

### `optOutCard`

使用する `optOutCard` エンドユーザーが Click to Pay から特定のカードを 1 枚だけ削除したい場合。

このオプションでは、ほかに登録済みのカードは変更されません。

### `optOutConsumer`

使用する `optOutConsumer` エンドユーザーが Click to Pay プロファイル全体を削除したい場合。

このオプションでは、そのエンドユーザーの Click to Pay に登録されているすべてのカードが削除されます。

## フロー

下の図は、SDK ベースのオプトアウトフロー全体を示しています:

<figure><img src="/files/2bacb5c246e6c84d9a5519d45469ad83d9a2963d" alt=""><figcaption></figcaption></figure>

## シーケンス図

SDK フローはバックエンドのオプトアウトフローと機能的には同じですが、イシュアアプリケーションから直接開始されます。

次のシーケンス図は、イシュアアプリケーションから開始されるフローを示しています:

<figure><img src="/files/323944053c649d91c3dd5bfd25ec6e6466e5be35" alt=""><figcaption></figcaption></figure>

### 重要なポイント

* どちらの操作も非同期です。
* 即時結果には、次のステータスが含まれます `SUCCESSFUL` または `PENDING`、および `operationID`.
* 使用する [D1 SDK によるプロファイル取得](/click-to-pay/ja/implement-click-to-pay-issuers/retrieve-click-to-pay-profiles/retrieve-profiles-by-d1-sdk.md) オプトアウト前に、イシュアアプリケーションが現在の Click to Pay 状態を表示する必要がある場合。
* `optOutCard` 決済ネットワーク側から 1 枚のデジタルカードを削除します。
* `optOutConsumer` 登録済みカード全体にわたって、エンドユーザーの Click to Pay プロファイル全体を削除します。
* 最終結果は、 [D1 API の概要](/click-to-pay/ja/integrate-the-d1-api/d1-api-summary.md) の Get Operation エンドポイント、または D1 Notifications を通じても追跡できます。

これらの図は、イシュアアプリケーションから開始されるオプトアウトフローを示しています。

`optOutConsumer` 同じ SDK パターンに従いますが、 `optOutCard`、ただしエンドユーザーに紐づくすべてのカードに適用されます。

## Click to Pay のプッシュ通知を処理する

次を参照してください。 [Click to Pay のプッシュ通知を処理する](/click-to-pay/ja/implement-click-to-pay-issuers/enroll-cards-in-click-to-pay/enroll-cards-by-d1-sdk.md#handle-click-to-pay-push-notifications) 実装の詳細については、D1 SDK 統合 – D1 SDK による登録のドキュメントを参照してください。

## の SDK API `optOutCard`

D1 SDK 4.2.0 以降、 `optOutCard` ([Android](https://thalesgroup.github.io/d1sdk-docs/d1-sdk/latest/android/com/thalesgroup/gemalto/d1/clicktopay/ClickToPayService.html#optOutCard\(java.lang.String,com.thalesgroup.gemalto.d1.D1Task.Callback\)) / [iOS](https://thalesgroup.github.io/d1sdk-docs/d1-sdk/4.3.0/ios/documentation/d1/clicktopayservice/optoutcard\(_:\))) は D1 SDK を通じて利用できます。

この API は、エンドユーザーが特定の 1 枚のカードだけをオプトアウトしたい場合に使用します。

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

```kotlin
fun optOutClick2Pay(d1Task: D1Task, cardID: String) {

    val callback: D1Task.Callback<Status?> =
        object : D1Task.Callback<Status?> {
            override fun onSuccess(data: Status?) {
                // Click to Pay へのオプトアウト成功
                val status: Status? = data
                val operationID = data?.operationID
            }

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

{% endtab %}

{% tab title="iOS" %}

```swift
let cardID = ""
do {
    let status = try await d1Task.clickToPayService().optOutCard(cardID)
    switch status {
    case .pending(let operationID):
        // Click to Pay へのオプトアウトは保留中です。
        print(operationID)
    case .successful(let operationID):
        // Click to Pay へのオプトアウトに成功しました。
        print(operationID)
    }
} catch {
    // エラーを処理します。
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
使用する `optOutCard` イシュアアプリケーションがカード一覧を表示し、エンドユーザーが削除するカードを 1 枚選択する場合。
{% endhint %}

## の SDK API `optOutConsumer`

D1 SDK 4.3.0 以降、 `optOutConsumer` ([Android](https://thalesgroup.github.io/d1sdk-docs/d1-sdk/latest/android/com/thalesgroup/gemalto/d1/clicktopay/ClickToPayService.html#optOutConsumer\(com.thalesgroup.gemalto.d1.D1Task.Callback\)) / [iOS](https://thalesgroup.github.io/d1sdk-docs/d1-sdk/4.3.0/ios/documentation/d1/clicktopayservice/optoutconsumer\(\))) は D1 SDK を通じて利用できます。

この API は、エンドユーザーが一度の操作で Click to Pay からすべてのカードをオプトアウトしたい場合に使用します。

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

```kotlin
fun optOutConsumerClick2Pay(d1Task: D1Task) {
    val callback: D1Task.Callback<Status?> =
        object : D1Task.Callback<Status?> {
            override fun onSuccess(data: Status?) {
                // Click to Pay へのオプトアウト成功
                val status: Status? = data
                val operationID = data?.operationID
            }

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

{% endtab %}

{% tab title="iOS" %}

```swift
do {
    let status = try await d1Task.clickToPayService().optOutConsumer()
    switch status {
    case .pending(operationID: let operationID):
        // 保留中のシナリオを処理
        print(operationID)
    case .successful(operationID: let operationID):
        // 成功シナリオを処理
        print(operationID)
    }
} catch let error {
    // エラーを処理します。
}
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
使用する `optOutConsumer` 慎重に。

この操作により、エンドユーザーの Click to Pay カードがすべて削除されます。
{% endhint %}


---

# 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/click-to-pay/ja/implement-click-to-pay-issuers/opt-out-cards-from-click-to-pay/opt-out-by-d1-sdk.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.
