Overview
The Payment Service (jea-pagos) manages payment methods used throughout the Sistema de Ventas platform. It provides a simple catalog of payment options for sales, purchases, and orders. Database: MySQL (pagos-ms)
Port: Dynamic (configured via Eureka)
Core Entities
FormaPago
Payment method definition. Location:jea-pagos/src/main/java/com/example/jeapagos/entity/FormaPago.java:10
Fields:
id(Long) - Primary keynombre(String) - Payment method name
forma_pago
Examples:
- Efectivo (Cash)
- Tarjeta de Crédito (Credit Card)
- Tarjeta de Débito (Debit Card)
- Transferencia Bancaria (Bank Transfer)
- Cheque (Check)
Key Components
Controllers
FormaPagoController
Location:jea-pagos/src/main/java/com/example/jeapagos/controller/FormaPagoController.java:12
Endpoints:
GET /pagos- List all payment methodsGET /pagos/{id}- Get payment method by IDPOST /pagos- Create new payment methodPUT /pagos/{id}- Update payment methodDELETE /pagos/{id}- Delete payment method
- Simple CRUD operations
- Standard REST conventions
- Exception handling for not found scenarios
Services
FormaPagoService
Location:jea-pagos/src/main/java/com/example/jeapagos/service/FormaPagoService.java
Implementation: FormaPagoServiceImpl.java
Key Methods:
listarFormasPago()- List all payment methodsbuscarPorId()- Find by IDguardar()- Create new payment methodactualizar()- Update existing payment methodeliminar()- Delete payment method
Repositories
FormaPagoRepository
Location:jea-pagos/src/main/java/com/example/jeapagos/repository/FormaPagoRepository.java
Extends JpaRepository<FormaPago, Long>
Provides standard data access operations.
Dependencies
Spring Boot Version: 3.1.3 Spring Cloud Version: 2022.0.2 Key Dependencies:spring-boot-starter-data-jpa- JPA/Hibernatespring-boot-starter-web- REST APIspring-boot-starter-validation- Bean validationspring-cloud-starter-netflix-eureka-client- Service discoveryspring-cloud-starter-config:4.0.4- Centralized configurationspringdoc-openapi-starter-webmvc-ui:2.0.2- OpenAPI/Swagger UImysql-connector-j- MySQL driverlombok- Code generation
Configuration
Config File:config-data/jea-pagos-service.yml
Key Settings:
Database Schema
Main Tables:forma_pago- Payment methods- Primary key:
id - Fields:
nombre
- Primary key:
Key Features
- Simple payment method catalog
- Full CRUD operations
- Referenced by Sales, Purchase, and Order services
- Lightweight microservice
- OpenAPI/Swagger documentation
- Eureka service discovery integration
- Centralized configuration via Config Server
Integration Points
Consumed by:
- Sales Service - References payment methods for sales transactions
- Purchase Service - References payment methods for purchase orders
- Orders Service - References payment methods for customer orders
APIs Exposed:
- Payment method CRUD operations
- Payment method listing
- Payment method lookup by ID
Usage Pattern
Other services reference payment methods by ID:Design Considerations
Why a Separate Service?
- Centralized Management - Single source of truth for payment methods
- Consistency - Same payment options across all transaction types
- Flexibility - Easy to add new payment methods without modifying other services
- Microservice Principles - Each service owns its domain data
Simplicity
This is one of the simplest services in the system:- Single entity (FormaPago)
- No complex business logic
- No external service dependencies
- Straightforward CRUD operations
- Serves as reference data for other services
Future Enhancements
Potential additions:- Payment method categories (online, offline)
- Enable/disable flags
- Processing fees or transaction costs
- Integration with payment gateways
- Payment method icons or images
- Default payment method configuration