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

# 5. Mostrar el contexto de la transacción

Manejar `ContactlessPaymentSession.Event.transactionCompleted` para mostrar el estado del pago al usuario final.

Este evento incluye un `TransactionContext` que contiene detalles clave sobre la transacción.

### Gestiona el evento de finalización

En tu `ContactlessPaymentSession.eventStream` bucle, maneja:

* `.transactionCompleted(let transactionContext)`

Usar `transactionContext` para actualizar tu interfaz y desencadenar cualquier acción de seguimiento.

### Campos de TransactionContext

`TransactionContext` normalmente incluye:

* `aid`: identificador de aplicación EMV (AID).
* `amount`: importe de la transacción (formateado para mostrarse en tu interfaz).
* `rawAmount`: valor bruto del importe recibido del terminal.
* `currencyCode`: código numérico de moneda ISO-4217.
* `transactionDate`: fecha de la transacción (YYMMDD, codificada en BCD).
* `transactionType`: código del tipo de transacción (por ejemplo, compra frente a reembolso).
* `digitalCardID`: identificador de tarjeta digital usado para el pago.
* `scheme`: red de pago (por ejemplo, Visa o Mastercard).
* `isTransit`: indica si la transacción es una transacción de tránsito.
* `transactionID`: identificador de la transacción.

Consulta el siguiente fragmento de código de ejemplo para obtener instrucciones de implementación:

{% code title="Formatea y muestra el contexto de la transacción" %}

```swift
func displayTransactionContext(_ context: TransactionContext) {
    // Establécelo según tu configuración regional.
    let locale = Locale(identifier: "en_US")

    // Asigna los códigos numéricos ISO-4217 a códigos alfabéticos.
    // Amplía este mapeo según las monedas que admitas.
    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 {
        // Alternativa: omite el renderizado de la fecha si falla el análisis.
        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":
        // Compra
        break
    case "20":
        // Reembolso / corrección
        break
    default:
        // Tipo de transacción desconocido
        break
    }

    // Actualiza tu interfaz con amountStr, dateStr, scheme, isTransit y 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 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/es/implement-nfc-wallet/make-payments/implement-contactless-payment/5.-display-the-transaction-context.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.
