Skip to main content

📡 Read a Credential over Proximity

The POS accepts an ISO/IEC 18013-5 engagement over NFC or by scanning an mdoc: QR code. Once it has the engagement, it creates a session transcript, builds the request against that transcript, and starts the reader exchange.

Model the reader lifecycle​

  • ProximityReaderModel keeps the engagement, request, and result in a small state machine so the UI cannot start a transfer before it has both an endpoint and a request.
  • setConnectionEndpoint() moves the model to WAITING_FOR_DEVICE_REQUEST state. At that point, create our request using the session transcript; then call setDeviceRequest() and start the exchange. This order prevents a request from being detached from the specific proximity session.

Send the request and receive the response​

The above code block:

  • Opens an MdocTransport request to the other peer.
  • Sends the request through ISO/IEC 18013-5 SessionEncryption
  • And closes the transport whether the holder responds or not surfacing the outcomes

The flow returns an explicit outcome for no response, a non-zero device-response status, or a successful response. Surface those outcomes to the cashier; do not advance the sale until the authoritative settlement step succeeds.