Inspiration

I worked on quote-to-cash systems for 15+ B2B clients, and the same problem came up at almost every one: the work after the deal closes is manual. Someone builds the invoice by hand from a quote or PO, someone else keeps a spreadsheet of who is late, reminders go out when somebody remembers, and payments get matched to invoices at month end. Small businesses feel this most. They wait weeks for cash they have already earned because nobody has time to chase it.

PayPal already holds the invoices, the payments, the fees and the disputes. I wanted to see how much of the receivables job an AI agent could do on top of that data while a human keeps control of anything that moves money.

What it does

Settle runs the receivables loop on PayPal:

  1. Quote to invoice. Paste a scope, quote, PO or email thread. AI extracts the customer, line items, terms and PO reference, flags anything ambiguous, and you create and send the PayPal invoice in one click.
  2. Receivables. A live ledger of every PayPal invoice with balance, days late, collection stage and whether the customer has opened it, plus outstanding, overdue, an aging chart and DSO:

$$\text{DSO} = \frac{\text{open receivables}}{\text{amount billed in the last 90 days}} \times 90$$

  1. Collections. A daily queue of invoices that are overdue or due within 3 days and haven't been reminded in the last 5 days, ranked by

$$\text{priority} = \text{balance} \times \left(1 + \frac{\text{days late}}{30}\right) \times \begin{cases} 1.2 & \text{if the invoice was never opened} \ 1 & \text{otherwise} \end{cases}$$

Unopened invoices get a boost because they were probably missed, not ignored. AI drafts each reminder in a tone that escalates with lateness (friendly, neutral, firm, final) and adjusts for partial payments. You approve it and it goes out through PayPal's reminder API.

  1. Reconciliation. Every payment is matched to its invoice, with the PayPal fee and net to bank. A small gap is treated as a short pay (bank or FX charges) and can be invoiced as a balance in one click. A larger gap is a partial payment and stays in collections. PayPal receipts not tied to any invoice show up as unapplied cash.
  2. Disputes. AI reads the buyer's claim and the invoice behind it, recommends accepting, refunding part of the payment or contesting, and drafts the evidence and the buyer message for you to edit and submit.
  3. Revenue recognition (ASC 606 / IFRS 15). AI classifies each invoice line as earned at a point in time (a build, hours already worked) or over a service period (hosting, a retainer). The schedule gives every full month the same amount $M$. A partial first or last month gets

$$M \times \frac{\text{days covered in that month}}{\text{days in that month}}$$

and the last month absorbs rounding so the schedule always sums to the line amount. A monthly waterfall shows billed, collected, recognized, deferred and unbilled revenue, exportable as CSV.

  1. AR agent. Ask "who should I chase today?", "any short pays?" or "remind everyone more than 14 days late". The agent reads invoices, transactions and disputes through the PayPal Agent Toolkit plus Settle's own AR, reconciliation and revenue tools. Every write (send, remind, record payment, cancel) stops for your approval.
  2. Live updates. Signature-verified PayPal webhooks for invoice and dispute events feed a live activity log and refresh the ledger.

How I built it

  • Next.js 16 on Vercel, TypeScript throughout.
  • PayPal: Invoicing API v2 (create, send, remind, record payment, cancel), Payments (capture fees and net), Transaction Search, Disputes API and Webhooks, plus the PayPal Agent Toolkit for the agent's tools.
  • AI: AI SDK 7 with Claude. Haiku 5.5 runs the agent loop and document extraction, where speed matters. Sonnet 5.5 handles the accounting judgment calls (revenue classification and dispute review), where a wrong answer is expensive. Extraction, reminders and dispute reviews use structured output with schemas, so the UI never parses free text.
  • AG Grid for the receivables ledger and the editable revenue grid.

The key design rule: AI reads and writes, deterministic code decides. Collection stages, aging, the queue ranking, short pay vs. partial payment, and all of the revenue math are plain functions with no model involved. The model extracts, classifies, drafts and explains around them. Every write to PayPal needs a human click, either a button in the UI or an approval card in the agent chat, and approvals are signed on the server so a client can't forge one.

Challenges I ran into

  • The Agent Toolkit targets an older AI SDK. Its adapter is built for AI SDK v4, so I re-wrapped every toolkit tool for AI SDK 7's tool and approval model.
  • Sandbox behavior differs from the docs. A few examples:
    • Sending an invoice without notifying the customer leaves it in UNPAID rather than SENT.
    • Recorded overpayments are rejected.
    • The conditional-rules endpoint returns 500, so I dropped early-payment discounts.
    • Invoices can't be sent to India-based sandbox buyers.
    • There is no API for reminder history, so Settle tracks reminders itself to avoid chasing the same customer twice in 5 days.
  • Making approval safe. Letting an agent call write tools is easy; making sure it can't act without a real human decision isn't. I split the tools into read tools that run freely and write tools that pause the loop, and the approval is checked server-side before PayPal is called.
  • Consistent revenue classification. Early prompts flip-flopped on lines like "setup and first month of hosting". Worked examples in the prompt plus caching per line made the classification repeatable: the same answers across three cold runs.

Accomplishments that I'm proud of

Settle runs end to end on real PayPal sandbox data rather than mocks. It creates and sends invoices, sends reminders, matches a webhook-confirmed payment in reconciliation, and shows a real sandbox dispute. A seeded demo book of 10 invoices covers every collection stage, including a partial payment and a short pay, and judges can reset it from the UI.

What I learned

  • In finance workflows, the AI is most useful at the edges: reading messy input, writing reminders, explaining a recommendation. The ledger logic itself should stay boring and testable.
  • Human-in-the-loop has to be enforced in the architecture, not just shown in the UI.
  • Matching the model to the task paid off: a fast model for the conversational loop and a stronger one for accounting judgment.

What's next for Settle

  • A persistent store so a daily collections autopilot can queue the day's reminders for one-click approval.
  • Early-payment discounts once PayPal's conditional rules work in the sandbox.
  • Multi-currency support and journal-entry export to accounting systems.

Built With

Share this project:

Updates

Submission history