# Payments Gateway Service A simple HTTP payments gateway. Add it as a new module to the existing multi-module Maven project. ## Tech Stack - Java 25, Spring Boot 3.5, Maven (use ./mvnw) - Spring Web for REST endpoints - Jakarta Validation for request validation - JUnit 5 + Spring Boot Test for testing ## Module Setup (Pre-configured) The module skeleton is already set up for you: - `payments-gateway` is registered in the root `pom.xml` - `payments-gateway/pom.xml` exists with all required dependencies - `payments-gateway/src/main/resources/application.yml` is configured - `payments-gateway/src/main/java/com/teya/payments/Application.java` exists **Do NOT modify any pom.xml, application.yml, or Application.java.** You only need to create Java source and test files for your assigned layer. ## Package Base com.teya.payments ## Endpoints - POST /payments — Create a payment (body: { amount, currency, merchantId, cardNumber }) - GET /payments/{id} — Get payment by ID - GET /merchants/{merchantId}/payments — List payments for a merchant ## Domain - PaymentId: record wrapping UUID — use this instead of raw UUID throughout - PaymentStatus: PENDING, APPROVED, DECLINED (enum) - Payment record: id (PaymentId), amount, currency, merchantId, maskedCard, status, createdAt - CreatePaymentRequest: amount, currency, merchantId, cardNumber (with Jakarta validation annotations) ## Validation - amount: positive number (@Positive) - currency: one of EUR, GBP, USD - cardNumber: 16 digits (store only last 4 as maskedCard) - merchantId: non-empty string (@NotBlank) ## Behavior - New payments start as PENDING, then randomly approve (80%) or decline (20%) - In-memory storage (ConcurrentHashMap, no real database) ## Build Phases The model layer (model/ types + repository interface) will be built first and merged into main. API and database layers should import and use model types and the PaymentRepository interface exactly as-is — do not recreate or modify them. The database layer implements the repository interface with `InMemoryPaymentRepository` (ConcurrentHashMap-backed, annotated with @Repository). ## Project Structure All source code goes under `payments-gateway/`: src/main/java/com/teya/payments/ model/ — Payment.java, PaymentId.java, PaymentStatus.java, CreatePaymentRequest.java repository/ — PaymentRepository.java (interface), InMemoryPaymentRepository.java (implementation) controller/ — PaymentController.java Application.java (pre-configured — do not modify) src/main/resources/ application.yml — server.port: 3000 src/test/java/com/teya/payments/ model/ — PaymentTest.java, PaymentIdTest.java, CreatePaymentRequestTest.java repository/ — InMemoryPaymentRepositoryTest.java controller/ — PaymentControllerTest.java (@WebMvcTest) ## Build & Test - Compile: ./mvnw compile -pl payments-gateway -am - Test: ./mvnw test -pl payments-gateway -am - Run: ./mvnw spring-boot:run -pl payments-gateway