> 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). Agents can also search and read this documentation through its [MCP server](https://docs.payments.thalescloud.io/~gitbook/mcp).

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

## 概要

非接触決済にウォレット取引データを付加できます。

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

ウォレット取引データは、デジタルカードごとに定義されます。

デジタルウォレットアプリケーションは、次の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() `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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.payments.thalescloud.io/nfc-wallet-sdk-ios/ja/additional-features/add-wallet-transaction-data.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
