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

# Retrieve profiles by D1 SDK

## Overview

This page explains how the issuer application can retrieve Click to Pay profiles by using the D1 SDK.

The issuer application calls `getProfiles` ([Android](https://thalesgroup.github.io/d1sdk-docs/d1-sdk/latest/android/com/thalesgroup/gemalto/d1/clicktopay/ClickToPayService.html#getProfiles\(com.thalesgroup.gemalto.d1.D1Task.Callback\)) / [iOS](https://thalesgroup.github.io/d1sdk-docs/d1-sdk/4.3.0/ios/documentation/d1/clicktopayservice/profiles\(\))) API which triggers the same backend retrieval behavior as the issuer backend calling the [Click to Pay get consumer profiles API](/click-to-pay/integrate-the-d1-api/d1-api-summary.md).

Use this SDK flow when you want to display the current Click to Pay profile data directly in the issuer application, for example before allowing the end user to update profile details or opt out a card.

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

* [Retrieve Click to Pay profiles](/click-to-pay/implement-click-to-pay-issuers/retrieve-click-to-pay-profiles.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)
* [Update Click to Pay profiles](/click-to-pay/implement-click-to-pay-issuers/update-click-to-pay-profiles.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 %}

## Flow

The SDK retrieve-profiles flow follows these steps:

1. The issuer application initializes D1 SDK and logs in the end user.
2. The issuer application calls the Click to Pay retrieve-profiles operation.
3. D1 sends the request to the D1 backend by using the authenticated end user context.
4. The D1 backend queries the configured Click to Pay directories.
5. D1 aggregates the result and returns at most one profile per payment network to the issuer application.

## Sequence diagram

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

For the detailed sequence diagram, refer to [Retrieve Click to Pay profiles](/click-to-pay/implement-click-to-pay-issuers/retrieve-click-to-pay-profiles.md).

### Key points

* This is a asynchronous operation. The issuer application receives the current profiles directly in the callback or returned result.
* The response contains a `ProfileResult.Profile` collection. Each entry represents one Click to Pay profile in one payment network directory.
* If several Click to Pay directories are configured, D1 consolidates the profiles into one response.
* If the end user exists in D1 but is not enrolled in Click to Pay, the operation returns an empty list.
* Use this flow when the issuer application must show the current Click to Pay State before calling [Enroll cards in Click to Pay](/click-to-pay/implement-click-to-pay-issuers/enroll-cards-in-click-to-pay.md) or [Opt out cards from Click to Pay](/click-to-pay/implement-click-to-pay-issuers/opt-out-cards-from-click-to-pay.md).

{% hint style="info" %}
Treat an empty profile list as a valid functional result.

It usually means the end user is known in D1 but has no Click to Pay profile yet.
{% endhint %}

## Response handling

The issuer application should expect the following data:

* `scheme`: the payment network directory for the returned profile.
* `consumerInfo`: the current end user data stored in the Click to Pay directory.
* `cards`: the list of cards associated with the Click to Pay profile for that payment network.
* `message`: optional troubleshooting text returned when D1 can only provide a partial response.

Use the returned data to:

* show the current Click to Pay enrollment state,
* display which cards are available in each payment network directory,
* prefill a profile update user interface, or
* help the end user choose the right next action.

{% hint style="warning" %}
Do not parse or display the optional `message` field to the end user.

Use it for troubleshooting only.
{% endhint %}

### Handle Click to Pay push notifications

Unlike enrollment or opt-out, retrieving Click to Pay profiles does not require a dedicated push notification flow.

This operation returns the current result directly to the issuer application. No asynchronous completion event is expected for the profile retrieval itself.

You can still keep Click to Pay push notifications enabled in the issuer application for other operations, such as enrollment or opt-out. For the implementation details, 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).

## SDK API

The `getProfiles` ([Android](https://thalesgroup.github.io/d1sdk-docs/d1-sdk/latest/android/com/thalesgroup/gemalto/d1/clicktopay/ClickToPayService.html#getProfiles\(com.thalesgroup.gemalto.d1.D1Task.Callback\)) / [iOS](https://thalesgroup.github.io/d1sdk-docs/d1-sdk/4.3.0/ios/documentation/d1/clicktopayservice/profiles\(\))) API is available through D1 SDK.

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

```kotlin
fun getProfilesC2Pay(d1Task: D1Task) {
    val callback: D1Task.Callback<ProfileResult?> = object : D1Task.Callback<ProfileResult?> {
        override fun onSuccess(data: ProfileResult?) {
            // Get Click to Pay profiles success
            val profiles: MutableList<Profile?>? = data?.getProfileList()
            val message: String? = data?.getErrorMessage()
            if (!message.isNullOrEmpty()) {
                // log the message and may retry again to get the complete profile
            }
            // display all the profile
        }

        override fun onError(exception: D1Exception) {
            // Refer to D1 SDK Integration – Error Management section.
        }
    }

    d1Task.getClickToPayService().getProfiles(
        callback
    )
}
```

{% endtab %}

{% tab title="iOS" %}

```swift
do {
    let profileResult = try await d1Task.clickToPayService().profiles()
    if let message = profileResult.errorMessage {
        // log the message and may retry again to get the complete profile
    }
    // display all the profile
} catch let error {
    // Handle the error.
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Use the returned profile data as the source for the issuer application user interface.

Do not assume that every payment network returns a profile for the end user.
{% 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/retrieve-click-to-pay-profiles/retrieve-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.
