Inspiration

Small shops can ship an order and still fail to collect the money. An authorization expires, a capture fails in a log, or a retry sends the same refund twice. The owner has to connect several payment records just to understand what happened.

Nightshift investigates those incidents without giving a language model permission to move money. The AI reads and proposes; a deterministic policy gate decides what can run.

What it does

Nightshift watches a PayPal sandbox merchant account through webhooks and periodic sweeps. It connects orders, authorizations, captures, refunds and invoices in a local ledger.

Ten detectors identify incidents such as expiring authorizations, failed captures, duplicate charges, excessive refunds and overdue invoices. An AI agent investigates with read-only PayPal tools and proposes a fix.

Each proposal receives one of three decisions: auto, needs approval, or forbidden. Safe qualifying actions can run automatically. Refunds require owner approval. Approved changes are checked again before execution.

Every step appears in an audit trail: the evidence, diagnosis, policy decision, PayPal request and response.

How we built it

The application uses Next.js, React, TypeScript and SQLite, deployed on Render with a persistent disk, an inline background worker and a scheduled sweep.

The official PayPal Agent Toolkit provides read tools, supplemented by a typed REST client. Only the executor can call money-moving endpoints. It claims actions atomically and uses stable PayPal-Request-Id values for idempotency.

AG Grid presents incidents and payment ledgers. AG Studio powers an Insights dashboard with a custom analyst agent and authorization-countdown widget. The LLM runs through a server-side OpenAI-compatible endpoint.

All payments use PayPal sandbox. The application refuses production mode.

Challenges we ran into

Our sandbox app did not support direct card processing, so the lab needed a PayPal-checkout buyer path.

Time was another boundary: advancing Nightshift's detector clock does not change PayPal's clock. A reauthorization can return REAUTHORIZATION_TOO_SOON. Nightshift shows that refusal and escalates rather than hiding it or retrying indefinitely.

Keeping the agent useful without making its suggestions authoritative required separate read tools, policy checks, approvals and execution.

Accomplishments that we're proud of

The recorded sandbox run shows 19 incidents, 8 automatic actions and $71 marked protected by the app. These are demonstration results, not real merchant savings.

The demo follows an incident from evidence to diagnosis, policy decision and PayPal response. It also shows owner approval and an untrusted order note, making the boundary between AI suggestions and payment authority visible.

What we learned

A plausible diagnosis is not permission to issue a refund. Payment automation needs to preserve uncertainty, explain API refusals and re-check an action when it is approved.

The useful interface is an incident with evidence, a proposed call and a recorded outcome—not just a chat window.

What's next for Nightshift

A supervised merchant pilot would follow production onboarding, stronger authentication, tenant isolation and payment-data handling review.

We would measure resolved incidents and false positives before making savings claims. Multi-instance storage and deployed workflow execution remain future work.

Built With

Share this project:

Updates

Submission history