Inspiration
In India, micro and small exporters and logistics firms carry the cost of late payment. Delayed-payment applications on the government's MSME Samadhaan portal reportedly total over ₹22,000 crore. Goods worth lakhs ship on an email thread; delivery is hard to prove; disputes are won by whoever has better paperwork; and nobody knows who actually pays on time. A payment platform processes the transaction, but the business relationship around it stays unverifiable. We wanted PayPal and AI to make that relationship provable.
What it does
Proof2Pay gives every shipment a verifiable contract, a documented delivery, a measurable payment obligation and an auditable outcome. Five AI agents recommend; people approve; PayPal settles.
-Contract AI fills a fixed, human-written clause library from the shipment terms, flags risks and explains every clause in plain language. A legal rule (MSMED Act, section 15) blocks illegal credit terms: try 60 days and acceptance is refused. Both parties accept the same SHA-256 hash; the AI never signs. A simulated cargo insurance quote is bound on acceptance.
- Delivery AI reads the signed proof of delivery and photos with Gemini vision. Deterministic rules match it against the contract (consignee, count, condition, date), and it flags discrepancies such as a dented carton.
- Payment AI proposes the PayPal invoice, due 30 days from acceptance, and nothing goes to PayPal until a finance manager approves. It runs a credit clock with statutory interest (3× the RBI bank rate, compounded monthly), drafts escalating reminders, and assembles an MSME evidence package for overdue invoices (clearly marked "not a government filing").
- Resolution AI weighs a refund request against the contract and delivery evidence. In the demo it recommends $300 of the $400 asked (the dented carton's contract value), citing its sources. On approval, PayPal executes the refund and a simulated insurance claim follows. For a PayPal dispute it builds a case file: timeline, contradictions, missing evidence and a response, sent only after a person approves.
- Trust AI builds payer and carrier profiles only from verified events, with confidence bands. Nobody is ever labelled a defaulter or a fraud.
- Command center: managers ask plain-English questions; Gemini turns them into read-only queries and AG Grid shows the answer.
- Audit trail: every AI decision, human approval and PayPal event is recorded with its reasoning, model and evidence.
Three end-to-end stories run on the live site: a successful shipment paid through PayPal, an Indian domestic invoice 28 days overdue, and damaged goods leading to a refund and a dispute.
How we built it
- PayPal REST APIs (sandbox): OAuth; Invoicing v2 (create, send, get, remind); Payments v2 refunds on the invoice's capture; Shipment Tracking (tracking attached to the PayPal transaction once paid); Disputes v1 (list, get, provide-evidence, with send-message as fallback); Webhooks with signature verification and registration through the API. An invoice is marked paid only from PayPal's own record, never from our UI.
- AI: Google Gemini over REST. Every output is validated against a zod schema. A chain of free models with automatic fallback keeps it running, and if every model fails the app shows clearly labelled sample output rather than inventing anything silently. Gemini vision reads delivery documents.
- Design principle: the model extracts, explains, drafts and recommends. Decisions with legal or financial weight (MSMED caps and interest, delivery matching, trust metrics, insurance decisions) are made by unit-tested deterministic code. Every movement of money passes an approval queue.
- Stack: Next.js 15 and TypeScript; Prisma on Neon Postgres; AG Grid Community for the receivables ledger, audit trail and command center; hosted on Render. Covered by 40 unit tests and CI. The whole stack runs at zero cost.
Challenges we ran into
- PayPal does not settle domestic payments between Indian businesses. Cross-border trade runs fully on PayPal; domestic trade keeps the same contracts, delivery proof and credit clock, with payment entered as a manually verified record.
- Gemini's free tier was often overloaded, so we built the model chain with fallback, a 5-minute skip for failing models, and honest labelling.
- Sandbox disputes are hard to open on demand and sandbox webhooks are unreliable. We added a labelled dispute replay and a "Sync from PayPal" check that reads PayPal's own invoice record.
- We had to keep the AI useful without letting it decide things it shouldn't.
Accomplishments we're proud of
- A real PayPal sandbox money flow, end to end: AI-proposed invoice → human approval → the buyer pays on PayPal's checkout → payment confirmed from PayPal → tracking attached → AI-recommended partial refund executed through PayPal.
- Human approval on every movement of money, and a complete audit trail of every agent decision.
- A statutory interest engine checked against the MSMED Act (sections 15 and 16).
What we learned
Agents are most valuable when they prepare decisions and paperwork (the contract review, the evidence pack, the reminder) while people take the irreversible steps. For trust, labelling what is simulated matters as much as the features.
What's next
Real cargo insurers; GST and Udyam verification; filing from the evidence package through MSME Samadhaan and ODR; PayPal Agent Toolkit tools for the payment agent; and settling Indian domestic B2B trade once PayPal can. By then, the contracts, delivery proof and payment histories are already on record.
Built With
- ag-grid
- google-gemini
- neon
- nextjs
- paypal
- paypal-rest-api
- postgresql
- prisma
- react
- render
- tailwindcss
- typescript