For six years I never had to build a fee line for UPI. Every card integration I have shipped carries a fee column in its ledger; every UPI one carried a zero, and most teams eventually dropped the column to tidy the schema. If the reporting is accurate, that tidy-up is about to cost somebody a bad month-end.
I will say my position up front. Most merchants will never compute this fee, because their gateway deducts it. The teams that must build real fee logic are PSPs, aggregators and platforms that settle to sub-merchants. Everyone else needs a place to store the fee and a reconciliation check that understands it. I would not build a full engine unless I sit on the settling side of the flow.
The first sections explain the concept; the later ones cover the design and code.…