En esta seccion encontrará ejemplos de consumos con varios lenguajes.
const SendInvoice = await fetch('https://api.nextpyme.plus/api/ubl2.1/invoice', {
method: 'post',
credentials: "same-origin",
body: JSON.stringify({
"number": 990000024,
"type_document_id": 1,
"date": "2022-04-21",
"time": "04:08:12",
"resolution_number": "18760000001",
"prefix": "SETP",
"notes": "ESTA ES UNA NOTA DE PRUEBA",
"disable_confirmation_text": true,
"sendmail": true,
"sendmailtome": false,
"send_customer_credentials": false,
"foot_note": "PRUEBA DE TEXTO LIBRE QUE DEBE POSICIONARSE EN EL PIE DE PAGINA DE LA REPRESENTACION GRAFICA DE LA FACTURA ELECTRONICA VALIDACION PREVIA DIAN",
"customer": {
"identification_number": 901249232,
"dv": 0,
"name": "BERCODE SAS",
"phone": "3017882489",
"address": "CLL 4 NRO 33-90",
"email": "soporte@nextpyme.plus",
"merchant_registration": "0000000-00",
"type_document_identification_id": 6,
"type_organization_id": 1,
"type_liability_id": 7,
"municipality_id": 439,
"type_regime_id": 1
},
"payment_form": {
"payment_form_id": 2,
"payment_method_id": 30,
"payment_due_date": "2022-05-21",
"duration_measure": "30"
},
"legal_monetary_totals": {
"line_extension_amount": "840336.134",
"tax_exclusive_amount": "840336.134",
"tax_inclusive_amount": "1000000.00",
"payable_amount": "1000000.00"
},
"tax_totals": [
{
"tax_id": 1,
"tax_amount": "159663.865",
"percent": "19.00",
"taxable_amount": "840336.134"
}
],
"invoice_lines": [
{
"unit_measure_id": 70,
"invoiced_quantity": "1",
"line_extension_amount": "840336.134",
"free_of_charge_indicator": false,
"tax_totals": [
{
"tax_id": 1,
"tax_amount": "159663.865",
"taxable_amount": "840336.134",
"percent": "19.00"
}
],
"description": "COMISION POR SERVICIOS",
"notes": "ESTA ES UNA PRUEBA DE NOTA DE DETALLE DE LINEA.",
"code": "COMISION",
"type_item_identification_id": 4,
"price_amount": "1000000.00",
"base_quantity": "1"
}
]
}),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer 7f67fbba91001812c960d792bab0ea8005d349dc440f0bc60e9100337ab2750d'
}
});
console.log(await SendInvoice.json())
$eFact = '{
"number": 990000025,
"type_document_id": 1,
"date": "2023-05-23",
"time": "09:00:44",
"resolution_number": "18760000001",
"prefix": "SETP",
"notes": "",
"sendmail": true,
"sendmailtome": true,
"send_customer_credentials": false,
"head_note": "",
"foot_note": "",
"customer": {
"identification_number": 901249232,
"dv": 0,
"name": "BERCODE SAS",
"phone": "3017882489",
"address": "CR 19 6 50 P 2",
"email": "soporte@gmail.com",
"merchant_registration": "0000000-00",
"type_document_identification_id": 8,
"type_organization_id": 1,
"type_liability_id": 14,
"municipality_id": "149",
"type_regime_id": 1
},
"payment_form": {
"payment_form_id": "1",
"payment_method_id": "1",
"payment_due_date": "2023-05-23",
"duration_measure": 45
},
"legal_monetary_totals": {
"line_extension_amount": 664270,
"tax_exclusive_amount": 664270,
"tax_inclusive_amount": 774957,
"payable_amount": 736798
},
"invoice_lines": [
{
"unit_measure_id": "70",
"invoiced_quantity": 1,
"line_extension_amount": 490000,
"free_of_charge_indicator": false,
"tax_totals": [
{
"tax_id": "1",
"tax_amount": 93100,
"percent": "19",
"taxable_amount": 490000
}
],
"description": "ALOJAMIENTO",
"notes": "",
"code": "ALOJA",
"type_item_identification_id": 1,
"price_amount": 583100,
"base_quantity": 1
},
{
"unit_measure_id": "70",
"invoiced_quantity": 1,
"line_extension_amount": 141130,
"free_of_charge_indicator": false,
"tax_totals": [
{
"tax_id": "4",
"tax_amount": 11290,
"percent": "8",
"taxable_amount": 141130
}
],
"description": "RESTAURANTE",
"notes": "",
"code": "RESTA",
"type_item_identification_id": 1,
"price_amount": 152420,
"base_quantity": 1
},
{
"unit_measure_id": "70",
"invoiced_quantity": 1,
"line_extension_amount": 25000,
"free_of_charge_indicator": false,
"tax_totals": [
{
"tax_id": "1",
"tax_amount": 4750,
"percent": "19",
"taxable_amount": 25000
}
],
"description": "PISCINA",
"notes": "",
"code": "PISCIM",
"type_item_identification_id": 1,
"price_amount": 29750,
"base_quantity": 1
},
{
"unit_measure_id": "70",
"invoiced_quantity": 1,
"line_extension_amount": 8140,
"free_of_charge_indicator": false,
"tax_totals": [
{
"tax_id": "1",
"tax_amount": 1547,
"percent": "19",
"taxable_amount": 8140
}
],
"description": "PRODUCTO DE PRUEBA",
"notes": "",
"code": "C001",
"type_item_identification_id": 1,
"price_amount": 9687,
"base_quantity": 1
}
]
}';
$invoice = curl_init('https://api.nextpyme.plus/api/ubl2.1/invoice');
curl_setopt($invoice, CURLOPT_RETURNTRANSFER, true);
curl_setopt($invoice, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($invoice, CURLOPT_POSTFIELDS, ($eFact));
curl_setopt($invoice, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Accept: application/json',
"Authorization: Bearer {$token}"
));
curl_setopt($invoice, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($invoice, CURLOPT_SSL_VERIFYPEER, 0);
$response = curl_exec($invoice);
$err = curl_error($invoice);
$response_api = json_decode($response);
if ($err) {
return $err;
} else {
if (property_exists($response_api, 'message') && $response_api->message == "Unauthenticated.") {
return ['message' => 'Token invalido', 'success' => false];
}
try {
return $response_api;
} catch (\Throwable $th) {
return response()->json("Error al emitiir el documeto {$th->getMessage()}");
}
}
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n \"number\": 990000001,\r\n \"type_document_id\": 1,\r\n \"date\": \"2023-04-04\",\r\n \"time\": \"04:08:12\",\r\n \"resolution_number\": \"18760000001\",\r\n \"prefix\": \"SETP\",\r\n \"notes\": \"ESTA ES UNA NOTA DE PRUEBA\", \r\n \"sendmail\": false,\r\n \"sendmailtome\": false,\r\n \"head_note\": \"PRUEBA DE TEXTO LIBRE QUE DEBE POSICIONARSE EN EL ENCABEZADO DE PAGINA DE LA REPRESENTACION GRAFICA DE LA FACTURA ELECTRONICA VALIDACION PREVIA DIAN\",\r\n \"foot_note\": \"PRUEBA DE TEXTO LIBRE QUE DEBE POSICIONARSE EN EL PIE DE PAGINA DE LA REPRESENTACION GRAFICA DE LA FACTURA ELECTRONICA VALIDACION PREVIA DIAN\", \r\n \"customer\": {\r\n \"identification_number\": 901249232,\r\n \"dv\": 0,\r\n \"name\": \"BERCODE SAS\",\r\n \"phone\": \"3017882489\",\r\n \"address\": \"CLL 18A 11 20\",\r\n \"email\": \"soporte@nextpyme.plus\",\r\n \"merchant_registration\": \"0000000-00\",\r\n \"type_document_identification_id\": 3,\r\n \"type_organization_id\": 1,\r\n \"type_liability_id\": 117,\r\n \"municipality_id\": 439,\r\n \"type_regime_id\": 1\r\n },\r\n \r\n \"payment_form\": {\r\n \"payment_form_id\": 2,\r\n \"payment_method_id\": 30,\r\n \"payment_due_date\": \"2023-04-04\",\r\n \"duration_measure\": \"30\"\r\n },\r\n \"allowance_charges\": [\r\n {\r\n \"discount_id\": 1,\r\n \"charge_indicator\": false,\r\n \"allowance_charge_reason\": \"DESCUENTO GENERAL\",\r\n \"amount\": \"50000.00\",\r\n \"base_amount\": \"1000000.00\"\r\n }\r\n ],\r\n \"legal_monetary_totals\": {\r\n \"line_extension_amount\": \"840336.134\",\r\n \"tax_exclusive_amount\": \"840336.134\",\r\n \"tax_inclusive_amount\": \"1000000.00\",\r\n \"allowance_total_amount\": \"50000.00\",\r\n \"payable_amount\": \"950000.00\" \r\n },\r\n \"tax_totals\": [\r\n {\r\n \"tax_id\": 1,\r\n \"tax_amount\": \"159663.865\",\r\n \"percent\": \"19\",\r\n \"taxable_amount\": \"840336.134\"\r\n }\r\n ],\r\n \"invoice_lines\": [\r\n {\r\n \"unit_measure_id\": 70,\r\n \"invoiced_quantity\": \"1\",\r\n \"line_extension_amount\": \"840336.134\",\r\n \"free_of_charge_indicator\": false,\r\n \"tax_totals\": [\r\n {\r\n \"tax_id\": 1,\r\n \"tax_amount\": \"159663.865\",\r\n \"taxable_amount\": \"840336.134\",\r\n \"percent\": \"19.00\"\r\n }\r\n ],\r\n \"description\": \"COMISION POR SERVICIOS\",\r\n \"notes\": \"ESTA ES UNA PRUEBA DE NOTA DE DETALLE DE LINEA.\",\r\n \"code\": \"COMISION\",\r\n \"type_item_identification_id\": 4,\r\n \"price_amount\": \"1000000.00\",\r\n \"base_quantity\": \"1\"\r\n }\r\n ]\r\n}");
Request request = new Request.Builder()
.url("https://api.nextpyme.plus/api/ubl2.1/invoice")
.method("POST", body)
.addHeader("Accept", "application/json")
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", "Bearer 7f67fbba91001812c960d792bab0ea8005d349dc440f0bc60e9100337ab2750d")
.build();
Response response = client.newCall(request).execute();
import http.client
import json
conn = http.client.HTTPSConnection("api.nextpyme.plus")
payload = json.dumps({
"number": 990000001,
"type_document_id": 1,
"date": "2023-04-04",
"time": "04:08:12",
"resolution_number": "18760000001",
"prefix": "SETP",
"notes": "ESTA ES UNA NOTA DE PRUEBA",
"sendmail": False,
"sendmailtome": False,
"head_note": "PRUEBA DE TEXTO LIBRE QUE DEBE POSICIONARSE EN EL ENCABEZADO DE PAGINA DE LA REPRESENTACION GRAFICA DE LA FACTURA ELECTRONICA VALIDACION PREVIA DIAN",
"foot_note": "PRUEBA DE TEXTO LIBRE QUE DEBE POSICIONARSE EN EL PIE DE PAGINA DE LA REPRESENTACION GRAFICA DE LA FACTURA ELECTRONICA VALIDACION PREVIA DIAN",
"customer": {
"identification_number": 901249232,
"dv": 0,
"name": "BERCODE SAS",
"phone": "3017882489",
"address": "CLL 18A 11 20",
"email": "soporte@nextpyme.plus",
"merchant_registration": "0000000-00",
"type_document_identification_id": 3,
"type_organization_id": 1,
"type_liability_id": 117,
"municipality_id": 439,
"type_regime_id": 1
},
"payment_form": {
"payment_form_id": 2,
"payment_method_id": 30,
"payment_due_date": "2023-04-04",
"duration_measure": "30"
},
"allowance_charges": [
{
"discount_id": 1,
"charge_indicator": False,
"allowance_charge_reason": "DESCUENTO GENERAL",
"amount": "50000.00",
"base_amount": "1000000.00"
}
],
"legal_monetary_totals": {
"line_extension_amount": "840336.134",
"tax_exclusive_amount": "840336.134",
"tax_inclusive_amount": "1000000.00",
"allowance_total_amount": "50000.00",
"payable_amount": "950000.00"
},
"tax_totals": [
{
"tax_id": 1,
"tax_amount": "159663.865",
"percent": "19",
"taxable_amount": "840336.134"
}
],
"invoice_lines": [
{
"unit_measure_id": 70,
"invoiced_quantity": "1",
"line_extension_amount": "840336.134",
"free_of_charge_indicator": False,
"tax_totals": [
{
"tax_id": 1,
"tax_amount": "159663.865",
"taxable_amount": "840336.134",
"percent": "19.00"
}
],
"description": "COMISION POR SERVICIOS",
"notes": "ESTA ES UNA PRUEBA DE NOTA DE DETALLE DE LINEA.",
"code": "COMISION",
"type_item_identification_id": 4,
"price_amount": "1000000.00",
"base_quantity": "1"
}
]
})
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': 'Bearer 7f67fbba91001812c960d792bab0ea8005d349dc440f0bc60e9100337ab2750d'
}
conn.request("POST", "/api/ubl2.1/invoice", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.nextpyme.plus/api/ubl2.1/invoice");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer 7f67fbba91001812c960d792bab0ea8005d349dc440f0bc60e9100337ab2750d");
var content = new StringContent("{\r\n \"number\": 990000001,\r\n \"type_document_id\": 1,\r\n \"date\": \"2023-04-04\",\r\n \"time\": \"04:08:12\",\r\n \"resolution_number\": \"18760000001\",\r\n \"prefix\": \"SETP\",\r\n \"notes\": \"ESTA ES UNA NOTA DE PRUEBA\", \r\n \"sendmail\": false,\r\n \"sendmailtome\": false,\r\n \"head_note\": \"PRUEBA DE TEXTO LIBRE QUE DEBE POSICIONARSE EN EL ENCABEZADO DE PAGINA DE LA REPRESENTACION GRAFICA DE LA FACTURA ELECTRONICA VALIDACION PREVIA DIAN\",\r\n \"foot_note\": \"PRUEBA DE TEXTO LIBRE QUE DEBE POSICIONARSE EN EL PIE DE PAGINA DE LA REPRESENTACION GRAFICA DE LA FACTURA ELECTRONICA VALIDACION PREVIA DIAN\", \r\n \"customer\": {\r\n \"identification_number\": 901249232,\r\n \"dv\": 0,\r\n \"name\": \"BERCODE SAS\",\r\n \"phone\": \"3017882489\",\r\n \"address\": \"CLL 18A 11 20\",\r\n \"email\": \"soporte@nextpyme.plus\",\r\n \"merchant_registration\": \"0000000-00\",\r\n \"type_document_identification_id\": 3,\r\n \"type_organization_id\": 1,\r\n \"type_liability_id\": 117,\r\n \"municipality_id\": 439,\r\n \"type_regime_id\": 1\r\n },\r\n \r\n \"payment_form\": {\r\n \"payment_form_id\": 2,\r\n \"payment_method_id\": 30,\r\n \"payment_due_date\": \"2023-04-04\",\r\n \"duration_measure\": \"30\"\r\n },\r\n \"allowance_charges\": [\r\n {\r\n \"discount_id\": 1,\r\n \"charge_indicator\": false,\r\n \"allowance_charge_reason\": \"DESCUENTO GENERAL\",\r\n \"amount\": \"50000.00\",\r\n \"base_amount\": \"1000000.00\"\r\n }\r\n ],\r\n \"legal_monetary_totals\": {\r\n \"line_extension_amount\": \"840336.134\",\r\n \"tax_exclusive_amount\": \"840336.134\",\r\n \"tax_inclusive_amount\": \"1000000.00\",\r\n \"allowance_total_amount\": \"50000.00\",\r\n \"payable_amount\": \"950000.00\" \r\n },\r\n \"tax_totals\": [\r\n {\r\n \"tax_id\": 1,\r\n \"tax_amount\": \"159663.865\",\r\n \"percent\": \"19\",\r\n \"taxable_amount\": \"840336.134\"\r\n }\r\n ],\r\n \"invoice_lines\": [\r\n {\r\n \"unit_measure_id\": 70,\r\n \"invoiced_quantity\": \"1\",\r\n \"line_extension_amount\": \"840336.134\",\r\n \"free_of_charge_indicator\": false,\r\n \"tax_totals\": [\r\n {\r\n \"tax_id\": 1,\r\n \"tax_amount\": \"159663.865\",\r\n \"taxable_amount\": \"840336.134\",\r\n \"percent\": \"19.00\"\r\n }\r\n ],\r\n \"description\": \"COMISION POR SERVICIOS\",\r\n \"notes\": \"ESTA ES UNA PRUEBA DE NOTA DE DETALLE DE LINEA.\",\r\n \"code\": \"COMISION\",\r\n \"type_item_identification_id\": 4,\r\n \"price_amount\": \"1000000.00\",\r\n \"base_quantity\": \"1\"\r\n }\r\n ]\r\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());