About PayGuard AI
Inspiration
Online payments are becoming faster, but fraud detection needs to be just as intelligent. We were inspired by a critical gap in the payment process: what if a suspicious transaction could be identified after the buyer approves a payment but before the merchant captures it?
This led us to build PayGuard AI, an intelligent pre-capture risk assessment system designed to help identify potentially fraudulent payments before money is captured. Instead of relying on a single fraud signal, we wanted to combine transaction patterns, behavioural indicators, blockchain intelligence, and machine learning to make payment decisions more explainable.
How We Built It
We designed PayGuard AI around a server-side risk assessment and payment authorization workflow, integrating the PayPal Sandbox with multiple intelligence layers.
- Transaction Intelligence: Evaluates transaction amounts, recipients, payment corridors, and transaction frequency.
- Behavioural Detection: Identifies unusual activity by comparing transactions against sender history, known devices, and familiar recipients.
- Blockchain Intelligence: Uses explicitly linked Ethereum PYUSD transfer data and NetworkX graph analysis to identify suspicious patterns such as circular fund movements and pass-through fan-out.
- Machine Learning: Uses an XGBoost model trained on the simulated PaySim dataset to estimate fraud probability. SHAP helps explain the model's contribution to the risk assessment.
- AI Investigation Agent: Uses Gemini to generate evidence-based investigation summaries, highlight red flags, and suggest next steps.
- PayPal Integration: Connects the risk assessment workflow with PayPal Sandbox orders, buyer approval, and server-side payment capture.
- Analyst Dashboard: Provides an interface for reviewing high-risk transactions, examining evidence, and approving or rejecting held payments.
Based on the calculated risk, PayGuard AI assigns one of three outcomes:
- LOW (0–30): Eligible for payment capture.
- MEDIUM (31–69): Requires an additional simulated OTP verification step.
- HIGH (70–100): Held for manual analyst review.
An important design decision was to keep the final payment decision on the backend. Neither the browser nor the AI investigation agent can independently authorize a payment capture.
What We Learned
Building PayGuard AI helped us understand how different technologies can work together in a real-world payment security workflow. We explored machine learning explainability through SHAP, graph-based fraud pattern detection using NetworkX, AI-assisted investigation with Gemini, and secure payment lifecycle integration using PayPal Sandbox.
We also learned that a fraud score alone is not enough. A useful fraud detection system should explain why a transaction is suspicious, preserve supporting evidence, and provide a controlled path for human review.
Challenges We Faced
One of our biggest challenges was combining multiple risk signals without allowing any single signal to determine the entire outcome. We had to balance machine learning predictions, fixed security rules, behavioural indicators, and blockchain patterns into a consistent risk assessment system.
Another challenge was distinguishing suspicious blockchain activity from legitimate high-volume wallet behaviour. During testing with real PYUSD transfer data, an initial fan-out detection rule flagged a busy service wallet. We refined the logic by adding pass-through conditions, helping reduce false positives while retaining detection of our synthetic suspicious-wallet scenario.
We also focused on making the system resilient: Gemini-generated reports are validated against available evidence, with a deterministic fallback if the AI service fails. Missing critical intelligence can trigger a policy override rather than allowing a transaction to receive an unjustifiably low-risk outcome.
What's Next
PayGuard AI is currently a working prototype built and tested with PayPal Sandbox, simulated fraud data, and explicitly supplied blockchain wallet relationships. It is not yet production-certified. Future improvements include broader model features, more extensive real-world validation, production-grade key management and data protection, and live public webhook testing.
Our goal is simple: Detect early. Explain clearly. Protect payments.
Built With
- artificial
- ethereum
- etherscan
- fastapi
- gemini
- google-ai
- graph-analysis
- intelligence
- machine-learning
- networkx
- paypal
- paypal-sandbox
- python
- pyusd
- shap
- sqlite
- streamlit
- xgboost