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
PaymentResponsehas no such field), soReversalResult.action_codestays empty when a reversal is parsed through this path.
Structs§
- Close
Response - Raw close-session response (
'C'). - DccInfo
- Optional DCC / currency-exchange block (parsed from a
'V'response). NamedDccInfoto mirror the reference; theclientmaps it tocrate::types::CurrencyExchange. - Payment
Response - Raw payment-family response (
'E'without DCC,'V'with DCC). Reused for reversal / card verification / pre-auth closure which share the layout. - PreAuth
Response - Raw pre-auth response (
'e'). - Status
Response - Raw status response (
's'). - Totals
Response - 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').