What it does

PHALANX is a dispute-defense workbench for a small PayPal merchant. When a dispute arrives (webhook, or the pull-sync fallback that polls PayPal's Disputes API), it pulls the dispute and transaction, assembles the merchant's evidence, and runs a deterministic 0–100 checklist — tracking DELIVERED (30), delivery verifiable (15), signature (15), merchant log (25), invoice/terms (15). A 6-stage swarm then works the case: Hound extracts evidence, Prosecutor drafts the rebuttal, Red-Team attacks the draft (up to 3 iterations), three jurors (evidence, policy, buyer-sympathy — quorum 2/3) audit the gaps, Judge frames the issue, Arbiter routes the verdict: 75+ CONTEST, 35–74 OFFER, under 35 CONCEDE. Nothing executes without human approval — the merchant approves exactly one PayPal action: provide-evidence, make-offer, or accept-claim. It's free and self-hosted (BYOK free-tier key), and the checklist score is a routing signal, never a win probability.

Three seeded demo cases show all three routes — including the demo moment: the $210 case flips from fight to offer after Red-Team finds the gap.

How I built it

Next.js + TypeScript on Vercel; PayPal Disputes REST API and Sandbox; Qwen3-30B-A3B-Instruct-2507 via Nebius Token Factory (OpenAI-compatible) — the model drafts wording and deliberation text only, the deterministic scorer decides every verdict; AG Grid for the dispute queue; pdf-lib for the 5-page evidence dossier. Architecture and design input came from Gemini; I built and verified everything against the live code and the live Sandbox.

Challenges I ran into

PayPal Sandbox recorded zero webhook events in 30 days with correct config, so I built a pull-sync fallback that reads disputes straight from the REST API. PayPal returns snake_case HATEOAS rels (accept_claim) while the code compared kebab-case, so approvals were refused until I normalized them. And accept-claim lists PARTIAL_REFUND first — which needs a refund_amount the tool never sends — so PayPal returned 400 until the executor preferred REFUND. PayPal's own error bodies with debug IDs pointed at each fix.

Accomplishments that I'm proud of

End-to-end proof on real Sandbox disputes: three live disputes ran through swarm → approve → execute, and the Resolution Center confirmed all three closed "Refunded" in the buyer's favour. The tool conceded all three correctly — they were bare Send Money payments with zero evidence, so there was nothing to contest. Seeded runs score 85 / 60 / 0 across the three routes, with 232 unit checks and 84 negative tests green.

What I learned

That a demo is only honest if the pipeline is real: webhooks, evidence, and execution all had to work against live PayPal before any claim counted. And that the most valuable engineering was the guardrails — the approval gate, the deterministic scorer, and refusing to invent evidence the merchant doesn't have.

What's next

Merchant evidence ingestion that feeds the checklist directly (tracking receipts, PODs, and logs raising a bare 15 to 60 or 85), cross-verification of attachments against the PayPal record, and a pre-concede hold that stops a winnable case from being refunded just because the evidence hasn't arrived yet.

Built With

  • ag-grid
  • nebius-token-factory
  • next.js
  • node.js
  • paypal-rest-api
  • paypal-sandbox
  • pdf-lib
  • qwen3-30b
  • react
  • typescript
  • vercel
  • webhook
Share this project:

Updates

Submission history