定制 strappberry/facturama-laravel 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

strappberry/facturama-laravel

Composer 安装命令:

composer require strappberry/facturama-laravel

包简介

Wrapper del SDK de Facturama para Laravel

README 文档

README

Configuración

Variables que puede ajustar en el archivo de entorno .env

VARIABLE Default Descripción
FACTURAMA_SANDBOX true Indica si se encuentra en entorno de desarrollo. Valores admitidos: true, false
FACTURAMA_PRODUCTION_ENDPOINT https://api.facturama.mx Url de la api de producción de facturama
FACTURAMA_SANDBOX_ENDPOINT https://apisandbox.facturama.mx Url de la api de pruebas de facturama
FACTURAMA_USERNAME pruebas Usuario de pruebas de facturama ver documentació del entorno de pruebas de facturana
FACTURAMA_PASSWORD pruebas2011 Contraseña del usuario de pruebas de facturama

Publicar archivo de configuración

php artisan vendor:publish --tag="facturama-laravel"

Referencia api

https://apisandbox.facturama.mx

#Introducción

// Instancia Laravel Facturama
$api = new \Strappberry\FacturamaLaravel\Classes\ApiFacturama();
// Obtener instancia de api web
$apiWeb = $api->web();
// Obtener instancia de api multiemisor
$apiMultiemisor = $api->multiemisor();

Api Web

Emitir factura

// Ejemplo tomado de la documenctación de la api de facturama
$datosAFacturar = [
  "Serie" => "R",
  "Currency" => "MXN",
  "ExpeditionPlace" => "78116",
  "PaymentConditions" => "CREDITO A SIETE DIAS",
  "Folio" => "100",
  "CfdiType" => "I",
  "PaymentForm" => "03",
  "PaymentMethod" => "PUE",
  "Receiver" => [
    "Rfc" => "XAXX010101000",
    "Name" => "Público en general",
    "CfdiUse" => "P01",
  ],
  "Items" => [
    [
      "ProductCode" => "10101504",
      "IdentificationNumber" => "EDL",
      "Description" => "Estudios de viabilidad",
      "Unit" => "NO APLICA",
      "UnitCode" => "MTS",
      "UnitPrice" => 50.0,
      "Quantity" => 2.0,
      "Subtotal" => 100.0,
      "Taxes" => [
        [
          "Total" => 16.0,
          "Name" => "IVA",
          "Base" => 100.0,
          "Rate" => 0.16,
          "IsRetention" => false,
        ],
      ],
      "Total" => 116.0,
    ],
    [
      "ProductCode" => "10101504",
      "IdentificationNumber" => "001",
      "Description" => "SERVICIO DE COLOCACION",
      "Unit" => "NO APLICA",
      "UnitCode" => "E49",
      "UnitPrice" => 100.0,
      "Quantity" => 15.0,
      "Subtotal" => 1500.0,
      "Discount" => 0.0,
      "Taxes" => [
        [
          "Total" => 240.0,
          "Name" => "IVA",
          "Base" => 1500.0,
          "Rate" => 0.16,
          "IsRetention" => false,
        ],
      ],
      "Total" => 1740.0,
    ],
  ],
];

// Solicitamos la generación de la factura y el timbrado
$resultado = $apiWeb->emitirCfdi($datosAFacturar)

Api Multiemisor

Subir archivos CSD

use Strappberry\FacturamaLaravel\Classes\CertificadoSelloDigital;

// Crear objeto con los datos del Certificado de Sello Digital
$csd = new CertificadoSelloDigital();
$csd->agregarRFC('RFC del CSD');
$csd->agregarCertificado(
    base64_encode(file_get_contents("/ruta/a/archivo.key"))
);
$csd->agregarLlavePrivada(
    base64_encode(file_get_contents("/ruta/a/archivo.key"))
);
$csd->agregarPasswordDeLlavePrivada('contraseña del csd');

$apiMultiemisor->agregarNuevoCertificado($csd);

Actualizar archivos CSD

use Strappberry\FacturamaLaravel\Classes\CertificadoSelloDigital;

// Crear objeto con los datos del Certificado de Sello Digital
$csd = new CertificadoSelloDigital();
$csd->agregarRFC('RFC del CSD');
$csd->agregarCertificado(
    base64_encode(file_get_contents("/ruta/a/archivo.key"))
);
$csd->agregarLlavePrivada(
    base64_encode(file_get_contents("/ruta/a/archivo.key"))
);
$csd->agregarPasswordDeLlavePrivada('contraseña del csd');

$apiMultiemisor->actualizarCertificado($csd);

Emitir factura

// Ejemplo tomado de la documenctación de la api de facturama
// Es importante agregar la clave Issuer
$datosAFacturar = [
  "Serie" => "R",
  "Currency" => "MXN",
  "ExpeditionPlace" => "78116",
  "PaymentConditions" => "CREDITO A SIETE DIAS",
  "Folio" => "100",
  "CfdiType" => "I",
  "PaymentForm" => "03",
  "PaymentMethod" => "PUE",
  "Issuer"=> [
        "FiscalRegime"=> "601",
        "Rfc"=> "RFC con el que desea timbrar",
        "Name"=> "Nombre del emisor"
  ],
  "Receiver" => [
    "Rfc" => "XAXX010101000",
    "Name" => "Público en general",
    "CfdiUse" => "P01",
  ],
  "Items" => [
    [
      "ProductCode" => "10101504",
      "IdentificationNumber" => "EDL",
      "Description" => "Estudios de viabilidad",
      "Unit" => "NO APLICA",
      "UnitCode" => "MTS",
      "UnitPrice" => 50.0,
      "Quantity" => 2.0,
      "Subtotal" => 100.0,
      "Taxes" => [
        [
          "Total" => 16.0,
          "Name" => "IVA",
          "Base" => 100.0,
          "Rate" => 0.16,
          "IsRetention" => false,
        ],
      ],
      "Total" => 116.0,
    ],
    [
      "ProductCode" => "10101504",
      "IdentificationNumber" => "001",
      "Description" => "SERVICIO DE COLOCACION",
      "Unit" => "NO APLICA",
      "UnitCode" => "E49",
      "UnitPrice" => 100.0,
      "Quantity" => 15.0,
      "Subtotal" => 1500.0,
      "Discount" => 0.0,
      "Taxes" => [
        [
          "Total" => 240.0,
          "Name" => "IVA",
          "Base" => 1500.0,
          "Rate" => 0.16,
          "IsRetention" => false,
        ],
      ],
      "Total" => 1740.0,
    ],
  ],
];

// Solicitamos la generación de la factura y el timbrado
$resultado = $apiMultiemisor->emitirCfdi($datosAFacturar)

Consultar datos de una factura

//Multiemisor
$api->multiemisor()->consultarCfdi($id, $tipo);

Consultar acuse cancelación

$id = '9DLXTRINxFpHGLGEDWu23g2';
$tipo='issuedLite';
$formato = 'pdf';

$api->web()->acuse($formato, $tipo, $id);

Consultar vigencia cfdi

  $api->web()->consultarEstadoCfdi(
    'cac0cb22-8406-4812-898a-6f6aec7c85b2',
    'EKU9003173C9',
    'CACX7605101P8',
    '1160.00'
  );

Credits

Desarrollador por Strappberry

统计信息

  • 总下载量: 274
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 2
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-08-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固