This document explains the high-level architecture of the StellarPay customer payments showcase.
The system is intentionally narrow in scope: it focuses on a customer-facing payment experience that can resolve tenant-scoped orders, authenticate the customer, create a payment intent, confirm payment status, and persist receipt history.
Show a credible end-to-end customer journey for LaundromatAI x StellarPay:
- customer signs in
- customer sees the correct order context
- customer initiates payment
- system checks payment confirmation state
- customer and support surfaces retain payment proof
flowchart TD
A[Customer Device] --> B[Next.js App Shell]
B --> C[Firebase Auth]
B --> D[Orders and Checkout Routes]
D --> E[Next.js Route Handlers]
E --> F[Demo Order Data Path]
E --> G[Payment State Store]
E --> H[Stellar Helpers]
H --> I[Horizon / Mainnet]
H --> K[Soroban PaymentRegistry Mainnet]
G --> J[Receipt and History Views]
Primary files:
src/app/layout.tsxsrc/app/AppFrame.tsxsrc/index.css
Responsibilities:
- establish the top-level application shell
- render navigation and mobile-first layout behavior
- keep the customer flow consistent across dashboard, orders, pay, history, and profile
Primary files:
src/lib/customerAuth.tsxdocs/customer-oauth-flow.md
Responsibilities:
- enforce signed-in customer context before protected actions
- bind demo customer flow to
demo-tenant-ph - keep the app aligned to the LaundromatAI Firebase Auth model instead of inventing a separate identity stack
Primary files:
src/app/orders/page.tsxsrc/lib/clientDemoOrders.tssrc/lib/customerData.tssrc/lib/useAppBase.ts
Responsibilities:
- resolve customer-visible orders for the target tenant
- provide demo/live fallback behavior for continuity
- route the same customer flow under
/and/stelllarcontexts when needed
Primary files:
src/app/pay/[orderId]/page.tsxsrc/components/QRScanner.tsxsrc/components/MobileSuccessScreen.tsx
Responsibilities:
- render the payment route for a selected order
- enforce the verify-then-pay interaction pattern
- present pending, retry, timeout, and confirmed states
- keep mobile tap behavior reliable enough for PWA-like usage
Primary files:
src/app/api/create-stellar-payment/route.tssrc/app/api/check-stellar-payment/route.tsserver/utils/stellar.tsserver/utils/paymentState.ts
Responsibilities:
- create payment intent and QR payload
- store and update payment snapshots
- poll and validate payment confirmation state
- write enough proof data for receipt and support visibility
Primary files:
src/app/history/page.tsxsrc/lib/receiptStore.tssrc/lib/stellarService.ts
Responsibilities:
- render receipts after payment completion
- preserve payment references for customer review
- provide support-friendly post-payment visibility
Primary files:
contracts/payment-registry/src/lib.rsserver/utils/stellar.tssrc/app/api/contract/verify/route.ts
Responsibilities:
- write confirmed payment records to mainnet contract via
record() - resolve deterministic keys (
PAY-{ORDER_ID}) for verification lookups - expose verifiable on-chain proof through API and direct explorer links
This showcase treats tenant scope as a first-class operating rule. The customer flow is bound to demo-tenant-ph so that order resolution, payment state, and presentation are all anchored to one demo context.
Payment flow is not treated as a public anonymous surface. The customer must enter with a valid auth-backed session before trusted order and payment state is shown.
The architecture does not end at payment initiation. It includes confirmation checks, pending/confirmed states, and receipt persistence because support and operational trust depend on what the user sees after tapping pay.
The repository is optimized to prove a specific end-to-end flow clearly. Some logic is intentionally scoped for demo reliability rather than building a fully generalized platform abstraction.
Hosting target:
- Firebase App Hosting backend
stelllar - region
asia-east1
Operational characteristics:
- production build via
npm run build - post-deploy smoke validation for key routes and assets
- route and asset hardening to reduce public demo regressions
- Local-to-production parity is still imperfect because auth and live data behavior vary by environment.
- Demo confirmation timing can still be influenced by live network conditions.
- Customer device behavior, especially on iPhone PWA, remains a practical checkout risk and requires focused validation.
The value of this repo is not just that it connects a UI to Stellar helpers. The stronger signal is that it treats customer payments as a workflow crossing identity, tenant scope, proof generation, deployment discipline, and mobile reliability.
That is the level at which enterprise reviewers usually evaluate trust in a payment-facing product.