Skip to main content

attach_event_protocol

Function attach_event_protocol 

Source
pub fn attach_event_protocol(
    request_xml: &str,
    response_xml: &str,
) -> Result<String, FiscalError>
Expand description

Attach an event protocol response to the event request, producing the <procEventoNFe> wrapper.

Extracts <evento> from request_xml and <retEvento> from response_xml, validates the event status, and joins them into a <procEventoNFe> document.

ยงErrors

Returns FiscalError::XmlParsing if:

  • Either input is empty
  • The <evento> tag is missing from request_xml
  • The <retEvento> tag is missing from response_xml
  • The <idLote> tag is missing from request_xml or response_xml
  • The idLote values differ between request and response

Returns FiscalError::SefazRejection if the event status code is not valid (135, 136, or 155 for cancellation only).