Building crypto balance top-ups into a proxy dashboard
To build crypto balance top-ups into a proxy dashboard, create one checkout per top-up, add credit only when the gateway reports the checkout as completed, and write that credit to a ledger that cannot record the same top-up twice. Then settle 4 rules before launch: the minimum per network, whether bonus credit exists, what happens when a payment arrives short, and whether unused balance can be refunded.
Why do proxy dashboards use a balance at all?
Proxy traffic is sold per gigabyte or per IP and used unevenly, so self-serve providers often sell a balance and meter against it. Decodo's billing FAQ describes a Wallet and says "You can top up your Wallet using any listed payment method". DataImpulse says "You can top up your balance with popular crypto assets" and sets a $50 minimum top-up for plans.
Crypto is a large share of payments at some sellers. In a February 2026 CoinGate article, which is vendor marketing built on figures its merchants reported, IPRoyal's CEO says "Over 30% of our transactions are now crypto payments". The same article has Thunderproxy at about 75% of total transactions. The wider picture is in crypto payments for proxy providers.
The weak point in these flows is the imperfect payment. Decodo's crypto payment help page says that when an invoice expires "a refund form will appear" and that the gateway handles those requests "manually within 48 hours". DataImpulse says an underpaid invoice does not complete on its own and sends the customer to CoinGate's support to recover the funds. A balance does not need that. If $18.40 of a $20 top-up arrives, the customer can be credited $18.40. The design below does exactly that, in Python and PostgreSQL with the CoinStack API.
The data model: top-ups and a ledger
Two tables carry the whole feature. A top-up row tracks one checkout. The ledger holds every change to a balance, and the balance is the sum of an account's ledger rows.
CREATE TABLE topups (
id bigserial PRIMARY KEY,
account_id bigint NOT NULL REFERENCES accounts (id),
amount numeric(12, 2) NOT NULL,
checkout_id text UNIQUE,
status text NOT NULL DEFAULT 'pending',
review boolean NOT NULL DEFAULT false,
created_at timestamptz NOT NULL DEFAULT now()
);
CREATE TABLE ledger (
id bigserial PRIMARY KEY,
account_id bigint NOT NULL REFERENCES accounts (id),
topup_id bigint REFERENCES topups (id),
kind text NOT NULL,
amount numeric(14, 4) NOT NULL,
created_at timestamptz NOT NULL DEFAULT now(),
UNIQUE (topup_id, kind)
);kind is topup, bonus, usage or refund. Usage and refund rows are negative. The unique constraint is what makes crediting safe: a top-up can produce one topup row and one bonus row, and a second attempt to insert either is rejected by the database. Usage rows have no topup_id, and PostgreSQL does not treat NULL values as equal in a unique constraint, so they are unaffected.
Hold the balance in dollars, not gigabytes. A dollar balance survives price changes and can be spent on any product you add later.
Step 1: create one checkout per top-up
When the customer submits the top-up form, insert the row, create a checkout for the same amount and send them to its url. The fields follow the checkouts guide. Here db is a psycopg 3 connection opened with autocommit=True.
import os
from datetime import datetime, timedelta, timezone
from decimal import ROUND_DOWN, Decimal
import requests
API = "https://coinstack.net/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['COINSTACK_API_KEY']}"}
def create_topup(db, account_id, amount):
# amount is a Decimal such as Decimal("25.00"), already checked against your limits
topup_id = db.execute(
"INSERT INTO topups (account_id, amount) VALUES (%s, %s) RETURNING id",
(account_id, amount),
).fetchone()[0]
body = requests.post(
f"{API}/checkouts",
headers=HEADERS,
json={
"amount": f"{amount:.2f}",
"currency": "USD",
"reference": f"topup-{topup_id}",
"description": "Proxy balance top-up",
"success_url": "https://dash.example.com/billing?checkout={CHECKOUT_ID}",
"cancel_url": "https://dash.example.com/billing",
"metadata": {"account_id": str(account_id)},
"expires_at": (datetime.now(timezone.utc) + timedelta(hours=2)).isoformat(),
},
timeout=30,
).json()
if not body["success"]:
raise RuntimeError(body["response"])
checkout = body["response"]["checkout"]
db.execute(
"UPDATE topups SET checkout_id = %s WHERE id = %s",
(checkout["checkout_id"], topup_id),
)
return checkout["url"]Three choices in that request matter.
The reference lets you find the checkout again. The API creates a new checkout on every call, so if the request times out, list checkouts by that reference before you retry.
The 2-hour expires_at replaces the 24-hour default. Expiry is when a short payment gets settled as partial credit, so a shorter window means the customer waits 2 hours for that credit instead of a day. A payment that lands after expiry and covers the amount still completes the checkout, flagged late, so a slow exchange withdrawal is not lost.
The return link is only a link on the checkout page. Customers close the tab. Credit must never depend on it.
Step 2: credit the balance once, from the webhook
Add a webhook that receives every event and verify each request with the code in the webhooks guide, which how to verify payment webhooks walks through line by line. The guide also warns that events can arrive twice or out of order, and suggests reading the checkout's current state when one arrives. That advice shapes the handler: the event is only a signal, and one function reads the checkout and applies whatever is true now.
def sync_topup(db, checkout_id):
body = requests.get(f"{API}/checkouts/{checkout_id}", headers=HEADERS, timeout=30).json()
if not body["success"]:
raise RuntimeError(body["response"])
checkout = body["response"]["checkout"]
status = checkout["status"]
if status == "expired" and checkout["underpaid"]:
# Part of the amount arrived before the checkout closed: accept it.
resolved = requests.post(
f"{API}/checkouts/{checkout_id}/resolve", headers=HEADERS, timeout=30
).json()
if not resolved["success"]:
raise RuntimeError(resolved["response"])
status = "resolved"
with db.transaction():
topup = db.execute(
"SELECT id, account_id, amount FROM topups WHERE checkout_id = %s FOR UPDATE",
(checkout_id,),
).fetchone()
if topup is None:
return
topup_id, account_id, amount = topup
if status == "completed":
credit = amount
elif status == "resolved":
paid = sum(
Decimal(payment["share"])
for payment in body["response"]["payments"]
if payment["status"] == "completed"
)
credit = (amount * min(paid, Decimal(1))).quantize(Decimal("0.01"), rounding=ROUND_DOWN)
else:
db.execute("UPDATE topups SET status = %s WHERE id = %s", (status, topup_id))
return
db.execute(
"INSERT INTO ledger (account_id, topup_id, kind, amount) "
"VALUES (%s, %s, 'topup', %s) ON CONFLICT (topup_id, kind) DO NOTHING",
(account_id, topup_id, credit),
)
db.execute(
"UPDATE topups SET status = 'credited', review = %s WHERE id = %s",
(checkout["overpaid"], topup_id),
)The webhook route stays small. CoinStack expects a 2xx answer within 10 seconds, so hand the checkout ID to a background worker and return at once. Here jobs stands for whatever queue you already run. Payment events are included on purpose: a short payment that lands after expiry changes no checkout status, so only payment.completed announces it.
event = json.loads(body) # after the signature check
record = event["data"].get("checkout") or event["data"]["payment"]
jobs.put(record["checkout_id"]) # a worker calls sync_topup
return "", 200Call the same function from the billing page when the customer returns with ?checkout= in the URL, and from a scheduled job for top-ups still open after their expiry. A missed webhook then costs nothing. CoinStack makes up to 8 delivery attempts over about a day in any case, and reliable payment webhooks covers duplicates and ordering in more depth.
What should the dashboard show at each status?
| Checkout status | What the customer sees | Balance |
|---|---|---|
pending | Awaiting payment, with a link back to the checkout page | No change |
confirming | Payment detected | No change |
partial | The amount received so far, and that the rest can go to the same address | No change |
completed | Credited | Plus the top-up amount |
resolved | Credited in part | Plus the share that arrived |
expired, nothing paid | Closed, with a button to start again | No change |
completed means the payment was converted and the USDC has reached your wallet. That is the point to release spendable credit. confirming only means a payment was seen.
How does a short payment become partial credit?
A payment within your underpayment allowance (0.5% by default, set under Settings, then Underpayment) completes the checkout, and the code credits the full amount. A larger shortfall leaves the checkout partial, and the customer can send the rest to the same address.
If they never do, the checkout expires with underpaid set to true, and the USDC from the part that was paid is already in your wallet. sync_topup then calls the resolve endpoint, which marks the checkout resolved, a final status. The credit is worked out from the share field on each completed payment, which says what fraction of the checkout that payment covered. A customer who owed $20 and sent a payment with a share of 0.92 is credited $18.40.
Resolving also works on a checkout that is still partial, so the dashboard can offer a "Credit what arrived" button that calls the same endpoint without waiting for expiry. Once a top-up is resolved, show it as closed and have the customer start a new one for any further amount.
Two causes are worth explaining to customers. An exchange may take its withdrawal fee out of the amount sent, and Decodo's help page calls forgotten fees "the most common reason users underpay". Underpaid crypto payments covers this in detail. And a customer paying in BTC after its 60-minute price lock is counted at the market price on arrival, so a falling price produces a partial checkout. Stablecoin top-ups have no time limit on the price.
When a customer sends more than 2% too much, the checkout still completes, the overpaid flag is set and the whole payment settles to your wallet. The code credits the requested amount and sets review, so a person can check the payment's value and add the difference.
What minimum top-up should each network have?
There are 2 floors: the gateway's and the customer's.
On the gateway side, the smallest CoinStack checkout is worth $1, and each token on each network has its own minimum, which is $1 on most networks and higher on Bitcoin and TRON, where the network cost is higher. A checkout below a token's minimum does not offer that token. List tokens returns the live figures, so the top-up form can show which methods an amount will offer before the customer commits:
def methods_for(amount):
body = requests.get(f"{API}/tokens", headers=HEADERS, timeout=30).json()
return [
(token["token"], token["network"], token["cost"])
for token in body["response"]["tokens"]
if token["active"] and Decimal(token["minimum"]) <= amount
]Cache the result for a minute or two. If you have narrowed your methods under Settings, then Payment methods, apply the same filter here.
On the customer's side, the floor is the exchange. These are flat withdrawal fees and minimums from Kraken's fee table:
| Route | Kraken fee | Kraken minimum | Fee as a share of a $10 top-up |
|---|---|---|---|
| USDT on TRON | 1 USDT | 6 USDT | 10% |
| USDC on Base | 1 USDC | 2.5 USDC | 10% |
| USDT on Polygon | 1 USDT | 2 USDT | 10% |
| USDC on Solana | 0.7083 USDC | 0.84996 USDC | 7.1% |
On TRON, Kraken's smallest withdrawal is 6 USDT with the fee included, so 5 USDT is the least that can arrive. If USDT on TRON is what your customers hold, check that token's live minimum and set your own at or above it, so the option is always offered. A $10 or $20 minimum with presets at $25, $50 and $100 also keeps a flat 1 USDT exchange fee at 10% of the top-up or less. Which networks to enable goes through the trade-offs.
How much bonus credit can you afford?
Compare what a top-up costs you by card and by crypto. The card figures use Stripe's US pricing as of December 2026: 2.9% plus 30 cents, with 1.5% more for international cards. CoinStack takes 0.8%.
| Top-up | Domestic card | International card | CoinStack fee | Largest bonus that still beats a domestic card |
|---|---|---|---|---|
| $20 | $0.88 | $1.18 | $0.16 | $0.72 (3.6%) |
| $50 | $1.75 | $2.50 | $0.40 | $1.35 (2.7%) |
| $100 | $3.20 | $4.70 | $0.80 | $2.40 (2.4%) |
| $500 | $14.80 | $22.30 | $4.00 | $10.80 (2.2%) |
The saving, as a percentage, shrinks as the top-up grows, because the card's 30 cents matters less. Fee savings alone justify about 2% at any size, and never a 5% or 10% tier for large top-ups. A tier like that is a pricing decision, in which you pay for cash up front and fewer payments.
Bonus credit is cheaper than it looks when it is spent on traffic. If a gigabyte you sell for $4 costs you $1.50 upstream, a $5 bonus buys 1.25 GB and costs you about $1.88. Write the bonus as its own bonus ledger row, so paid credit and gifted credit stay separate for refunds and for your books. Whether to offer a crypto discount covers the pricing side.
How should refunds of unused balance work?
Publish the rule next to the top-up button. Some sellers refuse outright. DataImpulse states "The 7-day refund policy does not apply to cryptocurrency payments." Whether you can take the same line depends on who your buyers are and where they live. The EU's Consumer Rights Directive, for one, gives individuals a 14-day right to withdraw from a distance contract and makes no exception for crypto. Confirm your policy with a lawyer.
If you do refund, these rules keep it manageable:
- Refund paid credit only. Bonus rows are never refundable, and traffic already used is not returned.
- Ask the customer for a refund address and network in writing. The address a payment came from is often an exchange's shared wallet, as paying straight from an exchange explains.
- Write a negative
refundrow when the request is approved, so the balance drops before the money moves. - Set a minimum refund so each refund is worth sending.
With CoinStack, a refund is a transfer you send from your own wallet. You can send it to any supported token and network, for example USDT on TRON for a customer who paid that way, and the dashboard shows the network cost before you send. The steps are in how to refund a crypto payment.
What to plan for before launch
Each top-up is a payment the customer sends, so send low-balance emails early, let customers set the threshold, and state what happens to running sessions at zero.
Prove the whole path with a $1 top-up before launch, and use the demo checkout to see the payment page while writing help text.
The coins buyers favor can shift under you. USDT led at IPRoyal (55.2%) and ProxyScrape (36.1%) in CoinGate's figures, and CoinGate then dropped USDT in 2025 over MiCA requirements. Check what your own customers ask for before ordering the methods on the form.
Settlement is in USDC, on the network and to the address you choose. If an upstream supplier takes USDC, you can pay it from that balance directly. If your upstream bandwidth bills are in dollars or euros, withdraw to your bank from the dashboard on a schedule rather than after every top-up: the balance is converted to fiat and sent to your bank account.
Frequently asked questions
Should a proxy balance be held in dollars or in gigabytes?
Hold it in dollars. Per-gigabyte prices change and differ between residential, mobile and datacenter products, so a gigabyte balance has to be re-priced every time. A dollar balance is topped up with a dollar checkout, spent at whatever the current price is, and refunded without an argument about what a gigabyte was worth on the day it was bought.
Do I need a separate deposit address for every proxy customer?
You need a separate address for every top-up, which the gateway provides. Each CoinStack checkout gets its own deposit address for each token and network the customer picks, so a payment identifies its top-up without memos or unique amounts. Reusing one address per customer invites payments you cannot match to a request. See why payment addresses change.
What happens if the completed webhook arrives twice?
Nothing, if credit is written the way this guide does it. The ledger has a unique constraint on the top-up and the kind of row, so the second insert is discarded by the database. CoinStack keeps the same event_id when it retries or resends an event, which gives you a second way to recognize a repeat.