Inspiration

Checkout has barely changed in twenty years. The merchant picks a price and you either pay it or leave. Fixed prices are one of the reasons carts get abandoned. When something goes wrong after the sale, the merchant usually learns about it from a chargeback and then has to dig up proof by hand.

We kept coming back to one question: what happens when AI agents sit on both sides of the sale? A buyer’s agent asks, “Can we get 10% off for 5 units, with expedited shipping?” The merchant’s agent answers within rules the merchant controls. PayPal closes the deal. And since the whole negotiation was recorded, the evidence for any later dispute already exists.

What it does

PayAgent AI has two sides that share one transaction.

As a buyer, you chat with an agent that negotiates for you. As a merchant, you get the Dispute Shield, an AG Grid dashboard that receives every transaction live, colour-codes it by dispute risk, and assigns an action: Auto-Defend, Manual Review or Dismiss. Each row carries an evidence packet built from the negotiation transcript.

Every purchase follows five steps:

Initiation: the buyer’s agent opens a negotiation from the cart intent. Agreement: the merchant’s agent accepts terms and a dynamic price payload is generated. Execution: the PayPal Sandbox API runs the secure checkout. Logging: the transaction is logged to the AG Grid backend. Resolution: the transaction is risk-scored and the Dispute Shield has the defense ready before any chargeback exists.

To be clear about how “agentic” it is today: the buyer agent uses an LLM (when an API key is set) to turn a natural-language request into structured intent, and the merchant agent is a policy engine that enforces the merchant’s rules. The conversation you see is generated from that decision. We chose that split on purpose, and the next section explains why.

How we built it

The client is React. The AI layer is Python (FastAPI) and handles intent parsing, negotiation and risk scoring. A Node.js (Express) backend orchestrates everything and holds the transaction state. PayPal’s sandbox handles orders, captures, webhooks and dispute evidence, and AG Grid shows live results fed by a server-sent event stream.

The language model never sets the price. It only reads what the buyer wants: units, requested discount, expedited shipping. A merchant-owned policy engine then decides what is allowed. For $N$ units at unit price $p$, with discount $d$ and shipping fee $s$:

$$P = N \cdot p \cdot (1 - d) + s, \qquad d = \min\big(d_{\text{ask}},\ d_{\text{tier}}(N) + d_{\text{loyalty}},\ 0.20\big)$$

The volume tiers are $0.05$, $0.10$ and $0.15$ at $N \ge 3$, $5$ and $10$. Loyal buyers with three or more past orders get an extra $0.03$. The $0.20$ cap is the merchant’s floor, so no prompt can push the price below it. The backend also keeps each agreed deal, so the browser only sends a deal ID and never a price. For the example in our deck, $N=5$, $p=\$30$, $d=10\%$, $s=\$15$:

$$P = 5 \cdot 30 \cdot (1 - 0.10) + 15 = \$150.00$$

That 150.00 is the amount in our POST /v2/checkout/orders call, which also sets intent: CAPTURE and custom_id: "AI-NEGOTIATED-DEAL".

After a payment is captured we score its dispute risk with a transparent, rule-based model. With $A$ the order amount in dollars, $d$ the discount in percent, $e \in {0,1}$ for expedited shipping, and $h$ a buyer-history term:

$$S = \operatorname{clamp}_{[0,100]}!\Big(8 + \min!\big(\tfrac{A}{8},\,30\big) + 1.5\,d + 12\,e + h\Big)$$

Here $h = +15$ for a first-time buyer and $h = -8$ for a loyal one. A score of $S \ge 65$ is High and gets Auto-Defend. A score from $40$ to $65$ is Medium and goes to Manual Review. Anything lower is Low and is dismissed. We kept it rule-based so a merchant can see exactly why a transaction was flagged.

The shield is proactive. At the moment of payment we compile a PROOF_OF_FULFILLMENT evidence packet with the negotiation transcript attached as notes, so a defense exists before a dispute does. In the demo the tracking number is a generated placeholder. In production it would come from the merchant’s shipping system. When a real sandbox dispute arrives by webhook, the packet is submitted through PayPal’s Disputes API, and we verify webhook signatures.

Everything is built to run in the PayPal Developer Sandbox with test credentials, and the code is MIT licensed.

Challenges we ran into

Keeping an agent from giving the store away. If a model can set prices, a persuasive buyer can talk it down. That’s why the LLM only parses intent and the policy engine decides the price. Asking for 40% off gets you the merchant’s best allowed offer, not 40%.

The PayPal redirect. Approving a payment sends the buyer away from our page and back, and in-memory state doesn’t survive that trip. We carry the deal ID through the return URL and de-duplicate captures by capture ID so one payment is never recorded twice.

Getting the dispute-evidence call right. PayPal’s evidence endpoint isn’t a plain JSON POST. It expects multipart form data with the JSON in an input field, an evidences array, and only accepts evidence while a dispute is waiting for the seller’s response. We fixed our integration after checking PayPal’s docs.

Testing disputes at all. Real disputes in the sandbox come from a buyer account opening one in the Resolution Center, and webhook simulator events carry made-up IDs that won’t match your own transactions. For anyone running the project without that setup, we added a clearly labelled Simulate chargeback button that runs the same defense logic locally.

Running without credentials. Not everyone has PayPal keys handy, so the backend has a labelled simulation mode that keeps the full flow working. Real sandbox orders switch on once keys are added.

Scope. Four services in a hackathon meant cutting a database, authentication and a full test suite. Transactions are held in memory, and the demo grid starts with a few seeded sample rows.

Accomplishments that we're proud of

A pricing design that can’t be talked out of its margin. The LLM understands, the policy decides, and the backend holds the agreed price. The headline deal prices out exactly. 5 units, 10% off and expedited shipping comes to $150.00, and that amount is what goes into the PayPal order. Evidence by default. A merchant’s defense packet is built from the negotiation itself, before any dispute. A live merchant dashboard where risk is colour-coded right in the AG Grid cells. Honesty built in. Simulated parts are labelled as simulated, and the project still runs without PayPal keys. A full stack in a hackathon: React, Python, Node.js, PayPal and AG Grid, plus an interactive browser prototype you can click through.

What we learned

The biggest lesson was about trust in agentic systems. The split that worked is that the LLM understands and a deterministic policy decides.

We also learned that dispute evidence works best as a by-product of checkout. When the negotiation is already a structured record of what the buyer agreed to, you don’t have to reconstruct it later.

On the technical side, PayPal’s Disputes API has more rules than it first appears. Evidence is multipart, it’s tied to the dispute stage, and sandbox disputes start from the buyer’s side.

What's next for PAY AGENT AI

Let the buyer and merchant agents hold a fully LLM-driven conversation, with the policy engine staying in charge of what’s allowed. Learn the risk model from real dispute outcomes instead of hand-tuned weights. Persistent storage and merchant logins. Product catalogs with merchant-defined negotiation rules. Real fulfillment data, such as carrier tracking from the merchant’s shipping system, in the evidence packet.

Built With

Share this project:

Updates

Submission history