Download the PHP package krendil007/verifactu-php without Composer

On this page you can find all versions of the php package krendil007/verifactu-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package verifactu-php

Verifactu PHP Library

[ES] Librería completa (registro, consulta, anulación) orientada a objetos para la integración del sistema de facturación digital de Verifactu.

[EN] Full object oriented (register, query, cancellation) library for integration of Verifactu digital invoicing system.

Disclaimer: this is an open source library, not an invoicing system. It is provided without any warranties; it is the sole responsibility of the integrator to verify its correct operation and compliance with legal or technical requirements. The library includes automated tests to help verify its functionality, but use in production is at your own risk.

A modern PHP library for integrating with 🇪🇸Spain’s AEAT Verifactu system (digital invoice submission, cancellation, querying, and events) according to the official regulatory technical specification.

[!NOTE] This library supports verfactu transactions only. For non verifactu signed transactions, such as those required when not using invoicing software, you may look for a different library.


Table of Contents


Introduction

This library provides an object-oriented, strongly-typed and extensible interface to Spain’s AEAT Verifactu digital invoicing system, including:

It is designed for easy Composer-based installation and seamless integration into any modern PHP 8.0+ application.


Features


Installation

Install via Composer:


Basic Usage

1. Configuration

Before using any service, you must configure the library with your certificate, password, certificate type, and environment.
Choose between certificate type (certificate or seal) and environment (production or sandbox) according to whether you'll be working in production or testing.


2. Register an Invoice (Alta)


3. Cancel an Invoice (Anulación)


4. Query Submitted Invoices


5. Generate QR for an Invoice

The library provides flexible options for generating QR codes for invoices, supporting different renderers, resolutions, and output formats.

Available Options:


AEAT Workflow Overview

The typical workflow to comply with AEAT Verifactu regulation is:

  1. Prepare Invoice Data: Build an InvoiceSubmission model (or InvoiceCancellation, EventRecord, etc.) with all required fields.
  2. Generate Hash (Huella): The library calculates the SHA-256 hash of the invoice using official field ordering.
  3. Serialize to XML: The library creates an XML structure strictly matching the AEAT XSD.
  4. Digitally Sign XML: The library signs the XML block using XAdES enveloped and your digital certificate.
  5. Transmit to AEAT: The signed XML is sent to AEAT via SOAP using the appropriate endpoint and certificate authentication.
  6. Parse Response: The response is parsed into a typed model (InvoiceResponse, QueryResponse, etc.), translating error codes using the official dictionary.
  7. Handle Results: Use the CSV, status, and error details to update your ERP, notify users, or perform follow-up actions.

The same flow applies to cancellations and events, changing only the data model and XML structure.


Configuration

The library is configured using the Verifactu::config() method, which accepts the following parameters:

Certificate Types

Environments

The library automatically selects the appropriate SOAP endpoints and QR verification URLs based on the certificate type and environment.

Advanced Configuration

If you need more control over the configuration, you can use the VerifactuService::config() method directly:


Main Models

The library provides a comprehensive set of object-oriented models that represent different aspects of the AEAT Verifactu system. All models extend the base Model class, which provides validation functionality.

Core Models

Component Models

Enumerations

The library uses enum classes for type-safe constants:

Model Validation

All models provide validation through the validate() method:

XML Serialization

Models can be serialized to XML using the toXml() method, which returns a DOMDocument:

See the /src/models directory for PHPDoc details and validation rules for each model.


Service Reference

The library is organized into specialized services that handle different aspects of the AEAT Verifactu integration. While most operations can be performed through the main Verifactu facade, you can also use these services directly for more advanced use cases.

Main Services

Specialized Services

Each service is designed to be used independently or as part of the overall workflow orchestrated by the VerifactuService. This modular design allows for flexibility and testability.


Error Handling

The library provides comprehensive error handling at multiple levels:

Model Validation Errors

When using the validate() method on models, validation errors are returned as an associative array:

AEAT Response Errors

Errors returned by AEAT in SOAP responses are parsed into structured objects:

All AEAT error codes are mapped to human-readable messages using the official code dictionary in /src/dictionaries/ErrorRegistry.php.

[!NOTE] If you receive the error: “The value of the NIF field in the ObligadoEmision block is not identified”, it means the issuer data you provided is not correct. They must exactly match your census data at the Spanish Tax Agency (AEAT). You can verify them on the AEAT website under “Mis datos censales”.

SOAP Communication Errors

When making SOAP requests, any communication errors (network issues, timeouts, etc.) will throw a SoapFault exception. Also if soap validation does not pass in AEAT, a code will be returned by AEAT. Here is a list of common codes:

Code Description
100 The SOAP request signature is not valid
101 The SOAP request is empty
102 The SOAP request is not well-formed: SOAP Envelope not found
103 The SOAP request is not well-formed: SOAP Body not found
104 The SOAP request is not well-formed: SOAP Header not found
106 The certificate used in the SOAP signature is on a blocklist or is a test certificate

Exception Handling

The library throws exceptions for various error conditions:

Common Error Types

Proper error handling is essential for a robust integration with AEAT Verifactu.


Contributing


License

MIT License. See LICENSE file.


Acknowledgements


For more information on the Verifactu regulation, see the AEAT website

Developing and testing

Testing

This library includes comprehensive tests to ensure code quality and that documentation examples work correctly:

Setting up for Sandbox Testing

To run tests that interact with the AEAT Verifactu sandbox environment, you need to provide a valid certificate. The library uses a .env file to securely load certificate information without committing it to the repository.

  1. Copy the .env.example file to .env in the project root:

  2. Edit the .env file and set the following variables:

  3. When you run any test command, the library will automatically check if the .env file exists and create it from .env.example if it doesn't. If the file is created automatically, you'll see a warning message indicating that you need to configure it.

  4. Tests that require a certificate will be skipped if the .env file is not properly configured.

Note: The .env file is excluded from version control by .gitignore to prevent accidentally committing sensitive information.

[!NOTE] To run integration tests you must define TEST_ISSUER_NIF and TEST_ISSUER_NAME in .env. Tests will throw an exception if they are not configured. These values must exactly match your AEAT census data (NIF and legal name). If they do not match, you will get issuer identification errors.

Development

See the CONTRIBUTING.md file for guidelines on how to contribute to this project, including setting up your development environment, running tests, and submitting pull requests.


All versions of verifactu-php with dependencies

PHP Build Version
Package Version
Requires bacon/bacon-qr-code Version ^3
robrichards/xmlseclibs Version ^3.0
php Version >=8.1
ext-soap Version *
ext-libxml Version *
ext-openssl Version *
ext-dom Version *
vlucas/phpdotenv Version ^5.5
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package krendil007/verifactu-php contains the following files

Loading the files please wait ...