> 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/implement-nfc-wallet/make-payments/implement-contactless-payment/5.-display-the-transaction-context.md).

# 5. Display the transaction context

Handle `ContactlessPaymentSession.Event.transactionCompleted` to show the payment status to the end user.

This event includes a `TransactionContext` that contains key details about the transaction.

### Handle the completion event

In your `ContactlessPaymentSession.eventStream` loop, handle:

* `.transactionCompleted(let transactionContext)`

Use `transactionContext` to update your UI and trigger any follow-up actions.

### TransactionContext fields

`TransactionContext` typically includes:

* `aid`: EMV application identifier (AID).
* `amount`: Transaction amount (formatted for display in your UI).
* `rawAmount`: Raw amount value as received from the terminal.
* `currencyCode`: ISO-4217 numeric currency code.
* `transactionDate`: Transaction date (YYMMDD, BCD-encoded).
* `transactionType`: Transaction type code (for example, purchase vs refund).
* `digitalCardID`: Digital card identifier used for the payment.
* `scheme`: Payment network (for example, Visa or Mastercard).
* `isTransit`: Indicates whether the transaction is a transit transaction.
* `transactionID`: Transaction identifier.

Refer to the following example code snippet for implementation instructions:

{% code title="Format and display transaction context" %}

```swift
func displayTransactionContext(_ context: TransactionContext) {
    // Set this to your locale.
    let locale = Locale(identifier: "en_US")

    // Map ISO-4217 numeric codes to alphabetic codes.
    // Expand this mapping based on your supported currencies.
    let iso4217NumToCode: [Int: String] = [
        978: "EUR",
        840: "USD"
    ]

    let currencyFormatter = NumberFormatter()
    currencyFormatter.locale = locale
    currencyFormatter.numberStyle = .currency

    if let currencyCode = iso4217NumToCode[context.currencyCode.bcdToInt()] {
        currencyFormatter.currencyCode = currencyCode
    }

    let rawDateFormatter = DateFormatter()
    rawDateFormatter.dateFormat = "yyMMdd"

    guard let transactionDate = rawDateFormatter.date(from: context.transactionDate.bcdToString()) else {
        // Fallback: skip date rendering if parsing fails.
        return
    }

    let displayDateFormatter = DateFormatter()
    displayDateFormatter.locale = locale
    displayDateFormatter.dateStyle = .medium

    let amountStr = currencyFormatter.string(from: context.amount as NSNumber) ?? "-"
    let dateStr = displayDateFormatter.string(from: transactionDate)

    let transactionTypeStr = context.transactionType.bcdToString()
    switch transactionTypeStr {
    case "00":
        // Purchase
        break
    case "20":
        // Refund / correction
        break
    default:
        // Unknown transaction type
        break
    }

    // Update your UI with amountStr, dateStr, scheme, isTransit, and transactionID.
}
```

{% endcode %}


---

# 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/implement-nfc-wallet/make-payments/implement-contactless-payment/5.-display-the-transaction-context.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.
