01Separate intent from attempts
A merchant payment can have several traceable attempts, but an unresolved attempt prevents blind rerouting.
Trade-off: Lower apparent availability during uncertainty; operational reconciliation is required.
Payments / Independent study
A timeout is not a failed payment.
Separating payment intent from provider attempts, so retries and late confirmations don't create a second charge.
Scope
Independent Java / Spring Boot / PostgreSQL service, architecture proposal and TypeScript browser model. Local fictional payments; no employer code or live payment provider.
Architecture stack: Java · Spring Boot · PostgreSQL · AWS SQS
Executable model: TypeScript
Runnable independent demonstration
Java 21, Spring Boot and PostgreSQL implement intent creation, a stable provider attempt, transactional outbox and confirmation inbox. A deterministic stub accepts the fictional payment and loses its response; a later demo confirmation resolves the uncertainty.
cd projects/payment-orchestration/java
docker compose up --build -d
# Java 21 + Maven + Docker: run PostgreSQL integration tests
mvn -B verify Source, curl walkthrough and test instructions This service is separate from the TypeScript model below and from employer production work. The public site does not host the Java backend. Authentication, signature verification, automatic reconciliation and real provider adapters remain outside this local slice.
A checkout request crosses a boundary the application cannot control. If a provider times out after accepting it, blindly retrying through another provider can turn a network problem into a duplicate charge.
Give the payment intent one owner. Persist the merchant-scoped idempotency key and request fingerprint before starting a provider attempt. Treat an ambiguous response as awaiting confirmation, then use a verified webhook or reconciliation result to resolve it.
Architecture
01
Authenticate merchant; validate amount and key.
02
Own intent, attempt history and legal transitions.
03
Translate requests; classify definite vs ambiguous failures.
PostgreSQL: payment intent + request fingerprint + attempt + outbox record. Unique merchant/key constraint. Never hold a database transaction open across a provider call.
Outbox relay → SQS → attempt worker. Verified webhooks enter an inbox; reconciliation resolves missing confirmations. Each consumer deduplicates independently.
Logical boundaries, not a deployed topology. The interactive model below covers state transitions only.
Exercise the failure path
Submit a simulated CAD 75.00 payment, retry the request, then deliver its provider confirmation twice.
key: checkout-001 / event: evt-001 / currency: CAD
Ready. Submit the payment to simulate a provider timeout.
Model limits: Single payment, in-memory TypeScript model. The webhook is assumed verified. No provider calls, persistence, concurrency or signature verification.
API design
Illustrative request and response. This contract specifies one command, not the entire proposed API.
POST /v1/payments
Idempotency-Key: command_demo
{
"amountMinor": 7500,
"currency": "CAD",
"providerToken": "tok_demo"
}Response
202 Accepted
Location: /v1/payments/pay_demo
{ "id": "pay_demo", "status": "awaiting_confirmation" }Technical decisions
A merchant payment can have several traceable attempts, but an unresolved attempt prevents blind rerouting.
Trade-off: Lower apparent availability during uncertainty; operational reconciliation is required.
Reuse a provider key for the same attempt, only where the provider guarantees that behaviour. Store the relationship locally.
Trade-off: Providers have different key retention and retry contracts. An abstraction cannot erase those differences.
Keep domain, adapter and webhook modules explicit inside one Spring Boot service before introducing more deployable services.
Trade-off: Less independent scaling initially, but simpler transaction boundaries and incident investigation.
Operating the system
Alert on age of awaiting-confirmation payments, not just HTTP error rates. Route unresolved items to a reconciliation queue with evidence.
Bound retries for definitively retryable failures. Dead-letter exhaustion for review. Never replay a financial operation without checking its current state.
Verify provider signatures and replay windows before inbox insertion. Redact tokens and sensitive payloads; retain correlation IDs and audit metadata.
Outcome & limits
The TypeScript model illustrates request identity and confirmation deduplication. The independent Java slice exercises those boundaries against real PostgreSQL, including concurrent requests and a simulated crash after stub acceptance. Neither is a production reliability claim.
View study sourceNext steps
Start a conversation
I'm interested in senior backend and Tech Lead roles across fintech, payments, SaaS and platform engineering in Canada.