All Projects → FacturAPI → facturapi-node

FacturAPI / facturapi-node

Licence: other
Crea Facturas Electrónicas válidas en México lo más fácil posible (CFDI)

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to facturapi-node

CfdiUtils
PHP Common utilities for Mexican CFDI 3.2, 3.3 & 4.0
Stars: ✭ 97 (+546.67%)
Mutual labels:  mexico, cfdi
eInvoice4D
Electronic invoice library for Delphi
Stars: ✭ 22 (+46.67%)
Mutual labels:  invoice
konik
A library to create, read and validate ZUGFeRD compliant invoices. Available for Java and .NET
Stars: ✭ 40 (+166.67%)
Mutual labels:  invoice
invoiced
Invoiced Demo app for Rails API and React Foundation
Stars: ✭ 33 (+120%)
Mutual labels:  invoice
veryfi-go
Go module for communicating with the Veryfi OCR API
Stars: ✭ 18 (+20%)
Mutual labels:  invoice
invoice-ninja
Invoice Ninja
Stars: ✭ 12 (-20%)
Mutual labels:  invoice
responsive-html-email-templates
Collection of Free responsive HTML templates for Startups
Stars: ✭ 187 (+1146.67%)
Mutual labels:  invoice
crater-mobile
Crater Invoice Mobile to manage your invoices on the go.
Stars: ✭ 253 (+1586.67%)
Mutual labels:  invoice
covid19-mx-time-series
Time series data of the COVID-19 epidemic in Mexico
Stars: ✭ 36 (+140%)
Mutual labels:  mexico
admin-portal
Invoice Ninja client built with Flutter
Stars: ✭ 1,208 (+7953.33%)
Mutual labels:  invoice
sypht-golang-client
A Golang client for the Sypht API
Stars: ✭ 33 (+120%)
Mutual labels:  invoice
openstamanager
Il software gestionale open source per l'assistenza tecnica e la fatturazione
Stars: ✭ 71 (+373.33%)
Mutual labels:  invoice
billy
An opensource invoicing engine --
Stars: ✭ 28 (+86.67%)
Mutual labels:  invoice
sat-ws-descarga-masiva
Librería para usar el servicio web del SAT de Descarga Masiva
Stars: ✭ 65 (+333.33%)
Mutual labels:  cfdi
chromic pdf
Convenient HTML to PDF/A rendering library for Elixir based on Chrome & Ghostscript
Stars: ✭ 196 (+1206.67%)
Mutual labels:  invoice
mxmaps
An R package for making maps of Mexico
Stars: ✭ 60 (+300%)
Mutual labels:  mexico
PythonMexico
Archivos y código para las comunidades de Python México
Stars: ✭ 19 (+26.67%)
Mutual labels:  mexico
fe-hacienda-cr-docs
Documentación General de la Factura Electrónica del Ministerio de Hacienda
Stars: ✭ 15 (+0%)
Mutual labels:  factura-electronica
constitucion-mexicana
Constitución Política de los Estados Unidos Mexicanos en formato ReST
Stars: ✭ 47 (+213.33%)
Mutual labels:  mexico
rfc-facil-js
Librería para calcular el Registro Federal de Contribuyentes en México (RFC) - Javascript/Typescript
Stars: ✭ 27 (+80%)
Mutual labels:  mexico

FacturAPI

npm version js-semistandard-style

This is the official Node.js wrapper for https://www.facturapi.io

FacturAPI makes it easy for developers to generate valid Invoices in Mexico (known as Factura Electrónica or CFDI).

If you've ever used Stripe or Conekta, you'll find FacturAPI very straightforward to understand and integrate in your server app.

Install

npm install --save facturapi

Getting started

Authenticate with your API Key

Make sure you have created your free account on FacturAPI and that you have your API Keys.

const Facturapi = require('facturapi');
const facturapi = new Facturapi('YOUR_API_KEY', {
  apiVersion: 'v2' // Optional, say what API version you want to use. Defaults to the latest version.
});

Create a customer

facturapi.customers.create({
  legal_name: 'Walter White',     // Razón social
  tax_id: 'WIWA761018',           // RFC
  email: '[email protected]', // Optional but useful to send invoice by email
  address: {
    street: 'Av. de los Rosales',
    exterior: '123',
    neighborhood: 'Tepito',
    zip: '06800',
    // city, municipality and state are filled automatically from the zip code
    // but if you want to, you can override their values
    // city: 'México',
    // municipality: 'Cuauhtémoc',
    // state: 'Ciudad de México'
  }
}).then(customer => {
  // Remember to store the customer.id in your records.
  // You will need it to create an invoice for this customer.
}).catch(err => console.log(err)); // Handle the error.

Create a product

facturapi.products.create({
  product_key: '4319150114',  // Clave Producto/Servicio from SAT's catalog. Log in to FacturAPI and use our tool to look it up.
  description: 'Apple iPhone 8',
  price: 20000, // price in MXN.
  // By default, taxes are calculated from the price with IVA 16%
  // But again, you can override that by explicitly providing a taxes array
  // taxes: [
  //   { type: Facturapi.TaxType.IVA, rate: 0.16 },
  //   { type: Facturapi.TaxType.ISR, rate: 0.03666, withholding: true }
  // ]
}).then(product => {
  // Remember to store the product.id in your records.
  // You will need it to create an invoice for this product.
}).catch(err => console.log(err)); // Handle the error.

Create an invoice

facturapi.invoices.create({
  customer: 'YOUR_CUSTOMER_ID',
  payment_form: Facturapi.PaymentForm.TRANSFERENCIA_ELECTRONICA, // Constant from SAT's catalog. Check out our documentation to learn more.
  items: [{
    quantity: 1, // Optional. Defaults to 1.
    product: 'YOUR_PRODUCT_ID' // You can also pass a product object instead
  }] // Add as many products as you want to include in your invoice
}).then(invoice => { ... });

Download your invoice

// Once you have successfully created your invoice, you can...
const fs = require('fs');
facturapi.invoices.downloadZip(invoice.id) // or downloadPdf or downloadXml
  .then(zipStream => {
    // stream containing the PDF and XML as a ZIP file
    // Save your invoice to a folder
    const myZipFile = fs.createWriteStream('/path/to/destination/folder');
    zipStream.pipe(myZipFile);
    myZipFile.on('finish', () => {
      // Finished downloading, Yay!
    });

Send your invoice by email

// Send the invoice to your customer's email (if any)
facturapi.invoices.sendByEmail(invioce.id) // Also returns a Promise
  .then(() => {
    // Successfully sent
  }).catch(err => console.log(err)); // Handle the error.

Documentation

There's more you can do with this library: List, retrieve, update, and remove Customers, Products and Invoices.

Visit the full documentation at http://docs.facturapi.io.

Help

Found a bug?

Please report it on the Issue Tracker

Want to contribute?

Send us your PR! We appreciate your help :)

Contact us!

[email protected]

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].