Inspiration
AI can make it easier to find and compare products, but purchasing decisions also need clear limits and accountability. We built PayPilot to explore how an AI assistant could help with procurement while leaving spending rules and payment authorization under the user’s control.
What it does
A user describes what they need in natural language. PayPilot searches a verified product catalog, recommends an option, and prepares a purchase plan. Server-side policy checks evaluate transaction and spending limits, while risk signals help explain the decision. If approval is required, the user reviews the plan before proceeding to PayPal Sandbox checkout.
After checkout, PayPal webhooks confirm payment events. PayPilot records the purchase and its review history in an audit trail.
The project also includes budget-aware replanning, bounded buyer–merchant negotiation, spending policy controls, analytics, and purchase activity views.
How we built it
The frontend uses Next.js, React, TypeScript, and Tailwind CSS. A NestJS API handles authentication, planning, policy evaluation, risk checks, approvals, and payment workflows. PostgreSQL and Prisma store the catalog, plans, policies, payment records, and activity history.
For regular accounts, OpenRouter provides structured AI output for interpreting requests and ranking catalog options. The server validates those results against database records. Deterministic code recalculates totals and enforces policy; the model cannot approve or execute a purchase. PayPal Orders v2 handles Sandbox checkout, and verified webhooks provide payment confirmation.
Challenges we ran into
A key challenge was deciding where AI should stop and deterministic logic should take over. The model can help interpret a request and explain product trade-offs, but it must not set spending limits, invent catalog items, or bypass approval requirements.
We also had to connect several stateful parts reliably: purchase plans, user approval, PayPal order creation, webhook delivery, and the audit trail. We designed the API to recheck policy at important transitions and handle webhook events idempotently.
What we learned
We learned that a useful AI purchasing flow depends on more than a good recommendation. It also needs clear policy decisions, server-side validation, explicit approval, reliable payment events, and enough history for a user to understand what happened.
What’s next
We would improve provider reliability and monitoring, expand the catalog and policy controls, and continue testing the experience across more devices and account configurations.
Built With
- ag
- api
- auth
- better
- css
- grid
- nestjs
- next.js
- openrouter
- orders
- paypal
- postgresql
- prisma
- query
- react
- render
- tailwind
- tanstack
- typescript
- webhooks
- zod