Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/mdiago/VeriFactu/llms.txt

Use this file to discover all available pages before exploring further.

This page documents all COM-visible objects exposed by the VeriFactu COM Interop assembly (Verifactu.Com). These objects mirror the .NET API but are designed for use from COM-compatible environments such as Excel VBA, Access VBA, and VB6. All validation rules and AEAT communication logic are identical to the .NET library — the COM layer is a thin, type-safe wrapper. For practical usage examples see the VBA / Excel guide.

VfInvoice

ProgId: Verifactu.VfInvoice
Interface: IVfInvoice
GUID: BBADB0CE-A83F-455C-8BCE-1D5E200BF5BC
The central object for creating, submitting, and cancelling VERI*FACTU invoice records. Each instance represents a single invoice. Tax lines are accumulated with InsertTaxItem; the final totals are computed automatically when reading TotalAmount or calling Send().

Properties

InvoiceType
string
Invoice type code. Corresponds to AEAT list L2. Defaults to "F1" if not set.
ValueDescription
F1Standard invoice
F2Simplified invoice (ticket)
F3Invoice replacing simplified invoices
R1Rectificative — legal basis error
R2Rectificative — art. 80.3
R3Rectificative — art. 80.4
R4Rectificative — other
R5Simplified rectificative
RectificationType
string
Identifies whether a rectificative invoice corrects by substitution (S) or by difference (I). Only relevant when InvoiceType starts with R. Corresponds to AEAT list L3. Defaults to "NA" (not applicable) if not set.
InvoiceID
string
required
Invoice identifier (número de factura). Must be unique per seller per day.
InvoiceDate
DateTime
required
Invoice issue date.
SellerID
string
required
Seller fiscal identifier (NIF, VAT number, DUNS, etc.).
SellerName
string
required
Seller name or company name (razón social).
BuyerID
string
Buyer fiscal identifier. Use the fiscal ID if one exists (NIF, VAT number, DUNS).
BuyerName
string
Buyer name or company name.
BuyerCountryID
string
ISO 3166-1 alpha-2 country code of the buyer (e.g. "ES", "FR", "DE"). Required for non-Spanish buyers.
BuyerIDType
int
Buyer identifier type code. Corresponds to AEAT list L7. Defaults to 2 (NIF) if not set.
ValueDescription
2NIF (default for Spanish buyers)
3Pasaporte
4Documento oficial de residencia
5Certificado de residencia fiscal
6Otro documento probatorio
7No censado
TotalAmount
decimal
Computed total amount: sum of all tax bases + total tax output − total tax withheld. Triggers recalculation on every read. Read-only.
TotalTaxOutput
decimal
Computed sum of all TaxAmount values across all VfTaxItem lines. Read-only.
TotalTaxOutputSurcharge
decimal
Computed sum of all TaxAmountSurcharge values across all VfTaxItem lines (recargo de equivalencia). Read-only.
TotalTaxWithheld
decimal
Computed total of withheld taxes (retenciones). Read-only.
Text
string
Free-text invoice description (concepto / descripción de la operación).

Methods

SetOperationDate(operationDate: DateTime)
void
Sets the operation date when it differs from the invoice issue date. Optional.
SetThirdPartyIssuer(thirdPartyType: string)
void
Marks the invoice as issued by a third party or by the buyer (autofactura). Corresponds to AEAT list L6.
  • "D" — Issued by the buyer (destinatario) — autofactura. Currently supported.
  • "T" — Issued by a third party. Not yet implemented; throws NotImplementedException.
InsertTaxItem(taxItem: IVfTaxItem)
void
Adds a VfTaxItem tax line to the invoice. Multiple tax lines can be added (e.g. different VAT rates, or IVA + recargo de equivalencia).
DeleteTaxItemAt(index: int)
void
Removes the tax line at the given zero-based index.
InsertRectificationItem(item: IVfRectificationItem)
void
Adds a VfRectificationItem reference to a previously-issued invoice that this invoice rectifies. Used with InvoiceType starting with R.
DeleteRectificationItemAt(index: int)
void
Removes the rectification reference at the given zero-based index.
SetSubstitution(taxItem: IVfTaxItem)
void
Sets the substitution data for R-type invoices corrected by substitution (RectificationType = "S"). The taxItem carries the TaxBase, TaxAmount, and TaxAmountSurcharge of the original (replaced) invoice. InvoiceType must start with R or an ArgumentException is thrown.
Send()
IVfInvoiceResult
Builds the VERI*FACTU RegistroAlta XML, signs it with the configured certificate, chains it to the blockchain, and submits it to the AEAT web service. Returns a VfInvoiceResult with the operation outcome.
Delete()
IVfInvoiceResult
Builds the VERI*FACTU RegistroAnulacion XML and submits it to the AEAT web service to cancel a previously submitted invoice. Returns a VfInvoiceResult with the operation outcome.
GetRegistroAlta()
string
Returns the full VERI*FACTU RegistroAlta XML as a UTF-8 string without sending it. Useful for previewing or storing the XML locally before submission.
GetRegistroAnulacion()
string
Returns the full VERI*FACTU RegistroAnulacion XML as a UTF-8 string without sending it.
GetUrlValidate()
string
Returns the AEAT validation URL for the invoice. This URL encodes the QR content and can be opened in a browser to verify the invoice on the AEAT portal.
GetValidateQr(path: string)
void
Generates the AEAT validation QR code as a bitmap and saves it to the file path specified by path.
GetValidateQrBytes()
byte[]
Returns the AEAT validation QR code bitmap as a raw byte array. Useful when you want to embed the image without writing to disk.
GetNifErrors(nif: string, name: string)
string
Validates the given NIF/name combination against the AEAT’s online NIF validation service. Returns null (or an empty string) if the NIF is valid, or a newline-separated string of error descriptions if validation fails.

VfTaxItem

ProgId: Verifactu.VfTaxItem
Interface: IVfTaxItem
GUID: F861507A-AFB0-4922-B694-554112103F75
Represents a single tax breakdown line on an invoice. Pass instances to VfInvoice.InsertTaxItem(). Numeric fields use float for COM compatibility (values are rounded to 2 decimal places internally when added to the invoice).

Properties

Tax
string
Applicable tax code. Corresponds to AEAT list L1. Defaults to "01" (IVA) if not set.
ValueDescription
01IVA — Impuesto sobre el Valor Añadido (default)
02IPSI — Impuesto sobre la Producción, los Servicios y la Importación (Ceuta y Melilla)
03IGIC — Impuesto General Indirecto Canario
05Otros
TaxScheme
string
Tax regime (régimen / clave de régimen). Corresponds to AEAT lists L8A / L8B. Defaults to "01" (régimen general) if not set. Common values: "01" (general), "02" (exportaciones), "05" (agencias de viajes), "07" (criterio de caja), etc.
TaxType
string
Operation qualification (calificación de operación). Corresponds to AEAT list L9. Defaults to "S1" (sujeta y no exenta — no inversión sujeto pasivo) if not set. Common values: "S1" (sujeta no exenta), "S2" (sujeta no exenta — inversión sujeto pasivo), "N1" (no sujeta art. 7), "N2" (no sujeta otros), "E1""E6" (exenta).
TaxException
string
Exemption cause (causa de exención). Corresponds to AEAT list L10. Defaults to "NA" if not set. Only relevant when TaxType indicates an exempt operation (E1E6).
TaxBase
float
required
Taxable base amount (base imponible) in euros.
TaxRate
float
Tax rate as a percentage (tipo impositivo), e.g. 21 for 21% IVA, 10 for 10% IVA, 4 for super-reduced rate.
TaxAmount
float
Tax quota amount in euros (cuota del impuesto). Must equal TaxBase × TaxRate / 100 (rounded to 2 decimals).
TaxRateSurcharge
float
Equivalence surcharge rate as a percentage (tipo del recargo de equivalencia), e.g. 5.2 for the 21% IVA surcharge. Leave at 0 if not applicable.
TaxAmountSurcharge
float
Equivalence surcharge quota in euros (cuota del recargo de equivalencia). Must equal TaxBase × TaxRateSurcharge / 100. Leave at 0 if not applicable.

VfRectificationItem

ProgId: Verifactu.VfRectificationItem
Interface: IVfRectificationItem
GUID: 119A584F-681D-4DE0-BBC1-929057B7F992
Identifies an original invoice being rectified. Add instances to a rectificative VfInvoice via InsertRectificationItem(). Multiple references can be added if the rectification covers more than one original invoice.

Properties

InvoiceID
string
required
Invoice identifier of the original invoice being rectified (número de la factura rectificada).
InvoiceDate
DateTime
required
Issue date of the original invoice being rectified (fecha de la factura rectificada).

VfInvoiceResult

ProgId: Verifactu.VfInvoiceResult
Interface: IVfInvoiceResult
GUID: 674199D6-27FE-4C42-B980-0BEC549CF304
Returned by VfInvoice.Send() and VfInvoice.Delete(). Contains the full outcome of the AEAT web service call.

Properties

ResultCode
string
Operation result code.
ValueMeaning
"0"Success — the AEAT accepted the record
"9001"Local exception (network error, config error, etc.)
"9002:..."SOAP fault returned by the AEAT (fault code appended after the colon)
"9009"Unknown error
OtherAEAT application-level error code (see ResultMessage for details)
ResultMessage
string
Human-readable description. "OK" on success; error description on failure. For AEAT errors this contains the AEAT’s DescripcionErrorRegistro field.
CSV
string
Código Seguro de Verificación assigned by the AEAT when the record is accepted (ResultCode = "0"). Store this value — it is the authoritative reference for the submitted record. Empty when the submission failed.
Response
string
Raw XML body of the AEAT web service response. Populated on both success and AEAT-level errors. Useful for audit logging and detailed error diagnostics. Empty on local exceptions (9001).

VfSettings

ProgId: Verifactu.VfSettings
Interface: IVfSettings
GUID: F04D6533-AAC5-453B-A19D-BB76711ED404
Configuration object that mirrors Settings.Current in the .NET library. Use it to configure the certificate, storage paths, AEAT endpoints, and billing software metadata before calling Send() or Delete(). Call Save() to persist settings to disk; they are loaded automatically on the next process start. For a full description of every property see Configuration / Settings.

Properties — Certificate

CertificatePath
string
Path to the .pfx certificate file. Used together with CertificatePassword to load the certificate from the filesystem.
CertificatePassword
string
Password for the .pfx certificate file. Only required when loading from a file via CertificatePath.
CertificateSerial
string
Serial number of the certificate in the Windows certificate store. Mutually exclusive with CertificatePath.
CertificateThumbprint
string
SHA-1 thumbprint (huella digital) of the certificate in the Windows certificate store. Mutually exclusive with CertificatePath.

Properties — Storage Paths

InboxPath
string
Directory used as the incoming message tray. Responses received from the AEAT are stored here.
OutboxPath
string
Directory used as the outgoing message tray. A copy of every submission sent to the AEAT is stored here.
BlockchainPath
string
Directory where the per-issuer blockchain files are stored. These files maintain the cryptographic chain of invoice records required by VERI*FACTU.
InvoicePath
string
Directory where issued invoice records are persisted locally.
LogPath
string
Directory for system message logs.

Properties — AEAT Endpoints & Algorithm

VeriFactuEndPointPrefix
string
Base URL prefix for the AEAT VERI*FACTU submission web service (alta and anulación).
VeriFactuEndPointValidatePrefix
string
Base URL prefix for the AEAT VERI*FACTU validation web service.
VeriFactuHashAlgorithm
string
Hash algorithm code for blockchain record fingerprints. Corresponds to AEAT list L12. Defaults to "01" (SHA-256).
VeriFactuHashInputEncoding
string
Text encoding used as input to the hash function (e.g. "UTF-8").
IDVersion
string
Schema version. Alfanumérico(3), list L15. Current value: "1.0".

Properties — Billing Software (SistemaInformatico)

These properties identify the invoicing software to the AEAT and are included in every submitted record.
SistemaInformaticoNombreRazon
string
Name/company name of the billing software producer. Up to 120 characters.
SistemaInformaticoNIF
string
NIF of the billing software producer. FormatoNIF(9).
SistemaInformaticoNombre
string
Name given by the producer to the billing software. Up to 30 characters.
SistemaId
string
Software system ID code. Up to 2 characters.
SistemaInformaticoVersion
string
Software version string. Up to 50 characters.
SistemaInformaticoNumeroInstalacion
string
Installation number, uniquely identifying this software installation for this taxpayer. Up to 100 characters.
SistemaInformaticoTipoUsoPosibleSoloVerifactu
string
"S" if the software can only operate in VERI*FACTU mode; "N" otherwise. List L4.
SistemaInformaticoTipoUsoPosibleMultiOT
string
"S" if the software can handle multiple taxpayers; "N" if it can only handle one. List L4.
SistemaInformaticoIndicadorMultiplesOT
string
"S" if the software is currently managing more than one taxpayer; "N" otherwise. Determined automatically by the software. List L4.

Properties — Validation Flags

SkipNifAeatValidation
bool
When true, the online NIF validation call to the AEAT census service is skipped. Useful for testing or offline scenarios.
SkipViesVatNumberValidation
bool
When true, the online VAT number validation against the EU VIES registry is skipped.
LoggingEnabled
bool
When true, the system message log is active and entries are written to LogPath.

Methods

Save()
void
Applies the current property values to Settings.Current and persists them to the XML configuration file on disk.
Load()
void
Reads Settings.Current into this object’s properties, refreshing all values from the in-memory (or previously loaded) configuration.
SetConfigFileName(fileName: string)
void
Overrides the default configuration file path. Call this before Load() or Save() to use a custom configuration file location.
LoadBlockchainsFromDisk()
void
Reads all blockchain files from BlockchainPath into memory. Call this once at application startup if your process needs to resume an existing blockchain state. Throws InvalidOperationException if BlockchainPath is not a valid directory.

VfInvoiceQuery

ProgId: Verifactu.VfInvoiceQuery
Interface: IVfInvoiceQuery
GUID: 9279A76F-E672-4128-899F-A2B3CCB8E6C0
Allows querying invoices registered with the AEAT for a given seller, year, and month. Results are returned as an array of VfInvoice objects accessible through GetInvoicesCount() and GetInvoice(index).

Properties

SellerID
string
required
Seller NIF or fiscal identifier whose invoices are to be queried.
SellerName
string
Seller name associated with SellerID.
Year
string
Four-digit year to query (e.g. "2024").
Month
string
Two-digit month to query (e.g. "01" through "12").

Methods

GetSales()
void
Queries the AEAT for issued (sales) invoices matching SellerID, Year, and Month. Populates the internal Invoices array. Call GetInvoicesCount() and GetInvoice(index) to iterate results.
GetPurchases()
void
Queries the AEAT for received (purchase) invoices matching SellerID, Year, and Month. Populates the internal Invoices array.
GetInvoicesCount()
int
Returns the number of invoices in the result set from the last GetSales() or GetPurchases() call. Returns 0 if no query has been executed yet.
GetInvoice(index: int)
VfInvoice
Returns the VfInvoice at the given zero-based index from the last query result. Throws ArgumentOutOfRangeException if index is out of range.

Example

Sub ConsultarFacturas()
    Dim cfg As New Verifactu.VfSettings
    cfg.CertificatePath = "C:\MiCertificado.pfx"
    cfg.CertificatePassword = "mi_password"
    cfg.Save

    Dim query As New Verifactu.VfInvoiceQuery
    query.SellerID = "B72877814"
    query.SellerName = "MI EMPRESA SL"
    query.Year = "2024"
    query.Month = "11"

    query.GetSales

    Dim i As Integer
    Dim msg As String
    msg = "Facturas encontradas: " & query.GetInvoicesCount() & vbCrLf
    For i = 0 To query.GetInvoicesCount() - 1
        Dim inv As Verifactu.VfInvoice
        Set inv = query.GetInvoice(i)
        msg = msg & inv.InvoiceID & " - " & inv.InvoiceDate & vbCrLf
    Next i

    MsgBox msg
End Sub

Build docs developers (and LLMs) love