Payment processors don't put payouts on hold at random. Most holds follow a predictable pattern. Something in your transaction stream looks different from your history, and the processor stops releasing funds until it understands why. For the merchant, the hold feels like it came out of nowhere. For the processor, it was a rule firing on data you also have.
That means you can run roughly the same checks yourself, earlier, and act before a hold lands. Acting usually means warning the processor, fixing a fraud leak, or handling a refund wave. This article walks through building that monitor: which signals to compute, how to compute them without fooling yourself, and where the common implementations go wrong.
For the business side, including what a revenue hold is, how it differs from a reserve or a freeze, and how to get one lifted, see Revenue Hold: Why Your Processor Is Holding Your Funds. Here we stay on the engineering side.
Why processors care: the exposure window
It helps to model the problem the way the processor sees it.
When a processor pays you for a sale, it is still exposed to that sale. A cardholder can dispute it for weeks or months afterward. The window is commonly cited as around 120 days for many dispute types. If the dispute succeeds and you can't cover it, the processor absorbs the loss.
So the processor's question is not "is this sale real?" It is "how much money have I released that could still come back, and is that number moving in a strange direction?"
You can compute your own version of that number:
from datetime import date, timedelta
def rolling_exposure(transactions, as_of: date, window_days: int = 120) -> float:
"""Settled sales still inside the dispute window, net of refunds."""
cutoff = as_of - timedelta(days=window_days)
return sum(
t.amount - t.refunded_amount
for t in transactions
if t.status == "settled" and t.settled_on > cutoff
)
This is a simplification. Real dispute windows vary by network, reason code, and whether the clock starts at the transaction date or the expected delivery date. Still, plotting this line over time shows you what a risk analyst sees. A slow climb is normal growth. A step change is what gets flagged.
The signals worth computing
The triggers processors describe publicly fall into a small set. Each one maps to a metric you can derive from your own ledger.
| Signal | What the processor fears | Merchant-side metric | Typical action |
|---|---|---|---|
| Volume spike | Fraud ring or bust-out before disappearing | Daily volume ÷ same-weekday baseline | Pre-notify processor; confirm the cause |
| Outlier ticket | Single large loss | Order amount vs. trailing p99 | Extra verification; send a heads-up before capture |
| Refund surge | Unhappy customers become disputes | Rolling refund rate | Investigate fulfillment or product issue |
| Dispute rate climb | Approaching network monitoring programs | Monthly disputes ÷ monthly transactions | Prevention, alerts, root-cause review |
| Category drift | Unapproved business model | New SKUs or categories vs. what was declared at onboarding | Update the processor before launch |
| Cold start | No history to judge against | Days since first live payment | Expect scrutiny; keep early volume steady |
The thresholds below are illustrative defaults. Your processor's internal rules aren't public, and the dispute thresholds in card network monitoring programs change. Check your merchant agreement and acquirer documentation for the numbers that actually apply to you.
Data flow
A minimal pipeline looks like this:
- Ingest. Consume payment, refund, and dispute events (processor webhooks or a nightly export) into an append-only ledger table. Store the processor's own timestamps alongside yours.
-
Aggregate. Once per day, after the processor's batch cutoff, roll up into a
daily_statstable. - Evaluate. Run the rules against the aggregates and the trailing history.
- Route. Warnings go to a channel. Critical alerts page whoever owns the processor relationship.
- Plan ahead. Separately, read the marketing and sales calendar and raise alerts before planned spikes.
Step 5 is the one most teams skip, and it matters most. A detector that fires after a spike only tells you a hold might be coming. A forecast that fires before a launch gives you time to email the processor.
Implementation
Daily aggregates
from dataclasses import dataclass
from datetime import date
from statistics import median
@dataclass
class DailyStats:
day: date
gross_volume: float
txn_count: int
refund_count: int
dispute_count: int
Volume spike against a seasonal baseline
Compare each day to the same weekday in recent history. Don't compare it to the plain mean of the last 30 days. Weekly seasonality is real, and the mean gets pulled up by the very spikes you are trying to detect.
def volume_spike(history: list[DailyStats], today: DailyStats,
warn_ratio=2.0, crit_ratio=3.0, lookback_days=56):
peers = [d.gross_volume for d in history[-lookback_days:]
if d.day.weekday() == today.day.weekday()]
if len(peers) < 4:
return {"rule": "volume", "level": "info", "msg": "cold start: insufficient baseline"}
baseline = median(peers)
if baseline <= 0:
return {"rule": "volume", "level": "warn", "msg": "volume after zero baseline"}
ratio = today.gross_volume / baseline
if ratio >= crit_ratio:
level = "crit"
elif ratio >= warn_ratio:
level = "warn"
else:
return None
return {"rule": "volume", "level": level, "msg": f"{ratio:.1f}x weekday median"}
Outlier tickets, checked before capture
This check is most useful inside the order flow, between authorization and capture, rather than in a nightly batch:
def percentile(values, p):
s = sorted(values)
k = (len(s) - 1) * p
f = int(k)
c = min(f + 1, len(s) - 1)
return s[f] + (s[c] - s[f]) * (k - f)
def ticket_outlier(amount, trailing_amounts, multiplier=3.0):
if len(trailing_amounts) < 200:
return None # not enough data for a stable p99
p99 = percentile(trailing_amounts, 0.99)
if amount > p99 * multiplier:
return {"rule": "ticket", "level": "warn",
"msg": f"{amount:.2f} > {multiplier}x p99 ({p99:.2f})"}
return None
When this fires on a legitimate wholesale order, the right response is a human one. Hold capture briefly, verify the buyer, and tell the processor the order is coming.
Refund and dispute rates
def rate_checks(month: list[DailyStats], refund_warn=0.05, dispute_warn=0.005):
txns = sum(d.txn_count for d in month)
if txns == 0:
return []
alerts = []
refund_rate = sum(d.refund_count for d in month) / txns
dispute_rate = sum(d.dispute_count for d in month) / txns
if refund_rate >= refund_warn:
alerts.append({"rule": "refunds", "level": "warn", "msg": f"{refund_rate:.2%}"})
if dispute_rate >= dispute_warn:
alerts.append({"rule": "disputes", "level": "crit", "msg": f"{dispute_rate:.2%}"})
return alerts
Networks and acquirers don't all calculate dispute ratios the same way. Some divide this month's disputes by this month's transactions, and some use the previous month's transactions as the denominator. Some programs also have count minimums alongside the ratio. Implement the formula your acquirer actually uses, and consider tracking both.
Forecasting from the calendar
def planned_spike_alerts(campaigns, baseline_daily_volume, notify_days_ahead=7, warn_ratio=2.0):
alerts = []
for c in campaigns:
expected_ratio = c.expected_daily_volume / baseline_daily_volume
if expected_ratio >= warn_ratio:
alerts.append({
"rule": "planned_spike",
"due": c.start - timedelta(days=notify_days_ahead),
"msg": f"{c.name}: ~{expected_ratio:.1f}x volume; notify processor",
})
return alerts
The output of this function is a task, not a page: "email the processor about next week's sale." That email turns a surprising spike into an expected one.
Worked example
A store usually does about $4,000 on Tuesdays. The last eight Tuesdays were $3,600, $4,100, $3,900, $4,300, $3,800, $4,200, $4,000, and $3,950, so the median is about $3,975.
This Tuesday a product gets featured in a newsletter, and volume hits $13,500. That's a ratio of 3.4x, which fires as critical. Inside that day is one order for $2,800. The store's trailing p99 is $310, so the order is about 9x p99 and the ticket rule fires too.
On its own, each signal has an innocent explanation. Together, on a single day, they look like what card-testing or a bust-out can look like from the processor's side. If the newsletter feature had been in the campaign calendar, the forecast alert would have prompted an email a week earlier. With that email on file, the processor's analyst sees context instead of a mystery.
Common mistakes
- Mean-based baselines. One prior spike inflates the mean and hides the next one. Use medians or trimmed means.
- Ignoring the processor's batch cutoff. If your day ends at midnight local time and the processor's batch closes at a different hour, your daily totals won't line up with theirs. Aggregate on their boundary.
- Counting dispute-related refunds twice. A refund issued in response to a dispute shouldn't be counted as both a refund and a dispute. Link these records in the ledger.
- Silent cold starts. New accounts are under the most scrutiny, and that's exactly when your baselines are empty. Emit an explicit "insufficient history" state instead of returning nothing.
- Currency mixing. Normalize to settlement currency before you aggregate. Otherwise FX swings look like volume changes.
- Alert-only, no owner. A critical alert that nobody turns into a message to the processor accomplishes nothing. Route every alert to someone who can contact the processor.
What this won't do
The monitor doesn't replicate the processor's model. They see network-level data, device signals, and cross-merchant patterns that you don't. What it gives you is the ability to explain your own numbers before someone asks, and to spot real problems early, such as a fraud leak or a fulfillment failure driving refunds. That covers a large share of the holds you can actually influence.
Top comments (0)