> 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, and the optional `goal` query parameter:

```
GET https://docs.payments.thalescloud.io/nfc-wallet-sdk-ios/ja/additional-features/add-wallet-transaction-data.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.
