factura-com / factura-com-sdk
dev-master
2024-02-23 17:59 UTC
Requires
- php: ^7.4 || ^8.0
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^7.3
- guzzlehttp/psr7: ^1.7 || ^2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.5
- phpunit/phpunit: ^10.3
This package is auto-updated.
Last update: 2024-11-07 19:28:59 UTC
README
Introducción Te invitamos a utilizar la documentación de nuestra API. Es un recurso completo y fácil de entender que te guiará en el uso de nuestras funcionalidades. Si tienes alguna pregunta, nuestro equipo de soporte técnico está disponible para ayudarte. Aprovecha las ventajas de nuestra API para automatizar tus procesos de facturación y agilizar tus operaciones comerciales. ¡Explora nuestra documentación de API y descubre todo lo que Factura.com puede hacer por ti! Atentamente, El equipo de Factura.com --- # Autenticación de API El API de factura.com utiliza autenticación básica la cual requiere los siguientes datos de acceso: - \[API_KEY\] - \[SECRET_KEY\] La autenticación del API requiere incluir en el header los datos de autorización junto a el F-PLUGIN cuyo valor siempre será: 9d4095c8f7ed5785cb14c0e3b033eeb8252416ed Los métodos disponibles en el workspace ya cuentan con un header de ejemplo en donde contienen los datos antes mencionados, en el entorno existen dos variables en donde podemos ingresar nuestras llaves para usarlas de forma mas sencilla estas variables se encuentran en: - Factura.com Workspace Publico → Variables Solo sustituye el texto Tu API key y Tu Secret key por los valores correspondientes # Genera tu API Key Puedes usar el API de factura.com en dos modos, sandbox y producción. El API Key y el Secret Key son diferentes para cada modo. Para obtener tus llaves de acceso deber seguir los siguientes pasos: - Iniciar sesión (Si es en producción en https://factura.com/, si es en sandbox en http://sandbox.factura.com/ ). - En el menú lateral dirígete a Configuraciones - API - Datos de acceso . - Haz clic en el botón que se encuentra junto a cada token de acceso para copiarlo. # Errores Todas las peticiones exitosas regresan un código de estatus HTTP 204. En caso de un error, el API regresa un JSON con los parámetros que contienen la razón del error. La documentación completa y explicación de los métodos la puedes encontrar en nuestra documentación para developers en: Documentación API factura.com # Construcción de la URL A continuación se explica la estructura básica de como están compuestos los siguientes métodos para operaciones de CFDI Host: https://api.factura.com/ (producción) / http://sandbox.factura.com/api/ (sandbox) Endpoint: /v4/cfdi/list Ejemplo: https://api.factura.com/v4/cfdi/list ## Ejemplo: php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, \"http://sandbox.factura.com/api/v4/cfdi/list\"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLOPT_HTTPHEADER, array( \"Content-Type: application/json\", \"F-PLUGIN: \" . '9d4095c8f7ed5785cb14c0e3b033eeb8252416ed', \"F-Api-Key: \".'Ingresa API KEY', \"F-Secret-Key: \" .'Ingresa SECRET KEY' )); $response = curl_exec($ch); return die($response); curl_close($ch); ?>
> <h3 >RECUERDA QUE 👀</h3> > Para probar el código de ejemplo es necesario que reemplaces el texto Ingresa API KEY por el API KEY de tu cuenta, e Ingresa SECRET KEY por el SECRET KEY correspondiente. ## Respuesta: ## Respuesta exitosa jason { \"status\": \"success\", \"response\": \"success\", \"total\": 2479, \"per_page\": 100, \"current_page\": 1, \"last_page\": 25, \"from\": 1, \"to\": 100, \"data\": [ { \"RazonSocialReceptor\": \"Venta Al Público en General\", \"Folio\": \"F 01\", \"UID\": \"5c04c662exxxx\", \"UUID\": \"1750d757-577d-xxxx-xxxx-518b87b24a87\", \"Subtotal\": \"5.000000\", \"Descuento\": null, \"Total\": \"5.800000\", \"ReferenceClient\": 0, \"NumOrder\": null, \"Receptor\": \"XAXX010101000\", \"FechaTimbrado\": \"2018-12-03\", \"Status\": \"enviada\", \"Version\": \"3.3\" }, { \"RazonSocialReceptor\": \"Cliente ejemplo\", \"Folio\": \"F 160\", \"UID\": \"5c033ca2e4xxx\", \"UUID\": \"c25c6c99-xxx-xxx-810e-e5ae7e12eb15\", \"Subtotal\": \"10000.000000\", \"Descuento\": null, \"Total\": \"11600.000000\", \"ReferenceClient\": 15, \"NumOrder\": null, \"Receptor\": \"XAXX010101000\", \"FechaTimbrado\": \"2018-12-01\", \"Status\": \"enviada\", \"Version\": \"3.3\" } ] }
## Respuesta erronea json { \"status\": \"error\", \"message\": \"La cuenta que intenta autenticarse no existe\", \"Data\": \"$2y$10$dnOV7qC7ZrD1CZitpUnTReLKtKPxG29XfwZylrEuiR0KVl18pOXXX\", \"Secret\": \"$2y$10$6ZN4aX5UExwz6HFlDSZcxOF1TGjHx8f40neE.CrXHHahyAfi8qiXXX\" }
# Métodos disponibles:
This PHP package is automatically generated by the Swagger Codegen project:
- API version: 1.0.0
- Build package: io.swagger.codegen.v3.generators.php.PhpClientCodegen
Requirements
PHP 5.5 and later
Installation & Usage
Composer
To install the bindings via Composer, add the following to composer.json
:
{
"repositories": [
{
"type": "git",
"url": "https://github.com/git_user_id/git_repo_id.git"
}
],
"require": {
"git_user_id/git_repo_id": "*@dev"
}
}
Then run composer install
Manual Installation
Download the files and include autoload.php
:
require_once('/path/to/SwaggerClient-php/vendor/autoload.php');
Tests
To run the unit tests:
composer install
./vendor/bin/phpunit
Getting Started
Please follow the installation procedure and then run the following:
<?php require_once(__DIR__ . '/vendor/autoload.php'); // Configure HTTP basic authorization: apikeyAuth $config = FacturaCom\FacturaComSdk\Configuration::getDefaultConfiguration() ->setUsername('YOUR_USERNAME') ->setPassword('YOUR_PASSWORD'); $apiInstance = new FacturaCom\FacturaComSdk\Api\APIV4Api( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $content_type = "content_type_example"; // string | $f_plugin = "f_plugin_example"; // string | $f_api_key = "f_api_key_example"; // string | $f_secret_key = "f_secret_key_example"; // string | try { $apiInstance->apiV4Cfdi4061cf901246a82AcuseGet($content_type, $f_plugin, $f_api_key, $f_secret_key); } catch (Exception $e) { echo 'Exception when calling APIV4Api->apiV4Cfdi4061cf901246a82AcuseGet: ', $e->getMessage(), PHP_EOL; } // Configure HTTP basic authorization: apikeyAuth $config = FacturaCom\FacturaComSdk\Configuration::getDefaultConfiguration() ->setUsername('YOUR_USERNAME') ->setPassword('YOUR_PASSWORD'); $apiInstance = new FacturaCom\FacturaComSdk\Api\APIV4Api( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $content_type = "content_type_example"; // string | $f_plugin = "f_plugin_example"; // string | $f_api_key = "f_api_key_example"; // string | $f_secret_key = "f_secret_key_example"; // string | try { $apiInstance->apiV4Cfdi4061cf901246a82CancelStatusGet($content_type, $f_plugin, $f_api_key, $f_secret_key); } catch (Exception $e) { echo 'Exception when calling APIV4Api->apiV4Cfdi4061cf901246a82CancelStatusGet: ', $e->getMessage(), PHP_EOL; } // Configure HTTP basic authorization: apikeyAuth $config = FacturaCom\FacturaComSdk\Configuration::getDefaultConfiguration() ->setUsername('YOUR_USERNAME') ->setPassword('YOUR_PASSWORD'); $apiInstance = new FacturaCom\FacturaComSdk\Api\APIV4Api( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $body = "body_example"; // string | $content_type = "content_type_example"; // string | $f_plugin = "f_plugin_example"; // string | $f_api_key = "f_api_key_example"; // string | $f_secret_key = "f_secret_key_example"; // string | try { $apiInstance->apiV4Cfdi4061d4c2d768a14CancelPost($body, $content_type, $f_plugin, $f_api_key, $f_secret_key); } catch (Exception $e) { echo 'Exception when calling APIV4Api->apiV4Cfdi4061d4c2d768a14CancelPost: ', $e->getMessage(), PHP_EOL; } // Configure HTTP basic authorization: apikeyAuth $config = FacturaCom\FacturaComSdk\Configuration::getDefaultConfiguration() ->setUsername('YOUR_USERNAME') ->setPassword('YOUR_PASSWORD'); $apiInstance = new FacturaCom\FacturaComSdk\Api\APIV4Api( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $content_type = "content_type_example"; // string | $f_plugin = "f_plugin_example"; // string | $f_api_key = "f_api_key_example"; // string | $f_secret_key = "f_secret_key_example"; // string | try { $apiInstance->apiV4Cfdi4061d4c3fe77dd8EmailGet($content_type, $f_plugin, $f_api_key, $f_secret_key); } catch (Exception $e) { echo 'Exception when calling APIV4Api->apiV4Cfdi4061d4c3fe77dd8EmailGet: ', $e->getMessage(), PHP_EOL; } // Configure HTTP basic authorization: apikeyAuth $config = FacturaCom\FacturaComSdk\Configuration::getDefaultConfiguration() ->setUsername('YOUR_USERNAME') ->setPassword('YOUR_PASSWORD'); $apiInstance = new FacturaCom\FacturaComSdk\Api\APIV4Api( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $content_type = "content_type_example"; // string | $f_plugin = "f_plugin_example"; // string | $f_api_key = "f_api_key_example"; // string | $f_secret_key = "f_secret_key_example"; // string | try { $apiInstance->apiV4Cfdi4061d4c3fe77dd8PdfGet($content_type, $f_plugin, $f_api_key, $f_secret_key); } catch (Exception $e) { echo 'Exception when calling APIV4Api->apiV4Cfdi4061d4c3fe77dd8PdfGet: ', $e->getMessage(), PHP_EOL; } // Configure HTTP basic authorization: apikeyAuth $config = FacturaCom\FacturaComSdk\Configuration::getDefaultConfiguration() ->setUsername('YOUR_USERNAME') ->setPassword('YOUR_PASSWORD'); $apiInstance = new FacturaCom\FacturaComSdk\Api\APIV4Api( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $content_type = "content_type_example"; // string | $f_plugin = "f_plugin_example"; // string | $f_api_key = "f_api_key_example"; // string | $f_secret_key = "f_secret_key_example"; // string | try { $apiInstance->apiV4Cfdi4061d4c3fe77dd8XmlGet($content_type, $f_plugin, $f_api_key, $f_secret_key); } catch (Exception $e) { echo 'Exception when calling APIV4Api->apiV4Cfdi4061d4c3fe77dd8XmlGet: ', $e->getMessage(), PHP_EOL; } // Configure HTTP basic authorization: apikeyAuth $config = FacturaCom\FacturaComSdk\Configuration::getDefaultConfiguration() ->setUsername('YOUR_USERNAME') ->setPassword('YOUR_PASSWORD'); $apiInstance = new FacturaCom\FacturaComSdk\Api\APIV4Api( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $body = "body_example"; // string | $content_type = "content_type_example"; // string | $f_plugin = "f_plugin_example"; // string | $f_api_key = "f_api_key_example"; // string | $f_secret_key = "f_secret_key_example"; // string | try { $apiInstance->apiV4Cfdi4062fbeb2d0fd5fTimbrarborradorPost($body, $content_type, $f_plugin, $f_api_key, $f_secret_key); } catch (Exception $e) { echo 'Exception when calling APIV4Api->apiV4Cfdi4062fbeb2d0fd5fTimbrarborradorPost: ', $e->getMessage(), PHP_EOL; } // Configure HTTP basic authorization: apikeyAuth $config = FacturaCom\FacturaComSdk\Configuration::getDefaultConfiguration() ->setUsername('YOUR_USERNAME') ->setPassword('YOUR_PASSWORD'); $apiInstance = new FacturaCom\FacturaComSdk\Api\APIV4Api( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $body = "body_example"; // string | $content_type = "content_type_example"; // string | $f_plugin = "f_plugin_example"; // string | $f_api_key = "f_api_key_example"; // string | $f_secret_key = "f_secret_key_example"; // string | try { $apiInstance->apiV4Cfdi40Create62fbe97d65eeaPost($body, $content_type, $f_plugin, $f_api_key, $f_secret_key); } catch (Exception $e) { echo 'Exception when calling APIV4Api->apiV4Cfdi40Create62fbe97d65eeaPost: ', $e->getMessage(), PHP_EOL; } // Configure HTTP basic authorization: apikeyAuth $config = FacturaCom\FacturaComSdk\Configuration::getDefaultConfiguration() ->setUsername('YOUR_USERNAME') ->setPassword('YOUR_PASSWORD'); $apiInstance = new FacturaCom\FacturaComSdk\Api\APIV4Api( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $content_type = "content_type_example"; // string | $f_plugin = "f_plugin_example"; // string | $f_api_key = "f_api_key_example"; // string | $f_secret_key = "f_secret_key_example"; // string | try { $apiInstance->apiV4CfdiFolioCop93Get($content_type, $f_plugin, $f_api_key, $f_secret_key); } catch (Exception $e) { echo 'Exception when calling APIV4Api->apiV4CfdiFolioCop93Get: ', $e->getMessage(), PHP_EOL; } // Configure HTTP basic authorization: apikeyAuth $config = FacturaCom\FacturaComSdk\Configuration::getDefaultConfiguration() ->setUsername('YOUR_USERNAME') ->setPassword('YOUR_PASSWORD'); $apiInstance = new FacturaCom\FacturaComSdk\Api\APIV4Api( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $content_type = "content_type_example"; // string | $f_plugin = "f_plugin_example"; // string | $f_api_key = "f_api_key_example"; // string | $f_secret_key = "f_secret_key_example"; // string | try { $apiInstance->apiV4CfdiListGet($content_type, $f_plugin, $f_api_key, $f_secret_key); } catch (Exception $e) { echo 'Exception when calling APIV4Api->apiV4CfdiListGet: ', $e->getMessage(), PHP_EOL; } // Configure HTTP basic authorization: apikeyAuth $config = FacturaCom\FacturaComSdk\Configuration::getDefaultConfiguration() ->setUsername('YOUR_USERNAME') ->setPassword('YOUR_PASSWORD'); $apiInstance = new FacturaCom\FacturaComSdk\Api\APIV4Api( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $content_type = "content_type_example"; // string | $f_plugin = "f_plugin_example"; // string | $f_api_key = "f_api_key_example"; // string | $f_secret_key = "f_secret_key_example"; // string | try { $apiInstance->apiV4CfdiUid632b94a897f8cGet($content_type, $f_plugin, $f_api_key, $f_secret_key); } catch (Exception $e) { echo 'Exception when calling APIV4Api->apiV4CfdiUid632b94a897f8cGet: ', $e->getMessage(), PHP_EOL; } // Configure HTTP basic authorization: apikeyAuth $config = FacturaCom\FacturaComSdk\Configuration::getDefaultConfiguration() ->setUsername('YOUR_USERNAME') ->setPassword('YOUR_PASSWORD'); $apiInstance = new FacturaCom\FacturaComSdk\Api\APIV4Api( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $content_type = "content_type_example"; // string | $f_plugin = "f_plugin_example"; // string | $f_api_key = "f_api_key_example"; // string | $f_secret_key = "f_secret_key_example"; // string | try { $apiInstance->apiV4CfdiUuid1a7cf8f934064024902884266cab1f13Get($content_type, $f_plugin, $f_api_key, $f_secret_key); } catch (Exception $e) { echo 'Exception when calling APIV4Api->apiV4CfdiUuid1a7cf8f934064024902884266cab1f13Get: ', $e->getMessage(), PHP_EOL; } // Configure HTTP basic authorization: apikeyAuth $config = FacturaCom\FacturaComSdk\Configuration::getDefaultConfiguration() ->setUsername('YOUR_USERNAME') ->setPassword('YOUR_PASSWORD'); $apiInstance = new FacturaCom\FacturaComSdk\Api\APIV4Api( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $body = "body_example"; // string | $content_type = "content_type_example"; // string | $f_plugin = "f_plugin_example"; // string | $f_api_key = "f_api_key_example"; // string | $f_secret_key = "f_secret_key_example"; // string | try { $apiInstance->apiV4Drafts6245dde60cc1eDropPost($body, $content_type, $f_plugin, $f_api_key, $f_secret_key); } catch (Exception $e) { echo 'Exception when calling APIV4Api->apiV4Drafts6245dde60cc1eDropPost: ', $e->getMessage(), PHP_EOL; } // Configure HTTP basic authorization: apikeyAuth $config = FacturaCom\FacturaComSdk\Configuration::getDefaultConfiguration() ->setUsername('YOUR_USERNAME') ->setPassword('YOUR_PASSWORD'); $apiInstance = new FacturaCom\FacturaComSdk\Api\APIV4Api( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $content_type = "content_type_example"; // string | $f_plugin = "f_plugin_example"; // string | $f_api_key = "f_api_key_example"; // string | $f_secret_key = "f_secret_key_example"; // string | try { $apiInstance->apiV4Drafts6245dde60cc1eGet($content_type, $f_plugin, $f_api_key, $f_secret_key); } catch (Exception $e) { echo 'Exception when calling APIV4Api->apiV4Drafts6245dde60cc1eGet: ', $e->getMessage(), PHP_EOL; } // Configure HTTP basic authorization: apikeyAuth $config = FacturaCom\FacturaComSdk\Configuration::getDefaultConfiguration() ->setUsername('YOUR_USERNAME') ->setPassword('YOUR_PASSWORD'); $apiInstance = new FacturaCom\FacturaComSdk\Api\APIV4Api( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $content_type = "content_type_example"; // string | $f_plugin = "f_plugin_example"; // string | $f_api_key = "f_api_key_example"; // string | $f_secret_key = "f_secret_key_example"; // string | try { $apiInstance->apiV4DraftsGet($content_type, $f_plugin, $f_api_key, $f_secret_key); } catch (Exception $e) { echo 'Exception when calling APIV4Api->apiV4DraftsGet: ', $e->getMessage(), PHP_EOL; } ?>
Documentation for API Endpoints
All URIs are relative to https://sandbox.factura.com
Documentation For Models
Documentation For Authorization
apikeyAuth
- Type: HTTP basic authentication