Inspiration
AI is changing how people discover and purchase products. Users can describe what they want in natural language and let AI help them find suitable products. However, giving an AI agent the ability to initiate purchases introduces a critical problem: How can we make AI-powered shopping convenient without giving AI uncontrolled authority over someone's money?
We built AI Cart around one principle: AI should assist purchasing decisions, but the user must remain in control of every financial commitment.
Instead of treating payment as the final step of an AI conversation, we designed a system in which product discovery, purchase validation, user authorization, and payment execution are separate, verifiable stages.
What it does
AI Cart is an AI-assisted shopping application that combines Gemini, Channel3, and PayPal to create a controlled purchasing workflow.
- Gemini: Understands natural-language shopping requests and structures them into a Purchase Contract.
- Channel3: Provides product discovery and candidate retrieval for the shopping workflow.
- Deterministic PolicyEngine: Evaluates product eligibility, category compatibility, and uncertainty using explicit backend rules rather than allowing an AI response to make financial decisions.
- User-controlled selection: The shopper reviews and selects the product before proceeding.
- Transaction authorization: A separate, single-use approval is required before payment can proceed.
- PayPal: Handles checkout and server-side payment capture through PayPal Orders v2 Sandbox.
The fundamental distinction is that an AI recommendation is never equivalent to purchase authorization.
How we built it
We built AI Cart using Python, Django, and SQLite, with a contract-first engineering approach.
The application follows a deliberately separated architecture:
- Intent understanding: Gemini converts the shopper's natural-language request into structured purchasing requirements.
- Product discovery: Channel3 supplies product candidates for evaluation.
- Policy evaluation: A deterministic Python PolicyEngine evaluates the proposed purchase against explicit rules.
- Purchase confirmation: The shopper selects and reviews the intended product.
- Transaction authorization: The backend validates a separate, single-use approval.
- Payment execution: The server creates and captures the PayPal order only after the required approvals.
- Auditability: Payment outcomes, transaction history, and receipts are recorded for subsequent review.
We also implemented several safeguards:
- SHA-256 cart fingerprints covering 15 transaction terms to detect changes between approval and execution.
- Atomic, single-use transaction approvals to prevent approval reuse.
- Python Decimal arithmetic for accurate monetary calculations.
- Server-side PayPal capture and webhook verification.
- Receipt-total reconciliation and payment/refund history.
- CSRF-protected application flows.
The architecture deliberately keeps financial authority in deterministic backend code rather than in the language model.
Challenges we faced
The biggest challenge was balancing AI flexibility with financial reliability.
Natural-language models can interpret ambiguous requests, but their outputs should not determine whether a transaction is financially authorized. We addressed this by separating AI-assisted interpretation from deterministic validation and transaction execution.
Another challenge was ensuring that the purchase approved by the user remained the same purchase submitted to PayPal. We implemented transaction fingerprints, atomic single-use approvals, and server-side checks to protect this boundary.
Integrating multiple services also required careful handling of external dependencies, payment states, webhook events, and failure scenarios. We treated unverified external-service behavior as something requiring further validation rather than assuming that a successful local test guaranteed production reliability.
What we learned
We learned that building an AI-powered commerce application requires more than connecting a language model to a payment API.
The important engineering challenge is defining exactly where AI authority ends and application authority begins.
Gemini can understand intent. Channel3 can help discover products. Deterministic backend logic can enforce purchasing policies. PayPal can execute the payment.
But the final purchasing decision belongs to the user.
AI Cart demonstrates our approach to a more controlled form of agentic commerce: AI-assisted shopping with explicit human authorization and deterministic financial safeguards.