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

# 支払い鍵を補充する

## 概要

決済キーは、非接触決済のためのEMV暗号を計算するために必要です。

ホストカードエミュレーション（HCE）モデルでは、決済キーは一時的なものです。支払いの中断を避けるために、切れる前に補充してください。

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

{% hint style="info" %}
NFCウォレットSDKは、さまざまな決済キーの種類をサポートします：

* **SUK（シングルユースキー）**：個々の取引ごとに使用される一回限りの決済キー。MastercardおよびThales EMVホワイトラベル（PURE）に適用されます。
* **LUK（リミテッドユースキー）**：有効期限が切れる前に複数の取引で使用できる決済キー。Visaに適用されます。
  {% endhint %}

## 前提条件

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

オンボーディング時に次と一緒に補充しきい値を構成します **Thales配信チーム**.

{% hint style="info" %}
しきい値を定義する際には次を考慮してください：

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

## SDK統合

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

次のシグナルのうち1つ（または両方）を使用します：

* **プロアクティブチェック**：読み取り `DigitalCard.PaymentKeyInfo.needsReplenishment`.
* **リアクティブプッシュ（TSPトリガー）**：処理 `MG:ReplenishmentNeededNotification` プッシュ通知を送信する **TSP**.

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

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

各デジタルカードについて定期的に確認します。例えば、各支払い後やアプリ起動時など。

```swift
func checkReplenishment(digitalCard: DigitalCard) async throws -> Bool {
    return try await digitalCard.paymentKeyInfo.needsReplenishment
}
```

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

* 後に **NFCウォレットSDK** 初期化。
* 支払い後。
* カードがデフォルトに設定されたとき。
* 接続が戻った後（オフライン → オンライン）。

{% hint style="info" %}
SDKが補充が必要であると示したらただちに補充をトリガーしてください。補充が進行中の間にアプリを終了しないでください。
{% endhint %}

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

呼び出す `ReplenishmentService.replenish(digitalCardID:)` 補充を行うと決めたときに。

{% code expandable="true" %}

```swift
func replenishment(digitalCard: DigitalCard) async {
    do {
        if try await digitalCard.paymentKeyInfo.needsReplenishment {
            let replenishmentService = ReplenishmentService()
            try await replenishmentService.replenish(digitalCardID: digitalCard.digitalCardID)
         
            // NFC Walletバックエンドは操作を確認するプッシュ通知を送信します。
            // あなたのアプリはそれを処理する必要があります。「プッシュ通知の処理」を参照してください。
        }
    } catch let error {
        switch (error as? ReplenishmentService.Error) {
            case .networkError:
                break
            case .missingWalletSecureEnrollment:
                break
            case .deviceEnvironmentUnsafe(let error):
                break
            case .clientError(let message):
                break
            case .serverError(let message):
                break
            case .unknown(let underlying):
                break
            @unknown default:
                break
        }
    }
}
```

{% endcode %}

補充リクエストを送信すると、 **NFCウォレットバックエンド** がプッシュ通知を送信します。アプリケーションがそれを処理し、SDKが新しい決済キーを取得します。

{% hint style="info" %}
**TSPトリガー** 受信したとき `MG:ReplenishmentNeededNotification`呼び出す `ReplenishmentService.replenish(digitalCardID:isForced:)` 次のパラメータで `isForced: true`.

参照してください [MG通知の処理（補充）](/nfc-wallet-sdk-ios/ja/get-started/configuration/4.-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-ios/ja/implement-nfc-wallet/make-payments/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.
