> 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/use-correlationid.md).

# correlationID を使用する

## 概要

各トークナイゼーション処理には、関連する `correlationID` これは、トラブルシューティングのために Thales と共有できます。

この識別子は、次の 2 通りの方法で取得できます。

* 有効性チェックの成功時、またはトークナイゼーションのエラー時に取得できます。
* 独自のカスタム `correlationID` を呼び出す際に `checkEligibility()` .

## SDK 統合

### correlationID を取得するには `checkEligibility(...)`

* 成功後 `checkEligibility(...)`
  * 有効性チェックが成功した後、読み取ります `acceptanceData.correlationID`.
  * 後で同じトークナイゼーション処理を追跡する必要がある場合は、この値を保存してください。
* エラー発生後に `checkEligibility(...)`
  * 読み取るか保存してください `correlationID` エラーが捕捉され次第。

次の例では、取得方法を説明します。 `correlationID` `checkEligibility(...)`

```swift
// digitizeCard() 中に correlationID を取得
let cardDigitizationService = CardDigitizationService()
let authenticationToken = Data() // イシュアバックエンドのトークン（グリーンフロー登録用）。
let fcmToken = "FACY6074293608087656831WRF1234" // 例のみ。

do {
    try await cardDigitizationService.digitizeCard(
        withTNC: termsAndConditions.accept(),
        pushToken: fcmToken, // Firebase Cloud Messaging (FCM) トークン
        language: "en",
        authenticationToken: authenticationToken
    )
} catch let error as CardDigitizationService.Error {
    let returnedCorrelationID = error.correlationID
} catch let error as CardDigitizationService.DigitizeError {
    let returnedCorrelationID = error.correlationID
} catch {
    // 他のエラーを処理します。
}

for await state in await cardDigitizationService.eventStream {
    switch state {
    case let .digitizationApproved(digitalCardID):
        _ = digitalCardID
        return
    case let .errorEncountered(error):
        if let error = error as? CardDigitizationService.Error {
            let returnedCorrelationID = error.correlationID
        } else if let error = error as? CardDigitizationService.DigitizeError {
            let returnedCorrelationID = error.correlationID
        }
        return
        default:
        break
    }
}
```

### カスタム correlationID を設定する

設定できます `correlationID` のみ `checkEligibility(...)`.

次の `checkEligibility(...)` バリアントがこのパラメータをサポートしています。

イシュアバックエンド、デジタルウォレットアプリケーション、Thales のログ全体でトークナイゼーション処理を追跡したい場合は、カスタム値を使用します。

独自の識別子形式も使用できます。例えば次のようになります。

```
ORDER-12345-SESSION-67890
```

#### インストゥルメントデータでカスタム correlationID を設定する

```swift
// カードデータを使用した checkEligibility()
let encryptedDataComponent = CardDigitizationService.InstrumentDataComponents(
    publicKey: pubKey,
    identifier: pubKeyIdentifier,
    pan: pan,
    expiryDate: expiryDate,
    cvv: cvv
)
let instrumentData = encryptedDataComponent.instrumentData()
let eligibilityData = "<eligibilityData>"
let correlationID = "<correlationID>"

do {
    let cardDigitizationService = try await CardDigitizationService()
    let acceptanceData = try await cardDigitizationService.checkEligibility(
        eligibilityData,
        instrumentData: instrumentData,
        correlationID: correlationID
    )
    let returnedCorrelationID = acceptanceData.correlationID
    let tnc = acceptanceData.termsAndConditions
} catch let error as CardDigitizationService.Error {
    let returnedCorrelationID = error.correlationID
} catch let error as CardDigitizationService.EligibleError {
    let returnedCorrelationID = error.correlationID
} catch {
    // 他のエラーを処理します。
}
```

#### pushSessionID でカスタム correlationID を設定する

```swift
// pushSessionID を使用した checkEligibility()
let eligibilityData = "<eligibilityData>"
let pushSessionID = "<pushSessionIDFromイシュアバックエンド>"
let correlationID = "<correlationID>"

do {
    let cardDigitizationService = try await CardDigitizationService()
    let acceptanceData = try await cardDigitizationService.checkEligibility(
        eligibilityData,
        pushSessionID: pushSessionID,
        correlationID: correlationID
    )
    let returnedCorrelationID = acceptanceData.correlationID
    let tnc = acceptanceData.termsAndConditions
} catch let error as CardDigitizationService.Error {
    let returnedCorrelationID = error.correlationID
} catch let error as CardDigitizationService.EligibleError {
    let returnedCorrelationID = error.correlationID
} catch {
    // 他のエラーを処理します。
}
```


---

# 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/use-correlationid.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.
