curl -X POST https://api.onepay.la/v1/invoices/preview \
-H "Authorization: Bearer $ONEPAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"items": [
{ "description": "Plan Fibra 200 Mbps", "unit_amount": 8990000, "tax": { "rate": 19 } },
{ "description": "Instalación", "unit_amount": 15000000, "tax": { "rate": 0 } }
]
}'
{
"data": {
"items": [
{
"description": "Plan Fibra 200 Mbps",
"quantity": 1,
"unit_amount": 8990000,
"subtotal": 8990000,
"tax_type": "IVA",
"tax_rate": 19,
"tax_amount": 1708100,
"total": 10698100,
"unit_measure": "94"
},
{
"description": "Instalación",
"quantity": 1,
"unit_amount": 15000000,
"subtotal": 15000000,
"tax_type": null,
"tax_rate": 0,
"tax_amount": 0,
"total": 15000000,
"unit_measure": "94"
}
],
"subtotal": 23990000,
"tax_amount": 1708100,
"total": 25698100
}
}
Previsualizar totales
Calcula subtotales, impuestos y total sin crear nada.
POST
/
invoices
/
preview
curl -X POST https://api.onepay.la/v1/invoices/preview \
-H "Authorization: Bearer $ONEPAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"items": [
{ "description": "Plan Fibra 200 Mbps", "unit_amount": 8990000, "tax": { "rate": 19 } },
{ "description": "Instalación", "unit_amount": 15000000, "tax": { "rate": 0 } }
]
}'
{
"data": {
"items": [
{
"description": "Plan Fibra 200 Mbps",
"quantity": 1,
"unit_amount": 8990000,
"subtotal": 8990000,
"tax_type": "IVA",
"tax_rate": 19,
"tax_amount": 1708100,
"total": 10698100,
"unit_measure": "94"
},
{
"description": "Instalación",
"quantity": 1,
"unit_amount": 15000000,
"subtotal": 15000000,
"tax_type": null,
"tax_rate": 0,
"tax_amount": 0,
"total": 15000000,
"unit_measure": "94"
}
],
"subtotal": 23990000,
"tax_amount": 1708100,
"total": 25698100
}
}
Úsalo para mostrar el detalle en tu interfaz antes de emitir. No crea la factura ni consume un consecutivo.
Es el mismo cálculo que hace la creación real. Si replicas la matemática de impuestos en tu lado, tu total y el nuestro van a diferir en algún redondeo — y esa diferencia solo aparece cuando la DIAN rechaza el documento.
Body
array
required
Mismas líneas que en crear factura. Mínimo 1, máximo 200.
curl -X POST https://api.onepay.la/v1/invoices/preview \
-H "Authorization: Bearer $ONEPAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"items": [
{ "description": "Plan Fibra 200 Mbps", "unit_amount": 8990000, "tax": { "rate": 19 } },
{ "description": "Instalación", "unit_amount": 15000000, "tax": { "rate": 0 } }
]
}'
{
"data": {
"items": [
{
"description": "Plan Fibra 200 Mbps",
"quantity": 1,
"unit_amount": 8990000,
"subtotal": 8990000,
"tax_type": "IVA",
"tax_rate": 19,
"tax_amount": 1708100,
"total": 10698100,
"unit_measure": "94"
},
{
"description": "Instalación",
"quantity": 1,
"unit_amount": 15000000,
"subtotal": 15000000,
"tax_type": null,
"tax_rate": 0,
"tax_amount": 0,
"total": 15000000,
"unit_measure": "94"
}
],
"subtotal": 23990000,
"tax_amount": 1708100,
"total": 25698100
}
}
Was this page helpful?
⌘I