PayGuard AI: Trust Before the Transaction.
The Problem
AI agents can discover products, choose services and even start purchases without any human intervention. But a crucial concern with direct payment access is a simpler one: who is responsible for how they spend?
There is a potential for an agent to spend too much, select the wrong merchant, misinterpret a request, or make an unauthorized transaction. Purchasing needs policy runs autonomously prior to payment.
Our Solution
PayGuard AI is an between autonomous AI agents and payment systems pre-transaction authorization layer.
The principle that it operates on: AI can suggest what to purchase, but PayGuard determines if the purchase shall be allowed or not.
PayGuard distinguishes between AI support and money control. Always payment authority is kept with backend policy checks. All requests for purchases go through a deterministic backend policy engine first and then to PayPal checkout.
How It Works
PayGuard consists of five stages of guidance:
1. Natural-Language Intent Understanding
Users describe purchases. With openai/gpt-oss-120b, Groq AI is able to identify structured data like product, merchant information, budget, and billing period.
2. Merchant Discovery
Tavily looks up merchants, products and prices. Users make a comparison and choose a provider. Discovered prices are unverifiable until the users confirm the price.
3. Explicit User Confirmation
The user verifies the merchant, domain, amount, currency, budget, category and agent. If it's an AI discovered price, it can't simply be an authorized amount.
4. Deterministic Authorization
These eight checks are performed in the backend: agent identity, merchant identity, amount validation, supported currency, category compliance, domain reputation rules, user budget limits and spending thresholds.
It will give you three results:
This purchase is approved. A supervisor review is necessary: -REVIEW_REQUIRED.
- BLOCKED: Purchase is not allowed.
Manual payment capture can not be triggered only through AI output.
5. PayPal Sandbox Checkout
Only approved decisions move forward to the creation of an order in PayPal. This is accepted by the buyer via checkout in PayPal Sandbox. The backend records and validates the payment. PostgreSQL and Prisma store authorizations and payment details.
Technology Stack
Frontend: React, TypeScript, Vite, Tailwind CSS.
Backend: Node.js, Express.js, TypeScript.
Database: PostgreSQL, Prisma ORM.
AI & Discovery: Groq API, Tavily API.
Payments: PayPal Orders API v2 Sandbox.
Deployment: Render.
What We Built and Tested
Developed Cloud VPS Purchase Workflow. The demo demonstrates Tavily discovery and user confirmation of a $4 DigitalOcean purchase, and a $20 budget. Successfully completed all 8 policy checks. The Sandbox order was approved by the buyer and was captured by the backend. The authorization and payment records were in production PostgreSQL.
We have also tried authorization enforcement, duplicate-payment protection, rejected requests and supervisor review.
Challenges and Learnings
The problem we faced was to make sure our AI wouldn't approve spending. We abstracted the extraction of intents from the evaluation of deterministic policies.
New payment lifecycle verification, duplicate-capture protection, persistence after backend restarts and integration between the frontend, backend, and PayPal Sandbox were also implemented. We have learned how to join AI support, user confirmation, deterministic control and auditable decisions.
Future Scope
Further enhancements would involve multi-agent spending wallets, organization level policies, better merchant verification, webhook signature validation and multi-signature approvals.
Our Core Principle
Groq is about intelligence. Tavily is about discovery. The deterministic policy engine grants authorizations, and PayPal handles approved payments.
PayGuard AI — Trust Before the Transaction.
*Demonstrated using PayPal Sandbox. No funds were paid.
Built With
- ai
- express.js
- groq
- node.js
- paypal
- postgresql
- prisma
- react
- rest
- tailwind
- tavily
- typescript
- vite