Inspiration

High-value B2B hardware and consumer electronics transactions fail for three connected reasons: buyers struggle to verify physical dimensions before checkout, sellers juggle manual GST invoicing and multi-marketplace fragmentation, and standard payment authorizations expire before long hardware manufacturing and shipping cycles finish. AC PayPilot unites spatial 3D/AR inspection, Gemini AI automation, and deterministic PayPal Escrow protection in a single zero-leak multi-tenant platform.

What it does

AC PayPilot delivers isolated, role-governed workspaces for both Customers and Business Operators:

  • Customer Spatial Discovery & SmartCart: Browse products in interactive 3D/WebXR (<model-viewer> backed by procedural binary glTF 2.0 .glb generation), ask grounded spec Q&A, optimize carts against a strict budget ceiling with Gemini AI, and track escrow-protected deliveries and tax receipts.
  • PayPal Escrow Settlement Engine: Protects buyer funds through an auditable state machine (created -> funded -> in_delivery -> released | disputed | refunded) with server-verified PayPal capture reconciliation and buyer/merchant dispute resolution.
  • Merchant & Finance Command Center: AI Listing Generator, custom Storefront Builder, InvoiceIQ deterministic Indian GST validation (CGST/SGST vs. IGST Place-of-Supply), payment ledger reconciliation, and executive KPIs.
  • Role-Scoped Autonomous Copilot: Recommends escrow actions and procurement optimizations while enforcing AI_DIRECT_MUTATION_FORBIDDEN—every escrow release, refund, or dispute requires explicit confirmation by an authorized human role.

How we built it

  • Frontend: React 19, TypeScript, Vite, Tailwind CSS v4, React Router, Three.js & <model-viewer> WebXR, Recharts, and AG Grid / AG Studio telemetry.
  • AI Layer: Google Gemini (@google/genai) powering SmartCart optimization, grounded Q&A, listing generation, InvoiceIQ document analysis, and role-scoped Copilot advisory.
  • Payments & Deterministic Accounting: Express + Node.js backend integrating PayPal Orders v2 and Zod validation. All monetary calculations run in integer minor units (paise/cents) to eliminate floating-point drift:

\( M_{\text{minor}} = \text{round}(M_{\text{major}} \times 100) \)

$$ \text{Total Payable} = \text{Subtotal}{\text{minor}} + \text{Tax}{\text{GST}} \quad\text{where}\quad \text{Net Merchant Payout} = \text{Total Payable} - \text{PayPal Fee} $$

  • Security & Multi-Tenancy: Firebase Authentication (Google, Facebook, and Email/Password) + Cloud Firestore with strict tenant-scoped security rules, server-derived RBAC (customer, seller, finance, business_head), and complete UI/API isolation so customers never see operator controls or tenant secrets.

Challenges we ran into

  1. PayPal Authorization Expiration vs. Physical Shipping Windows: Under PayPal Orders v2 intent=AUTHORIZE, card network honor guarantees last only 3 days (expiring at 29 days), which is too short for 5–14 day B2B hardware manufacturing and delivery. We architected immediate intent=CAPTURE at checkout paired with an immutable application-level escrow ledger and audit event trail (escrowEvents).
  2. Capture Concurrency & Crash-Safe Reconciliation: Simultaneous capture requests or database interruptions during PayPal capture can leave funds captured without an updated order record. We implemented idempotency-key locking, capture-ID reuse rejection (409 PAYPAL_CAPTURE_REUSED), and an explicit 502 PAYMENT_CAPTURED_RECONCILIATION_REQUIRED failsafe so paid orders are never silently marked failed.
  3. Zero-Leak Customer Isolation: Preventing cross-role escalation required locking both backend Firestore rules/API tokens and frontend route guards, search indexes, notifications, and live Firestore subscriptions (businesses/{bizId}) away from customer sessions.

What we learned

  • Financial AI agents work best as deterministic auditors and advisors, never holding unilateral authority to mutate settlement balances (AI_DIRECT_MUTATION_FORBIDDEN).
  • Enforcing single-source-of-truth pricing on the server (ignoring client-submitted totals) and integer minor-unit math makes payment reconciliation predictable under concurrency.

What's next for AC PayPilot

  • Multi-currency cross-border settlement corridor expansion beyond INR and USD.
  • Webhook-driven carrier GPS telemetry to trigger automated buyer delivery verification prompts.
  • Merchant custom domain automation with one-click SSL provisioning for public storefronts.

Built With

Share this project:

Updates

Submission history