Inspiration
Free trials are the easiest thing on a subscription product to abuse. One person, a new email, another trial, and every abused trial costs real money. Blunt fixes like IP bans punish honest customers too.
What it does
TrustGate sits in front of PayPal Subscriptions.
- Before PayPal is called, every signup gets a risk score (0-100) and a decision: allow, flag or block, with plain-language reasons. The score combines a rule engine (disposable email, datacenter IP, device and IP velocity) with a small ML model. The higher of the two wins.
- Clean signups go to PayPal and get a 7-day free trial. Flagged ones must pass a one-time code first. Blocked ones never reach PayPal.
- After the buyer approves on PayPal, TrustGate reads the subscription. If that PayPal account already holds another free trial, it cancels the new one through the PayPal API. A fresh email or a new device does not help the abuser, because the payment identity is the same.
- A console shows every signup, every trial with its PayPal subscription id, and the model.
- Principle: paying customers are never blocked from paying. TrustGate only stops repeat free trials.
How we built it
FastAPI, PostgreSQL, Redis (sliding-window velocity counters), React, Docker Compose. PayPal Subscriptions API on Sandbox. The ML model is LightGBM trained on synthetic signup data that we generate ourselves, calibrated, with per-decision reasons. 22 automated tests (PayPal mocked), and the three flows were also run end to end against the real PayPal Sandbox.
Challenges we ran into
Keeping honest customers out of the way: a flag means a one-time code, not a ban. Being honest about the model: it is trained on synthetic data, so we report its numbers as a pipeline check, not real-world accuracy. And PayPal Sandbox accounts created with country India failed on the approval page, so we use US accounts.
Accomplishments that we're proud of
A complete flow that works end to end on the real Sandbox: allow, approve, detect reuse, cancel via API, and block before PayPal.
What we learned
How PayPal billing plans model a free trial (a TRIAL cycle followed by a REGULAR cycle), and that the strongest anti-abuse signal in a subscription flow is the payer account, not the email.
What's next for TrustGate
An AI agent that resolves account-sharing cases (offer a family plan or a verification step instead of blocking a paying customer), real labelled data from a live store, and multi-tenant API keys.
Built With
- docker
- fastapi
- lightgbm
- postgresql
- react
- redis