On this page
An e-commerce app needs to turn a product choice into an order the merchant can fulfill. Begin with physical products, one currency and clear shipping rules rather than mixing downloads, subscriptions and multiple warehouses. The first build should prove that a customer pays the trusted price, receives one durable order and cannot purchase inventory that another checkout has already consumed.
Screens
- Home: introduce owner-supplied collections and direct customers to available products.
- Product list: filter the actual catalog and distinguish unavailable variants from purchasable ones.
- Product detail: show variant-specific price, images, stock status and supplied product descriptions.
- Cart: keep selected variant quantities with estimates that are refreshed before payment.
- Checkout: collect required delivery details and present the authoritative shipping and tax quote.
- Orders: retrieve customer-owned purchases and their actual fulfillment and refund states.
Data model
| Table | Key fields | Purpose |
|---|---|---|
| products | id (uuid), title (text), description (text), active (bool) | Merchant-maintained catalog entries and approved product information. |
| variants | id (uuid), product_id (uuid), sku (text), price_minor (int), currency (text), stock (int) | Purchasable size or color variants with trusted prices and inventory. |
| orders | id (uuid), customer_id (uuid), total_minor (int), state (text), request_key (uuid) | Idempotent purchases with a server-calculated payable amount. |
| order_lines | id (uuid), order_id (uuid), variant_id (uuid), quantity (int), unit_price_minor (int) | Historical purchase facts that survive later catalog edits. |
| payments | id (uuid), order_id (uuid), provider_reference (text), state (text) | Verified provider results without storing payment credentials. |
| stock_reservations | id (uuid), order_id (uuid), variant_id (uuid), quantity (int), expires_at (timestamptz) | Temporary capacity holds governed by an explicit expiration policy. |
Expose published product information publicly, but restrict order reads to the purchasing customer and authorized merchant roles through backend row-level security. Only server code may calculate final amounts, reserve stock or change verified payment state. Use conditional stock updates or locked inventory rows inside a transaction so two buyers cannot consume the same final unit. Define reservation expiration and delayed-payment handling together: a successful late provider event must not silently sell already released inventory. Private shipping addresses must never be returned with the public catalog.
Native features
For a physical-goods shop, the most useful native features are a recoverable cart, an address handoff that avoids retyping where appropriate, and order-status notifications. Room and SwiftData may preserve selected variant IDs and quantities, but checkout must retrieve current prices and stock from the server. Purchase alerts require a configured remote sender tied to verified order changes, not a timer started when the customer taps Pay. Let a customer open an order receipt even with notifications refused. Never treat a phone's cached total as authority to charge a merchant account.
Android notes (Kotlin and Jetpack Compose)
Render catalog results with a LazyVerticalGrid keyed by product ID and use Material 3 chips to choose available variants. A ModalBottomSheet can edit quantity and size, while Navigation Compose carries the variant identifier into the cart. Persist the cart in Room, separating it from server-owned order and payment state. WorkManager may refresh recoverable cart metadata, but it must not silently repeat checkout or charge a card. On an Android phone, save the last unit of a size, background the app, sell that unit from another account, and resume checkout. Show the unavailable line and updated total before allowing another purchase attempt.
iPhone notes (Swift and SwiftUI)
Use a NavigationStack for catalog, product detail, cart and receipt, with a List of cart lines keyed by variant rather than product name. A SwiftData cart can retain quantities between launches; .refreshable should revalidate availability without erasing the customer's choices. Present shipping-address editing in a sheet, and keep payment cancellation distinct from an order failure. Route UserNotifications taps to an authenticated order lookup. On an iPhone, complete a test payment, interrupt the return to the app, then reopen Orders. The verified purchase must appear once even if the client never saw the payment success screen.
Copy-paste prompt
Build an e-commerce app for Android with Home, Product list, Product detail, Cart, Checkout and Orders. Sell physical products initially in one owner-selected currency. Ask for actual catalog prices, variants, tax, shipping regions, delivery fees, stock reservation expiry, cancellations and refund policies. Model products, variants, order lines, orders, payments and inventory holds. Calculate trusted prices on the server and reserve stock transactionally so the final unit cannot be oversold. Use Stripe or Razorpay with server-created payment orders, server verification and signature-checked webhooks; never mark paid from a client callback alone. Treat duplicate events idempotently. Include loading, empty catalog, unavailable variant, changed price, payment pending, connection failure and denied notification states. Acceptance requires one verified test purchase, correct stock handling, order recovery after reopening and rejection of another customer’s attempt to read the shipping details.
Opens Apirex with this prompt in the box. Pick the Android · Kotlin tab before you send.
Acceptance test
- Configure a physical product with two variants and set one variant’s stock to one; define explicit test shipping and tax rules.
- Submit competing checkouts for the final unit from two accounts and verify the server admits only the permitted inventory reservation.
- Change the submitted unit price and require the trusted server price; complete the accepted purchase through the provider’s test environment.
- Replay the verified provider event and confirm one paid order, one inventory decrement and unchanged purchased line prices.
- Reopen Orders as the buyer, then request that order from the other account; preserve the purchase for its owner and deny access to its private address.
Frequently asked questions
Can I use the same payment flow for downloadable products?
Not without reviewing distribution rules and product type. As of November 2026, digital goods used within native apps may require Google Play or App Store billing; physical merchandise checkout is not blanket permission to sell in-app digital access through Stripe or Razorpay.
What if payment arrives after an inventory hold expires?
The merchant must choose an explicit recovery policy, such as a new stock check followed by fulfillment or a controlled refund process. Do not issue a shipping promise merely because a delayed provider notification says money was received.
When should a refund return stock?
Payment refund and physical return are different events. Ask the merchant whether restocking follows cancellation, warehouse inspection or another documented step, then make that stock movement auditable rather than automatically increasing inventory on every refund notification.
Build this blueprint
The blueprint prompt, ready for your platform. Edit anything before you send it.
Opens Apirex with this prompt. Pick the Android · Kotlin tab before you send. The Free plan includes 5 Rex Credits a day.