Inspiration

Anyone who has run a small e-commerce business knows that handling customer disputes and refunds is one of the most stressful, time-consuming parts of the job. It often involves back-and-forth emails, verifying claims, and manually logging into payment gateways to issue refunds. We realized that with the reasoning capabilities of modern LLMs and the powerful APIs of PayPal, this entire workflow could be automated. We built FairPlay to be a "smart escrow" or automated mediator that saves businesses hours of customer service time while giving customers instant resolutions.

What it does

FairPlay is an automated dispute resolution center for e-commerce.

The Purchase: A customer buys an item using the PayPal Checkout integration. The Dispute: If the customer has an issue, they enter their PayPal Capture ID into the FairPlay Resolution Center. The Mediation: The customer chats with our AI Agent (powered by Google Gemini). The AI acts as the merchant's representative, equipped with a strict set of return policies (e.g., "Full refund for broken items, $15 partial refund for scratches, deny refunds for 'change of mind'"). The Resolution: If the AI determines the customer's complaint is valid under the policy, it automatically triggers the PayPal Refunds API in the background, sending the money back to the customer instantly without any human intervention from the merchant. How we built it

We built the application using a full-stack JavaScript environment to keep it lightweight and fast:

Frontend: Vanilla HTML, CSS, and JS. We integrated the PayPal JavaScript SDK to render the smart payment buttons and capture the initial order. Backend: A Node.js / Express server. This server securely handles the PayPal REST API calls (generating access tokens, capturing orders, and issuing refunds). AI Integration: We used the @google/generative-ai SDK (Gemini 1.5 Flash). We designed a system prompt that forces the AI to evaluate the chat history against our mock store policy. When the AI decides to refund, it outputs a hidden JSON command ({"action": "refund", "amount": "X"}). Our Node.js server intercepts this JSON and bridges it directly to the PayPal Refunds endpoint.

Challenges we ran into

The biggest challenge was bridging the gap between natural language (AI) and rigid financial APIs (PayPal). Language models are conversational, but PayPal requires strict API calls with specific Capture IDs and exact monetary amounts. We had to do some prompt engineering to ensure the Gemini model would only output the refund trigger command when it was absolutely certain, preventing users from tricking the AI into giving them free money!

Accomplishments that we're proud of

We are incredibly proud of the "Magic Bridge" we built between Gemini and PayPal. Watching the AI agree with a customer's complaint and seeing the PayPal refund execute automatically a split-second later feels like a glimpse into the future of automated e-commerce.

What we learned

We learned a lot about the intricacies of the PayPal Developer platform. Moving beyond simple checkout buttons to programmatic server-side captures and refunds opened our eyes to how powerful the PayPal ecosystem is for developers building complex marketplace logic.

What's next for FairPlay

In the future, we want to expand FairPlay to accept image uploads. By utilizing Gemini's multimodal vision capabilities, a customer could upload a photo of a broken product, and the AI could visually verify the damage before issuing the PayPal refund, making the system completely foolproof!

Built With

Share this project:

Updates

Submission history