Eliminar factura
curl --request DELETE \
--url https://api.onepay.la/v1/invoices/{invoice_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"reason": "<string>",
"provider_payment_id": "<string>"
}
'import requests
url = "https://api.onepay.la/v1/invoices/{invoice_id}"
payload = {
"reason": "<string>",
"provider_payment_id": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.delete(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'DELETE',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({reason: '<string>', provider_payment_id: '<string>'})
};
fetch('https://api.onepay.la/v1/invoices/{invoice_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.onepay.la/v1/invoices/{invoice_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_POSTFIELDS => json_encode([
'reason' => '<string>',
'provider_payment_id' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.onepay.la/v1/invoices/{invoice_id}"
payload := strings.NewReader("{\n \"reason\": \"<string>\",\n \"provider_payment_id\": \"<string>\"\n}")
req, _ := http.NewRequest("DELETE", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.delete("https://api.onepay.la/v1/invoices/{invoice_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"reason\": \"<string>\",\n \"provider_payment_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.onepay.la/v1/invoices/{invoice_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"reason\": \"<string>\",\n \"provider_payment_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodyno content
{
"message": "La factura no existe o pertenece a otra compañía.",
"code": 10004,
"code_name": "not_found"
}
{
"message": "No se puede eliminar una factura que ya fue pagada o conciliada.",
"code": 10009,
"code_name": "conflict"
}
Cancela el Payment asociado y elimina la factura.
DELETE
/
invoices
/
{invoice_id}
Eliminar factura
curl --request DELETE \
--url https://api.onepay.la/v1/invoices/{invoice_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"reason": "<string>",
"provider_payment_id": "<string>"
}
'import requests
url = "https://api.onepay.la/v1/invoices/{invoice_id}"
payload = {
"reason": "<string>",
"provider_payment_id": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.delete(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'DELETE',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({reason: '<string>', provider_payment_id: '<string>'})
};
fetch('https://api.onepay.la/v1/invoices/{invoice_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.onepay.la/v1/invoices/{invoice_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_POSTFIELDS => json_encode([
'reason' => '<string>',
'provider_payment_id' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.onepay.la/v1/invoices/{invoice_id}"
payload := strings.NewReader("{\n \"reason\": \"<string>\",\n \"provider_payment_id\": \"<string>\"\n}")
req, _ := http.NewRequest("DELETE", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.delete("https://api.onepay.la/v1/invoices/{invoice_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"reason\": \"<string>\",\n \"provider_payment_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.onepay.la/v1/invoices/{invoice_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"reason\": \"<string>\",\n \"provider_payment_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodyno content
{
"message": "La factura no existe o pertenece a otra compañía.",
"code": 10004,
"code_name": "not_found"
}
{
"message": "No se puede eliminar una factura que ya fue pagada o conciliada.",
"code": 10009,
"code_name": "conflict"
}
Path params
ID de la factura a eliminar. Crear factura.
Body
Motivo de la eliminación. Valores permitidos:
DELETE_FROM_PROVIDER— La factura fue eliminada desde el proveedor. Se notifica al cliente que la factura fue eliminada.PAID_FROM_PROVIDER— La factura fue pagada fuera de OnePay. El pago se cancela silenciosamente sin enviar eventos.
Referencia del pago externo en el proveedor. Solo aplica cuando
reason es PAID_FROM_PROVIDER.Cuando se envía este campo junto con reason=PAID_FROM_PROVIDER, OnePay genera automáticamente un recibo de pago en PDF y lo envía al cliente por WhatsApp, confirmando que su pago fue registrado por la empresa.Este campo es opcional. Si no se envía, la factura se elimina sin enviar ningún recibo al cliente.
Ejemplos de uso
- curl
- JavaScript
- Python
curl https://api.onepay.la/v1/invoices/2f2b1e5a-1a2b-4c33-8a18-5e9f3b9f4b1a \
-X DELETE \
-H "Authorization: Bearer sk_test_xxx" \
-H "Content-Type: application/json" \
-d '{
"reason": "PAID_FROM_PROVIDER",
"provider_payment_id": "EXT-REF-001"
}'
const response = await fetch('https://api.onepay.la/v1/invoices/2f2b1e5a-1a2b-4c33-8a18-5e9f3b9f4b1a', {
method: 'DELETE',
headers: {
'Authorization': 'Bearer sk_test_xxx',
'Content-Type': 'application/json',
},
body: JSON.stringify({
reason: 'PAID_FROM_PROVIDER',
provider_payment_id: 'EXT-REF-001',
}),
});
// 204 No Content
import requests
response = requests.delete(
'https://api.onepay.la/v1/invoices/2f2b1e5a-1a2b-4c33-8a18-5e9f3b9f4b1a',
headers={'Authorization': 'Bearer sk_test_xxx'},
json={
'reason': 'PAID_FROM_PROVIDER',
'provider_payment_id': 'EXT-REF-001',
},
)
# 204 No Content
Response
no content
{
"message": "La factura no existe o pertenece a otra compañía.",
"code": 10004,
"code_name": "not_found"
}
{
"message": "No se puede eliminar una factura que ya fue pagada o conciliada.",
"code": 10009,
"code_name": "conflict"
}
Solo puedes eliminar facturas que pertenezcan a tu compañía y que no estén en estado
PAID o CONCILIATED.Was this page helpful?
⌘I