Inspiration

I kept reading about AI agents that can shop and pay for things on your behalf, and I couldn't stop thinking about what happens when one gets it wrong. It spends more than you wanted. It pays some random site you've never heard of. It charges the same bill twice. Right now nothing really stands in the way of that, so I decided to build the thing that does.

What it does

PaySec sits between the AI agent and the payment. The agent can ask to pay, but it can't actually pay. Every request goes through a security check first, and the check ends in one of three answers:

  • Approved: it looks fine, so the payment goes through.
  • Blocked: it breaks one of your rules, like going over your daily limit or paying a merchant you've blocked.
  • Pending: it looks a bit off, so it waits until you say yes or no.

Each request gets a risk score from 0 to 100. The score looks at the amount, your limits, how much you trust the merchant, and how often the agent has been paying lately. Your hard limits come first though. If a payment goes over your limit, it's blocked, even if the score looks great.

You can also just type what you want, like "buy a laptop under ₹50,000 from a trusted merchant". The agent turns that into a payment request, and the request still has to pass the check like everything else.

How I built it

The frontend is React, with a dashboard, charts, a page that explains each risk score, an approval center, and pages for merchants and spending limits. The backend is Node and Express with a MySQL database, and login uses JWT.

The risk engine is its own module, so I can swap in a smarter model later. To be clear, right now it's rule-based scoring. It isn't machine learning, and I didn't want to pretend it was.

Payments are simulated, and there's optional PayPal Sandbox support. No real money touches anything.

Challenges

The hardest part was making sure nothing can sneak around the check. The agent, the API and the approval button all go through the same single function, so there's no side door.

Duplicate payments were the other headache. If two identical requests arrive at the same moment, only one should go through. I used idempotency keys, timestamps and database locks for that. When you approve a pending payment, it also re-checks your limits first, because things may have changed since the request came in.

What I learned

Rules and scores do different jobs. The score tells you how worried to be, and the rules tell you what is never allowed. I started out thinking a single score would be enough, and it isn't.

What's next

I'd like to train a real model on transaction history and plug it into the risk engine. I also want two-factor confirmation for big payments, and real PayPal checkout instead of just sandbox orders.

Built With

Share this project:

Updates

Submission history