Inspiration

A refund looks simple from the customer’s side: something went wrong, and they want their money back. For a merchant, the decision can involve checking the original payment, understanding the customer’s request, reviewing order and return records, applying the right policy, and keeping a reliable record of what happened.

AI can help bring those facts together, but a fluent recommendation should never be mistaken for permission to move money. We built AgentGate around that boundary: AI investigates, deterministic rules enforce merchant policy, and the merchant stays in control of submission and approvals.

What it does

AgentGate is a local-first merchant workspace for investigating and managing refund requests.

A merchant opens a case against a payment and records the customer’s request. They can add structured order, return, inspection, and policy records. Gemini then investigates the case using read-only tools and prepares an evidence-backed recommendation or asks for clarification.

Before a refund can proceed, AgentGate independently checks merchant eligibility, the remaining refundable balance, returned-item value, daily budget, and configured limits. The merchant reviews and submits the request. Requests above the automatic threshold require individual merchant approval, with policy checks repeated at approval time.

In PayPal Sandbox mode, AgentGate can create and capture a test checkout, submit a permitted refund, and record the provider’s outcome. The Refund Requests screen uses AG Grid to organize review queues, while the audit trail keeps a sequence of case and payment events.

AgentGate uses PayPal Sandbox test money only. It does not process live payments.

How we built it

We built AgentGate with Node.js, vanilla JavaScript, and SQLite. The frontend provides a command center, a refund investigation workspace, a request review grid, evidence search, an audit trail, and connection settings.

The main integrations are:

  • Google Gemini: Investigates a case through scoped, read-only tools and produces a recommendation with citations. It cannot change eligibility, modify policy, approve requests, or execute refunds.
  • PayPal Sandbox: Handles test checkout, payment capture, refund execution, and provider outcome retrieval. Incoming webhook notifications are verified with PayPal before being recorded.
  • AG Grid Community: Powers the refund review table with filtering, sorting, pagination, request details, and individual review actions.
  • Elasticsearch: Provides optional search over sanitized operational evidence. Investigation citations are checked against the local audit ledger; SQLite remains the source of truth.
  • Postman: Provides separate Demo and Sandbox collections for exercising the API and validating key controls.

For the demo, we use synthetic customer, order, and return records alongside real PayPal Sandbox test transactions. The application also has a credential-free demo mode with simulated payment outcomes.

Challenges we ran into

Keeping AI useful without giving it payment authority. We separated investigation from authorization. Gemini can gather evidence and propose an amount, but deterministic code checks the decision and the merchant explicitly submits the request.

Preventing duplicate or unsafe refunds. A payment call can time out even when the provider may have processed it. AgentGate reserves the amount before execution and uses stable idempotency keys. Uncertain outcomes retain their reservations and require reconciliation rather than an automatic second refund.

Grounding a recommendation in the right case. The investigator’s read-only tools are scoped to the selected payment. Recommendation amounts, clarification responses, and citation references are validated before the result becomes actionable. Changes to the underlying facts can make a recommendation stale and require reinvestigation.

Making the provider outcome reviewable. We linked the case, policy decision, refund request, provider response, and audit events so a merchant can follow the sequence. PayPal webhook events are signature-verified before being recorded.

Accomplishments that we’re proud of

We completed a PayPal Sandbox flow that creates an approved test purchase, captures it, investigates a refund case, applies merchant controls, and records a refund outcome.

We also implemented automatic and above-threshold approval paths, duplicate-operation protection, a hash-chained local audit trail, and a review workspace that brings the customer’s words, evidence, AI recommendation, policy decision, and outcome together.

What we learned

Building a payment-related AI workflow taught us that the model is only one part of the system. Evidence quality, explicit merchant review, deterministic limits, idempotency, and clear handling of uncertain outcomes matter just as much as the recommendation itself.

We also learned to be precise about what a verification proves: a signed provider notification supports confidence in its source, while an AI citation helps a merchant inspect evidence—it does not automatically prove every sentence in the AI’s reasoning is correct.

What’s next for AgentGate

We want to connect real merchant order and returns systems, improve reconciliation of refunds made outside AgentGate, and add stronger identity and multi-user access controls. We would also like to evaluate the workflow with merchants and compare it with their existing manual process.

AgentGate is currently a single-merchant hackathon prototype. Its audit chain is local rather than externally anchored, and its PayPal integration is limited to Sandbox.

Share this project:

Updates

Submission history