> 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/enroll-cards-in-click-to-pay/enroll-cards-by-d1-sdk.md).

# D1 SDK でカードを登録する

## 概要

このページでは、イシュアアプリケーションが D1 SDK を使用してカードとその最終利用者を Click to Pay に登録する方法を説明します。

イシュアのアプリケーションが `登録`、これはイシュアのバックエンドが呼び出すのと同じバックエンドの Click to Pay 登録操作をトリガーします [D1 API](/click-to-pay/ja/integrate-the-d1-api/d1-api-summary.md).

D1 が Click to Pay ディレクトリおよび決済ネットワークとのバックエンド連携をオーケストレーションする一方で、最終利用者にイシュアアプリケーションのユーザーインターフェース内で直接 Click to Pay 登録を開始させたい場合に、この SDK フローを使用してください。

## フロー

次の図は、SDK の Click to Pay 登録フローの主な手順を示しています。

<figure><img src="/files/fb7bdfd6a82117ad187218ef09d16482b0ca00b0" alt=""><figcaption></figcaption></figure>

## シーケンス図

D1 SDK 4.2.0 以降では、バックエンドフローの追加により、 `登録` ([Android](https://thalesgroup.github.io/d1sdk-docs/d1-sdk/latest/android/com/thalesgroup/gemalto/d1/clicktopay/ClickToPayService.html#enrol\(java.lang.String,com.thalesgroup.gemalto.d1.clicktopay.ConsumerInfo,java.lang.String,com.thalesgroup.gemalto.d1.clicktopay.BillingAddress,com.thalesgroup.gemalto.d1.D1Task.Callback\)) / [iOS](https://thalesgroup.github.io/d1sdk-docs/d1-sdk/4.3.0/ios/documentation/d1/clicktopayservice/enrol\(_:consumerinfo:name:billingaddress:\))) API も [D1 SDK](/click-to-pay/ja/integrate-the-d1-sdk/api-reference.md).

### 前提条件

SDK フローには、バックエンドフローと同じ前提条件および制限があります。詳細は [前提条件](/click-to-pay/ja/implement-click-to-pay-issuers/enroll-cards-in-click-to-pay.md#prerequisites).

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

<figure><img src="/files/e5bbc38df79b1fd563345bae38fb14afb9b66c84" alt=""><figcaption></figcaption></figure>

### 要点

* イシュアアプリケーションは、消費者情報を提供する必要があります。参照してください `ConsumerInfo` ([SDK API](/click-to-pay/ja/integrate-the-d1-sdk/api-reference.md)).
* 登録は非同期操作です。最終結果は次のいずれかで取得できます。
  * コールバックステータスを使用する（`成功` または `保留中`),
  * 次を呼び出す `Get Operation` エンドポイントは [D1 API](/click-to-pay/ja/integrate-the-d1-api/d1-api-summary.md)、または
  * D1 通知を有効にする。SDK フローでは、イシュアは [アプリ内プッシュ通知](/click-to-pay/ja/integrate-d1-notifications.md) に加えて、イシュアのバックエンド通知も有効にできます。
* 決済ネットワークに関連付けられた TSP が、一般的なデジタル化フローを開始します。

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

イシュアアプリケーションが D1 バックエンドから Click to Pay 登録通知を受信できるようにする前に、プッシュ通知が次のように設定されていることを確認してください。

{% stepper %}
{% step %}
**プッシュ通知を設定する**

で概説されている必要な手順を実行します [プッシュ通知の設定](https://gitlab.sre.ops.gcloud.thalescloud.io/bps/gitbook/d1-gitbook-docs/-/blob/main/Products/Click-to-Pay/integrate-the-d1-sdk/getting-started/configuration/4.-push-notifications).
{% endstep %}

{% step %}
**プッシュ通知トークンを登録する**

次を登録します [プッシュ通知トークン](https://gitlab.sre.ops.gcloud.thalescloud.io/bps/gitbook/d1-gitbook-docs/-/blob/main/Products/Click-to-Pay/integrate-the-d1-sdk/getting-started/configuration/4.-push-notifications).
{% endstep %}

{% step %}
**メッセージ通知に登録する**

次に登録します [メッセージ通知](/click-to-pay/ja/integrate-d1-notifications/in-app-notifications-and-messaging.md).
{% endstep %}
{% endstepper %}

これらの手順が完了すると、イシュアアプリケーションは次のようなプッシュ通知を受信し始めることができます `clickToPayEnrolment` および `clickToPayOptOutCard`.

D1 SDK が `clickToPayEnrolment` ([Android](https://thalesgroup.github.io/d1sdk-docs/d1-sdk/latest/android/com/thalesgroup/gemalto/d1/messaging/MessageType.html#CLICKTOPAY_ENROLMENT) / [iOS](https://thalesgroup.github.io/d1sdk-docs/d1-sdk/4.3.0/ios/documentation/d1/messagetype/clicktopayenrolment)）または `clickToPayOptOutCard` ([Android](https://thalesgroup.github.io/d1sdk-docs/d1-sdk/latest/android/com/thalesgroup/gemalto/d1/messaging/MessageType.html#CLICKTOPAY_OPTOUT_CARD) / [iOS](https://thalesgroup.github.io/d1sdk-docs/d1-sdk/4.3.0/ios/documentation/d1/messagetype/clicktopayoptoutcard)）の種類のプッシュ通知を受信すると、イシュアアプリケーションは通知を確認して、Click to Pay 登録操作またはオプトアウトが成功したかどうかを判断します。

## SDK API

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

```kotlin
fun enrolClick2Pay(d1Task: D1Task, cardID: String) {
    // ユーザー入力またはバックエンドから受信した消費者情報。
    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 Integration – Error Management セクションを参照してください。
            }
        }
    d1Task.getClickToPayService().enrol(
        cardID,
        consumerInfo,
        "Bella Lin",
        billingAddress,
        callback
    )
}
```

{% endtab %}

{% tab title="Android - JAVA" %}

```java
public void enrolClick2Pay(@NonNull D1Task d1Task, @NonNull String cardID) {
    // ユーザー入力またはバックエンドから受信した消費者情報。
    ConsumerInfo consumerInfo = new ConsumerInfo(
        "Bella", 
        "middle name", 
        "Lin", 
        "en-US", 
        "+65", 
        "99998888", 
        "email@thalesgroup.com"
    );
    BillingAddress billingAddress = new BillingAddress("CZ");

    D1Task.Callback<Status> callback = new D1Task.Callback<Status>() {
        @Override
        public void onSuccess(Status data) {
            // Click to Pay への登録成功
            Status status = data;
            String operationID = data.operationID;
        }

        @Override
        public void onError(D1Exception exception) {
            // D1 SDK Integration – Error Management セクションを参照してください。
        }
    };
    d1Task.getClickToPayService().enrol(
            cardID,
            consumerInfo,
            "Bella Lin",
            billingAddress,
            callback);
}
```

{% endtab %}

{% tab title="iOS" %}

```swift
let cardID = ""
let name = "Bella Lin"
let consumerInfo = ConsumerInfo(firstName: "Bella",
                                middleName: nil,
                                lastName: "Lin",
                                language: "en-US",
                                phoneNumberCountryCode: "+65",
                                phoneNumber: "99998888",
                                email: "email@thalesgroup.com")

let billingAddress = BillingAddress(line1: "1230 Rue de Rivoli",
                                    line2: nil,
                                    line3: nil,
                                    city: "Paris",
                                    state: "75",
                                    zipCode: "75000",
                                    countryCode: "FR")
do {
    let status = try await d1Task.clickToPayService().enrol(cardID,
                                                            consumerInfo: consumerInfo,
                                                            name: name,
                                                            billingAddress: billingAddress)
    switch status {
    case .pending(let operationID):
        // Click to Pay への登録は保留中です。
        print(operationID)
    case .successful(let operationID):
        // Click to Pay への登録に成功しました。
        print(operationID)
    }
} catch {
    // エラーを処理します。
}
```

{% endtab %}
{% endtabs %}


---

# 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/enroll-cards-in-click-to-pay/enroll-cards-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.
