← Back to panelCase file · ST-03
Lab fees paid once, reports found fast

E-LAB

RoleApp, payments, mobile API · team product
PeriodOct 2024 – now
Stack size10 parts
double charges since the fix

A materials-testing lab system for public works. I took over the Flutter app engineers, contractors and AROs use, added payments to it, built the payment service and rewrote the mobile API behind it.

What was broken

Contractors pay lab fees per test and wait for signed reports. Payments were retried by hand, so the same invoice could be charged twice, and reports were scattered across separate PDFs.

What I built

  1. 01Flutter app: invoice list, in-app checkout, receipts, and an invoice and collection calendar.
  2. 02A payment service on the bank's gateway: orders, webhooks, status checks and a duplicate guard.
  3. 03A reconciliation job, locked so only one copy runs, that records a payment only when it's charged for the exact amount.
  4. 04A rewrite of the mobile API: JWT plus API key, rate limits, two departments.
  5. 05Receipts and registers in Jasper, plus merging test reports that were signed elsewhere into one PDF.
roles: engineer, contractor, ARO
endpoints (36 app + 16 payment)
tests in the mobile API

How data moves

SCHEMATIC · E-LAB● SIGNAL
E-LAB appengineer · contractor · AROMobile APIJWT · rate limitPostgreSQLper departmentPayment serviceduplicate guardBank gatewaycard · UPIReconcilerevery 12 h · lockedReportsJasper + signed PDFs

What broke, and how it holds now

INCIDENTST-03 · what broke

One invoice, two charges.

Every payment attempt created a fresh gateway order, so a contractor who retried after a slow page could pay the same invoice twice. Now the service checks the invoice before creating an order. Already charged: it refuses. Pending: it asks the gateway, syncs the result and expires stale orders. Only then does it issue a new order.

Replay · break it yourself
Lab fee · one invoice · bank gateway (simulated)● DUPLICATE GUARD ON
Invoice₹4,250
Gateway orders0
Charged₹0
payment log · pay a fee to start

Nothing here touches a real gateway. Before the fix, every tap made a fresh order. Now the invoice is checked first, and the gateway is asked about any order still pending. A reconciliation job, locked to one copy, records a payment only when it's charged for the exact amount.

What people see

Stack

  • Flutter
  • Java 21
  • Spring Boot
  • PostgreSQL
  • Redis
  • Bucket4j
  • ShedLock
  • JasperReports
  • PDFBox
  • Docker
Next case file · ST-04Society Seva →One app for a housing society