Inspiration
Payment instructions often arrive in informal, natural language: a business owner may ask an assistant to pay a supplier, settle an invoice, or send a specific amount to a recipient. Turning those instructions into financial actions introduces risks, especially when an AI system is involved.
We wanted to explore a safer architecture for AI-assisted payments: one where AI can understand an instruction, but cannot independently authorize or execute a payment.
That led to AgentPay.
What it does
AgentPay is an AI-assisted payment workflow built around PayPal Sandbox.
A user provides a natural-language payment instruction. The AI interprets it and extracts a structured payment intent containing the recipient, amount, currency, and purpose.
Before any payment can proceed, a deterministic policy engine evaluates the request against configured security rules. A human operator must explicitly approve the payment. Only then can the application proceed through the PayPal Sandbox payment workflow.
The architecture separates interpretation from authorization:
AI interpretation → deterministic policy evaluation → human approval → PayPal execution → independent verification → audit record.
How we built it
AgentPay is built with TypeScript and Node.js, using Groq's AI API with the "openai/gpt-oss-20b" model for natural-language interpretation.
PayPal Sandbox REST APIs provide the payment infrastructure, including OAuth authentication and order operations. SQLite supports payment lifecycle persistence and audit records.
The deterministic policy engine enforces constraints independently of the AI model. These include recipient validation, currency restrictions, transaction limits, approval requirements, and payment-state checks.
The system also distinguishes between a confirmed payment and an uncertain outcome. A payment is only marked as captured after independent provider verification. An ambiguous capture result is recorded as "UNKNOWN" rather than being incorrectly reported as successful.
Safety by design
AgentPay is deliberately restricted to PayPal Sandbox. It does not process real-money transactions.
Its safeguards include:
- AI cannot authorize or execute payments.
- Human approval is mandatory.
- Deterministic rules control payment authorization.
- A maximum transaction limit of $10 is enforced.
- Provider-side verification is required before a payment is marked as captured.
- Ambiguous payment outcomes are not automatically retried.
- Payment operations and state transitions are recorded for auditability.
Challenges and what we learned
One of the main engineering challenges was preventing AI-generated output from becoming payment authority. We addressed this by separating the AI interpretation layer from the deterministic payment-control layer.
We also had to account for unreliable network responses and ambiguous payment outcomes. A successful API request is not sufficient evidence that a payment has completed, so the system uses independent provider verification before confirming completion.
Building AgentPay reinforced an important lesson: useful AI automation in financial workflows requires more than accurate language understanding. It needs explicit authorization boundaries, deterministic controls, reliable state management, and verifiable outcomes.
What's next
AgentPay is a prototype demonstrating a safety-first architecture for AI-assisted payments. The current implementation focuses on PayPal Sandbox, controlled transaction execution, and verification. Future work could extend the architecture to additional payment providers, richer approval workflows, and more comprehensive operational monitoring.
Built With
- ai
- automation
- gpt-oss-20b
- groq
- node.js
- paypal
- rest
- sqlite
- typescript