Context
Services that work with self-employed contractors need to register income and issue invoices programmatically through the «Moy Nalog» API. No ready-made Java client existed — every team wrote its own, duplicating authentication, token refresh, and error handling.
Solution
A library with two integration options: a Spring Boot Starter with auto-configuration (two lines in application.properties) and a standalone mode without Spring. Internally it provides login/password authentication with automatic retry, background token refresh (ReadWriteLock), sync/async receipt submission, invoice issuance with bank details, proxy support (HTTP/HTTPS, with or without authentication), and a configurable timeout.
Stack and architecture
- Runtime: Java 17.
- Network layer: HTTP client with built-in retry.
- Concurrency:
ReadWriteLockon token refresh. - Auto-config: Spring Boot Starter.
- Configuration: via Spring properties or the client constructor.
Role and outcome
We built the library out of a real need: a single entry point for all Federal Tax Service operations, safe multithreaded use, and two lines of configuration to get connected. It has been used in several services in production.