-
-
Verify authorization and pooling events through a SHA-256 hash chain built for disputes, investigations, and release decisions.
-
Observe Risk Agent metrics, Copilot tools, and safe fallbacks from AI responses to rules-based fail-safe holds.
-
Hold only suspicious authorizations in focused pools, with plain-English reasons for velocity, IP, and billing mismatches.
-
Review every payment with IDs, risk scores, states, amounts, and clear reasons for captured or held decisions.
-
SafeHaven Pay isolates risky orders into micro-pools, keeping healthy merchant cash available and visible in one live dashboard.
Inspiration
Picture a small online seller on the best day of their year. A flash sale goes viral and orders pour in. Then a handful of them look odd, and suddenly the whole balance is on hold. Rent, suppliers and refunds all wait while nobody can say why. Weeks later, a buyer opens a dispute and the seller has nothing solid to prove the parcel arrived.
That felt backwards to us. One risky order shouldn't freeze a whole business. So we asked three questions:
- What if only the risky payments were held, and everything else kept moving?
- What if every hold came with a reason a normal person could read?
- What if delivery proof couldn't be quietly changed after the fact?
SafeHaven Pay is our answer.
What it does
SafeHaven Pay is a merchant risk console built on top of PayPal's sandbox APIs. It uses PayPal's real authorize and capture model, so we are not replacing PayPal. We are giving merchants a smarter way to use it.
- Isolated Micro-Pools: Every order is authorized first. An AI Risk Agent scores it. Safe orders are captured straight away. Risky ones stay as open authorizations in a small, temporary pool, while the rest of the merchant's money stays free to withdraw.
- Explanations you can trust: Each held payment shows a plain-English reason, like "14 orders in 4 minutes from one IP, and the billing country doesn't match." The reasons come from the model's own feature contributions (SHAP). The language model only rewrites them as a sentence, so the explanation matches what the model actually did, not a plausible story.
- Two agents that cooperate: A Buyer Agent shops within a signed spending mandate (a budget, a category and an expiry). A Merchant Copilot answers questions and manages pools through tool calls. It only proposes actions that move money, and a human approves them before PayPal captures or voids anything.
- Tamper-evident delivery evidence: Carrier events arrive on a signed webhook and are stored in a hash chain. A live "tamper" button changes one record, and the verifier shows exactly where the chain breaks.
- Impact you can see: A flash-sale simulator compares an account freeze with SafeHaven Pay. In our run, a freeze held [100%] of funds while SafeHaven Pay held [X%], with model precision of [P] and recall of [R].
How we built it
We started from one real sandbox payment: create an order with AUTHORIZE, approve it as the buyer, authorize it, then capture it. Nothing else mattered until that worked live.
- PayPal: Orders v2, authorization capture and void, webhooks with signature verification, and Payouts, all against the live sandbox. Retries use idempotency keys so a dropped connection never charges twice.
- Risk model: A gradient-boosted model trained on a synthetic order stream with named features like order velocity, IP and billing country match, account age and amount versus the merchant's average. We say openly that the data is synthetic.
- Agent pipeline: Each decision goes through feature checks, scoring, SHAP, phrasing, schema validation and policy thresholds. Output is capped in tokens and time. If something fails, we fall back step by step: model plus LLM, then templates, then a rules engine, then a safe hold. The system never auto-captures when it is unsure.
- Telemetry: Every agent run (latency, tokens, fallback level, validation errors) is logged to Elastic, with a Postgres copy so the page still works if Elastic is down.
- Front end: React with AG Grid streaming [5,000] rows live, and a Bryntum timeline showing when each pool is due to release.
- API and infrastructure: We wrote the OpenAPI spec first, generated an SDK with APIMatic, and built a Postman collection that computes the webhook signature and asserts the results. Everything runs on Render using a Blueprint, managed Postgres and a cron job for releases and reconciliation. All secrets live in environment variables.
The evidence chain is simple on purpose. Each event hashes the one before it:
h_i = SHA-256(h_(i-1) || payload_i || t_i)
Change any record and every hash after it stops matching.
Challenges we ran into
- Keeping explanations honest: Our first version let the LLM write the reason freely, and it sometimes sounded right but mentioned things the model never used. We fixed it by giving the LLM only the SHAP output and rejecting any sentence that includes a feature or number that isn't in it.
- Dropped connections: A capture that times out might still have succeeded at PayPal. We solved it with idempotency keys, a "pending reconcile" state and a cron job that asks PayPal what really happened.
- Authorization time windows: Held orders can't wait forever, so we had to handle expiry and re-authorization.
- Making the demo real: It was tempting to hard-code outputs. We built a failure-injection panel instead, so you can break the LLM, the model, the network or a webhook signature and watch the system fail safely.
Accomplishments that we're proud of
- Every AI decision changes a real PayPal sandbox call, not a mock.
- The system keeps working when parts fail: kill the LLM or the model and decisions continue, with the fallback level visible in telemetry.
- Humans stay in control: agents propose, people approve, and every step is logged.
- It held up under load: [50] concurrent users with [result].
- We can tell you exactly what works and what is still simulated.
What we learned
Trust in AI payments doesn't come from smarter models alone. It comes from limits and proof: spending mandates, human approval for money moves, explanations tied to the real model, and evidence that shows tampering. We also learned that failing safely is a feature.
What's next for SafeHaven Pay
- Connecting to real carrier networks instead of our simulator.
- Training on real, labeled fraud data and learning from outcomes over time.
- Supporting many merchants, with proper identity checks and compliance review.
- Working with emerging standards for agent-to-agent payments.
Honest scope
The PayPal sandbox flow, risk model, agents, console and evidence chain run live. The fraud data is synthetic, carrier events come from a simulator that posts to the real signed endpoint, and the spending-mandate format is our own design.
Built With
- ag-grid
- bryntum
- fastapi
- github
- paypal
- postgresql
- python
- react
- rend
- scikit-learn
- shap
- typescript
- vite
- webhooks
- xboost