Back to projects
Ledger logo

Ledger

Stripe-inspired payment processing engine with idempotency, event ledger, and webhook delivery built with Java + Spring Boot

Accomplishments

  • Built REST APIs for charges, refunds, payment events, and webhook endpoint management.
  • Implemented deterministic card simulation for successful payments, card declines, and insufficient funds.
  • Designed database-backed idempotency with request hashing, replayed responses, conflict detection, and expiration cleanup.
  • Protected mutating operations against duplicate concurrent requests using transactional database locking.
  • Implemented full and partial refunds with safeguards against refunding failed charges or exceeding the original charge amount.
  • Created an immutable append-only payment event ledger for charge and refund state transitions.
  • Implemented signed webhook delivery using HMAC-SHA256 signatures.
  • Added asynchronous webhook dispatching with bounded executor configuration.
  • Implemented persisted webhook delivery states, attempt tracking, failure responses, and exponential retry scheduling.
  • Added scheduled retry processing for failed webhook deliveries with a maximum of eight attempts.
  • Added API key authentication with consistent authentication error responses.
  • Implemented centralized exception handling with a documented JSON error envelope and consistent error codes.
  • Added Flyway-managed PostgreSQL schema migrations for charges, refunds, events, idempotency, endpoints, and deliveries.
  • Configured Hibernate schema validation to prevent accidental automatic database schema creation.
  • Added OpenAPI and Swagger UI documentation with request and response schemas and examples.
  • Built unit tests for domain transitions, services, authentication, idempotency, webhook signing, and retry behavior.
  • Built integration tests with Testcontainers PostgreSQL and MockWebServer.
  • Verified 57 unit tests and 23 integration tests with zero failures.
  • Achieved 94.7% line coverage for service packages and 88.2% for idempotency packages.
  • Added Checkstyle quality gates with zero reported violations.
  • Documented architecture, local setup, API examples, simulation rules, idempotency design, webhook retries, and engineering tradeoffs.

Links

Skills used

Java 21Spring Boot 3.3Spring Data JPAHibernatePostgreSQL 16FlywayREST APIsOpenAPIDocker ComposeMavenJUnit 5MockitoTestcontainersMockWebServerHMAC-SHA256

Status

Completed
Not Live