Obtener pago por id
GET/payment
Recupera un solo pago (factura) por ID, limitado a su organización. Solo lectura.
Ejemplos de código
Node.js
const fetch = require('node-fetch');
async function llamarApi() {
const claveApi = 'YOUR_API_KEY';
const id = 'su-id';
const queryString = new URLSearchParams({
id: id
}).toString();
const url = `https://account.lunahealth.app/api/payment` + (queryString ? `?${queryString}` : '');
try {
const response = await fetch(url, {
method: 'GET',
headers: {
'Authorization': `Bearer ${claveApi}`,
'Content-Type': 'application/json'
}
});
if (!response.ok) {
throw new Error(`API error: ${response.status}`);
}
const data = await response.json();
console.log(data);
return data;
} catch (error) {
console.error('Error al llamar a la API:', error);
throw error;
}
}
llamarApi();
Python
import requests
def llamarApi():
claveApi = 'YOUR_API_KEY'
url = 'https://account.lunahealth.app/api/payment'
headers = {
'Authorization': f'Bearer {claveApi}',
'Content-Type': 'application/json'
}
params = {
'id': 'su-id'
}
try:
response = requests.get(
url,
headers=headers,
params=params
)
response.raise_for_status()
data = response.json()
print(data)
return data
except requests.exceptions.RequestException as e:
print(f'Error al llamar a la API: {e}')
raise
llamarApi()
Parámetros
| Nombre | Ubicación | Tipo | Requerido | Descripción |
|---|
id | query | string | Sí | Identificador único |
Respuestas
| Estado | Descripción |
|---|
200 | Respuesta exitosa |
400 | Datos de entrada no válidos |
401 | Autorización no proporcionada |
403 | Acceso insuficiente |
404 | No encontrado |
500 | Error interno del servidor |
200 — Respuesta exitosa
Campos de la respuesta
| Nombre | Tipo | Requerido | Descripción |
|---|
id | string | Sí | — |
invoice_number | string | Sí | — |
status | string | Sí | — |
currency | string | null | Sí | — |
total_amount | number | Sí | — |
subtotal_amount | number | Sí | — |
tax_amount | number | Sí | — |
paid_amount | number | null | Sí | — |
balance | number | Sí | — |
payment_method | string | null | Sí | — |
payment_date | string | null | Sí | — |
due_date | string | Sí | — |
created_at | string | Sí | — |
updated_at | string | Sí | — |
patient | object | null | Sí | — |
Ejemplo de respuesta
{
"id": "string",
"invoice_number": "string",
"status": "PAID",
"currency": "string",
"total_amount": 0,
"subtotal_amount": 0,
"tax_amount": 0,
"paid_amount": 0,
"balance": 0,
"payment_method": "CARD",
"payment_date": "string",
"due_date": "string",
"created_at": "string",
"updated_at": "string",
"patient": {
"id": "string",
"first_name": "string",
"last_name": "string",
"email": "string"
}
}
400 — Datos de entrada no válidos
Campos de la respuesta
| Nombre | Tipo | Requerido | Descripción |
|---|
message | string | Sí | The error message |
code | string | Sí | The error code |
issues | array<object> | No | An array of issues that were responsible for the error |
Ejemplo de respuesta
{
"code": "BAD_REQUEST",
"message": "Invalid input data",
"issues": []
}
401 — Autorización no proporcionada
Campos de la respuesta
| Nombre | Tipo | Requerido | Descripción |
|---|
message | string | Sí | The error message |
code | string | Sí | The error code |
issues | array<object> | No | An array of issues that were responsible for the error |
Ejemplo de respuesta
{
"code": "UNAUTHORIZED",
"message": "Authorization not provided",
"issues": []
}
403 — Acceso insuficiente
Campos de la respuesta
| Nombre | Tipo | Requerido | Descripción |
|---|
message | string | Sí | The error message |
code | string | Sí | The error code |
issues | array<object> | No | An array of issues that were responsible for the error |
Ejemplo de respuesta
{
"code": "FORBIDDEN",
"message": "Insufficient access",
"issues": []
}
404 — No encontrado
Campos de la respuesta
| Nombre | Tipo | Requerido | Descripción |
|---|
message | string | Sí | The error message |
code | string | Sí | The error code |
issues | array<object> | No | An array of issues that were responsible for the error |
Ejemplo de respuesta
{
"code": "NOT_FOUND",
"message": "Not found",
"issues": []
}
500 — Error interno del servidor
Campos de la respuesta
| Nombre | Tipo | Requerido | Descripción |
|---|
message | string | Sí | The error message |
code | string | Sí | The error code |
issues | array<object> | No | An array of issues that were responsible for the error |
Ejemplo de respuesta
{
"code": "INTERNAL_SERVER_ERROR",
"message": "Internal server error",
"issues": []
}
Abrir en la referencia interactiva →