Inspiration
Coupon codes are a leaky way to give a discount: they get forwarded, posted publicly, and farmed. Earned Price replaces the code with proof — the price a buyer pays depends on verified public facts about them, so there is nothing to leak.
What it does
Earned Price is a checkout where the price depends on verified public facts about the buyer instead of a coupon code — so there is no code to leak, forward, or farm. A merchant writes a discount rule in a plain sentence (for example: 20% off for buyers whose GitHub account is at least a year old). AI compiles that sentence into a typed, tiered rule over a small whitelist of GitHub profile fields, and reads it back in plain English for the merchant to confirm — AI proposes, but deterministic code decides every money figure. At checkout the buyer signs in with GitHub (zero OAuth scopes requested) or picks a labelled sample profile; the price builds up live, tier by tier, from facts read at that moment. Payment runs through PayPal at the earned price, with the discount shown as its own line and a hash of the fact snapshot stored in the order's custom_id. The licence key is issued only after capture. The receipt page re-reads the order from PayPal and verifies the amount, so every figure the buyer sees after payment comes from PayPal itself. It also supports buy-first-prove-later: pay full price now, prove eligibility afterward, and the difference is refunded through PayPal with an idempotency key. One redemption per GitHub user ID stops repeat farming. Built for developer-tool and course sellers, and conferences that discount for open-source contributors.
How we built it
Next.js and TypeScript for the app, PayPal Sandbox REST API for orders, captures, and refunds, GitHub OAuth (zero scopes) for verified public profile facts, Neon Postgres for orders, rules, and redemptions, Render for hosting, and Nebius Token Factory (DeepSeek-V4.1-Flash) for the natural-language rule compiler. The compiler is constrained to a typed, whitelisted set of GitHub fields and tiered rules; deterministic code — not the model — computes every price.
Challenges we ran into
Keeping AI in its place: letting a merchant write rules in plain English without letting the model touch money. The fix was a strict boundary — AI proposes a typed rule and a plain-English read-back, and only deterministic code evaluates it. We also had to close farming loopholes, for example by excluding a buyer's own repositories from contribution-based tiers, enforce one redemption per GitHub user ID, and make the receipt trustworthy by re-reading the order from PayPal instead of trusting local state.
What we learned
That a trustworthy discount needs three separate proofs: the facts at pricing time, the amount PayPal actually captured, and the receipt re-read from PayPal — and that a clear AI/human boundary makes a natural-language feature safe to ship.
Verified test purchases (PayPal Sandbox — no real money)
- Full price $49.00 — PayPal order 3CS134817H552132M, capture 197537775B952582H — receipt https://earned-price.onrender.com/receipt/412e4544-5bc1-4646-aacb-2713f245607b
- Discounted $39.20 (20% rule) — order 8UL89980VA964960L, capture 6K137337FV498643Y — receipt https://earned-price.onrender.com/receipt/981494b0-762d-46e0-b340-e44aa10f95b4
- Card-path purchase $39.20 — capture 0LR99988EE190960X, licence EP-LU4YTJ35DNAMDPNVKNZO — receipt https://earned-price.onrender.com/receipt/6682a314-32f4-3d3b-8ebc-8250279310fe
Try it
- Live demo: https://earned-price.onrender.com
- Pre-built rule shop (20% off for GitHub accounts at least 365 days old): https://earned-price.onrender.com/shop/d12efe07-a04b-418f-abfd-5d5c99cdaad0
- Public repo (MIT): https://github.com/Ps23102004/earned-price
Built With
- deepseek
- github
- nebius
- neon
- next.js
- oauth
- paypal
- postgresql
- render
- typescript