Overview
ThedocumentAuthorization function queries the SRI (Servicio de Rentas Internas) for the authorization status of a previously submitted document. This is the second step in the electronic invoicing process, performed after document reception.
Function Signature
Parameters
The access key (clave de acceso) of the document to check authorization status. This is a unique identifier generated for each electronic document.
The SRI SOAP endpoint URL for authorization queries. Use the testing or production URL depending on your environment.
SRI Endpoints
Testing Environment
Production Environment
Return Value
The response from the SRI’s
autorizacionComprobante SOAP method, containing the authorization status, authorized XML, and authorization details.Usage Example
Implementation Details
The function performs the following steps:- Constructs a SOAP request with the access key as
claveAccesoComprobante - Creates a SOAP client using the provided authorization URL
- Calls the
autorizacionComprobanteSOAP method - Returns the authorization response containing status and details
Authorization States
The SRI can return the following authorization states:- AUTORIZADO: Document successfully authorized
- NO AUTORIZADO: Document rejected
- EN PROCESAMIENTO: Document still being processed (query again later)
Error Handling
The function will reject with an error if:- The SOAP client creation fails
- The
autorizacionComprobantecall fails - Network connectivity issues occur
- The access key is invalid or not found