> 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)).
* 登録は非同期操作です。最終結果は次のいずれかの方法で取得できます:
  * コールバックのステータス（`SUCCESSFUL` または `PENDING`),
  * を呼び出す、 `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://docs.payments.thalescloud.io/click-to-pay/integrate-the-d1-sdk/getting-started/configuration/4.-push-notifications/push-notification-configuration).
{% endstep %}

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

登録する [プッシュ通知トークン](https://docs.payments.thalescloud.io/click-to-pay/integrate-the-d1-sdk/getting-started/configuration/4.-push-notifications/push-notification-configuration#update-push-token).
{% endstep %}

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

登録する [メッセージ通知](https://docs.payments.thalescloud.io/click-to-pay/integrate-the-d1-sdk/getting-started/configuration/4.-push-notifications/message-handling).
{% 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",
        "ミドルネーム",
        "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().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", 
        "ミドルネーム", 
        "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 統合 – エラー管理のセクションを参照してください。
        }
    };
    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.
