Skip to content

ISSNet Integration

MIDDAG Account integrates with ISSNet to issue Brazilian electronic service invoices (NFSe -- Nota Fiscal de Servico Eletronica) for the municipality of Brasilia/DF. The integration uses the ABRASF 2.04 standard over SOAP.

What it does

When a payment is confirmed, the plugin automatically generates an NFSe. The tax invoice is submitted to the municipal tax authority, and the plugin tracks its status through polling until the NFSe is issued or an error occurs.

Setup

Prerequisites

  • An active A1 digital certificate (.pfx file) issued for the company.
  • A valid municipal registration (inscricao municipal) in Brasilia/DF.
  • The certificate file must be stored outside the web root for security.

Configuration

All settings are stored in wp_options with the prefix middag_issnet_:

SettingDescriptionExample
middag_issnet_cnpj_prestadorCompany CNPJ (digits only)12345678000190
middag_issnet_inscricao_municipalMunicipal registration number0123456789
middag_issnet_certificado_pathAbsolute path to the .pfx file/etc/ssl/middag.pfx
middag_issnet_certificado_senhaCertificate password (stored encrypted)---
middag_issnet_ambientehomologacao or producaohomologacao
middag_issnet_codigo_servicoService code per LC 116/20031.01
middag_issnet_aliquota_issISS tax rate0.05

The certificate password is encrypted in wp_options -- it is never stored as plaintext.

Environments

EnvironmentWSDL endpoint
Homologacaohttps://www.issnetonline.com.br/homologaabrasf/webservicenfse204/nfse.asmx
ProducaoConfigurable via middag_issnet_wsdl_producao option

Always test in homologacao before making changes to production configuration.

When it triggers

The emission flow starts when the plugin fires the middag_order_payment_confirmed event:

If ISSNet configuration is missing or incomplete, the plugin logs a warning and skips the emission. The rest of the order flow continues normally (graceful degradation).

Status tracking

The TaxInvoice entity tracks the full lifecycle:

StatusMeaning
PENDINGTaxInvoice created, not yet submitted
PROCESSINGRPS submitted, awaiting municipal response
ISSUEDNFSe issued successfully
FAILEDEmission failed after retries
CANCELLEDNFSe cancelled (within legal deadline)

When the NFSe is issued, the plugin stores the NFSe number, verification code, and the public URL for the issued document.

SOAP operations

OperationDirectionPurpose
RecepcionarLoteRpsOutboundSubmit an RPS lot (one RPS per lot)
ConsultarSituacaoLoteRpsPollingCheck lot processing status
ConsultarNfseServicoPrestadoPollingRetrieve issued NFSe data
CancelarNfseOutboundCancel an issued NFSe (with reason)

Cancellation

NFSe cancellation is allowed within 15 days of issuance (Brasilia/DF regulation). After this deadline, cancellation requires an administrative process with the municipality. The plugin blocks the cancellation action after the deadline has passed.

Error handling

ScenarioAction
SOAP error codeDetailed log, TaxInvoice status set to FAILED, admin notified
Certificate expiredEmission blocked, admin notified by email and admin notice
SOAP timeoutRetry via WP-Cron with exponential backoff (max 3 attempts)
Incomplete configurationLog warning, admin notice displayed. Emission not attempted.
Invalid payer CNPJ/CPFTaxInvoice status set to FAILED with specific error message
Certificate file not foundEmission blocked, admin notified

Retry policy

AttemptTiming
1Immediate
2+2 minutes
3+10 minutes
After 3Status: FAILED

An admin can reprocess a failed TaxInvoice manually from the admin UI.

Hooks

HookWhenPayload
middag_taxinvoice_pendingTaxInvoice created$tax_invoice_id
middag_taxinvoice_issuedNFSe issued successfully$tax_invoice_id, $nfse_number
middag_taxinvoice_failedEmission failed$tax_invoice_id, $error
middag_taxinvoice_cancelledNFSe cancelled$tax_invoice_id, $nfse_number
middag_issnet_certificate_expiringCertificate expires in < 30 days$days_remaining