Inspiration
Managing payments is more complicated than simply sending or receiving money. Freelancers and small businesses often have to track invoices, prioritize pending payments, decide when to follow up, and manually navigate payment workflows.
We wanted to explore how AI could make these operations smarter without giving an AI agent unrestricted control over financial transactions.
That idea inspired PayPilot AI — Your Intelligent Payment Operations Copilot.
Our goal was to build an AI-powered assistant that understands payment operations, analyzes invoice information, recommends appropriate actions, and helps users execute transactions securely through PayPal. We wanted to combine the intelligence of AI with the reliability of payment infrastructure while keeping the human in control of important financial decisions.
What it does
PayPilot AI acts as an intelligent assistant for managing invoice and payment workflows.
Its core capabilities include:
- Invoice Management: Organizes invoice information, amounts, due dates, and payment statuses.
- AI-Powered Recommendations: Uses Google's Gemini API to analyze invoice context and generate actionable payment recommendations.
- Intelligent Payment Prioritization: Helps users identify which invoices require attention based on their payment context.
- Human-in-the-Loop Approval: Requires explicit user approval before executing a payment action.
- PayPal Integration: Uses the PayPal Orders API and Sandbox environment to create and process payment workflows.
- Payment Validation: Validates payment amounts, currencies, authorization, and transaction details before proceeding.
- Transaction Tracking: Tracks payment attempts and their statuses.
- Audit Trail: Records important payment operations to improve transparency and traceability.
The central principle is simple: AI recommends, the backend validates, the user approves, and PayPal processes.
How we built it
We built PayPilot AI using a modern full-stack architecture, separating the user interface, business logic, AI reasoning, and payment processing.
Frontend
- React.js
- TypeScript
- Vite
- Tailwind CSS
Backend
- Node.js
- Express.js
- TypeScript
- Zod for request and response validation
Database
- Prisma ORM
- SQLite
AI Integration
- Google Gemini API for invoice analysis and payment recommendations.
Payment Integration
- PayPal Orders API v2
- PayPal Sandbox for testing payment workflows.
Testing and Reliability
- Vitest
- Supertest
- Playwright
Payment workflow
The application follows a controlled payment execution process:
- The user manages invoice information in PayPilot AI.
- Gemini analyzes the available context and generates a recommendation.
- The backend validates the proposed action against business rules and payment constraints.
- The user reviews the recommendation and explicitly authorizes the payment action.
- The backend creates a PayPal Sandbox order.
- The payment proceeds through the PayPal checkout and capture workflow.
- The backend verifies the provider response before updating payment records.
- The operation is recorded in the audit trail.
We deliberately separated AI recommendations from payment execution. Gemini does not directly execute transactions or bypass backend authorization and validation.
Challenges we ran into
Building an AI-powered payment application introduced challenges beyond ordinary CRUD operations.
1. Integrating AI with financial workflows
AI-generated recommendations cannot be treated as trusted financial instructions. We needed to ensure that every recommendation passed through backend validation and explicit user approval before any payment operation could proceed.
2. PayPal API response validation
One of our major challenges involved handling PayPal order responses. The application encountered an unexpected response structure, which caused strict schema validation to fail.
We investigated the issue and focused on requesting the complete order representation, maintaining strict validation, and separating order verification from capture verification.
3. Handling uncertain payment outcomes
A payment request can reach the payment provider even when the application fails to receive or persist the expected response. Blindly retrying such a request could introduce duplicate-order risks.
We designed the workflow around payment-attempt tracking, idempotency, explicit ambiguous states, and provider-side verification rather than assuming that every failed API response means the transaction failed.
4. Maintaining transaction integrity
We needed to ensure that an invoice would not be marked as paid merely because an order was created or approved. Payment completion must be supported by verified capture information, including the relevant order, amount, and currency.
5. Balancing automation and control
Our biggest design challenge was deciding how much authority an AI copilot should have. We chose a human-in-the-loop approach: AI can analyze and recommend, but financial execution remains subject to backend rules and user approval.
Accomplishments that we're proud of
- Built an end-to-end AI-powered payment operations copilot.
- Integrated Google Gemini for intelligent invoice analysis and recommendations.
- Integrated PayPal Orders API v2 using the Sandbox environment.
- Designed a human-in-the-loop payment approval workflow.
- Implemented backend validation for payment operations.
- Designed payment-attempt tracking and idempotency handling.
- Added audit logging to improve transaction traceability.
- Focused on safe handling of uncertain payment outcomes instead of blindly retrying financial operations.
- Created a modular architecture that separates AI reasoning, business rules, and payment execution.
We are particularly proud of the decision to prioritize trust, validation, and user control rather than allowing AI to execute financial actions without oversight.
What we learned
This project taught us that building an agentic financial application requires much more than connecting an LLM to a payment API.
We learned:
- How to integrate Gemini into a practical business workflow.
- How to work with PayPal Orders API and Sandbox payment operations.
- Why idempotency is essential when designing payment systems.
- How to validate external API responses using schema validation.
- Why order creation, buyer approval, and payment capture must be treated as separate stages.
- How to design human-in-the-loop agentic workflows.
- Why auditability and transaction integrity are essential in financial applications.
- How to handle uncertain outcomes without assuming that a failed request means no transaction occurred.
Most importantly, we learned that a useful financial AI agent should not just be intelligent; it must also be predictable, accountable, and safe.
What's next for PayPilot AI — Your Intelligent Payment Operations Copilot
PayPilot AI is a foundation for a more intelligent payment operations platform. Our next steps include:
- Automated Invoice Follow-ups: Generate contextual payment reminders and follow-up schedules.
- Cash Flow Forecasting: Analyze upcoming invoices and expected payments to provide better financial visibility.
- Smarter Payment Prioritization: Improve recommendations using historical payment patterns and invoice urgency.
- Multi-Provider Support: Explore integrations with additional payment providers.
- Advanced Analytics: Provide dashboards for payment trends, outstanding invoices, and transaction history.
- Enhanced Agentic Workflows: Introduce more sophisticated multi-step workflows with approval gates and configurable business policies.
- Production Readiness: Strengthen security, monitoring, testing, and payment reconciliation before supporting real financial transactions.
Our long-term vision is to make PayPilot AI a trusted financial operations copilot that helps freelancers and small businesses spend less time managing payments and more time growing their businesses.
PayPilot AI — Smarter payment decisions. Controlled execution. Greater financial confidence.
Built With
- agentic
- artificial
- css
- express.js
- fintech
- full-stack
- gemini
- generative
- human-in-the-loop
- intelligence
- javascript
- node.js
- payment
- prisma
- processing
- react
- rest
- sandbox
- sqlite
- supertest
- tailwind
- typescript
- vite
- vitest
- zod