factura-com/factura-com-sdk

dev-master 2024-02-23 17:59 UTC

This package is auto-updated.

Last update: 2024-09-05 19:57:40 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

此PHP包是由Swagger Codegen项目自动生成的

  • API版本:1.0.0
  • 构建包:io.swagger.codegen.v3.generators.php.PhpClientCodegen

要求

PHP 5.5及更高版本

安装与使用

Composer

要通过Composer安装绑定,请将以下内容添加到composer.json

{
  "repositories": [
    {
      "type": "git",
      "url": "https://github.com/git_user_id/git_repo_id.git"
    }
  ],
  "require": {
    "git_user_id/git_repo_id": "*@dev"
  }
}

然后运行composer install

手动安装

下载文件并包含autoload.php

    require_once('/path/to/SwaggerClient-php/vendor/autoload.php');

测试

要运行单元测试

composer install
./vendor/bin/phpunit

入门指南

请按照安装过程进行操作,然后运行以下命令

<?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;
}
?>

API端点文档

所有URI相对于https://sandbox.factura.com

模型文档

授权文档

apikeyAuth

  • 类型:HTTP基本认证

作者