Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/josemmo/Verifactu-PHP/llms.txt

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

AeatResponse (josemmo\Verifactu\Models\Responses\AeatResponse) is returned by the promise resolved from AeatClient::send()->wait() and holds the fully parsed SOAP response from the AEAT VERI*FACTU web service. It exposes the global submission status, an optional CSV verification code, mandatory throttle timing, and a per-record status array so you can handle partial acceptance and errors programmatically.

AeatResponse properties

csv
?string
The CSV (Código Seguro de Verificación) code assigned by AEAT to this submission (<CSV>). Only present when the submission is not globally rejected — null when status is ResponseStatus::Incorrect.
submittedAt
?DateTimeImmutable
The server-side timestamp recorded by AEAT at the moment of acceptance (<DatosPresentacion/TimestampPresentacion>). Parsed from ISO 8601. null when the submission is rejected before being registered.
waitSeconds
int
The number of seconds your system information system (SIF) must wait before making the next send() call (<TiempoEsperaEnvio>). Subject to NotBlank and Positive constraints — always a positive integer.
status
ResponseStatus
The global status of the entire submission batch (<EstadoEnvio>). Subject to NotBlank. See ResponseStatus below for possible values.
items
ResponseItem[]
Array of per-record status objects, one for each <RespuestaLinea> element in the response. Subject to Valid. See ResponseItem properties below.

ResponseStatus enum

ResponseStatus (josemmo\Verifactu\Models\Responses\ResponseStatus) describes the overall outcome of a submission batch.
CaseValueDescription
CorrectCorrectoAll records in the submission were accepted without errors.
PartiallyCorrectParcialmenteCorrectoAt least one record has status Incorrect or AcceptedWithErrors; others may have been accepted.
IncorrectIncorrectoEvery record in the submission was rejected.

ResponseItem properties

Each element of AeatResponse::$items is a ResponseItem (josemmo\Verifactu\Models\Responses\ResponseItem) instance describing the fate of a single submitted record.
invoiceId
InvoiceIdentifier
The invoice identifier (<IDFactura>) that this line item refers to, populated from the <IDEmisorFactura>, <NumSerieFactura>, and <FechaExpedicionFactura> sub-elements of <RespuestaLinea/IDFactura>. Subject to NotBlank and Valid.
recordType
RecordType
Whether the record was a registration (Alta) or cancellation (Anulacion) (<Operacion/TipoOperacion>). Subject to NotBlank.
CaseValue
RegistrationAlta
CancellationAnulacion
isCorrection
bool
true when the record was flagged as a correction/resubmission (<Operacion/Subsanacion> = S). Defaults to false.
status
ItemStatus
The per-record acceptance status (<EstadoRegistro>). Subject to NotBlank. See ItemStatus enum below.
errorCode
?string
The AEAT numeric or alphanumeric error code (<CodigoErrorRegistro>), present only when status is Incorrect or AcceptedWithErrors. null for fully correct records.
errorDescription
?string
A human-readable description of the error in Spanish (<DescripcionErrorRegistro>). null when errorCode is null.

ItemStatus enum

ItemStatus (josemmo\Verifactu\Models\Responses\ItemStatus) describes the outcome for a single record.
CaseValueDescription
CorrectCorrectoRecord accepted without errors and registered in the AEAT system.
AcceptedWithErrorsAceptadoConErroresRecord accepted but contains non-fatal errors. Inspect errorCode / errorDescription.
IncorrectIncorrectoRecord rejected. Must be corrected and resubmitted.

Static methods

AeatResponse::from(UXML $xml): self
static
Parses the raw SOAP XML response and returns a populated AeatResponse instance. Called internally by the AeatClient — you typically do not need to call this directly.Throws josemmo\Verifactu\Exceptions\AeatException if:
  • The response contains a SOAP <Fault> element
  • The <RespuestaRegFactuSistemaFacturacion> root element is absent
  • Any date field cannot be parsed as ISO 8601
After parsing, validate() is called automatically to enforce NotBlank / Positive constraints.

Code example

use josemmo\Verifactu\Exceptions\AeatException;
use josemmo\Verifactu\Models\Responses\ItemStatus;
use josemmo\Verifactu\Models\Responses\ResponseStatus;

try {
    /** @var \josemmo\Verifactu\Models\Responses\AeatResponse $response */
    $response = $client->send($records)->wait();
} catch (AeatException $e) {
    // SOAP fault or unparseable response — see AeatException docs
    echo 'AEAT server error: ' . $e->getMessage();
    exit(1);
}

// Respect the throttle window before the next send()
echo "Wait {$response->waitSeconds}s before next submission\n";

// Check the global outcome
match ($response->status) {
    ResponseStatus::Correct          => print("All records accepted. CSV: {$response->csv}\n"),
    ResponseStatus::PartiallyCorrect => print("Partial acceptance. CSV: {$response->csv}\n"),
    ResponseStatus::Incorrect        => print("Submission rejected entirely.\n"),
};

// Inspect individual record outcomes
foreach ($response->items as $item) {
    $invoiceRef = $item->invoiceId->invoiceNumber;

    match ($item->status) {
        ItemStatus::Correct => printf(
            "[OK]      %s accepted\n",
            $invoiceRef
        ),
        ItemStatus::AcceptedWithErrors => printf(
            "[WARN]    %s accepted with errors — %s: %s\n",
            $invoiceRef,
            $item->errorCode,
            $item->errorDescription
        ),
        ItemStatus::Incorrect => printf(
            "[ERROR]   %s rejected — %s: %s\n",
            $invoiceRef,
            $item->errorCode,
            $item->errorDescription
        ),
    };
}

Build docs developers (and LLMs) love