Inspiration

E-commerce merchants have a silver bullet against chargebacks: physical FedEx tracking numbers. If a buyer claims they didn't receive their shoes, the merchant uploads the tracking ID to PayPal and wins.

But there is no FedEx tracking number for digital services like software development or UI design. When a client pays a freelancer $3,000 via PayPal and later files a MERCHANDISE_OR_SERVICE_NOT_AS_DESCRIBED (SNAD) dispute, both sides resort to uploading messy screenshots while human agents guess who is lying.

We built AegisPay to be the "Digital FedEx Tracking Number + AI Referee" for B2B services. It is an end-to-end autonomous escrow and chargeback defense shield that secures trust before, during, and after a digital PayPal transaction.

What it does

AegisPay manages the entire lifecycle of a digital contract across 4 stages using the "One Workspace, Two Modes" UI pattern:

  1. Scope-to-Escrow: A client pastes a project brief. Our AI parses it into strict milestones inside a Bryntum visual timeline and locks the funds via the @paypal/agent-toolkit (create_invoice, create_order).
  2. AI Proof-of-Work (The Happy Path): When the developer submits a GitHub PR and live preview URL, our Gemini 2.5 Flash agent inspects the code against the acceptance criteria. If it passes, AegisPay generates a cryptographic SHA-256 "Proof-of-Work Receipt," registers it via PayPal’s Shipment Tracking API (carrier: DIGITAL), and settles the milestone.
  3. Pre-Dispute AI Mediation: If the work only meets 75% of the spec, our Groq Mediator Agent intervenes before a formal chargeback is filed. It calculates the Expected Value (EV) of fighting a dispute vs. settling early using the following model: $$ EV_{fight} = (P_{win} \times \text{Amount}) - \text{DisputeFee} - \text{OpsCost} $$ It then proposes a "Bounded Autonomy" 1-click partial settlement via the PayPal Refunds API (create_refund).
  4. Autonomous Chargeback Defense: If a malicious client files a Sandbox Dispute, a PayPal Webhook (CUSTOMER.DISPUTE.CREATED) wakes our Defense Agent. It pulls the Stage 2 cryptographic receipt, generates a structured PDF dossier (pdf-lib), and autonomously submits it to the PayPal Customer Disputes API (/v1/customer/disputes/{id}/provide-evidence), updating the case status live in our AG Grid Financial Command Center.

How we built it

  • Frontend: Next.js (App Router), TypeScript, Tailwind CSS, and Shadcn UI.
  • Workspace UI: We used AG Grid for the high-density financial dispute ledger and Bryntum for the interactive milestone delivery timeline.
  • Backend & Database: Next.js API routes securely interacting with a Supabase PostgreSQL database to store SHA-256 verification receipts and PDF evidence logs.
  • AI & Orchestration: We utilized Gemini 2.5 Flash for multimodal code/UI verification and Groq (llama-3.3-70b-versatile) for blazing-fast inference during autonomous mediation.
  • PayPal Integration: We heavily utilized @paypal/agent-toolkit (Invoices, Orders, Shipment) alongside direct REST calls to the robust /v1/customer/disputes endpoints, all tested inside the live PayPal Sandbox.

Challenges we ran into

  • State Syncing with PayPal APIs: We initially struggled with PayPal's Invoicing API keeping invoices in a DRAFT state, which prevented the public payer-view URLs from working. We engineered a solution to automatically fire the send_invoice action right after creation to activate the live Sandbox URL and QR codes.
  • Strict Security Tooling: While pushing to GitHub, GitHub's Push Protection caught our Supabase and Gemini keys. We had to rewrite our Git history, properly utilize .env.local, and transition our automated test suite to read purely from environment variables.
  • Sponsor Integration Conflicts: We encountered an AG Grid #239 theming error and #200 module registry error when trying to merge their latest v36 Turbopack-compatible modules with Next.js 15, which required surgically adjusting how we registered AllCommunityModule at the root.

Accomplishments that we're proud of

  • We successfully combined two highly complex workflows (freelance escrow & merchant chargeback defense) into one cohesive, uncluttered UI without overwhelming the user.
  • We completely automated the tedious multipart/form-data evidence submission process for PayPal Disputes, reducing a 2-hour manual process to a 4-second API payload.

What we learned

  • Deep-dived into the PayPal Sandbox ecosystem, specifically how the Dispute Simulator and webhooks interact with live merchant orders.
  • Learned how to structure multi-agent workflows where one AI's output (Verification Agent) acts as the exact deterministic input for another (Defense Agent).

What's next for AegisPay

We plan to integrate PayPal Payouts to handle automated commission splitting for multi-vendor digital agencies, and implement a decentralized storage layer (like IPFS) to make the Proof-of-Work receipts completely immutable.

Built With

Share this project:

Updates

Submission history