> 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/nfc-wallet-sdk-android/ja/implement-nfc-wallet/make-payment/replenish-payment-keys.md).

# 支払いキーを補充する

## 概要

コンタクトレス決済のEMV暗号を算出するには、支払いキー（SUKまたはLUK）が必要です。

ホストカードエミュレーション（HCE）モデルでは、支払いキーは一時的です。枯渇する前に補充してください。これにより決済の中断を防げます。

このガイドは、いつ補充するかとそのトリガー方法を説明します。

{% hint style="info" %}
NFCウォレットSDKは次の支払いキータイプをサポートします：

* **SUK（シングルユースキー）**： 取引ごとに1つのキーを使用します。MastercardおよびPURE（ホワイトラベルEMV）で使用されます。
* **LUK（リミテッドユースキー）**： 複数の取引で1つのキーを使用します。Visaで使用されます。
  {% endhint %}

## 前提条件

### 補充しきい値の設定（オンボーディング）

オンボーディング時に補充しきい値を設定します（ **Thales配信チーム**.

{% hint style="info" %}
しきい値を定義する際に考慮する点：

* **SUK**： 補充をトリガーする残りのSUK数。
* **LUK**： 残りの取引回数とLUKの有効期限。
  {% endhint %}

## SDK統合

### 補充が必要かを検出する

次の信号のいずれか（一方または両方）を使用します：

* **プロアクティブチェック**： デジタルカードのステータスを読み取ります。
* **リアクティブプッシュ（TSPトリガー）**： 処理 `MG:ReplenishmentNeededNotification` からの **TSP**.

プッシュ配信とルーティングについては、こちらを参照してください： [プッシュ通知の処理](/nfc-wallet-sdk-android/ja/get-started/configuration/5.-push-notifications/handle-push-notifications.md).

#### プロアクティブチェック

このチェックは各デジタルカードごとに実行します。アプリ起動時または支払い後に実行してください。

1. 取得するもの `DigitalizedCardStatus` から `DigitalizedCard`.
2. 呼び出す `DigitalizedCardStatus.needsReplenishment()`.

参照： [デジタルカードの表示](/nfc-wallet-sdk-android/ja/implement-nfc-wallet/manage-digital-cards/display-digital-cards.md).

{% code title="デジタルカードが補充を必要とするかどうかを確認する" %}

```java
public static boolean needsReplenishment(final DigitalizedCard card) {
    AsyncResult<DigitalizedCardStatus> result =
            card.getCardState(null).waitToComplete();

    if (!result.isSuccessful()) {
        // TODO: エラーを処理する
        return false;
    }

    DigitalizedCardStatus status = result.getResult();
    return status != null && status.needsReplenishment();
}
```

{% endcode %}

このプロアクティブチェックを実行する：

* 定期的なアプリケーション起動時に
  * アプリケーションが支払いのために起動されている場合はチェックを実行しないでください - 下の警告を参照
* 支払い後に
  * イベント時に `onNextTransactionReady`  - 参照： [コンタクトレス支払いコールバックを実装する](/nfc-wallet-sdk-android/ja/implement-nfc-wallet/make-payment/implement-contactless-payments/2.-implement-contactless-payment-callbacks.md).
* カードがデフォルトに設定されたとき。
* 接続が復帰した後（オフライン → オンライン）。

{% hint style="warning" %}
このチェックは、次の後にアプリ起動時に実行してください： **NFCウォレットSDK** 初期化。

エンドユーザーがコンタクトレス支払いを行うためにアプリを起動した場合にはこのチェックを実行しないでください。支払いの実行が遅延する可能性があります。
{% endhint %}

### 補充をトリガーする

呼び出す `ProvisioningBusinessService.sendRequestForReplenishment(...)` を使用して新しい支払いキーをリクエストします。

1. カード識別子を取得します。

   使用する： **トークン化されたカードID**  - 参照： [デジタルカードを表示](/nfc-wallet-sdk-android/ja/implement-nfc-wallet/manage-digital-cards/display-digital-cards.md#tokenized-card-id-versus-digital-card-id).
2. 補充リクエストを送信します。

   呼び出す `sendRequestForReplenishment(...)` を呼び出し、次を実装します： `PushServiceListener`:

   * `onComplete`： リクエストが受理されました。
   * `onError`： SDKがリクエストを送信できません。次を確認してください： `ProvisioningServiceError`.

   <pre class="language-java" data-title="補充リクエストを送信する"><code class="lang-java">public void replenish(final String tokenizedCardId, final boolean forced) {
       ProvisioningBusinessService service =
               ProvisioningServiceManager.getProvisioningBusinessService();

       service.sendRequestForReplenishment(
               tokenizedCardId,
               new ReplenishmentListener(),
               forced
       );
   }

   private static class ReplenishmentListener implements PushServiceListener {
       @Override
       public void onComplete() {
           // TODO: 成功をログに記録する
       }

       @Override
       public void onError(final ProvisioningServiceError error) {
           // TODO: エラーをログに記録する
       }

       @Override
       public void onUnsupportedPushContent(final Bundle bundle) {
           // この呼び出しでは使用されません。
       }

       @Override
       public void onServerMessage(final String tokenizedCardId,
                                   final ProvisioningServiceMessage message) {
           // この呼び出しでは使用されません。
       }
   }
   </code></pre>
3. 補充プッシュを処理する。

   リクエストを送信すると、NFCウォレットのバックエンドがプッシュ通知を送信します。あなたの **デジタルウォレットアプリケーション** はそれを処理する必要があります。SDKはその後新しい支払いキーを取得します。

{% hint style="info" %}
補充が進行中の間は、を終了しないでください。 **デジタルウォレットアプリケーション** （進行中に終了してはいけません）
{% endhint %}

{% hint style="info" %}
**TSPトリガーによる補充**

を受信したとき、 `MG:ReplenishmentNeededNotification`forced = true `で補充をトリガーします。`.

参照： [MG通知（補充）を処理する](/nfc-wallet-sdk-android/ja/get-started/configuration/5.-push-notifications/handle-push-notifications.md#process-mg-notifications-replenishment).
{% 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:

```
GET https://docs.payments.thalescloud.io/nfc-wallet-sdk-android/ja/implement-nfc-wallet/make-payment/replenish-payment-keys.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
