Skip to main content

emv_3ds/message/
error_msg.rs

1use crate::types::MessageVersion;
2use serde::{Deserialize, Serialize};
3
4/// EMV 3DS Error Message.
5///
6/// Sent by any component (3DS Server, DS, ACS) to indicate a protocol error.
7/// A received ErrorMessage should abort the current transaction.
8#[derive(Debug, Clone, Serialize, Deserialize)]
9#[serde(rename_all = "camelCase")]
10pub struct ErrorMessage {
11    pub message_type: MessageType,
12    pub message_version: MessageVersion,
13    /// Three-digit code; see EMVCo spec Table A.5.
14    pub error_code: String,
15    /// Human-readable description of the error.
16    pub error_description: String,
17    /// Detail about the specific field that caused the error.
18    pub error_detail: String,
19    /// The messageType of the message that caused this error.
20    pub error_message_type: String,
21    /// Transaction ID of the erroring message.
22    #[serde(
23        rename = "threeDSServerTransID",
24        skip_serializing_if = "Option::is_none"
25    )]
26    pub three_ds_server_trans_id: Option<String>,
27    #[serde(rename = "acsTransID", skip_serializing_if = "Option::is_none")]
28    pub acs_trans_id: Option<String>,
29    #[serde(rename = "dsTransID", skip_serializing_if = "Option::is_none")]
30    pub ds_trans_id: Option<String>,
31    #[serde(rename = "sdkTransID", skip_serializing_if = "Option::is_none")]
32    pub sdk_trans_id: Option<String>,
33}
34
35/// Well-known EMVCo error codes.
36pub mod error_codes {
37    pub const INVALID_FORMAT: &str = "101";
38    pub const INVALID_FORMAT_CRITICAL: &str = "102";
39    pub const REQUIRED_ELEMENT_MISSING: &str = "201";
40    pub const CRITICAL_ELEMENT_MISSING: &str = "202";
41    pub const FORMAT_VIOLATION: &str = "203";
42    pub const DUPLICATE_ELEMENT: &str = "301";
43    pub const TRANSACTION_TIMED_OUT: &str = "402";
44    pub const TRANSACTION_TIMED_OUT_DECOUPLED: &str = "403";
45    pub const ACCESS_DENIED: &str = "404";
46    pub const UNKNOWN_PROTOCOL_ELEMENT: &str = "405";
47    pub const SYSTEM_ERROR: &str = "500";
48}
49
50#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
51pub enum MessageType {
52    Erro,
53}