Inspiration
Whenever you shop on an unfamiliar website, there is always a moment of hesitation: Is this seller actually legitimate? At checkout, payment buttons like PayPal, Paytm, or PhonePe handle the transaction smoothly, but they don't tell you whether the merchant behind the storefront is a physical business, a newly registered ghost domain, or a known scam.
So we built TrustMate AI as a microservice designed specifically for PayPal. Right at checkout, you see the standard PayPal button, and right beside it: PayPal with TrustMate AI. Think of it like Truecaller for payments. When you click it, a lightweight verification window opens to audit the seller in real time before PayPal ever processes the order.
How We Built It
TrustMate AI is structured as a decoupled microservice architecture designed to plug directly into checkout flows without bloating the host storefront:
- Frontend (
Next.js): Renders the lightweight checkout modal where users can search, compare offers, inspect risk signals, and trigger payment. - API Gateway & Orchestration (
FastAPI): Parses user intent (extracting product category, budget, and use case), normalizes currency values, and enforces server-side payment gating. - Verification Engine (
FastMCPServer): Exposes modular Model Context Protocol (MCP) tools (rank_offersandexplain_score) that perform live seller intelligence checks:- Physical Existence: Cross-references merchant locations via Foursquare and OpenStreetMap.
- Domain Longevity: Queries RDAP records to verify domain registration age.
- Threat Intelligence: Checks domains against URLhaus databases for known malware or scam activity.
- Payment & Audit Layer (
PayPal Sandbox API): Enforces a hard backend gate—if a seller's score falls below the safety threshold, order creation is blocked at the server level before a PayPal order ID is ever generated. Approved transactions are captured and logged to an immutable audit trail.
Scoring Model
Each seller is evaluated on a 5-point scale weighted heavily toward security (\( 70\% \) trust signals, \( 30\% \) price competitiveness):
$$S_{\text{total}} = 0.70 \cdot S_{\text{trust}} + 0.30 \cdot S_{\text{price}}$$
Where the composite trust score \( S_{\text{trust}} \in [0, 5] \) aggregates physical verification (\( V_{\text{geo}} \)), domain age factor (\( A_{\text{rdap}} \)), and threat clearance (\( T_{\text{clean}} \in {0, 1} \)):
$$S_{\text{trust}} = T_{\text{clean}} \cdot \left( w_1 V_{\text{geo}} + w_2 A_{\text{rdap}} \right)$$
Any merchant scoring below the server-side threshold of \( S_{\text{total}} < 2.5 \) is automatically blocked from initiating a PayPal order.
Challenges We Faced
- Real-Time Latency vs. Thorough Auditing: Querying RDAP, geospatial APIs, and threat feeds sequentially introduced noticeable delays during checkout. We solved this by orchestrating concurrent lookups inside our MCP server and caching verified seller profiles so repeat queries resolve almost instantaneously.
- Preventing Hallucinated Risk Explanations: LLMs can easily fabricate reassuring reasons when summarizing ambiguous data. To keep explanations strictly factual, we isolated data retrieval inside
rank_offersand restrictedexplain_scoreto translating only verified, deterministic check outputs into plain English. - Enforcing True Security Beyond the UI: Disabling a checkout button on the frontend isn't enough—malicious actors or client-side bypasses could still trigger an order. Moving the \( S_{\text{total}} < 2.5 \) check directly into the FastAPI order-creation endpoint ensured risky sellers are blocked before PayPal is ever invoked.
What We Learned
- Designing Agentic Microservices with MCP: Building with
FastMCPdemonstrated how cleanly tool-based architectures separate deterministic verification logic from conversational or natural-language interfaces. - Trust Requires Deterministic Grounding: In financial and payment workflows, AI works best when paired with hard cryptographic/API signals (like RDAP and threat registries) and strict server-side guardrails rather than probabilistic guesses.
- Frictionless UX at Checkout: Security tools only get used if they fit naturally into existing user habits—embedding verification right next to the PayPal button keeps checkout intuitive while adding a critical layer of buyer protection.
Built With
- ai-agents
- backend
- channel3
- data
- fastapi
- foursquare
- fraud-prevention
- frontend
- mcp
- model-context-protocol
- nextjs
- openstreetmap
- paypal
- paypal-rest-api
- paypal-sandbox
- pydantic
- python
- react
- sources
- sqlalchemy
- sqlite
- tailwindcss
- uvicorn