Inspiration
A huge share of small-business commerce never touches a storefront. Ceramicists, florists, bakers and resellers take orders in WhatsApp, Instagram DMs, WeChat and email. Every order gets retyped into an invoice by hand. Every evening goes to scrolling notifications to work out who has actually paid, and fake "payment sent" screenshots are a well-known scam against these sellers. We wanted the shortest possible path from a messy conversation to money received, with PayPal doing the money part.
What it does
Paste2Pay is an AI receivables agent:
- Reads anything. You paste a buyer chat, an emailed order or the OCR text of a paper invoice. The AI extracts the customer, email, line items, quantities, unit prices, currency, shipping, tax, payment terms and notes.
- Checks itself. It works out whether "x4 – 180.00" is a unit price or a line total by testing both readings against the stated total. It recomputes amounts exactly as PayPal will and flags currency restrictions. It refuses to bill when a price is missing.
- Decides and acts on PayPal. If there is an email, it creates and sends a PayPal invoice (Invoicing v2). If the buyer is only in a chat, it creates a PayPal Orders v2 checkout link to paste back into the conversation.
- Tracks to paid. It syncs status from PayPal, captures approved orders automatically when the buyer returns, flags underpayments and drafts a reminder with the pay link.
- Reconciles. You paste bank-statement lines or payment notices. The AI matches each to an open bill by reference, amount and payer name, records off-PayPal payments on the PayPal invoice through the API, detects duplicates and flags "payment received" messages that PayPal's API contradicts.
- Shows its work. Every AI step and every PayPal API call, with HTTP status and debug_id, appears in a live agent trace. ## How we built it
- PayPal REST APIs in the sandbox: OAuth 2.0 client credentials (token cached); Orders v2 create with itemised breakdown, experience_context, PayPal-Request-Id idempotency, get and capture; Invoicing v2 generate-next-invoice-number, create, send, get, record payment. A mock twin returns identical JSON shapes so judges can run with zero setup.
- AI: pluggable extraction layer — deterministic offline engine plus adapter for any OpenAI-compatible model (OpenAI, OpenRouter, local Ollama), with fallback and a shared self-check that validates every result before any money request is created.
- App: Python standard library only (http.server + single-page vanilla-JS UI) plus a CLI demo.
- Tests: 36 unit and integration tests. ## Challenges we ran into
- Unit price vs line total ambiguity, solved by searching interpretations that match the stated total.
- Matching PayPal's arithmetic for item_total, tax_total and per-item tax.
- Keeping the mock faithful to the sandbox lifecycles. ## Accomplishments that we're proud of
- From a paste to a sent PayPal invoice in one click, every step explained.
- The fake-payment-notice check that never trusts a pasted message over the PayPal API.
- Runs anywhere in one command, no dependencies, no keys needed to try it. ## What we learned
- Orders v2 and Invoicing v2 complement each other: invoices for known customers, checkout links for chat buyers.
- Keeping AI output behind a deterministic validator makes an agent safe to let near money. ## What's next for Paste2Pay PayPal webhooks instead of polling; WhatsApp/Telegram bot front-end; direct image OCR; PayPal Transaction Search for statement import; multi-merchant hosting.
Built With
- html5
- javascript
- ollama
- openai
- paypal
- paypal-invoicing-v2
- paypal-orders-v2
- python
Log in or sign up for Devpost to join the conversation.