Accounting for DevelopersModule 4: Production financial systemsAdvanced4 min read
Payment Processor Reconciliation and Clearing Accounts
Reconcile Stripe and payment processors in your ledger: clearing accounts, gross charges, fees, net bank payouts, refunds, chargebacks and rolling reserves.
Course outline (16 lessons)
Before this lesson:Invoice and Payment Lifecycle in Accounting SoftwareBuilding a Bank Reconciliation Engine
In this lesson · 6 sections
When a customer buys a $100 product on Monday via Stripe, Adyen or PayPal, you do not receive $100 in your bank account on Monday. On Wednesday, a single lump-sum payout lands in your bank covering dozens of orders, minus card fees, minus yesterday’s refunds, minus any chargebacks or reserves.
If your code tries to debit Operating Cash directly on every card charge, your bank reconciliation breaks immediately. The solution is a Processor Clearing Account.
How a Processor Clearing Account works
Think of 1020 Processor Clearing (an asset account) as a virtual wallet representing money the payment processor currently owes you:
- Charge succeeds: money enters
Processor Clearing(net of fee), while Revenue is recorded gross and fees are recorded as Expense. - Refund or dispute occurs: money leaves
Processor Clearing. - Payout hits your bank: money moves out of
Processor Clearinginto1000 Operating Cash.
At any moment, the balance of 1020 Processor Clearing in your ledger must equal the live balance shown in your processor’s dashboard (available + pending).
Ending clearing = Opening clearing + Gross charges − Processing fees − Refunds − Disputes − Reserves − Bank payouts
- Gross charges
- full customer charge amounts captured by the processor
- Processing fees
- percentage + fixed per-transaction fees deducted at capture
- Bank payouts
- net lump-sum transfers settled into your operating bank account
Mapping processor events to balanced entries
| Processor webhook / balance event | Debit | Credit | Notes |
|---|---|---|---|
| Charge captured | Processor Clearing (net), Processing Fee Expense (fee) |
Revenue or AR (gross) |
Always book gross revenue + fee expense |
| Customer refund | Sales Returns / Refunds |
Processor Clearing |
Most processors do not return the original card fee |
| Bank payout settled | Operating Cash |
Processor Clearing |
Matches the exact deposit on your bank statement |
| Chargeback opened | Chargeback Receivable (or Dispute Loss), Chargeback Fee Expense |
Processor Clearing |
Reclassify if dispute is later won |
| Rolling reserve held | Processor Reserve Held (asset) |
Processor Clearing |
Reversed when reserve releases |
Worked example
Verve Tickets (fictional) — 3-step charge, refund and net bank payout
Verve Tickets uses PayBridge (fictional processor, fee 2.9% + $0.30 per charge, non-refundable on refunds, $15.00 dispute fee).
Step 1 — Charge captured (Monday): Customer buys a $100.00 ticket (10000 cents). Processing fee = 2.9% × $100 + $0.30 = $2.90 + $0.30 = $3.20. Net added to clearing = $96.80.
| Account | Debit (Dr) | Credit (Cr) |
|---|---|---|
| Processor Clearing | $96.8 | |
| Payment Processing Fees | $3.2 | |
| Ticket Revenue | $100 | |
| Total✓ Balanced | $100 | $100 |
Step 2 — Customer refund (Tuesday): Verve refunds a $50.00 ticket from an earlier order. PayBridge deducts $50.00 from Verve’s clearing balance and keeps the original fee.
| Account | Debit (Dr) | Credit (Cr) |
|---|---|---|
| Sales Returns and Refunds | $50 | |
| Processor Clearing | $50 | |
| Total✓ Balanced | $50 | $50 |
Step 3 — Net bank payout (Wednesday): PayBridge settles the remaining balance ($96.80 − $50.00 = $46.80) to Verve’s bank account.
| Account | Debit (Dr) | Credit (Cr) |
|---|---|---|
| Operating Cash | $46.8 | |
| Processor Clearing | $46.8 | |
| Total✓ Balanced | $46.8 | $46.8 |
Verify clearing balance: +$96.80 − $50.00 − $46.80 = $0.00. Meanwhile, Operating Cash shows the exact $46.80 deposit on the bank statement, Ticket Revenue shows gross $100.00, Sales Returns shows $50.00 and Payment Processing Fees shows $3.20.
Bonus — Chargeback opened: If a buyer later disputes a $40.00 charge and PayBridge charges a $15.00 dispute fee, Verve books:
| Account | Debit (Dr) | Credit (Cr) |
|---|---|---|
| Chargeback Receivable | $40 | |
| Chargeback Fee Expense | $15 | |
| Processor Clearing | $55 | |
| Total✓ Balanced | $55 | $55 |
If Verve wins the dispute and PayBridge returns $55.00, Verve reverses those lines; if lost, $40.00 moves from Chargeback Receivable to Dispute Loss Expense (or Sales Returns).
Idempotent webhook handler in TypeScript
Anchor ledger ingestion to the processor’s balance transaction feed (not just checkout success callbacks), using the processor’s immutable balance transaction ID as idempotencyKey:
type ProcessorEvent =
| { id: string; type: "charge"; date: string; currency: string; grossMinor: bigint; feeMinor: bigint }
| { id: string; type: "refund"; date: string; currency: string; refundMinor: bigint }
| { id: string; type: "payout"; date: string; currency: string; payoutMinor: bigint };
function buildProcessorEntry(ev: ProcessorEvent) {
const c = ev.currency;
if (ev.type === "charge") {
const netMinor = ev.grossMinor - ev.feeMinor;
return {
idempotencyKey: `processor:${ev.id}`,
effectiveDate: ev.date,
sourceType: "processor_charge",
sourceId: ev.id,
postings: [
{ accountId: "processor_clearing", amountMinor: netMinor, currency: c },
{ accountId: "processing_fee_expense", amountMinor: ev.feeMinor, currency: c },
{ accountId: "revenue", amountMinor: -ev.grossMinor, currency: c },
],
};
}
if (ev.type === "refund") {
return {
idempotencyKey: `processor:${ev.id}`,
effectiveDate: ev.date,
sourceType: "processor_refund",
sourceId: ev.id,
postings: [
{ accountId: "sales_returns", amountMinor: ev.refundMinor, currency: c },
{ accountId: "processor_clearing", amountMinor: -ev.refundMinor, currency: c },
],
};
}
return {
idempotencyKey: `processor:${ev.id}`,
effectiveDate: ev.date,
sourceType: "processor_payout",
sourceId: ev.id,
postings: [
{ accountId: "operating_cash", amountMinor: ev.payoutMinor, currency: c },
{ accountId: "processor_clearing", amountMinor: -ev.payoutMinor, currency: c },
],
};
}
Real-world application
High-volume SaaS, marketplaces and e-commerce platforms run an automated nightly job comparing each (processor, currency) balance from the processor’s API against SUM(postings.amount_minor) on its Processor Clearing account. When that delta is $0.00, finance knows every single charge, fee, refund, dispute and payout made it into the ledger without a single missing webhook.
Recap
- Route every card charge, fee, refund, dispute and reserve through a dedicated
Processor Clearingasset account. - Always record gross revenue and processing fee expense separately—never net them together.
- Settle bank payouts as
Dr Operating Cash / Cr Processor Clearing, matching bank statement lines one-for-one. - Ingest from the processor’s immutable balance transaction feed using idempotency keys and alert whenever clearing drifts from the processor’s live balance.
Active recall
Quick check · Test yourself
Work out each answer in your head first, then reveal the explanation and mark whether you got it right.
1A customer pays $100.00 by card and the processor deducts a $3.20 fee (2.9% + $0.30), settling $96.80 two days later. Why is booking Dr Cash $96.80 / Cr Revenue $96.80 wrong?
Show worked answer
It understates both Revenue (actually $100.00) and Payment Processing Fees (actually $3.20), and it debits Bank Cash two days before money reaches the bank—breaking bank reconciliation.
2Your Processor Clearing account holds +$96.80 from a captured charge. You issue a $50.00 customer refund (the processor keeps the original fee), and the processor pays out the remaining $46.80 to your bank. What is the clearing balance after payout?
Show worked answer
$0.00. Clearing started at +$96.80 Dr, decreased by $50.00 Cr on the refund (to +$46.80 Dr), and decreased by $46.80 Cr on the bank payout—matching the processor balance transaction log exactly.
3How should a $1,000 rolling reserve withheld by a payment processor for 90 days be recorded?
Show worked answer
Reclassify it between two asset accounts: Dr Processor Reserve Held $1,000, Cr Processor Clearing $1,000. It is restricted cash owed back to you, not an expense.
Key terms in this lesson
Lesson 15 of 16 · Accounting for Developers
Finished this lesson?
Mark it complete to track your progress through the course. Progress is saved in this browser only.
Previous lesson: Designing a Tax Calculation Engine for Ledgers
Connected lessons
Educational content only—not accounting, tax, legal or investment advice. See our editorial policy or report an error via our corrections policy.