> 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/f8dd24eecda730c71fbdd80ce1b12bffa1a1909a" alt=""><figcaption></figcaption></figure>

## シーケンス図

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

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

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

### 要点

* どちらの操作も非同期です。
* 直近の結果には、次のステータスが含まれます。 `成功` または `保留中`、および `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 通知でも追跡できます。

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

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

## 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 による登録のドキュメントを参照してください。

## の 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 を通じて利用できます。

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

{% 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 Integration – Error Management セクションを参照してください。
            }
        }
    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 を通じて利用できます。

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

{% 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 Integration – Error Management セクションを参照してください。
            }
        }
    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.
