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

# Update profiles by D1 SDK

## Overview

This page explains how the issuer application can update Click to Pay profile data by using the D1 SDK.

The issuer application can call `updateConsumer` to update end user profile data, or `updateCard` to update card-level data for one card.

Use this SDK flow when you want the end user to review and update Click to Pay data directly in the issuer application, while D1 orchestrates the backend update with the Click to Pay directories.

{% hint style="info" %}
**Quick links**

* [Update Click to Pay profiles](/click-to-pay/implement-click-to-pay-issuers/update-click-to-pay-profiles.md)
* [Retrieve profiles by D1 SDK](/click-to-pay/implement-click-to-pay-issuers/retrieve-click-to-pay-profiles/retrieve-profiles-by-d1-sdk.md)
* [Enroll cards by D1 SDK](/click-to-pay/implement-click-to-pay-issuers/enroll-cards-in-click-to-pay/enroll-cards-by-d1-sdk.md)
* [Opt out by D1 SDK](/click-to-pay/implement-click-to-pay-issuers/opt-out-cards-from-click-to-pay/opt-out-by-d1-sdk.md)
  {% endhint %}

## Choose the right SDK API

### `updateConsumer`

Use `updateConsumer` when consumer data stored in Click to Pay must change.

Provide all consumer fields, even if only one value changed.

If you also provide a billing address, D1 updates the billing address for all cards linked to the consumer profile.

### `updateCard`

Use `updateCard` when only one enrolled card must change.

This API updates the billing address for the selected card and, for Visa only, the cardholder name.

{% hint style="warning" %}
Do not use these SDK APIs for card renewal or card replacement.

Use the D1 renew or replace flow instead.
{% endhint %}

## Flow

The SDK update flow follows these steps:

1. The issuer application initializes D1 SDK and logs in the end user.
2. The issuer application retrieves the current Click to Pay profiles.
3. The end user updates the required data in the issuer application.
4. The issuer application calls `updateConsumer` or `updateCard`.
5. D1 sends the request to the D1 backend by using the authenticated end user context.
6. The D1 backend updates the relevant Click to Pay directories.
7. D1 returns the operation status to the issuer application.

## Sequence diagram

The SDK flow has the same functional behavior as the backend update flow, but it is initiated directly from the issuer application.

For the detailed sequence diagrams, refer to [Update Click to Pay profiles](/click-to-pay/implement-click-to-pay-issuers/update-click-to-pay-profiles.md).

### Key points

* Both operations are asynchronous.
* The immediate result contains a status of `SUCCESSFUL` or `PENDING`, plus an `operationID`.
* Use [Retrieve profiles by D1 SDK](/click-to-pay/implement-click-to-pay-issuers/retrieve-click-to-pay-profiles/retrieve-profiles-by-d1-sdk.md) to prefill the issuer application user interface with the current Click to Pay data.
* Use `updateConsumer` only when you want to update Click to Pay data specifically.
* If the issuer backend stores the end user profile in D1, prefer [Update consumer information](/click-to-pay/integrate-the-d1-api/d1-api-reference/inbound-api-to-d1/consumer-api.md) when you want all channels, including Click to Pay, to stay synchronized.
* For Mastercard, when you provide a billing address, provide the complete address object.

## Handle Click to Pay push notifications

Refer to [Handle Click to Pay push notifications](/click-to-pay/implement-click-to-pay-issuers/enroll-cards-in-click-to-pay/enroll-cards-by-d1-sdk.md#handle-click-to-pay-push-notifications) in the enrollment by D1 SDK documentation for the implementation details.

## SDK API for `updateConsumer`

Use `updateConsumer` when the issuer application updates end user profile data in Click to Pay.

This API updates the end user profile in all relevant Click to Pay directories. If you provide a billing address, D1 also updates the billing address for each enrolled card.

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

```kotlin
fun updateConsumerClick2Pay(d1Task: D1Task) {
    // Consumer info received from user input.
    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?) {
                // Update consumer to Click to Pay success
                val status: Status? = data
                val operationID = data?.operationID
            }

            override fun onError(exception: D1Exception) {
                // Refer to D1 SDK Integration – Error Management section.
            }
        }
    d1Task.getClickToPayService().updateConsumer(
        consumerInfo,
        billingAddress,
        callback
    )
}
```

{% endtab %}

{% tab title="iOS" %}

```swift
func updateConsumerClick2Pay(d1Task: D1Task) {
    do {
        // Consumer info received from user input.
        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):
            // Handle pending scenario
            print(operationID)
        case .successful(operationID: let operationID):
            // Handle successful scenario
            print(operationID)
        }
    } catch let error {
        // Handle the error.
    }
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Always send the full consumer data set.

Do not send only the changed field.
{% endhint %}

## SDK API for `updateCard`

Use `updateCard` when the issuer application updates one enrolled card in Click to Pay.

This API updates card-level data only. Use it for the billing address, or for the cardholder name when the card belongs to 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?) {
                // Update card to Click to Pay success
                val status: Status? = data
                val operationID = data?.operationID
            }

            override fun onError(exception: D1Exception) {
                // Refer to D1 SDK Integration – Error Management section.
            }
        }
    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):
        // Handle pending scenario
        print(operationID)
    case .successful(operationID: let operationID):
        // Handle successful scenario
        print(operationID)
    }
} catch let error {
    // Handle the error.
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Use `updateCard` only for data attached to one card.

If the end user profile changes, use `updateConsumer` instead.
{% 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/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.
