AgentPay Guard — Policy-First AI Shopping

Inspiration

AI shopping assistants can help people discover products, but purchasing involves more than finding a good recommendation. Buyers must also consider budgets, product eligibility, merchant information, payment authorization, and accountability.

AgentPay Guard was built around a simple principle: AI can recommend a purchase, but it should not have unrestricted authority to complete one.

We wanted to explore how AI-assisted commerce could combine useful recommendations with enforceable policies, explicit human approval, and a transparent audit trail.

What it does

AgentPay Guard is a policy-first AI shopping workspace that separates product discovery, purchase validation, human authorization, and payment execution.

Users describe what they want to purchase and specify constraints such as their budget. The application uses an AI-assisted recommendation workflow, grounded against an application-controlled product catalog, to prepare a structured purchase proposal.

Before a proposal can proceed, a deterministic backend policy engine evaluates six checks. The application presents the policy evidence so users can understand whether a proposed purchase is eligible.

The user can review and approve an eligible proposal. Approval is recorded separately from PayPal buyer authorization and payment capture, preventing these distinct actions from being presented as a single step.

The workspace also provides proposal history, lifecycle visibility, and owner-scoped audit records.

How we built it

The frontend uses Next.js, React, TypeScript, and Tailwind CSS. The backend uses Python and FastAPI, with PostgreSQL for persistent application records and Alembic for database migrations.

Google Gemini supports AI-assisted recommendations, while a clearly identified deterministic fallback allows the application to remain usable when the AI provider is unavailable.

The backend independently validates proposals against authoritative catalog information and policy constraints rather than trusting AI-generated product details or prices.

PayPal's Sandbox APIs are integrated into the purchase lifecycle. The project has previously verified Sandbox order creation and buyer-approval behavior. Payment capture is deliberately disabled in the public deployment.

The application is deployed using Vercel for the frontend, Render for the backend, and Neon PostgreSQL for persistence.

Challenges we faced

One major challenge was designing a reliable boundary between probabilistic AI recommendations and deterministic purchase authorization.

We also had to distinguish proposal approval, PayPal buyer approval, and payment capture as separate lifecycle stages, each with different security implications.

Additional challenges included AI provider quota and connectivity failures, maintaining session ownership across workflows, deploying the backend and frontend separately, and configuring strict production origin validation.

Accomplishments

  • Implemented a policy-controlled AI shopping workflow with six backend checks.
  • Built an explicit human-approval process.
  • Integrated PayPal Sandbox order creation and buyer-approval flows during development.
  • Developed an owner-scoped audit and history experience.
  • Added a transparent deterministic fallback for AI-provider failures.
  • Built a responsive, multi-view application with accessible navigation and reduced-motion support.
  • Established automated backend, frontend, and browser regression tests.

What we learned

We learned that integrating AI into financial workflows requires careful separation of responsibilities. AI can help generate recommendations, but pricing, policy decisions, ownership, and authorization need independent verification.

We also learned the importance of honest application-state reporting: a proposed purchase, an approved proposal, an authorized PayPal order, and a captured payment are not equivalent events.

What's next

Future development will focus on completing and validating the hosted end-to-end workflow, expanding policy configurability, improving merchant and catalog integrations, and strengthening payment lifecycle verification.

The longer-term goal is to make AI-assisted purchasing more transparent, controllable, and accountable.

Current demonstration scope

The public demonstration keeps PayPal order creation and capture disabled. Prior Sandbox integration milestones are documented separately from public production capabilities. Hosted proposal and persistence behavior must be verified after the production origin configuration is corrected.

Built With

Share this project:

Updates

Submission history