shop: AGENTS.md describes one-tap checkout
- Commit
88ae4a2ff8639073fce607ef2350d21f3e67f318- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-01 21:05 UTC (1 month ago)
- Parents
6fae978
Diff
shop/AGENTS.md
diff --git a/shop/AGENTS.md b/shop/AGENTS.mdindex b601ef29fd..58899565b6 100644--- a/shop/AGENTS.md+++ b/shop/AGENTS.md@@ -13,7 +13,7 @@ Entry types: MainActivity, Route, Navigation. Navigation remains a root-only gra - Directory merchant links open in the app via an unverified intent-filter generated into `AndroidManifest.xml` by `scripts/shop/generate_merchant_links.py` (rerun per release). Product URLs (`/products/<handle>`) open the product; other URLs open a scoped search. A one-time card sends the user to "Open by default" to approve the hosts. - The buyer profile (first name, last name, email, phone required; delivery address optional) is stored only in the module's SQLCipher Room database (`ProfileRepository`). The app is locked behind the profile form until the required fields validate; the Profile tab edits it. - Checkout takes no buyer input: every session field comes from the saved profile (`ProfileCheckout`). Merchant shipping-option choices remain selectable. Merchant totals and legal links are authoritative.-- Checkout writes require explicit user action and a stable idempotency key per intent. Never replay an uncertain mutation automatically. One Create press may issue a second write that carries the saved delivery address, only after the create succeeded and the merchant advertised shipping or reported `delivery_address_required`.+- Checkout is one tap (a per-store Checkout button in Cart, or Buy now): `ShopViewModel.checkoutStore` creates a fresh session carrying the whole profile (name, contact, address) with a stable idempotency key, then opens the merchant's `continue_url` (from the session or a rejection) in Embedded Checkout. There is no in-app review screen. Never replay an uncertain mutation automatically. - Preserve cart lines through partial failures and browser handoffs. A session or browser return is not a paid order. - Payment happens only inside the merchant's own checkout via UCP Embedded Checkout (ECP) without payment delegation: `ui/EmbeddedCheckoutScreen` loads the merchant `continue_url` with `ec_version`/`ec_color_scheme`/`ec_delegate=window.open` in a WebView. The app never sees card data or tokens and never calls Complete Checkout. The `EmbeddedCheckoutProtocolConsumer` bridge is an origin-scoped `WebViewCompat.addWebMessageListener` (merchant domain, its subdomains, the handoff host, shop.app); `domain/EmbeddedCheckout` answers `ec.ready`, opens `ec.window.open_request` links in a Custom Tab, and treats `ec.complete` as the only completion signal. Only the order id, order permalink and total are persisted; the session URL stays in memory. - Only supported integer quantities can be added. Detail refresh sends the product ID and selected options, and must confirm the exact variant before cart actions. If a valid detail response returns only another featured option, one fresh advertised merchant search may confirm the exact SKU. Cached snapshots and empty lookup responses are not verification; denied/rate-limited calls are never retried automatically.@@ -25,7 +25,7 @@ Entry types: MainActivity, Route, Navigation. Navigation remains a root-only gra ## Responsibilities - `ShopBackend` owns the four server calls (search/product/checkout/merchants) plus error-envelope mapping. It never talks to merchant hosts.-- ShopViewModel owns explicit cart, profile and per-merchant native-review state. Buyer PII must never enter logs or persisted history; the encrypted profile database is its only store.+- ShopViewModel owns the cart, profile and the in-flight one-tap checkout. Buyer PII must never enter logs or persisted history; the encrypted profile database is its only store. - Local stores retain pending checkout records for browser recovery, not order confirmations. - UI uses shared app scaffolds and controls; one public composable per file. Metadata previews are class members with PreviewTest and Preview.