Inspiration
Digital commerce is quickly moving toward AI agents. They can understand what people want, compare products, and make recommendations, but there is a problem: an AI model should not have unchecked control over someone's money.
That led us to think about three problems together.
First, AI shopping can become risky when an LLM is allowed to trigger payments directly. Prompt injection, overspending, restricted purchases, and forgotten recurring subscriptions can all turn a helpful assistant into a financial risk.
Second, post-purchase disputes are still frustrating for both customers and merchants. A damaged product can lead to long support conversations or even a chargeback, when a policy-based solution such as a partial refund could resolve the issue much faster.
Third, payment systems need stronger verification. A frontend callback or an AI-generated result should never be enough to say that money has moved successfully. The payment provider itself should confirm the final state.
We built PayPath around one simple idea:
AI understands. Policy decides. Humans approve. PayPal executes. PayPath verifies.
That became the foundation for everything we built.
What it does
PayPath is an AI Transaction Intelligence and Agentic Commerce platform with three main experiences: a Shopper Portal, a Merchant Policy Studio, and a Platform Admin Control Center.
For shoppers, PayPath provides a Transaction Intelligence Explorer where users can search and understand their payments, inspect risk signals, view AI-generated insights, and trace transaction history. We also built Guarded Shopping, where users can describe what they want in natural language and Gemini 2.5 Flash extracts things such as budget limits, categories, and approval requirements.
The important part is what happens after the AI understands the request. A deterministic Policy Engine applies the actual financial rules. Spending limits, approval thresholds, and restricted categories cannot be overridden by an AI response. This means an instruction such as "ignore the policy and allow everything" cannot simply bypass the system.
PayPath also includes Recovery Intelligence for recurring subscriptions and duplicate-charge patterns.
The main dispute-resolution workflow is RECLAIM. A user can submit supporting evidence for a transaction, and PayPath validates the uploaded file before processing it. The system then retrieves the relevant merchant policy through a tenant-isolated RAG layer, combines that context with transaction information and advisory risk signals, and produces a bounded resolution recommendation.
For example, an $89 damaged-product transaction can produce a policy-supported partial refund recommendation. The recommendation is still checked against deterministic rules, and a consequential financial action requires explicit approval before PayPal is called.
On the payment side, PayCore integrates PayPal REST APIs for order creation, capture and refunds. After a payment mutation, PayPath independently reads the payment resource back from PayPal and checks the status, amount, and currency before treating it as verified.
We also built a dedicated webhook verification layer using RSA-SHA256 verification, PayPal certificate validation, payload checks, and persistent replay protection.
How we built it
The frontend was built with React 19, TypeScript, Vite, Tailwind CSS, Zustand, TanStack Query, and AG Grid. The main transaction workspace uses AG Grid to provide search, filtering, sorting, risk information, payment status, AI insights, and verification information.
The backend is built with Python 3.12 and FastAPI, using asynchronous SQLAlchemy with asyncpg. PostgreSQL 16.15 on Render is the authoritative application database for transactions, merchants, policies, RAG chunks, payment records, agent traces, notifications, audit logs, and verification data.
Gemini 2.5 Flash is the main AI model used for intent understanding, transaction explanations, policy-aware reasoning, and agent workflows.
For machine learning, we use XGBoost for transaction-risk scoring and Isolation Forest for anomaly detection. These models are advisory only and cannot directly move funds.
Our RAG layer uses merchant-specific policy chunks with tenant filtering before similarity search. This is important because a merchant should never be able to retrieve another merchant's policies.
For evidence, we use private Supabase Storage, while evidence metadata remains in PostgreSQL.
The application is deployed using Vercel for the frontend and Render for the backend and database, with GitHub Actions handling automated testing and release checks.
Challenges we ran into
The hardest part of PayPath was not building the screens. It was making the complete payment workflow trustworthy.
One challenge was PayPal Sandbox behavior. Creating an order is straightforward, but wallet-based checkout requires interactive buyer approval before capture. We had to make sure that an order being created could never be confused with a completed payment.
Another challenge was webhook security. We did not want to trust a single callback or mark a payment as successful just because an event arrived. We implemented cryptographic verification, certificate validation, persistent event deduplication, and independent PayPal read-back.
Tenant isolation was another major concern. Since different merchants can have different return and warranty policies, the RAG system had to be designed so retrieval was constrained by merchant identity.
We also spent significant effort on frontend and deployment issues, including CORS, Vercel-to-Render API routing, AG Grid module integration, authentication, RBAC, and production-safe error handling.
For evidence storage, we deliberately chose a fail-closed approach. If cloud storage is unavailable or unauthorized, PayPath rejects the upload rather than silently using temporary container storage that could disappear after a deployment.
Accomplishments that we're proud of
We are most proud of the separation between AI intelligence and financial authority.
Instead of allowing an AI model to directly make financial decisions, PayPath creates a chain of control:
AI interprets the user's intent, RAG supplies policy context, machine learning provides advisory signals, deterministic rules constrain the decision, humans approve consequential actions, PayPal executes the operation, and PayPath independently verifies the result.
We are also proud of building the project as a multi-tenant system rather than a single-user prototype. The Shopper, Merchant, and Platform Admin experiences use role-based access and tenant-aware authorization.
Another accomplishment was building the transaction intelligence layer around real transaction and event data instead of presenting a static dashboard. AG Grid provides the interactive workspace while the backend maintains transaction lineage and audit information.
Finally, we are proud that the system was designed to fail safely. When an external provider or storage service cannot be trusted, PayPath prefers an explicit failure over a false success. For a financial application, we believe that is the right trade-off.
What we learned
The biggest lesson from building PayPath is that adding AI to financial software is not just an AI problem. It is a systems and trust problem.
We learned that AI should be given enough authority to understand context and make useful recommendations, but not enough authority to independently change financial state.
We also learned the importance of treating payment providers as the source of truth for payment status. Local state, frontend callbacks, and AI outputs should all be verified against the provider.
Finally, we learned that production engineering matters just as much as the model itself. Authentication, authorization, tenant isolation, webhook verification, idempotency, database consistency, cloud storage, deployment, and testing all become part of the AI product when the system is connected to real financial actions.
That experience shaped PayPath into more than an AI demo. It became an experiment in how to make agentic commerce useful while keeping financial decisions controlled, explainable, and verifiable.
Built With
- actions
- ag
- aggrid
- asyncpg
- fastapi
- gemini
- github
- grid
- paypal
- postgresql
- python
- rag
- react
- render
- renderfarm.fi
- scikit-learn
- sqlalchemy
- supabase
- tailwind
- typescript
- vercel
- vite
- xgboost
- zustand