> 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/additional-features/add-wallet-transaction-data.md).

# ウォレット取引データを追加する

## 概要

ウォレットのトランザクションデータを非接触決済に添付できます。

イシュアのバックエンドは、このデータを承認処理中に使用できます。

ウォレットのトランザクションデータは、デジタルカードごとに定義されます。

デジタルウォレットアプリケーションは、これを次の2つのモードで提供できます:

* **永続**: NFC Wallet SDK はデータをセキュアストレージに保存します。アプリケーションの再起動後も保持されます。
* **一時的**: デジタルウォレットアプリケーションは、その1回のトランザクションに対する値のみを提供します。

デジタルウォレットアプリケーションは、各支払いにウォレットのトランザクションデータを含めるかどうかを決定します。

{% hint style="info" %}
NFC Wallet SDK は、Mastercard および PURE の非接触プロファイルでのみウォレットのトランザクションデータをサポートします。
{% endhint %}

### Mastercard 仕様（MCBP 2.3）

NFC Wallet SDK は Mastercard 仕様をサポートします **MCBP 2.3**.

非接触トランザクションの前にウォレットのトランザクションデータが利用可能な場合、NFC Wallet SDK は次を更新します `IAD` （EMVタグ `9F10`、イシュアアプリケーションデータ）:

* 開始オフセット: 19バイト目
* IADの最大長: 32バイト
* ウォレットのトランザクションデータの最大長: 14バイト

{% hint style="info" %}
MCBP 2.3 では、この機能は次のように呼ばれます **ウォレット独自情報**.
{% endhint %}

### PURE 仕様

NFC Wallet SDK は、PURE の非接触プロファイルに対してもウォレットのトランザクションデータをサポートします。

非接触トランザクションの前にウォレットのトランザクションデータが利用可能な場合、NFC Wallet SDK は次を更新します `IAD` （EMVタグ `9F10`、イシュアアプリケーションデータ）:

* 開始オフセット: 18バイト目
* IADの最大長: 32バイト
* ウォレットのトランザクションデータの最大長: 15バイト

## SDK統合

### Mastercard の永続ウォレットトランザクションデータを設定する

次を使用します `DigitalCard.setWalletTransactionData` を使用して永続ウォレットトランザクションデータを設定します:

* 14バイトの `Data` 値を渡して、このデジタルカードのウォレットトランザクションデータを保存します。
* を渡して `nil` このデジタルカードに保存されている値を消去します。

```swift
do {      
    // Mastercard 用のウォレットトランザクションデータを設定します。データ長 = 14バイト。
    let walletData = Data([0x57, 0x61, 0x6C, 0x6C, 0x65, 0x74, 0x44,
                            0x61, 0x74, 0x61, 0x00, 0x00, 0x00, 0x00])      
    try await digitalCard.setWalletTransactionData(walletData)
    // このカードのウォレットトランザクションデータを消去します
    try await digitalCard.setWalletTransactionData(nil)  
} catch {
    // エラーを処理します  
}
```

### PURE の永続ウォレットトランザクションデータを設定する

次を使用します `DigitalCard.setWalletTransactionData` を使用して永続ウォレットトランザクションデータを設定します:

* 15バイトの `Data` 値を渡して、このデジタルカードのウォレットトランザクションデータを保存します。
* を渡して `nil` このデジタルカードに保存されている値を消去します。

```swift
do {      
    // この特定のカードのウォレットトランザクションデータを設定します
    let walletData = Data([0x57, 0x61, 0x6C, 0x6C, 0x65, 0x74, 0x44,
                            0x61, 0x74, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00])      
    try await digitalCard.setWalletTransactionData(walletData)
    // このカードのウォレットトランザクションデータを消去します
    try await digitalCard.setWalletTransactionData(nil)  
} catch {
    // エラーを処理します  
}
```

### エラーを処理します

ウォレットのトランザクションデータは、次の要件を満たす必要があります:

* Mastercard の長さ: 正確に14バイト
* PURE の長さ: 正確に15バイト
* スキームのサポート: サポートされているのは Mastercard と PURE の非接触プロファイルのみです。別のスキームにウォレットのトランザクションデータを設定すると、SDK は `.schemeNotSupported`.

```swift
do {
      try await digitalCard.setWalletTransactionData(data)
  } catch DigitalCard.Error.invalidWalletTransactionData {
      // スキームに基づく長さの検証。
      // Mastercard の場合、データ長が14バイトではありません。 
      // PURE カードの場合、データ長が15バイトではありません。 
  } catch DigitalCard.Error.schemeNotSupported {
      // カードのスキームはウォレットのトランザクションデータをサポートしていません（例: Visa）
  } catch {
      // その他のエラー
  }
```

### 支払い用のウォレットトランザクションデータを提供する

次を使用します `startPayment()` と `ContactlessPaymentInputData` を使用して、非接触決済中にウォレットのトランザクションデータを提供します。

`ContactlessPaymentInputData` は、2つのウォレットトランザクションデータモードをサポートします:

* `.storage`: セキュアストレージに保存された値を使用します（設定されている場合）。
* `.ephemeral`: このトランザクションに対する値のみを提供します。

#### ストレージモード

```swift
let paymentInputData = ContactlessPaymentInputData(
    digitalCardID: card.id,
    walletTransactionDataMode: .storage
)
```

#### 一時モード

```swift
let paymentInputData = ContactlessPaymentInputData(
    digitalCardID: card.id,
    walletTransactionDataMode: .ephemeral(customData)
)
```

#### 支払いを開始する

```swift
// 提供された contactlessPaymentInputData を使用して支払いを開始します
// ユースケース: 手動モード（ユーザー操作あり）
await session.startPayment(with contactlessPaymentInputData: contactlessPaymentInputData)
```


---

# 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/additional-features/add-wallet-transaction-data.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.
