Inspiration

Small online sellers are often their own payment operations team. Alongside making products and serving customers, they must investigate transactions, resolve payment issues, and send invoices.

A simple question—"Did this customer pay me twice?"—can turn into a manual investigation across payment records. Two similar payments might be an accidental duplicate or a legitimate repeat purchase. Sellers need evidence, not an automatic refund based on a guess.

I built SellerOps Copilot around one principle:

AI investigates and proposes. The seller approves. PayPal executes.

The goal is to reduce payment administration without giving an AI model independent control over financial actions.

What it does

SellerOps Copilot brings a PayPal Sandbox storefront, payment ledger, conversational assistant, and approval workflow into one application.

Flags likely duplicate payments

The application checks for payments from the same buyer, for the same amount and currency, within a 30-minute window.

When matching payments arrive, the dashboard displays a live alert with supporting transaction details. These are candidates for review, not proof of an accidental charge. The seller decides whether to refund or keep the payment.

Investigates transactions through conversation

Sellers can ask questions such as:

  • "Did anyone pay me twice?"
  • "Summarize my payments."
  • "Prepare a refund for the duplicate."
  • "Which invoices are still unpaid?"

The AI agent retrieves application records through tools, explains what it finds, and references the relevant transactions.

Its five core tools are:

  • list_transactions
  • find_duplicate_payments
  • propose_refund
  • propose_invoice
  • list_invoices

Duplicate detection is deterministic code. The AI interprets the seller's request, investigates the evidence, and prepares an appropriate next step.

Prepares refunds for human approval

The model can propose a refund, but it cannot execute one directly.

The seller reviews the proposal and explicitly approves it. Only then does the backend call the PayPal Payments v2 API to refund the captured payment.

Concurrency-safe approval state transitions and PayPal idempotency keys help protect against repeated execution.

Creates invoices through chat

A seller can ask:

Send John Doe an invoice for $40 for a personalized candle set.

The copilot looks up the recipient from previous payment records and prepares an invoice proposal. If it cannot identify the recipient, it asks for an email address rather than guessing.

After seller approval, the backend creates and sends the invoice through the PayPal Invoicing v2 API. The customer opens PayPal's hosted payment page, and an invoice-paid webhook updates the dashboard when payment is received.

Keeps the dashboard synchronized

Server-Sent Events deliver payment updates, duplicate alerts, proposal results, and invoice status changes to connected dashboards.

The webhook integration supports PayPal signature verification when configured. Event-ID and capture-ID deduplication help avoid processing the same records repeatedly.

How I built it

Backend

I used Go, primarily with the standard library, to implement HTTP endpoints, the PayPal client, the agent tool loop, approval workflows, and event streaming.

A JSON file store holds transactions, proposals, invoices, and processed webhook IDs. This keeps the prototype lightweight and easy to run.

PayPal integration

PayPal is central to the application's workflow:

  • JavaScript SDK: Storefront checkout.
  • Orders v2 API: Creating and capturing orders.
  • Payments v2 API: Refunding captured payments.
  • Invoicing v2 API: Creating and sending invoices.
  • Webhooks and signature verification: Payment and invoice updates.
  • Sandbox accounts: Testing without moving real money.

AI agent

The conversational agent uses Google Gemini through an OpenAI-compatible chat-completions interface with tool calling.

The model does not receive PayPal credentials or call PayPal's financial APIs directly. Its action-generating tools create proposals. Execution happens through separate backend approval endpoints.

I also implemented bounded retries, configurable fallback models, and a deterministic rule-based fallback for supported workflows when the model is unavailable.

Frontend and deployment

The frontend uses plain HTML, CSS, and JavaScript, alongside the PayPal JavaScript SDK.

The application is deployed on Render, with credentials supplied through environment variables.

Challenges I faced

Getting the Sandbox environment right

An initial India-based Sandbox business account rejected USD transactions with UNSUPPORTED_PAYEE_CURRENCY.

I moved testing to a US Sandbox business account and a dedicated application. This reinforced how important account configuration and currency support are when validating payment integrations.

Preserving Gemini tool-calling information

Gemini's function-calling flow required provider-specific thought-signature information to survive across tool interactions.

I extended the OpenAI-compatible client to preserve that information when returning assistant tool calls to the model.

Separating AI suggestions from financial execution

The most important architectural challenge was ensuring that a model-generated suggestion was never treated as authorization.

I separated transaction-reading tools, proposal-generation tools, and execution endpoints. This made the approval boundary explicit: a proposal can explain an action, but it cannot authorize itself.

Handling concurrency and repeated events

Payment systems must account for double clicks, repeated webhook deliveries, and overlapping requests.

I used concurrency-safe proposal transitions, reusable pending proposals, PayPal request IDs, and event deduplication. Tests cover scenarios including concurrent approvals and repeated webhook events.

Accomplishments I'm proud of

The demo connects several working PayPal Sandbox capabilities into one seller workflow:

  • Two separate $18 Sandbox payments trigger a likely-duplicate alert.
  • A seller-approved refund executes through PayPal.
  • Payment capture and refund webhooks appear with verified signatures in the configured demo.
  • A $40 invoice is prepared through chat and sent after approval.
  • After the buyer pays, the invoice-paid webhook updates the dashboard to PAID.

I'm especially proud that the application makes the distinction between detecting a possible problem, proposing a resolution, and authorizing a financial action visible to the seller.

What I learned

Building an AI payment assistant is not just about connecting a model to an API.

The model can make a workflow easier to understand, but reliable financial operations depend on deterministic validation, authorization, idempotency, event handling, and clear status reporting.

I also learned that an AI agent needs a specific role. In SellerOps Copilot, that role is not to replace the seller's judgment. It is to gather evidence, explain the situation, and reduce the work required to make a decision.

The strongest use of AI here is assistance with accountability—not unrestricted autonomy.

Current limitations

SellerOps Copilot is a single-seller PayPal Sandbox prototype, not a production financial service.

  • Duplicate detection flags likely matches and can include legitimate repeat purchases.
  • The JSON store is designed for a lightweight prototype.
  • Webhook signature verification requires the appropriate configuration.
  • Seller authentication, authorization hardening, durable storage, and stronger recovery for uncertain API outcomes remain priorities before production use.

What's next

My next step is to strengthen the existing workflow before expanding its scope:

  1. Add authenticated seller access and proposal ownership checks.
  2. Require webhook verification in PayPal-connected deployments.
  3. Improve reconciliation after timeouts or interrupted operations.
  4. Make transaction evidence and action history easier to review.
  5. Move to durable database storage.

Longer term, I want to explore invoice reminders, scheduled sales summaries, and additional PayPal capabilities such as disputes and subscriptions.

The vision remains simple: help small sellers spend less time investigating payments while keeping them in control of the decisions.

AI tools used

  • Google Gemini: Powers conversational requests, tool selection, explanations, and refund and invoice proposals.
  • Notion AI: Assisted with project planning, development, debugging, testing, deployment, and presentation preparation.

SellerOps Copilot — AI proposes. You approve. PayPal executes.

Built With

Share this project:

Updates

Submission history