Technical guide · Embedded payments and ledger design

How Vertical SaaS Platforms Match Embedded Payments and a Postgres Ledger to QuickBooks or Xero

Why your merchant wallet table, Stripe Connect and your books drift apart, and the three-way matching design that keeps them at a $0.00 difference.

By Brian Kelly, Founder of Kellcat · 20+ years in accounting, 10+ years as a software engineer · Updated December 2026 · About 7 minutes

All amounts and IDs are illustrative, built from Stripe test-mode examples. Your Stripe pricing and setup may differ.

1. Three records that never agree on their own

When your software starts taking payments for its customers, the same dollar shows up in three places:

  • Your product database (Postgres): merchant wallet balances, pending payouts, your fee on each sale and any holds.
  • Stripe Connect: the full charge, your fee, Stripe's fees, reserves and batched payouts to bank accounts.
  • Your books (QuickBooks Online, Xero or Puzzle): usually just the bank deposits. That's how customer money gets booked as your revenue, and how Stripe Clearing ends the month with a balance nobody can explain.

Each record is right on its own terms. The work is making them agree.

2. One accounting rule for every Stripe event

Example: a customer pays a merchant $1,000 through your software. You keep a 5% platform fee ($50.00). Stripe's fee is $29.30 (2.9% + 30¢ on a US card at standard pricing), and your platform pays it. The merchant is owed $950.00. In this example you hold the money and transfer it later (separate charges and transfers).

Stripe event (trimmed, test mode)

{
  "id": "evt_test_...",
  "type": "charge.succeeded",
  "data": { "object": {
    "id": "ch_test_...",
    "amount": 100000,
    "currency": "usd",
    "balance_transaction": "txn_test_...",
    "metadata": { "internal_merchant_id": "m_1042", "order_id": "ord_88213" }
  } }
}

Your product ledger (Postgres)

INSERT INTO ledger_entries (event_id, merchant_id, entry_type, amount_cents)
VALUES
  ('evt_test_...', 'm_1042', 'sale_gross',    100000),
  ('evt_test_...', 'm_1042', 'platform_fee',   -5000),
  ('evt_test_...', 'm_1042', 'wallet_credit',  95000);

Your books

Stripe eventDebitCreditAmount
charge.succeededStripe ClearingMerchant Payable (owed to merchant)$950.00
Stripe ClearingPlatform Fee Revenue$50.00
Stripe fee (on the balance transaction)Payment Processing FeesStripe Clearing$29.30
transfer.created (to the merchant's connected account)Merchant PayableStripe Clearing$950.00
payout.paid (to your bank)Operating BankStripe Clearing$20.70

The proof

  • Stripe Clearing for this sale: $1,000.00 − $29.30 − $950.00 − $20.70 = $0.00
  • Each line balances: every debit has an equal credit.
  • Merchant money never touches your revenue. Only the $50.00 fee does.

Destination charges work differently. Stripe moves the full amount to the merchant's connected account right away and sends your fee back to you, and your platform still pays the Stripe fee. The merchant's money isn't on your books, so your product wallets should match the connected account balances in Stripe, not your Merchant Payable.

3. Three edge cases that break simple integrations

Refunds and disputes after the merchant was paid

With destination charges and separate charges and transfers, Stripe takes disputed amounts and dispute fees from your platform's balance, not the merchant's. If the $950 already went to the merchant, book it as Due from Merchant (money the merchant owes you) until you reverse the transfer or take it from a future payout. It is not an expense yet.

Reserves and held money

Money Stripe holds back is not cash you can spend. Keep it in its own account (for example, Stripe Reserve), so your runway never counts it.

Month-end cutoff

A sale captured on Nov 30 at 11:58 PM UTC may not pay out until Dec 2. Stripe Clearing carries that money across the month-end. On Nov 30, Stripe Clearing should equal Stripe's ending balance for Nov 30 to the cent.

4. The fields to save on every money event

Give this list to whoever builds your payments service, so accounting never has to guess:

  • stripe_event_id (so the same event is never booked twice)
  • payment_intent_id and charge_id
  • balance_transaction_id (where Stripe's fee lives)
  • transfer_id and payout_id
  • connected_account_id (acct_...)
  • internal_merchant_id (your Postgres key)
  • gross_amount, platform_fee_amount and stripe_fee_amount
  • currency and event_timestamp_utc

5. A daily check before month-end

Run this after your daily sync from QuickBooks or Xero, and flag any difference above $0.00:

-- Daily check: product wallets and Stripe vs. the books (illustrative)
WITH product AS (
  SELECT SUM(balance_cents) / 100.0 AS wallets_held
  FROM merchant_wallets
  WHERE funds_location = 'platform'          -- money you still hold
),
books AS (
  SELECT
    MAX(CASE WHEN account = 'Merchant Payable' THEN balance END) AS merchant_payable,
    MAX(CASE WHEN account = 'Stripe Clearing'  THEN balance END) AS stripe_clearing
  FROM gl_balances
  WHERE as_of = CURRENT_DATE
),
stripe AS (
  SELECT (available_cents + pending_cents) / 100.0 AS stripe_balance
  FROM stripe_balance_snapshots
  WHERE as_of = CURRENT_DATE
)
SELECT
  product.wallets_held - books.merchant_payable AS wallet_difference,
  stripe.stripe_balance - books.stripe_clearing AS clearing_difference
FROM product, books, stripe;
-- Both differences should be 0.00.

6. Where Kellcat stops

Whether payment revenue is reported gross or net (principal or agent), sales tax, and money transmission licensing stay with your CPA or tax pro and your attorney. Kellcat designs the accounting rules, maps every Stripe event to your books and proves the numbers match.

Next steps

Building now, or already live on Stripe Connect? Start where you are.