Skip to main content

Module response

Module response 

Source
Expand description

Parsers for ECR17 terminal response application messages.

Each parser takes the application payload as text — the bytes between STX and ETX (crate::codec::DecodedPacket::payload, a Vec<u8>) decoded to a &str by the caller — and returns a raw struct whose fields sit at the exact 1-based spec offsets. Fields are mostly the raw strings as received, plus a few derived conveniences (the outcome TransactionOutcome, the numeric status, and boolean flags). The client layer maps these raw structs onto the fully typed crate::types results (enum/amount/date conversions).

Parsing is defensive: a field starting beyond the payload comes back empty (and a partial field is clamped) rather than panicking, so a short/truncated response degrades gracefully. Port of the reference C++ Ecr17Response.

§Known limitations (carried from the reference; validate on a real terminal)

  • DCC is parsed only for the uppercase 'V' payment response. Pre-auth closure DCC responses reportedly use a lowercase 'v' with a different DCC offset; that variant is not parsed here (matches the reference) and would need real-terminal data to add safely.
  • The shared payment-family parser does not extract a reversal action code (the reference PaymentResponse has no such field), so ReversalResult.action_code stays empty when a reversal is parsed through this path.

Structs§

CloseResponse
Raw close-session response ('C').
DccInfo
Optional DCC / currency-exchange block (parsed from a 'V' response). Named DccInfo to mirror the reference; the client maps it to crate::types::CurrencyExchange.
PaymentResponse
Raw payment-family response ('E' without DCC, 'V' with DCC). Reused for reversal / card verification / pre-auth closure which share the layout.
PreAuthResponse
Raw pre-auth response ('e').
StatusResponse
Raw status response ('s').
TotalsResponse
Raw totals response ('T').
VasResponse
Raw VAS response ('K').

Functions§

outcome_from_code
Maps the raw 2-digit result code to a TransactionOutcome.
parse_close
Parses a close-session response ('C').
parse_payment
Parses a payment-family response ('E' plain / 'V' DCC).
parse_pre_auth
Parses a pre-auth response ('e').
parse_status
Parses a status response ('s').
parse_totals
Parses a totals response ('T').
parse_vas
Parses a VAS response ('K').