Inspiration
When I first explored the PayPal Developer portal, I was struck by the simplicity of creating a payment flow, but I wondered what would happen if an AI could drive that flow on behalf of the user. The idea of turning a natural‑language request (e.g., “I need a cheap wireless mouse”) into a complete e‑commerce transaction seemed both novel and instantly understandable for judges.
What it does
Provides a chat‑style interface where users ask for product recommendations. Uses OpenAI’s Chat Completion API to generate a single product suggestion in JSON (name, description, price). Dynamically creates a PayPal order for the quoted price and renders the PayPal button. Captures the payment in the PayPal sandbox and shows a success message.
How we built it
Backend (Flask) – Exposes /api/chat, /api/create-order, and /api/capture-order endpoints. AI Prompt Engineering – System prompt forces the model to return strict JSON. PayPal SDK – paypalcheckoutsdk on the server for order creation/capture; JavaScript SDK on the client for the button. Frontend (HTML/JS) – Simple chat UI, parses the JSON response, injects the PayPal button with the generated order ID. Environment Management – .env for credentials, .gitignore to keep secrets out of version control.
Challenges we ran into
LLM output variability – tackled with a constrained system prompt and client‑side JSON parsing fallback. Sandbox token handling – kept client‑id public for the JS SDK and secret server‑side for the Python SDK. CORS concerns – served from localhost to avoid cross‑origin restrictions. Deployability – documented how to set secrets on Render/Vercel for cloud deployment.
Accomplishments that we're proud of
End‑to‑end flow: user message → AI recommendation → PayPal checkout → capture, all in under 30 seconds. Minimal codebase (≈ 150 lines backend, 100 lines frontend) that is easy to understand and extend. Fully functional with PayPal sandbox and OpenAI without any proprietary SDKs beyond the official ones.
What we learned
Effective prompt engineering is key to getting deterministic AI outputs. PayPal’s sandbox provides a realistic testing environment with no real money movement. Secure handling of API keys via environment variables is essential for open‑source projects. Coordinating async flows between front‑end (PayPal button) and back‑end (order creation) is straightforward once the contract is defined.
What's next for PayPal‑AI Checkout
Multi‑turn shopping: refine recommendations based on user feedback. Live product catalog: integrate with an e‑commerce API for up‑to‑date inventory. Voice‑enabled ordering: add Web Speech API for hands‑free interaction. Analytics dashboard: track conversion rates, AI confidence scores, and payment success metrics. Production‑grade deployment: containerize with Docker and set up CI/CD pipelines.
Log in or sign up for Devpost to join the conversation.