Inspiration

Big companies have whole teams watching for fraud. A small online seller has nobody. If a weird payment shows up, they either don't notice it or they notice it and have no idea if it's risky. I wanted to build something that looks at the payment for them, tells them what it thinks in normal language, and lets them decide in one tap.

What it does

Fraud Shield sits behind a seller's PayPal account. When a payment comes in, PayPal sends a webhook to my AWS Lambda function. If the amount is over $500, it gets flagged. Anything smaller just passes through without bothering anyone.

For a flagged payment, I send Gemini some context about the shop: how many payments were flagged before, the average and largest amount, and how many came in the last hour. Gemini replies with a risk level (low, medium or high), a short explanation, and a recommendation to freeze or approve.

The seller gets all of that on Telegram with two buttons, Freeze and Approve. Tapping one saves the decision. There's also a small dashboard that shows every flagged payment with its risk, the explanation and the current status.

How I built it

I used the PayPal sandbox for real test payments and webhooks, three AWS Lambda functions in Python (one for the webhook, one for the Telegram buttons, one that feeds the dashboard), DynamoDB to store the payments, the Gemini API for the analysis, and the Telegram Bot API for alerts. The dashboard and the test checkout page are plain HTML on GitHub Pages. All keys are kept in Lambda environment variables and not in the code, and each Lambda can only touch the one table it needs.

Challenges

The Gemini API gave me the most trouble. Models timed out, returned 503s, or turned out to be retired and returned 404. I ended up with a list of models to try in order, and if all of them fail the seller still gets the alert with a note to check the payment manually.

I also had to fit that retry chain inside Lambda's 30 second limit, which meant shortening timeouts.

PayPal's sandbox blocked my test payments at first because the buyer and seller accounts were both set to India. Creating a buyer in another country fixed it.

The first version of the AI part only looked at the amount, which made it basically a rule with a chatbot attached. Giving it the shop's history made the explanations much more useful.

What I learned

I'm still new to cloud, and this was my first project that connects several services end to end. I learned a lot about webhooks, IAM permissions, how Lambda timeouts work, and how much of the work is debugging the connections between services.

What's missing

Freeze only records the seller's decision right now. It doesn't hold the money in PayPal yet. Calling PayPal's API to do that is the first thing I'd add next.

I also haven't added webhook signature verification, and the endpoints are public, so this is a sandbox demo and not something to run on real payments. After that I'd add a rule for several payments in a short time and put a login on the dashboard.

Links

Built With

Share this project:

Updates

Submission history