Agent Wranglers

PAY-22Recommended

Reconcile every payout

Within 2 business days of each provider payout, match it to the transactions it contains, to your ledger and to the bank statement.

How to do it

The provider pays out the net of charges, fees, refunds, disputes and currency conversion. Fetch the payout's balance transactions from the API or the provider's report. Match each one to a ledger row by provider ID, and add fee and conversion rows where they are missing. The payout amount must equal the sum of its rows to the minor unit. Then match the payout to its bank statement line. Put unmatched items on a list that a person clears every week. Match against the entries in the append-only payment ledger.

Examples

JavaScript example

async function reconcilePayout(payoutId) {
  const payout = await stripe.payouts.retrieve(payoutId)
  let matchedMinor = 0
  for await (const txn of stripe.balanceTransactions.list({ payout: payoutId, limit: 100 })) {
    if (txn.type === 'payout') continue
    await ledger.ensureEntry({ providerId: txn.id, amountMinor: txn.net, currency: txn.currency, type: txn.type })
    matchedMinor += txn.net
  }
  if (matchedMinor !== payout.amount) throw new Error(`Payout ${payoutId} is off by ${payout.amount - matchedMinor}`)
}

Python example

def reconcile_payout(payout_id: str) -> None:
    payout = stripe.Payout.retrieve(payout_id)
    matched_minor = 0
    for txn in stripe.BalanceTransaction.list(payout=payout_id, limit=100).auto_paging_iter():
        if txn.type == "payout":
            continue
        ledger.ensure_entry(provider_id=txn.id, amount_minor=txn.net, currency=txn.currency, type=txn.type)
        matched_minor += txn.net
    if matched_minor != payout.amount:
        raise ReconciliationError(f"Payout {payout_id} is off by {payout.amount - matched_minor}")

How to check

The reconciliation job fails and alerts when a payout differs from the sum of its matched rows by one minor unit or more. It also alerts when any item stays unmatched for more than 7 days.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/payments/payment-events-and-reconciliation/payout-reconciliation">Agent Wranglers payments and billing playbook</a>. In code you write, add a comment next to it with the same link.