Inspiration

Picture a parts maker in Aba (an illustrative case, not a customer) shipping to a buyer in Texas on 60-day terms and then waiting two months to be paid. A funder could pay her now, but the funder's risk is the paperwork. In January 2026 PayPal went live in Nigeria through Paga, so the payment rail is arriving. What's missing is a desk that can say yes to good paper and no to bad paper, quickly and with reasons. The customer is the funder, and the product is the refusal.

What it does

  • Checks before listing: nothing is offered for funding until its delivery evidence passes eleven deterministic checks (E00–E10): consignee against the debtor, the carrier's tracking-number format, delivery inside the invoice window, a signature, duplicates and more.
  • Refuses with a reason: a refused invoice leads with the decision, the rule, the line of the document that failed and what the seller can do. A-1043 ($48,000) is refused because the delivery was signed for Halcyon Logistics, not the debtor Halcyon Retail Group.
  • Accepts corrections without rewriting history: the corrected proof comes back as A-1043-R2, clears the eleven checks (E00 by the sandbox override, shown on the page) and prices at a $36,428.01 advance. The original refusal stands.
  • Prices from the record: the debtor score and band set the rate (A-1042: score 78, band B, 14.0% a year).
  • Funds on PayPal: on the funder view the position (commit $493.01, and what comes back at maturity) sits beside the Fund button. Fund creates one Orders v2 order with two payees. The funder approves once in PayPal's checkout, and the capture pays $489.76 to the seller and $3.25 to the platform. The settlement book balances.
  • Proves itself in public: /status re-walks the hash-chained audit log on every load and shows the counts with no login.

How we built it

  • Runtime: Node.js 24 running TypeScript directly, with the built-in node:sqlite. There is no framework, and pages are server-rendered HTML.
  • PayPal: POST /v1/oauth2/token, POST /v2/checkout/orders (one purchase unit per payee), GET /v2/checkout/orders/{id}, POST /v2/checkout/orders/{id}/capture, POST /v1/notifications/verify-webhook-signature, and optionally GET /v2/payments/captures/{id} and GET /v1/reporting/transactions for debtor history (RAIL_HISTORY=1). The client refuses any host other than api-m.sandbox.paypal.com.
  • AI: any OpenAI-compatible chat endpoint. Photos are read by two vision models from different families (Gemini and NVIDIA Nemotron in the recorded run). Text documents are read by a model plus a deterministic parser. When the readers disagree, the field's confidence is halved, and anything under 70% counts as unreadable. The model never sees the verdict.
  • Rules: rules/checks.yaml, applied by src/gate.ts, with every decision hashed into the audit chain.
  • Hosting: Docker on Render's free plan, from render.yaml. The container seeds the same synthetic book on every start, and judges read it as guests (DEMO_PUBLIC_READ=1).

Challenges we ran into

  • Capture responses are not the order: a capture can come back without payee, and GET /v2/payments/captures/{id} reports the payer. Settlement reads payee and amount from the order's purchase units.
  • Multi-payee needs a US platform account: a Nigerian business account was refused at checkout (PAYEE_ACCOUNT_LOCKED_OR_CLOSED). That narrows the story, and the write-up says so.
  • Seller Protection in the sandbox: PayPal returns UNKNOWN for the sandbox account, so check E00 is overridden in the sandbox only, and every page shows it.
  • Keeping the AI out of the decision: a smudged photo (A-1054) gave both readers the same nine-digit tracking number. A FedEx number has 12, 15 or 20 digits, so rule E02 refuses it, whatever the models think.

Accomplishments that we're proud of

  • Live sandbox run: funding NW-2277 ran end to end on 9 Nov 2026 (order 4YS26797M70171205, one capture per payee).
  • Refusals are explained: 626 of the 1,007 invoices are refused, and each refusal names its reason and the check that raised it.
  • Tests: 175, all offline.

What we learned

The hardest part of trade finance isn't the payment, it's deciding which paper deserves one. An AI that reads well is useful only when something it can't argue with makes the decision.

What's next for The Discount Window

  • Real paperwork: test on redacted documents from Nigerian exporters.
  • Paga-linked payees: test them once PayPal business acceptance through Paga opens.
  • More carriers: add tracking-number rules for more carriers.
  • A pilot: run one with a single funder or export-finance desk.

Judge in 3 clicks

No login is needed to read. The free instance may take up to a minute to wake.

  1. https://the-discount-window.onrender.com/n/A-1043: refused with CONSIGNEE_MISMATCH. Proves: the desk refuses before any money moves, with the rule, the failing line and a fix.
  2. https://the-discount-window.onrender.com/n/A-1054: the phone photo and both AI readers' answers, refused by rule E02. Proves: the AI reads and the rules decide.
  3. https://the-discount-window.onrender.com/n/NW-2277?view=funder: the funder's position beside Fund (one Orders v2 order, two payees). Proves: settlement where the platform never holds the money.

Also worth a click: /n/A-1043-R2 (the corrected proof, priced), /archive (626 refusals by reason) and /status (the audit chain re-checked live).

Summary

Funders will pay exporters early against their invoices, but only if the paperwork is true. Goods that never arrived, a delivery signed for the wrong company, the same invoice funded twice: checking for these by hand doesn't scale, so small exporters mostly go unfunded. The Discount Window is a desk that checks the paper first. A seller files an invoice and its proof of delivery. Two AI readers pull out the fields (two vision models from different families for a photo, a model plus a deterministic parser for text), and eleven fixed rules decide. Each invoice is either refused, with the rule, the failing line and a fix the seller can act on, or priced from the desk's own record with the debtor. Funding runs on PayPal Orders v2 in the sandbox: one order with two purchase units, one approval by the funder, and a capture that pays the seller's advance and the platform's fee separately, so the platform never holds the money. Webhooks are signature-verified before they can change a position. It is a sandbox prototype with a synthetic book of 1,007 invoices, 175 tests and no users yet.

Built With

Share this project:

Updates

Submission history