Skip to content

Lesson 9 of 9 · 30m

Reconciliation, Refunds, Disputes, and Financial Close

Reconcile application orders against provider balance transactions, design refund-safe ledgers, handle disputes, and give finance a close process they can trust.

Payment integration is not finished when the customer can pay. It is finished when finance can explain where every cent went. Reconciliation is the daily discipline of matching your orders, provider charges, fees, payouts, refunds, and disputes. Teams skip it because the dashboard looks plausible. Six months later nobody knows whether revenue, credits issued, and cash received ever agreed.

Your order total is not cash received

A card payment may have fees, cross-border adjustments, currency conversion, partial capture, refunds, or dispute withdrawals. Stripe represents money movement through charges, balance transactions, fees, and payouts. PayPal has capture, fee, settlement, and withdrawal records with its own reporting shape. Reconcile at the ledger level, not merely order count.

gross amount       what customer paid
processor fee      what provider charged
net amount         gross minus fee and adjustments
refunds            money returned, sometimes fees retained
disputes           temporary withdrawal plus possible dispute fee
payout             batch deposited to your bank

An order can be paid while no payout exists yet. A payout can contain many unrelated payments. A refund can happen long after fulfillment. These are normal states.

Build an internal ledger

Even if the provider dashboard is excellent, your application needs accounting-oriented records:

CREATE TABLE payment_ledger_entries (
    id BIGSERIAL PRIMARY KEY,
    order_id BIGINT,
    entry_type TEXT NOT NULL,
    amount_minor BIGINT NOT NULL,
    currency CHAR(3) NOT NULL,
    provider TEXT,
    provider_reference TEXT,
    reference TEXT NOT NULL UNIQUE,
    created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);

Record gross payment, processor fee if imported, refund, dispute adjustment, entitlement credit, and manual correction separately. Do not mutate history. Corrections should be reversing entries, not edited rows.

Reconcile in both directions

There are two equally important questions:

Do all local paid orders exist and match at the provider?
Do all provider payments/refunds map back to local orders?

The second catches orphan payments, dashboard-created refunds, accidental API operations, and fraud. Match by provider object ID first, metadata second, amount/customer/time heuristics last. Heuristic matches should be flagged for review rather than silently accepted.

Refunds are state transitions too

A refund can be full or partial, pending or failed, and sometimes initiated outside your application. Make refund requests idempotent:

refund = stripe.Refund.create(
    payment_intent=order.payment_intent_id,
    amount=refund.amount_minor,
    metadata={"refund_id": str(refund.id)},
    idempotency_key=f"refund-{refund.id}-attempt-{refund.attempt}",
)

Do not automatically remove access before refund confirmation if the product policy requires completed refund state. Conversely, do not leave unlimited access indefinitely because nobody handled refund failure. Policy belongs in the state machine.

Disputes need evidence and deadlines

Chargebacks and PayPal disputes are operational workflows, not just balance adjustments. Keep customer communications, delivery records, access logs, refund policy acceptance, and provider object IDs retrievable. Evidence deadlines are short. A webhook for dispute creation should open an internal case immediately rather than merely changing a payment status.

Financial close needs boring reports

Finance usually wants daily or monthly answers:

gross sales by currency
refunds and disputes by currency
processor fees
net provider settlement
payouts grouped by provider batch
unmatched provider movements
stuck or aging payment states

Produce these from immutable ledger data and provider reconciliation imports. Do not calculate revenue from the mutable current status of orders.

Field notes

  • Store amount sign and currency explicitly. Never infer refunds from negative amounts alone.
  • Fees and settlement timing differ by payment method; aggregate reports can hide reconciliation errors.
  • Dashboard-initiated refunds still need to enter your internal workflow through webhooks or reconciliation.
  • Currency conversion introduces rate and timing differences; do not expect exact equality across naive reports.
  • Rounding belongs at ledger boundaries using defined minor-unit rules, not ad hoc floating-point arithmetic.
  • Reconciliation mismatches are normal. The failure is having no queue, owner, or audit trail for resolving them.

Was this lesson helpful?

Sign in to rate