Income invoices
The Income invoice, also known simply as an invoice, is a document used to record an income of money in exchange for the delivery of goods or a service. It details the conditions of the exchange, such as the payment method, and whether the payment is received at that time or agreed to be collected later.
The most common case is to issue an invoice for a sale, and send it by email to your customer, or make it available for download.
If at the time of receiving a payment your customer does not ask for an invoice, you can create a Digital Receipt that you can send to the customer to complete their information on a self-service portal.
Examples
Below are some common use cases.
To fully understand all the options available when creating an invoice, detailed descriptions of each field and the most commonly used catalogs, consult the Create Invoice method reference.
Paid invoices (default)
In this example, the payment is received at the same time as the goods or service is delivered.
- Node.js
- C#
- PHP
- cURL
const Facturapi = require('facturapi');
const facturapi = new Facturapi('sk_test_API_KEY');
const invoice = await facturapi.invoices.create({
customer: {
legal_name: 'Dunder Mifflin',
email: 'email@example.com',
tax_id: 'ABC101010111',
tax_system: '601',
address: {
zip: '85900'
}
},
items: [{
quantity: 2,
product: {
description: 'Ukelele',
product_key: '60131324', // Product key from SAT's catalog
price: 345.60,
taxes: [
{
type: 'IVA',
rate: 0.16
}
]
}
}],
use: 'G01',
payment_form: "28" // key for "Debit card"
});
var facturapi = new FacturapiClient("sk_test_API_KEY");
var invoice = await facturapi.Invoice.CreateAsync(new Dictionary<string, object>
{
["customer"] = new Dictionary<string, object>
{
["legal_name"] = "Dunder Mifflin",
["email"] = "email@example.com",
["tax_id"] = "ABC101010111",
["tax_system"] = "601",
["address"] = new Dictionary<string, object>
{
["zip"] = "85900"
}
},
["items"] = new Dictionary<string, object>[]
{
new Dictionary<string, object>
{
["quantity"] = 2,
["product"] = new Dictionary<string, object>
{
["description"] = "Ukelele",
["product_key"] = "60131324", // Product key from SAT's catalog
["price"] = 345.60,
["taxes"] = new Dictionary<string, object>[]
{
new Dictionary<string, object>
{
["type"] = "IVA",
["rate"] = 0.16
}
}
}
["product"] = new Dictionary<string, object>
{
["description"] = "Ukelele",
["product_key"] = "60131324", // Product key from SAT's catalog
["price"] = 345.60,
["taxes"] = new Dictionary<string, object>[]
{
new Dictionary<string, object>
{
["type"] = "IVA",
["rate"] = 0.16
}
}
}
}
},
["use"] = "G01",
["payment_form"] = "28" // key for "Debit card"
});
$facturapi = new Facturapi( "sk_test_API_KEY" );
$invoice = $facturapi->Invoices->create([
"customer" => [
"legal_name" => "Dunder Mifflin",
"email" => "email@example.com",
"tax_id" => "ABC101010111",
"tax_system" => "601",
"address" => [
"zip" => "85900"
]
],
"items" => [
[
"quantity" => 2,
"product" => [
"description" => "Ukelele",
"product_key" => "60131324", // Product key from SAT's catalog
"price" => 345.60,
"taxes" => [
[
"type" => "IVA",
"rate" => 0.16,
]
]
]
],
],
"payment_form" => "28" // key for "Debit card"
]);
curl https://www.facturapi.io/v2/invoices \
-H "Authorization: Bearer sk_test_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"customer": {
"legal_name": "Dunder Mifflin",
"email": "email@example.com",
"tax_id": "ABC101010111",
"tax_system": "601",
"address": {
"zip": "85900"
}
},
"items": [{
"quantity": 2,
"product": {
"description": "Ukelele",
"product_key": "60131324", // Product key from SAT's catalog
"price": 345.60,
"taxes": [
{
"type": "IVA",
"rate": 0.16
}
]
}
}],
"use": "G01",
"payment_form": "28" // key for "Debit card"
}'
Non-paid invoices
In this example, the goods or service are delivered, but payment is not received yet.
Later, when you receive a payment, either for the full amount or a partial payment, you must issue a Payment invoice.
- Node.js
- C#
- PHP
- cURL
const Facturapi = require('facturapi');
const facturapi = new Facturapi('sk_test_API_KEY');
const invoice = await facturapi.invoices.create({
customer: {
legal_name: 'Dunder Mifflin',
email: 'email@example.com',
tax_id: 'ABC101010111',
tax_system: '601',
address: {
zip: '85900'
}
},
items: [{
quantity: 2,
product: {
description: 'Ukelele',
product_key: '60131324', // Product key from SAT's catalog
price: 345.60,
taxes: [
{
type: 'IVA',
rate: 0.16
}
]
}
}],
use: 'G01',
payment_form: "99", // key for "To be defined" from SAT's catalog
payment_method: 'PPD', // key for "Payment in installments or deferred" from SAT's catalog
conditions: 'Fecha límite de pago: 2022-01-01' // Free text specifying the payment conditions such as the due date
});
var facturapi = new FacturapiClient("sk_test_API_KEY");
var invoice = await facturapi.Invoice.CreateAsync(new Dictionary<string, object>
{
["customer"] = new Dictionary<string, object>
{
["legal_name"] = "Dunder Mifflin",
["email"] = "email@example.com",
["tax_id"] = "ABC101010111",
["tax_system"] = "601",
["address"] = new Dictionary<string, object>
{
["zip"] = "85900"
}
},
["items"] = new Dictionary<string, object>[]
{
new Dictionary<string, object>
{
["quantity"] = 2,
["product"] = new Dictionary<string, object>
{
["description"] = "Ukelele",
["product_key"] = "60131324", // Product key from SAT's catalog
["price"] = 345.60,
["taxes"] = new Dictionary<string, object>[]
{
new Dictionary<string, object>
{
["type"] = "IVA",
["rate"] = 0.16
}
}
}
}
},
["use"] = "G01",
["payment_form"] = "99", // key for "To be defined" from SAT's catalog"
["payment_method"] = "PPD", // key for "Payment in installments or deferred" from SAT's catalog
["conditions"] = "Fecha límite de pago: 2022-01-01" // Free text specifying the payment conditions such as the due date
});
$facturapi = new Facturapi( "sk_test_API_KEY" );
$invoice = $facturapi->Invoices->create([
"customer" => [
"legal_name" => "Dunder Mifflin",
"email" => "email@example.com",
"tax_id" => "ABC101010111",
"tax_system" => "601",
"address" => [
"zip" => "85900"
]
],
"items" => [
[
"quantity" => 2,
"product" => [
"description" => "Ukelele",
"product_key" => "60131324",
"price" => 345.60,
"taxes" => [
[
"type" => "IVA",
"rate" => 0.16,
]
]
]
],
],
"payment_form" => "99", // key for "To be defined" from SAT's catalog"
"payment_method" => "PPD", // key for "Payment in installments or deferred" from SAT's catalog
"conditions" => "Fecha límite de pago: 2022-01-01" // Free text specifying the payment conditions such as the due date
]);
curl https://www.facturapi.io/v2/invoices \
-H "Authorization: Bearer sk_test_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"customer": {
"legal_name": "Dunder Mifflin",
"email": "email@example.com",
"tax_id": "ABC101010111",
"tax_system": "601",
"address": {
"zip": "85900"
}
},
"items": [{
"quantity": 2,
"product": {
"description": "Ukelele",
"product_key": "60131324",
"price": 345.60,
"taxes": [
{
"type": "IVA",
"rate": 0.16
}
]
}
}],
"use": "G01",
"payment_form": "99", // key for "To be defined" from SAT's catalog"
"payment_method": "PPD", // key for "Payment in installments or deferred" from SAT's catalog
"conditions": "Fecha límite de pago: 2022-01-01" // Free text specifying the payment conditions such as the due date
}'