Payments
Gestión de Pagos
Los endpoints de pagos permiten administrar las transacciones, métodos de pago y monedas del sistema.
Pagos Principales
-
GET /payments: Obtiene todos los pagos del sistema.- Authorization: Requiere
payments_read - cURL Example:
curl -X GET "http://127.0.0.1:9154/payments" \-H "Cookie: accessToken=$ACCESS_TOKEN" \-H "Cookie: refreshToken=$REFRESH_TOKEN"- Response Body (Éxito - 200 OK):
[{"id": "payment-uuid-1","method_id": "method-uuid-1","currency_id": "currency-uuid-1","transaction_id": "txn-123456","amount": 45.50},{"id": "payment-uuid-2","method_id": "method-uuid-2","currency_id": "currency-uuid-1","transaction_id": "txn-789012","amount": 32.80}]- Response Body (Sin contenido - 204 No Content):
"No payments found" - Authorization: Requiere
-
GET /payments/{id}: Obtiene un pago específico por su ID.- Authorization: Requiere
payments_read - Path Parameters:
id(string): ID del pago a obtener
- cURL Example:
curl -X GET "http://127.0.0.1:9154/payments/payment-uuid-1" \-H "Cookie: accessToken=$ACCESS_TOKEN" \-H "Cookie: refreshToken=$REFRESH_TOKEN"- Response Body (Éxito - 200 OK):
{"id": "payment-uuid-1","method_id": "method-uuid-1","currency_id": "currency-uuid-1","transaction_id": "txn-123456","amount": 45.50} - Authorization: Requiere
-
POST /payments: Crea un nuevo pago.- Authorization: Requiere
payments_create - Request Body:
{"method_id": "string","currency_id": "string","transaction_id": "string","amount": 0.0}- cURL Example:
curl -X POST "http://127.0.0.1:9154/payments" \-H "Cookie: accessToken=$ACCESS_TOKEN" \-H "Cookie: refreshToken=$REFRESH_TOKEN" \-H "Content-Type: application/json" \-d '{"method_id": "method-uuid-1","currency_id": "currency-uuid-1","transaction_id": "txn-345678","amount": 78.90}'- Response Body (Éxito - 201 Created):
{"id": "generated-uuid","message": "Payment added successfully"} - Authorization: Requiere
-
PUT /payments/{id}: Actualiza un pago existente.- Authorization: Requiere
payments_update - Path Parameters:
id(string): ID del pago a actualizar
- Request Body:
{"method_id": "string","currency_id": "string","transaction_id": "string","amount": 0.0}- Response Body (Éxito - 200 OK):
"Payment updated successfully" - Authorization: Requiere
-
DELETE /payments/{id}: Elimina un pago del sistema.- Authorization: Requiere
payments_delete - Path Parameters:
id(string): ID del pago a eliminar
- Response (Éxito - 204 No Content): sin cuerpo
- Authorization: Requiere
Métodos de Pago
-
GET /payments/methods: Obtiene todos los métodos de pago disponibles.- Authorization: Requiere
payments_read - cURL Example:
curl -X GET "http://127.0.0.1:9154/payments/methods" \-H "Cookie: accessToken=$ACCESS_TOKEN" \-H "Cookie: refreshToken=$REFRESH_TOKEN"- Response Body (Éxito - 200 OK):
[{"id": "method-uuid-1","name": "Efectivo"},{"id": "method-uuid-2","name": "Tarjeta de Crédito"},{"id": "method-uuid-3","name": "Bitcoin Lightning"}]- Response Body (Sin contenido - 204 No Content):
"No payment methods found" - Authorization: Requiere
-
GET /payments/methods/{id}: Obtiene un método de pago específico.- Authorization: Requiere
payments_read - Path Parameters:
id(string): ID del método de pago
- Response Body (Éxito - 200 OK):
{"id": "method-uuid-1","name": "Efectivo"} - Authorization: Requiere
Monedas
-
GET /payments/currencies: Obtiene todas las monedas disponibles.- Authorization: Requiere
payments_read - cURL Example:
curl -X GET "http://127.0.0.1:9154/payments/currencies" \-H "Cookie: accessToken=$ACCESS_TOKEN" \-H "Cookie: refreshToken=$REFRESH_TOKEN"- Response Body (Éxito - 200 OK):
[{"id": "currency-uuid-1","acronym": "EUR"},{"id": "currency-uuid-2","acronym": "USD"},{"id": "currency-uuid-3","acronym": "BTC"}]- Response Body (Sin contenido - 204 No Content):
"No currencies found" - Authorization: Requiere
-
GET /payments/currencies/{id}: Obtiene una moneda específica.- Authorization: Requiere
payments_read - Path Parameters:
id(string): ID de la moneda
- Response Body (Éxito - 200 OK):
{"id": "currency-uuid-1","acronym": "EUR"} - Authorization: Requiere
Relaciones Ticket-Pago
-
POST /payments/ticket-payments: Crea una relación entre un ticket y un pago.- Authorization: Requiere
payments_create - Request Body:
{"payment_id": "string","ticket_id": "string"}- cURL Example:
curl -X POST "http://127.0.0.1:9154/payments/ticket-payments" \-H "Cookie: accessToken=$ACCESS_TOKEN" \-H "Cookie: refreshToken=$REFRESH_TOKEN" \-H "Content-Type: application/json" \-d '{"payment_id": "payment-uuid-1","ticket_id": "ticket-uuid-1"}'- Response Body (Éxito - 201 Created):
{"paymentId": "payment-uuid-1","ticketId": "ticket-uuid-1","message": "Ticket payment relationship created successfully"} - Authorization: Requiere
-
GET /payments/ticket-payments/by-ticket/{ticketId}: Obtiene todos los pagos de un ticket.- Authorization: Requiere
payments_read - Path Parameters:
ticketId(string): ID del ticket
- cURL Example:
curl -X GET "http://127.0.0.1:9154/payments/ticket-payments/by-ticket/ticket-uuid-1" \-H "Cookie: accessToken=$ACCESS_TOKEN" \-H "Cookie: refreshToken=$REFRESH_TOKEN" - Authorization: Requiere
-
GET /payments/ticket-payments/by-payment/{paymentId}: Obtiene todos los tickets de un pago.- Authorization: Requiere
payments_read - Path Parameters:
paymentId(string): ID del pago
- Authorization: Requiere
-
DELETE /payments/ticket-payments?paymentId={id}&ticketId={id}: Elimina una relación ticket-pago específica.- Authorization: Requiere
payments_delete - Query Parameters:
paymentId(string): ID del pagoticketId(string): ID del ticket
- cURL Example:
curl -X DELETE "http://127.0.0.1:9154/payments/ticket-payments?paymentId=payment-uuid-1&ticketId=ticket-uuid-1" \-H "Cookie: accessToken=$ACCESS_TOKEN" \-H "Cookie: refreshToken=$REFRESH_TOKEN"- Response (Éxito - 204 No Content): sin cuerpo
- Authorization: Requiere
-
DELETE /payments/ticket-payments/by-ticket/{ticketId}: Elimina todas las relaciones de pago de un ticket.- Authorization: Requiere
payments_delete - Path Parameters:
ticketId(string): ID del ticket
- Response (Éxito - 204 No Content): sin cuerpo
- Authorization: Requiere
Notas importantes:
- Todos los endpoints de pagos requieren autenticación JWT
- Los IDs son UUID generados automáticamente
- Un pago debe estar asociado a un método de pago válido (
method_id) - Un pago debe estar asociado a una moneda válida (
currency_id) - El
transaction_ides único para cada transacción - Los pagos pueden estar asociados a múltiples tickets (pagos divididos)
- Un ticket puede tener múltiples pagos (pagos mixtos)
- El sistema soporta Bitcoin Lightning Network como método de pago
- Los tokens se envían automáticamente via cookies del navegador