Gestión de Pagos
Gestión de Pagos
Section titled “Gestión de Pagos”Dominio: https://test-api-factura.edw-dev.com
Dominio: https://api-financiero.e-dinky.com
La API de facturación proporciona endpoints completos para la gestión de pagos, incluyendo consulta, creación, actualización y eliminación de registros de pago.
Endpoints Disponibles
Section titled “Endpoints Disponibles”Listar Todos los Pagos
Section titled “Listar Todos los Pagos”GET /api/v1/payments
Retorna una lista paginada de todos los pagos registrados en el sistema.
Headers Requeridos
Section titled “Headers Requeridos”Authorization: Bearer {token}Accept: application/json
Parámetros de Consulta Opcionales
Section titled “Parámetros de Consulta Opcionales”Parámetro | Tipo | Descripción |
---|---|---|
page | integer | Número de página (por defecto: 1) |
per_page | integer | Elementos por página (por defecto: 15, máximo: 100) |
filters | string | Filtros avanzados en formato JSON |
Ejemplos de Implementación
Section titled “Ejemplos de Implementación”curl -X GET "https://dev-facturacion.e-dinky.test/api/v1/payments?page=1&per_page=20" \ -H "Authorization: Bearer your_token_here" \ -H "Accept: application/json"
use Illuminate\Support\Facades\Http;
class PaymentController extends Controller{ public function getAllPayments(Request $request) { $page = $request->get('page', 1); $perPage = $request->get('per_page', 20); $filters = $request->get('filters');
$queryParams = [ 'page' => $page, 'per_page' => $perPage ];
if ($filters) { $queryParams['filters'] = $filters; }
$response = Http::withHeaders([ 'Authorization' => 'Bearer ' . $this->getToken(), 'Accept' => 'application/json' ])->get('https://dev-facturacion.e-dinky.test/api/v1/payments', $queryParams);
if ($response->successful()) { return $response->json(); }
return response()->json(['error' => 'Error al consultar pagos'], 400); }}
const axios = require('axios');
async function getAllPayments(page = 1, perPage = 20, filters = null, token) { try { const params = { page: page, per_page: perPage };
if (filters) { params.filters = filters; }
const response = await axios.get( 'https://dev-facturacion.e-dinky.test/api/v1/payments', { params: params, headers: { 'Authorization': `Bearer ${token}`, 'Accept': 'application/json' } } );
return response.data; } catch (error) { console.error('Error al consultar pagos:', error.response?.data); throw error; }}
Respuesta Exitosa (200)
Section titled “Respuesta Exitosa (200)”{ "message": "Pagos", "status": "OK", "payload": { "items": [ { "id": 724442659, "document_id": 2062421972, "client_id": 1768824762, "parent_type": "invoice", "date": "2025-01-23", "amount": "24.00", "transaction_id": null, "method": "SIN UTILIZACIÓN DEL SISTEMA FINANCIERO", "code": "01", "time": null, "term": null, "created_at": "2025-01-23 10:05:37", "created_by": 1768824762, "client": { "id": 61247344, "name": "Final", "lastname": "Consumidor", "full_name": "Consumidor Final", "identification_type": null, "identification_number": "9999999999", "address": null, "phone": null, "website": null, "is_business": false }, "user": { "uuid": 61247344, "name": "User", "last_name": "Updated", "phone": null, "status": "active", "its_me": true, "is_protected": true }, "methodUsaged": { "code": "01", "title": "SIN UTILIZACIÓN DEL SISTEMA FINANCIERO", "short_name": "Efectivo" } } ], "pagination": { "current_page": 1, "per_page": 15, "total": 100, "last_page": 7, "from": 1, "to": 15 } }}
Obtener Pago por Documento
Section titled “Obtener Pago por Documento”GET /api/v1/payments/:id/by-doc
Retorna los pagos asociados a un documento específico.
Headers Requeridos
Section titled “Headers Requeridos”Authorization: Bearer {token}Accept: application/json
Parámetros de Ruta
Section titled “Parámetros de Ruta”Parámetro | Tipo | Descripción |
---|---|---|
id | integer | ID del documento |
Ejemplos de Implementación
Section titled “Ejemplos de Implementación”curl -X GET "https://dev-facturacion.e-dinky.test/api/v1/payments/123/by-doc" \ -H "Authorization: Bearer your_token_here" \ -H "Accept: application/json"
use Illuminate\Support\Facades\Http;
class PaymentController extends Controller{ public function getPaymentsByDocument($documentId) { $response = Http::withHeaders([ 'Authorization' => 'Bearer ' . $this->getToken(), 'Accept' => 'application/json' ])->get("https://dev-facturacion.e-dinky.test/api/v1/payments/{$documentId}/by-doc");
if ($response->successful()) { return $response->json(); }
return response()->json(['error' => 'Error al consultar pagos del documento'], 400); }}
const axios = require('axios');
async function getPaymentsByDocument(documentId, token) { try { const response = await axios.get( `https://dev-facturacion.e-dinky.test/api/v1/payments/${documentId}/by-doc`, { headers: { 'Authorization': `Bearer ${token}`, 'Accept': 'application/json' } } );
return response.data; } catch (error) { console.error('Error al consultar pagos del documento:', error.response?.data); throw error; }}
Pagos Agrupados
Section titled “Pagos Agrupados”GET /api/v1/payments/grouped
Retorna los pagos agrupados por criterios específicos.
Headers Requeridos
Section titled “Headers Requeridos”Authorization: Bearer {token}Accept: application/json
Ejemplos de Implementación
Section titled “Ejemplos de Implementación”curl -X GET "https://dev-facturacion.e-dinky.test/api/v1/payments/grouped" \ -H "Authorization: Bearer your_token_here" \ -H "Accept: application/json"
use Illuminate\Support\Facades\Http;
class PaymentController extends Controller{ public function getGroupedPayments() { $response = Http::withHeaders([ 'Authorization' => 'Bearer ' . $this->getToken(), 'Accept' => 'application/json' ])->get('https://dev-facturacion.e-dinky.test/api/v1/payments/grouped');
if ($response->successful()) { return $response->json(); }
return response()->json(['error' => 'Error al consultar pagos agrupados'], 400); }}
const axios = require('axios');
async function getGroupedPayments(token) { try { const response = await axios.get( 'https://dev-facturacion.e-dinky.test/api/v1/payments/grouped', { headers: { 'Authorization': `Bearer ${token}`, 'Accept': 'application/json' } } );
return response.data; } catch (error) { console.error('Error al consultar pagos agrupados:', error.response?.data); throw error; }}
Fechas de Pagos
Section titled “Fechas de Pagos”GET /api/v1/payments/dates
Retorna información sobre las fechas de los pagos.
Headers Requeridos
Section titled “Headers Requeridos”Authorization: Bearer {token}Accept: application/json
Ejemplos de Implementación
Section titled “Ejemplos de Implementación”curl -X GET "https://dev-facturacion.e-dinky.test/api/v1/payments/dates" \ -H "Authorization: Bearer your_token_here" \ -H "Accept: application/json"
use Illuminate\Support\Facades\Http;
class PaymentController extends Controller{ public function getPaymentDates() { $response = Http::withHeaders([ 'Authorization' => 'Bearer ' . $this->getToken(), 'Accept' => 'application/json' ])->get('https://dev-facturacion.e-dinky.test/api/v1/payments/dates');
if ($response->successful()) { return $response->json(); }
return response()->json(['error' => 'Error al consultar fechas de pagos'], 400); }}
const axios = require('axios');
async function getPaymentDates(token) { try { const response = await axios.get( 'https://dev-facturacion.e-dinky.test/api/v1/payments/dates', { headers: { 'Authorization': `Bearer ${token}`, 'Accept': 'application/json' } } );
return response.data; } catch (error) { console.error('Error al consultar fechas de pagos:', error.response?.data); throw error; }}
Obtener Pago Específico
Section titled “Obtener Pago Específico”GET /api/v1/payments/:id
Retorna los detalles de un pago específico.
Headers Requeridos
Section titled “Headers Requeridos”Authorization: Bearer {token}Accept: application/json
Parámetros de Ruta
Section titled “Parámetros de Ruta”Parámetro | Tipo | Descripción |
---|---|---|
id | integer | ID del pago |
Ejemplos de Implementación
Section titled “Ejemplos de Implementación”curl -X GET "https://dev-facturacion.e-dinky.test/api/v1/payments/123" \ -H "Authorization: Bearer your_token_here" \ -H "Accept: application/json"
use Illuminate\Support\Facades\Http;
class PaymentController extends Controller{ public function getPayment($paymentId) { $response = Http::withHeaders([ 'Authorization' => 'Bearer ' . $this->getToken(), 'Accept' => 'application/json' ])->get("https://dev-facturacion.e-dinky.test/api/v1/payments/{$paymentId}");
if ($response->successful()) { return $response->json(); }
return response()->json(['error' => 'Error al consultar el pago'], 400); }}
const axios = require('axios');
async function getPayment(paymentId, token) { try { const response = await axios.get( `https://dev-facturacion.e-dinky.test/api/v1/payments/${paymentId}`, { headers: { 'Authorization': `Bearer ${token}`, 'Accept': 'application/json' } } );
return response.data; } catch (error) { console.error('Error al consultar el pago:', error.response?.data); throw error; }}
Crear Pago
Section titled “Crear Pago”POST /api/v1/payments/create
Crea un nuevo registro de pago.
Headers Requeridos
Section titled “Headers Requeridos”Authorization: Bearer {token}Accept: application/jsonContent-Type: application/json
Cuerpo de la Solicitud
Section titled “Cuerpo de la Solicitud”{ "document_id": 123, "client_id": 456, "amount": "100.00", "date": "2025-01-25", "method": "01", "transaction_id": "TXN123456", "term": 30}
Campos del Cuerpo
Section titled “Campos del Cuerpo”Campo | Tipo | Requerido | Descripción |
---|---|---|---|
document_id | integer | Sí | ID del documento asociado |
client_id | integer | Sí | ID del cliente |
amount | string | Sí | Monto del pago |
date | string | Sí | Fecha del pago (YYYY-MM-DD) |
method | string | Sí | Código del método de pago |
transaction_id | string | No | ID de la transacción |
term | integer | No | Plazo en días |
Ejemplos de Implementación
Section titled “Ejemplos de Implementación”curl -X POST "https://dev-facturacion.e-dinky.test/api/v1/payments/create" \ -H "Authorization: Bearer your_token_here" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -d '{ "document_id": 123, "client_id": 456, "amount": "100.00", "date": "2025-01-25", "method": "01" }'
use Illuminate\Support\Facades\Http;
class PaymentController extends Controller{ public function createPayment(Request $request) { $paymentData = [ 'document_id' => $request->document_id, 'client_id' => $request->client_id, 'amount' => $request->amount, 'date' => $request->date, 'method' => $request->method, 'transaction_id' => $request->transaction_id, 'term' => $request->term ];
$response = Http::withHeaders([ 'Authorization' => 'Bearer ' . $this->getToken(), 'Accept' => 'application/json', 'Content-Type' => 'application/json' ])->post('https://dev-facturacion.e-dinky.test/api/v1/payments/create', $paymentData);
if ($response->successful()) { return $response->json(); }
return response()->json(['error' => 'Error al crear el pago'], 400); }}
const axios = require('axios');
async function createPayment(paymentData, token) { try { const response = await axios.post( 'https://dev-facturacion.e-dinky.test/api/v1/payments/create', { document_id: paymentData.document_id, client_id: paymentData.client_id, amount: paymentData.amount, date: paymentData.date, method: paymentData.method, transaction_id: paymentData.transaction_id, term: paymentData.term }, { headers: { 'Authorization': `Bearer ${token}`, 'Accept': 'application/json', 'Content-Type': 'application/json' } } );
return response.data; } catch (error) { console.error('Error al crear el pago:', error.response?.data); throw error; }}
Creación Masiva de Pagos
Section titled “Creación Masiva de Pagos”POST /api/v1/payments/mass-create
Crea múltiples pagos en una sola operación.
Headers Requeridos
Section titled “Headers Requeridos”Authorization: Bearer {token}Accept: application/jsonContent-Type: application/json
Cuerpo de la Solicitud
Section titled “Cuerpo de la Solicitud”{ "payments": [ { "document_id": 123, "client_id": 456, "amount": "100.00", "date": "2025-01-25", "method": "01" }, { "document_id": 124, "client_id": 457, "amount": "200.00", "date": "2025-01-25", "method": "02" } ]}
Ejemplos de Implementación
Section titled “Ejemplos de Implementación”curl -X POST "https://dev-facturacion.e-dinky.test/api/v1/payments/mass-create" \ -H "Authorization: Bearer your_token_here" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -d '{ "payments": [ { "document_id": 123, "client_id": 456, "amount": "100.00", "date": "2025-01-25", "method": "01" } ] }'
use Illuminate\Support\Facades\Http;
class PaymentController extends Controller{ public function massCreatePayments(Request $request) { $paymentsData = [ 'payments' => $request->payments ];
$response = Http::withHeaders([ 'Authorization' => 'Bearer ' . $this->getToken(), 'Accept' => 'application/json', 'Content-Type' => 'application/json' ])->post('https://dev-facturacion.e-dinky.test/api/v1/payments/mass-create', $paymentsData);
if ($response->successful()) { return $response->json(); }
return response()->json(['error' => 'Error al crear los pagos masivamente'], 400); }}
const axios = require('axios');
async function massCreatePayments(paymentsArray, token) { try { const response = await axios.post( 'https://dev-facturacion.e-dinky.test/api/v1/payments/mass-create', { payments: paymentsArray }, { headers: { 'Authorization': `Bearer ${token}`, 'Accept': 'application/json', 'Content-Type': 'application/json' } } );
return response.data; } catch (error) { console.error('Error al crear los pagos masivamente:', error.response?.data); throw error; }}
Filtros Avanzados
Section titled “Filtros Avanzados”Los pagos soportan el sistema de filtros avanzados de la API. Puedes filtrar por:
Campos Filtrables
Section titled “Campos Filtrables”Campo | Tipo | Descripción |
---|---|---|
id | integer | ID del pago |
document_id | integer | ID del documento |
client_id | integer | ID del cliente |
amount | decimal | Monto del pago |
date | date | Fecha del pago |
method | string | Método de pago |
code | string | Código del método |
created_at | datetime | Fecha de creación |
created_by | integer | ID del usuario creador |
Ejemplo de Filtros
Section titled “Ejemplo de Filtros”curl -X GET "https://dev-facturacion.e-dinky.test/api/v1/payments?filters=[{\"field\":\"date\",\"condition\":\"ge\",\"value\":\"2025-01-01\"},{\"field\":\"amount\",\"condition\":\"gt\",\"value\":\"50.00\"}]" \ -H "Authorization: Bearer your_token_here" \ -H "Accept: application/json"
Métodos de Pago
Section titled “Métodos de Pago”Los códigos de métodos de pago disponibles son:
Código | Descripción | Nombre Corto |
---|---|---|
01 | SIN UTILIZACIÓN DEL SISTEMA FINANCIERO | Efectivo |
02 | COMPENSACIÓN DE DEUDAS | Compensación |
03 | TARJETA DE DÉBITO | Débito |
04 | TARJETA DE CRÉDITO | Crédito |
05 | TRANSFERENCIA BANCARIA | Transferencia |
Códigos de Respuesta
Section titled “Códigos de Respuesta”Código | Descripción |
---|---|
200 | Operación exitosa |
201 | Pago creado exitosamente |
400 | Solicitud inválida |
401 | No autorizado |
404 | Pago no encontrado |
422 | Error de validación |
500 | Error interno del servidor |
Notas Importantes
Section titled “Notas Importantes”- Todos los montos deben enviarse como strings con formato decimal (ej: “100.00”)
- Las fechas deben estar en formato YYYY-MM-DD
- Los pagos están asociados a documentos y clientes específicos
- La creación masiva permite procesar múltiples pagos eficientemente
- Los filtros permiten consultas complejas sobre los datos de pagos