<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: fangrenyu634-cell</title>
    <description>The latest articles on DEV Community by fangrenyu634-cell (@fangrenyu634cell).</description>
    <link>https://dev.to/fangrenyu634cell</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4285879%2F5bd08a71-318b-4cc7-9914-4967fa3bf69f.png</url>
      <title>DEV Community: fangrenyu634-cell</title>
      <link>https://dev.to/fangrenyu634cell</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/fangrenyu634cell"/>
    <language>en</language>
    <item>
      <title>Why My First Seller Fee Calculator Got Bank Payouts Wrong (and How We Fixed It With Tests)</title>
      <dc:creator>fangrenyu634-cell</dc:creator>
      <pubDate>Sun, 06 Dec 2026 06:13:40 +0000</pubDate>
      <link>https://dev.to/fangrenyu634cell/why-my-first-seller-fee-calculator-got-bank-payouts-wrong-and-how-we-fixed-it-with-tests-1h9l</link>
      <guid>https://dev.to/fangrenyu634cell/why-my-first-seller-fee-calculator-got-bank-payouts-wrong-and-how-we-fixed-it-with-tests-1h9l</guid>
      <description>&lt;p&gt;When I started building a lightweight static fee calculator for cross-border sellers and freelancers (&lt;a href="https://feeclear.pages.dev/" rel="noopener noreferrer"&gt;FeeClear&lt;/a&gt;), 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."&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Platform Balance != Bank Payout != Net Order Profit
&lt;/h2&gt;

&lt;p&gt;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:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Stage 1 — Balance After Platform Fees (in platform settlement currency):&lt;/strong&gt;
For example, a UK Etsy seller pays a &lt;code&gt;$0.20 USD&lt;/code&gt; listing fee (converted to GBP), &lt;code&gt;6.5%&lt;/code&gt; transaction fee, &lt;code&gt;4.0% + £0.20&lt;/code&gt; Etsy Payments fee, and a &lt;code&gt;0.48%&lt;/code&gt; UK Regulatory Operating Fee (plus optional &lt;code&gt;20%&lt;/code&gt; 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 &lt;code&gt;2.5%&lt;/code&gt; conversion) happens here.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stage 2 — Estimated Bank Payout (in bank currency):&lt;/strong&gt;
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 &lt;strong&gt;Stage-2 FX conversion&lt;/strong&gt; (exchange spread &lt;code&gt;%&lt;/code&gt; + fixed wire fee).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stage 3 — Estimated Order Profit:&lt;/strong&gt;
Only after subtracting separately paid operating costs (COGS, shipping labels, packaging, ad spend) do you get true order profit.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Splitting the output into all three stages made the numbers immediately auditable against real payout statements.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Linear Reverse Formulas Break on Caps and Minimum Charge Floors
&lt;/h2&gt;

&lt;p&gt;Many calculators solve &lt;em&gt;"What should I charge to net $100?"&lt;/em&gt; using a closed-form linear formula:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Price = (Target + FixedFee) / (1 - Rate)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That formula silently produces wrong answers whenever a platform introduces non-linear constraints:&lt;/p&gt;

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

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




&lt;h2&gt;
  
  
  3. Hardening Client-Side Share Links Without a Backend
&lt;/h2&gt;

&lt;p&gt;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 &lt;code&gt;#s=&lt;/code&gt; URL hashes safely:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We eliminated all &lt;code&gt;.innerHTML&lt;/code&gt; usage across &lt;code&gt;app.js&lt;/code&gt; in favor of safe DOM node construction.&lt;/li&gt;
&lt;li&gt;Incoming share payloads pass through strict schema &amp;amp; enum validation (&lt;code&gt;validateSharePayload&lt;/code&gt;) plus rule-version compatibility checks.&lt;/li&gt;
&lt;li&gt;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.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Try It or Inspect the Code
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Live Web App:&lt;/strong&gt; &lt;a href="https://feeclear.pages.dev/" rel="noopener noreferrer"&gt;https://feeclear.pages.dev/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dedicated Regional Calculators:&lt;/strong&gt; &lt;a href="https://feeclear.pages.dev/en-us/stripe-fee-calculator/" rel="noopener noreferrer"&gt;US Stripe&lt;/a&gt; · &lt;a href="https://feeclear.pages.dev/en-gb/etsy-fee-calculator/" rel="noopener noreferrer"&gt;UK Etsy&lt;/a&gt; · &lt;a href="https://feeclear.pages.dev/en-us/paypal-fee-calculator/" rel="noopener noreferrer"&gt;US PayPal&lt;/a&gt; · &lt;a href="https://feeclear.pages.dev/en/fiverr-fee-calculator/" rel="noopener noreferrer"&gt;Fiverr&lt;/a&gt; · &lt;a href="https://feeclear.pages.dev/en/gumroad-fee-calculator/" rel="noopener noreferrer"&gt;Gumroad&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Open-Source Repo &amp;amp; Verification Suite (MIT):&lt;/strong&gt; &lt;a href="https://github.com/fangrenyu634-cell/feeclear" rel="noopener noreferrer"&gt;https://github.com/fangrenyu634-cell/feeclear&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;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 &lt;a href="https://github.com/fangrenyu634-cell/feeclear/issues" rel="noopener noreferrer"&gt;GitHub Issue&lt;/a&gt;!&lt;/p&gt;




&lt;p&gt;&lt;em&gt;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.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
