> 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/update-click-to-pay-profiles/update-profiles-by-d1-sdk.md).

# D1 SDK でプロファイルを更新する

## 概要

このページでは、イシュアのアプリケーションが D1 SDK を使用して Click to Pay のプロファイルデータを更新する方法を説明します。

イシュアのアプリケーションは `updateConsumer` を呼び出してエンドユーザープロファイルデータを更新するか、 `updateCard` を呼び出して 1 枚のカードのカードレベルデータを更新できます。

エンドユーザーにイシュアのアプリケーション内で直接 Click to Pay データを確認・更新してもらい、その間に D1 が Click to Pay ディレクトリとのバックエンド更新を調整する場合は、この SDK フローを使用します。

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

* [Click to Payプロファイルを更新する](/click-to-pay/ja/implement-click-to-pay-issuers/update-click-to-pay-profiles.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/opt-out-cards-from-click-to-pay/opt-out-by-d1-sdk.md)
  {% endhint %}

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

### `updateConsumer`

使用する `updateConsumer` Click to Pay に保存されている顧客データを変更する必要がある場合。

1 つの値しか変更されていなくても、すべての顧客フィールドを提供してください。

請求先住所も提供した場合、D1 はその請求先住所を顧客プロファイルに関連付けられたすべてのカードに対して更新します。

### `updateCard`

使用する `updateCard` 登録済みカードの 1 枚だけを変更する必要がある場合。

この API は、選択したカードの請求先住所と、Visa の場合のみカード名義人名を更新します。

{% hint style="warning" %}
カード更新やカード置換にこれらの SDK API を使用しないでください。

代わりに D1 の更新または置換フローを使用してください。
{% endhint %}

## フロー

SDK 更新フローは次の手順に従います。

1. イシュアのアプリケーションが D1 SDK を初期化し、エンドユーザーをログインさせます。
2. イシュアのアプリケーションが現在の Click to Pay プロファイルを取得します。
3. エンドユーザーがイシュアのアプリケーションで必要なデータを更新します。
4. イシュアのアプリケーションが `updateConsumer` または `updateCard`.
5. を呼び出します。D1 は認証済みのエンドユーザーコンテキストを使用して、リクエストを D1 バックエンドに送信します。
6. D1 バックエンドが関連する Click to Pay ディレクトリを更新します。
7. D1 が操作ステータスをイシュアのアプリケーションに返します。

## シーケンス図

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

詳細なシーケンス図については、 [Click to Payプロファイルを更新する](/click-to-pay/ja/implement-click-to-pay-issuers/update-click-to-pay-profiles.md).

### 重要なポイント

* どちらの操作も非同期です。
* 即時結果には `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 データを事前入力できます。
* 使用する `updateConsumer` Click to Pay データを特に更新したい場合のみ。
* イシュアのバックエンドがエンドユーザープロファイルを D1 に保存している場合は、 [顧客情報を更新](/click-to-pay/ja/integrate-the-d1-api/d1-api-reference/inbound-api-to-d1/consumer-api.md) を優先してください。これにより、Click to Pay を含むすべてのチャネルを同期状態に保てます。
* Mastercard の場合、請求先住所を提供する際は、住所オブジェクト全体を提供してください。

## 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 `updateConsumer`

使用する `updateConsumer` イシュアのアプリケーションが Click to Pay でエンドユーザープロファイルデータを更新する場合。

この API は、関連するすべての Click to Pay ディレクトリのエンドユーザープロファイルを更新します。請求先住所を提供した場合、D1 は登録済みの各カードの請求先住所も更新します。

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

```kotlin
fun updateConsumerClick2Pay(d1Task: D1Task) {
    // ユーザー入力から受け取った顧客情報。
    val consumerInfo = ConsumerInfo(
        "Bella",
        "middle name",
        "Lin",
        "en-US",
        "+65",
        "99998888",
        "email@thalesgroup.com"
    )
    val billingAddress = BillingAddress("CZ")

    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().updateConsumer(
        consumerInfo,
        billingAddress,
        callback
    )
}
```

{% endtab %}

{% tab title="iOS" %}

```swift
func updateConsumerClick2Pay(d1Task: D1Task) {
    do {
        // ユーザー入力から受け取った顧客情報。
        let consumerInfo = ConsumerInfo(firstName: "Bella",
                                        middleName: nil,
                                        lastName: "Lin",
                                        language: "en-US",
                                        phoneNumberCountryCode: "+65",
                                        phoneNumber: "99998888",
                                        email: "email@thalesgroup.com")
        let billingAddress = BillingAddress(countryCode: "CZ")
        let status = try await d1Task.clickToPayService().updateConsumer(consumerInfo: consumerInfo,
                                                                         billingAddress: billingAddress)
        switch status {
        case .pending(operationID: let operationID):
            // 保留中のシナリオを処理
            print(operationID)
        case .successful(operationID: let operationID):
            // 成功シナリオを処理
            print(operationID)
        }
    } catch let error {
        // エラーを処理します。
    }
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
常に顧客データ一式を送信してください。

変更されたフィールドだけを送信しないでください。
{% endhint %}

## の SDK API `updateCard`

使用する `updateCard` イシュアのアプリケーションが Click to Pay で登録済みカード 1 枚を更新する場合。

この API はカードレベルのデータのみを更新します。請求先住所、またはカードが Visa の場合はカード名義人名に使用してください。

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

```kotlin
fun updateCardClickToPay(d1Task: D1Task, cardID: String, billingAddress: BillingAddress) {

    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().updateCard(
        cardID,
        "Bella Lin",
        billingAddress,
        callback
    )
}
```

{% endtab %}

{% tab title="iOS" %}

```swift
do {
    let cardID = ""
    let name = "Bella Lin"
    let billingAddress = BillingAddress(countryCode: "CZ")
    let status = try await d1Task.clickToPayService().updateCard(cardID,
                                                                 name: name,
                                                                 billingAddress: billingAddress)
    switch status {
    case .pending(operationID: let operationID):
        // 保留中のシナリオを処理
        print(operationID)
    case .successful(operationID: let operationID):
        // 成功シナリオを処理
        print(operationID)
    }
} catch let error {
    // エラーを処理します。
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
使用する `updateCard` 1 枚のカードに関連付けられたデータに対してのみ。

エンドユーザープロファイルが変更された場合は、代わりに `updateConsumer` を使用してください。
{% 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/update-click-to-pay-profiles/update-profiles-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.
