Dev.to WebDev ๐Ÿ›  Dev ๐Ÿ‘ 0 ๐Ÿ“– 3 min read

Why My First Seller Fee Calculator Got Bank Payouts Wrong (and How We Fixed It With Tests)

When I started building a lightweight static fee calculator for cross-border sellers and freelancers (FeeClear), I initially thought it was just basic percentage math: multiply the order price by a fee rate, subtract a f

When I started building a lightweight static fee calculator for cross-border sellers and freelancers (FeeClear), I initially thought it was just basic percentage math: multiply the order price by a fee rate, subtract a fixed fee, and call it "net profit."

During testing against real US and UK platform pricing schedules, that naive model broke in three surprisingly common places. Here is what went wrong and how we redesigned the calculation engine to handle it cleanly in zero-dependency vanilla JavaScript.

1. Platform Balance != Bank Payout != Net Order Profit

Most free online fee calculators lump everything into one "Net Profit" box. In real cross-border selling, three different numbers happen at three different stages:

  1. Stage 1 โ€” Balance After Platform Fees (in platform settlement currency): For example, a UK Etsy seller pays a $0.20 USD listing fee (converted to GBP), 6.5% transaction fee, 4.0% + ยฃ0.20 Etsy Payments fee, and a 0.48% UK Regulatory Operating Fee (plus optional 20% VAT on seller fees). If the buyer pays in a different currency from the shop's settlement currency, Stage-1 platform FX (such as Etsy's 2.5% conversion) happens here.
  2. Stage 2 โ€” Estimated Bank Payout (in bank currency): When moving funds from a platform balance to a local bank, sellers often hit withdrawal fees (e.g., batch-amortized bank transfers on Fiverr) plus Stage-2 FX conversion (exchange spread % + fixed wire fee).
  3. Stage 3 โ€” Estimated Order Profit: Only after subtracting separately paid operating costs (COGS, shipping labels, packaging, ad spend) do you get true order profit.

Splitting the output into all three stages made the numbers immediately auditable against real payout statements.

2. Linear Reverse Formulas Break on Caps and Minimum Charge Floors

Many calculators solve "What should I charge to net $100?" using a closed-form linear formula:

Price = (Target + FixedFee) / (1 - Rate)

That formula silently produces wrong answers whenever a platform introduces non-linear constraints:

  • Etsy Offsite Ads cap: 15% or 12% attribution fees are capped at $100 USD per order. Once an order crosses the cap threshold, the marginal fee rate drops.
  • Stripe minimum charge floors: Under US Stripe standard pricing (2.9% + $0.30), the mathematical break-even point at zero cost is $0.31 USD. However, Stripe enforces an official minimum charge of $0.50 USD (and ยฃ0.30 GBP, ยฅ50 JPY, etc. depending on settlement currency). Recommending a $0.31 break-even price or a 99.69% safe discount is not executable in production โ€” the executable minimum is $0.50 (99.50% max discount on a $100 item).

To guarantee forward and reverse math never diverge, we replaced separate reverse formulas with a unified monotonic binary-search solver (solveTargetPrice) that calls the exact same forward engine (evaluateOrder) and verifies every solution to the cent across 200 randomized forward-reverse roundtrip tests.

3. Hardening Client-Side Share Links Without a Backend

FeeClear runs 100% client-side on Cloudflare Pages with zero backend servers and zero ad or marketing cookies. To let users share a calculation via #s= URL hashes safely:

  • We eliminated all .innerHTML usage across app.js in favor of safe DOM node construction.
  • Incoming share payloads pass through strict schema & enum validation (validateSharePayload) plus rule-version compatibility checks.
  • Viewing a shared link runs in an isolated snapshot mode so it never overwrites a user's saved local workspace until they explicitly edit a field.

Try It or Inspect the Code

If you spot a fee schedule change or an edge case that doesn't match your real payout statement, feel free to leave a comment or open a GitHub Issue!

Transparency note: This project and article were built and drafted with AI assistance, with all fee schedules verified against official US/UK pricing documentation and validated via automated test scripts and live browser checks.

๐Ÿ“ฐ Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes โ€” full credit and traffic to the original publisher.