clearance-core is a specialized financial middleware service responsible for the Clearing phase of the payment lifecycle. It aggregates authorized transactions, calculates network fees, and prepares batches for final settlement.
- Automated Clearing Worker: A scheduled engine that captures
AUTHORIZEDpayments. - Fee Engine: Calculates bank/network fees (default 1.5%) per transaction.
- Batch Management: Groups individual payments into a
ClearingBatchfor auditability. - Persistence: Built with Spring Data JPA and H2 (In-memory) for rapid processing.
- CI/CD Ready: Includes Docker and GitHub Actions configurations.
This project is part of a split-core architecture:
- Clearance Core: (This service) Handles Bank Network capture and fee deduction.
- Settlement Core: Handles merchant payouts and net fund movement.
- Java 17 (Eclipse Temurin)
- Spring Boot 3.2.0
- Spring Data JPA
- H2 Database (Development/Testing)
- Maven (Build Tool)
- JDK 17 or higher
- Maven 3.8+
To compile the project and run the integration tests:
mvn clean install
mvn spring-boot:runIf Docker is available in your deployment environment:
docker build -t clearance-core .
docker run -p 8083:8083 clearance-coreThe ClearingWorker is configured to run automatically every 60 seconds (see SchedulingConfig). It looks for any records in the payments table with the status AUTHORIZED and transitions them to CLEARED.
-
Start the application on port 8083.
-
Access the H2 Console and insert payments with status AUTHORIZED.
-
Observe the ClearingWorker logs: 3.1. Starting clearing process for X payments. 3.2. Batch 1 [USD] completed successfully.
-
Query the clearing_batches table to see the aggregated totals and 1.5% fee deduction.
For clearance-core as a standalone module: Yes.