Inspiration
I'm a student from Bangladesh, and I kept reading about small sellers losing payment disputes even when they did nothing wrong. Two things seemed to cause it. Buyers don't understand the fees and protection rules before they pay. And sellers don't keep proper evidence, so they scramble when a dispute opens. I wanted to try fixing the problem before the dispute, not only after it.
What it does
ClearSettle is a merchant-side prototype that follows one order from start to finish:
- The merchant creates an order.
- AI explains the buyer-protection policy in English and Bengali, using only policy text I verified. Merchant and buyer each accept it, and the buyer gets a one-time link.
- The buyer pays with a Braintree Sandbox test card (test money only).
- The merchant uploads packing, label and delivery photos. Each gets a SHA256 fingerprint so later changes can be detected.
- For a simulated dispute, AI drafts a reply from the facts saved in the database. The merchant edits it and clicks Approve. Nothing is approved automatically.
The integrity check is simple: a file is unchanged if its SHA256 fingerprint today matches the fingerprint saved at upload. This does not prove a photo is genuine or when it was taken, and the app says so.
How we built it
- Backend: Python, Flask, MongoDB (PyMongo), Jinja2 pages
- Payments: Braintree Sandbox, which is a PayPal service
- AI: Google Gemini API for the policy explanations and the dispute draft
- Hosting: Render
- Safety: the AI only sees verified policy text and facts from the database. Missing facts must be written as "not recorded"
- Security: hashed passwords, ownership checks on every order, CSRF tokens, 5 MB image-only uploads, and amounts read from the database instead of the browser
Money is stored as whole cents, so a payment of $10.00 is saved as 1000. This avoids rounding errors.
Challenges we ran into
- I couldn't create a PayPal developer account from Bangladesh, so I used Braintree instead and dropped the PayPal REST API, webhooks and the real Disputes API.
- Braintree setup was slow, and its login kept saying my correct password was wrong, which cost me a lot of time.
- I couldn't confirm real PYUSD settlement is available in the sandbox, so I did not build it. Settlement is a clearly labelled simulation.
- I had to stop the AI from inventing rules. The fix was to give it only verified text and block anything unverified.
- I was learning Flask, MongoDB and payments at the same time, mostly alone.
Accomplishments that we're proud of
- A full working flow from order to consent to payment to evidence to AI draft to approval.
- It is clearly labelled as real or simulated everywhere. Nothing fake is shown as real.
- The AI can't act without the merchant: it only drafts, and a human must approve.
- It runs from the README setup steps.
What we learned
- How a web app moves data from a browser to Flask to MongoDB.
- How sandbox payments work with client tokens and one-time payment nonces.
- That a hash detects changes but doesn't prove authenticity.
- That being honest about limits is better than overclaiming.
- How to write prompts that treat supplied text as data.
What's next for ClearSettle PYUSD
- Real PayPal REST and Disputes API integration with webhook signature checks
- PYUSD settlement, only if PayPal supports it and I can verify it
- OCR to read tracking numbers from shipping labels
- A native-speaker review of the Bengali text, plus more languages
- PayPal as a payment method in the Braintree Drop-in
Links: GitHub repo - https://github.com/Iffeleen/ClearSettle-PYUSD
AI disclosure: Gemini powers the app's explanations and drafts. I used Claude as a coding and teaching assistant, and I ran, tested and reviewed the code myself.