Diagnostic Bank transfers and statement matching
Why WooCommerce bank-transfer orders go unmatched
A customer picks Direct bank transfer, the order goes On hold, and then you wait. Days later the money is in your account but nobody can say which order it belongs to: the reference is missing, mistyped, cut short by the bank, or the amount is not quite right. Here is why payments and orders stop lining up, and a small read-only check that lists every bank-transfer order still waiting, with its age and total.
WooCommerce sets every Direct bank transfer order On hold and waits for you to confirm that the money arrived. The payment reaches your bank carrying whatever the customer typed, and the statement only repeats it. A missing or mistyped reference, text cut or wrapped by the bank, one transfer paying two orders, or an amount that is off each leave a payment with no clear order. Run a small Python or Node.js check that lists On hold bank-transfer orders older than N days, with age and total. It changes nothing.
The problem in plain words
A customer orders for 49.90 and chooses Direct bank transfer. WooCommerce sets the order On hold and shows your bank details. Its default instructions ask the customer to use the order ID as the payment reference, but nothing makes them: the transfer is typed into a banking app you do not control.
Four days later 49.90 appears on your statement. The text says "Bestellung", or "Rechnung 1O42", or nothing at all. Someone has to read the statement line by line and decide which order it pays. Meanwhile the order stays On hold, the customer asks where their parcel is, and you cannot tell the payments nobody has sent from the payments nobody has matched.
Why it happens
Four ordinary things go wrong between the customer's banking app and your order list:
- The reference is missing or mistyped. A bare order number typed wrong is usually a different, real order number, so a typo can look like a perfect match to the wrong order.
- The text is cut or wrapped. SEPA's unstructured remittance text is at most 140 characters, and German MT940 statements carry it in 27-character subfields (?20 to ?29, then ?60 to ?63), so a reference can arrive broken across two pieces of one line.
- One transfer pays two orders, or two transfers pay one. Nothing in a payment says how it should be split.
- The amount is not the amount. A rounded figure, a fee taken out on an international transfer or a forgotten shipping line makes the exact total, the one number a matcher can check, the one that is wrong.
An unmatched payment is not a failed payment. The money arrived; what is missing is evidence about whose it is. Count the orders that have waited and the money they hold, and you can see the size of the problem before you decide how to match them.
The fix, as a flow
The check reads every On hold order, keeps the ones paid by direct bank transfer (payment method bacs), works out how many whole days each has waited from its creation time in UTC, and lists the ones older than your limit, oldest first, with the total. The orders endpoint takes a status filter, so the payment-method test is made in the script.
Build it step by step
Give the script read access
Create a WooCommerce REST API key with Read permission (WooCommerce, Settings, Advanced, REST API), or use an application password for an administrator. The script only ever sends GET requests.
pip install requests
export WOO_STORE_URL="https://yourstore.com"
export WOO_CONSUMER_KEY="ck_..." # or an admin username
export WOO_CONSUMER_SECRET="cs_..." # or its application password
# Node 18 or later: fetch is built in, nothing to install.
export WOO_STORE_URL="https://yourstore.com"
export WOO_CONSUMER_KEY="ck_..." # or an admin username
export WOO_CONSUMER_SECRET="cs_..." # or its application password
Decide with one pure function
One function takes an order and the current time and returns a report row or nothing. It works in whole cents so totals add up exactly, and it reads the creation time as UTC because WooCommerce gives date_created_gmt without a zone.
def decide(order, now, max_age_days):
"""One order -> a row for the report, or None when it is not a stale bank-transfer order."""
if order.get("status") != "on-hold" or order.get("payment_method") != "bacs":
return None
age = age_in_days(order, now)
if age < max_age_days:
return None
return {
"id": order["id"],
"number": str(order.get("number") or order["id"]),
"age_days": age,
"total_minor": minor(order.get("total")),
"currency": order.get("currency", ""),
}
export function decide(order, now, maxAgeDays) {
if (order.status !== "on-hold" || order.payment_method !== "bacs") return null;
const age = ageInDays(order, now);
if (age < maxAgeDays) return null;
return {
id: order.id,
number: String(order.number || order.id),
age_days: age,
total_minor: minor(order.total),
currency: order.currency || "",
};
}
Run it each morning
It exits with status 1 when any order has waited past your limit, so a cron job can tell you. Set MAX_AGE_DAYS to the longest wait you still call normal for your customers.
MAX_AGE_DAYS=3 python3 check_stale_transfers.py
# every morning, 07:00
0 7 * * * cd /opt/checks && python3 check_stale_transfers.py || echo "see the list above"
MAX_AGE_DAYS=3 node check-stale-transfers.mjs
# every morning, 07:00
0 7 * * * cd /opt/checks && node check-stale-transfers.mjs || echo "see the list above"
The check never writes: no order notes, no edits, no status changes. Matching a payment to an order is a decision to make after reading the list, not something a script should do on its own.
The full code
The complete check in one file for each language. It reads its settings from the environment and pages through every On hold order, 100 at a time.
"""List bank-transfer orders that have waited too long for a payment to be matched.
WooCommerce puts every Direct bank transfer (BACS) order On hold and leaves it
there until a person confirms the money arrived. This lists the ones older than
MAX_AGE_DAYS (default 3), oldest first, with the age and the total. Read only:
it sends GET requests and changes nothing.
Guide: https://www.allanninal.dev/woocommerce/why-bank-transfer-orders-go-unmatched/
"""
from datetime import datetime, timezone
from requests.auth import HTTPBasicAuth
import os
import requests
import sys
WOO_URL = os.environ["WOO_STORE_URL"].rstrip("/")
AUTH = HTTPBasicAuth(os.environ["WOO_CONSUMER_KEY"], os.environ["WOO_CONSUMER_SECRET"])
def woo(path, **params):
r = requests.get(f"{WOO_URL}/wp-json/wc/v3/{path}", auth=AUTH, params=params, timeout=30)
r.raise_for_status()
return r.json()
def every(path, **params):
page = 1
while True:
batch = woo(path, per_page=100, page=page, **params)
yield from batch
if len(batch) < 100:
return
page += 1
def minor(amount):
"""'25.00' -> 2500. Two-decimal currencies; zero-decimal ones need their own factor."""
return round(float(amount or 0) * 100)
MAX_AGE_DAYS = int(os.environ.get("MAX_AGE_DAYS", "3"))
def age_in_days(order, now):
"""Whole days since the order was created. date_created_gmt has no zone suffix: it is UTC."""
created = datetime.fromisoformat(order["date_created_gmt"]).replace(tzinfo=timezone.utc)
return max(0, (now - created).days)
def decide(order, now, max_age_days):
"""One order -> a row for the report, or None when it is not a stale bank-transfer order."""
if order.get("status") != "on-hold" or order.get("payment_method") != "bacs":
return None
age = age_in_days(order, now)
if age < max_age_days:
return None
return {
"id": order["id"],
"number": str(order.get("number") or order["id"]),
"age_days": age,
"total_minor": minor(order.get("total")),
"currency": order.get("currency", ""),
}
def main():
now = datetime.now(timezone.utc)
rows = []
for order in every("orders", status="on-hold"):
row = decide(order, now, MAX_AGE_DAYS)
if row:
rows.append(row)
rows.sort(key=lambda r: (-r["age_days"], r["id"]))
totals = {}
for r in rows:
print(f"#{r['number']}: {r['age_days']} days on hold, {r['total_minor'] / 100:.2f} {r['currency']}")
totals[r["currency"]] = totals.get(r["currency"], 0) + r["total_minor"]
money = ", ".join(f"{t / 100:.2f} {c}" for c, t in sorted(totals.items())) or "nothing"
print(f"{len(rows)} bank-transfer order(s) on hold for {MAX_AGE_DAYS}+ days: {money} waiting.")
return 1 if rows else 0
if __name__ == "__main__":
sys.exit(main())
/**
* List bank-transfer orders that have waited too long for a payment to be matched.
*
* WooCommerce puts every Direct bank transfer (BACS) order On hold and leaves it there
* until a person confirms the money arrived. This lists the ones older than MAX_AGE_DAYS
* (default 3), oldest first, with the age and the total. Read only: it sends GET requests
* and changes nothing.
*
* Guide: https://www.allanninal.dev/woocommerce/why-bank-transfer-orders-go-unmatched/
*/
import { pathToFileURL } from "node:url";
const WOO_URL = (process.env.WOO_STORE_URL || "https://example.com").replace(/\/$/, "");
const AUTH = "Basic " + Buffer.from(
`${process.env.WOO_CONSUMER_KEY || "ck_dummy"}:${process.env.WOO_CONSUMER_SECRET || "cs_dummy"}`
).toString("base64");
async function woo(path, params = {}) {
const url = new URL(`${WOO_URL}/wp-json/wc/v3/${path}`);
for (const [k, v] of Object.entries(params)) url.searchParams.set(k, v);
const res = await fetch(url, { headers: { Authorization: AUTH } });
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
return res.json();
}
async function* every(path, params = {}) {
for (let page = 1; ; page++) {
const batch = await woo(path, { per_page: 100, page, ...params });
yield* batch;
if (batch.length < 100) return;
}
}
/** "25.00" -> 2500. Two-decimal currencies; zero-decimal ones need their own factor. */
const minor = (amount) => Math.round(Number(amount || 0) * 100);
const MAX_AGE_DAYS = Number(process.env.MAX_AGE_DAYS || 3);
/** Whole days since the order was created. date_created_gmt has no zone suffix: it is UTC. */
export function ageInDays(order, now) {
const created = new Date(order.date_created_gmt + "Z");
return Math.max(0, Math.floor((now - created) / 86400000));
}
export function decide(order, now, maxAgeDays) {
if (order.status !== "on-hold" || order.payment_method !== "bacs") return null;
const age = ageInDays(order, now);
if (age < maxAgeDays) return null;
return {
id: order.id,
number: String(order.number || order.id),
age_days: age,
total_minor: minor(order.total),
currency: order.currency || "",
};
}
export async function run() {
const now = new Date();
const rows = [];
for await (const order of every("orders", { status: "on-hold" })) {
const row = decide(order, now, MAX_AGE_DAYS);
if (row) rows.push(row);
}
rows.sort((a, b) => b.age_days - a.age_days || a.id - b.id);
const totals = {};
for (const r of rows) {
console.log(`#${r.number}: ${r.age_days} days on hold, ${(r.total_minor / 100).toFixed(2)} ${r.currency}`);
totals[r.currency] = (totals[r.currency] || 0) + r.total_minor;
}
const money = Object.entries(totals).sort().map(([c, t]) => `${(t / 100).toFixed(2)} ${c}`).join(", ") || "nothing";
console.log(`${rows.length} bank-transfer order(s) on hold for ${MAX_AGE_DAYS}+ days: ${money} waiting.`);
return rows.length ? 1 : 0;
}
if (import.meta.url === pathToFileURL(process.argv[1]).href) {
run().then((code) => process.exit(code)).catch((err) => { console.error(err); process.exit(2); });
}
Add a test
The decision is the part most worth testing, and because it is a pure function the tests need no store and no network: they feed in plain objects and check the answer.
from datetime import datetime, timezone
from check_stale_transfers import decide
NOW = datetime(2026, 11, 20, 12, 0, tzinfo=timezone.utc)
def order(created="2026-11-10T09:00:00", **over):
return {"id": 7, "number": "7", "status": "on-hold", "payment_method": "bacs", "total": "49.90", "currency": "EUR", "date_created_gmt": created, **over}
def test_an_old_bank_transfer_order_is_listed_with_age_and_total():
row = decide(order(), NOW, 3)
assert row == {"id": 7, "number": "7", "age_days": 10, "total_minor": 4990, "currency": "EUR"}
def test_a_young_order_is_left_out():
assert decide(order("2026-11-19T09:00:00"), NOW, 3) is None
def test_the_age_limit_is_inclusive():
assert decide(order("2026-11-17T12:00:00"), NOW, 3)["age_days"] == 3
def test_other_payment_methods_and_statuses_are_left_out():
assert decide(order(payment_method="stripe"), NOW, 3) is None
assert decide(order(status="processing"), NOW, 3) is None
def test_a_total_with_floating_point_noise_stays_exact():
assert decide(order(total="19.99"), NOW, 3)["total_minor"] == 1999
import { test } from "node:test";
import assert from "node:assert/strict";
import { decide } from "./check-stale-transfers.mjs";
const NOW = new Date("2026-11-20T12:00:00Z");
const order = (over = {}) => ({ id: 7, number: "7", status: "on-hold", payment_method: "bacs", total: "49.90", currency: "EUR", date_created_gmt: "2026-11-10T09:00:00", ...over });
test("an old bank-transfer order is listed with age and total", () =>
assert.deepEqual(decide(order(), NOW, 3), { id: 7, number: "7", age_days: 10, total_minor: 4990, currency: "EUR" }));
test("a young order is left out", () => assert.equal(decide(order({ date_created_gmt: "2026-11-19T09:00:00" }), NOW, 3), null));
test("the age limit is inclusive", () => assert.equal(decide(order({ date_created_gmt: "2026-11-17T12:00:00" }), NOW, 3).age_days, 3));
test("other payment methods and statuses are left out", () => {
assert.equal(decide(order({ payment_method: "stripe" }), NOW, 3), null);
assert.equal(decide(order({ status: "processing" }), NOW, 3), null);
});
test("a total with floating point noise stays exact", () => assert.equal(decide(order({ total: "19.99" }), NOW, 3).total_minor, 1999));
Worked example
What it found
On a throwaway WooCommerce 11.3.0 store with seven orders, the check listed the four bank-transfer orders that had been On hold for 3 days or more, oldest first, and the 114.90 EUR they hold. It left out the order placed one day earlier, an On hold order paid by cash on delivery, and a bank-transfer order already Processing. The Python and Node.js runs printed the same lines.
#18: 12 days on hold, 15.00 EUR
#10: 9 days on hold, 49.90 EUR
#12: 5 days on hold, 25.00 EUR
#14: 4 days on hold, 25.00 EUR
4 bank-transfer order(s) on hold for 3+ days: 114.90 EUR waiting.
(exit status 1)
#18: 12 days on hold, 15.00 EUR
#10: 9 days on hold, 49.90 EUR
#12: 5 days on hold, 25.00 EUR
#14: 4 days on hold, 25.00 EUR
4 bank-transfer order(s) on hold for 3+ days: 114.90 EUR waiting.
(exit status 1)
The report names orders by number and amount only, no customer names or addresses. A short wait is normal: set MAX_AGE_DAYS for your own customers.
FAQ
Why does a WooCommerce bank transfer order stay On hold?
WooCommerce does not see your bank account. The Direct bank transfer gateway sets the order On hold and leaves it there until you confirm that the money arrived and change the status yourself. WooCommerce's documentation says you need to confirm the payment before processing the order.
Can I just match on the amount?
Only when exactly one unpaid order has that amount, and even then it is a guess about a stranger's money: a different customer may have paid, or the payer may have meant another order. With two orders of the same amount it is a coin toss. The next notes cover both cases.
How long should a bank transfer take to arrive?
That depends on the banks and countries involved, so the script makes the limit yours: MAX_AGE_DAYS. Pick the longest wait you still consider normal for your customers, and look at what is older.
Related field notes
Citations
- WooCommerce docs: Direct bank transfer (BACS). New orders are set On hold and you confirm the deposit yourself. woocommerce.com/document/bacs
- WooCommerce REST API: listing orders, their status, payment method, totals and dates. woocommerce.github.io/woocommerce-rest-api-docs
- Deutsche Kreditwirtschaft, DFU agreement Anlage 3, version 3.5 (Postbank's copy; the last to specify MT940): the :61: marks and the :86: subfields. www.postbank.de/dam/postbank/pdf/firmenkunden/Postbank-DFUe-Spezifikationen-Anlage-3-20211121.pdf
Transferproof reads your bank's statement file (camt.053, MT940 or CSV) and matches each payment to an unpaid bank-transfer order. Automatic confirmation is off until you switch it on, and even then it needs a reference that names exactly one order and the exact amount. Everything else is a suggestion for you to approve.
Did this save you a morning with the bank statement?
If it did, you can buy me a coffee. It is the best way to keep these field notes free and growing.
Buy me a coffee on Ko-fi