Mobile Design Rounds
Case studyAndroidiOS15 min read

Design a hotel or ride booking app (Android and iOS): holds, payments and recovery

Last reviewed . Drafted with AI assistance. Checked against official documentation where noted (how this is checked). Part of: The five-step method · Offline-first guide · Staff-level guide.

Build it. The database schema, API, code and platform limits for a booking app are on a separate page: Build it: a booking app on Android and iOS (18 min read).

How to read this. This page is the 45 minutes, in the order I would spend them. The schema, REST calls, code and platform tables are in the build guide. The follow-up questions are my reconstruction of challenges that public prep material reports. They are not transcripts of real rounds.

TL;DR. My answer: the server owns the money, the rooms, the time and the booking state. The phone keeps one saved attempt and a key (a unique ID that lets the server spot a repeat request). The phone makes the key before the first send. The key is the attempt id. On iOS the attempt is a SwiftData or Core Data row, and the Apple Pay sheet is handled in a short delegate call. After an interruption (a timeout, a bank page, or the system stopping the app), the phone asks the server. It does not guess.

Patterns in this round.

  • State machine (the booking moves through states that the server owns)
  • Memento (one saved attempt and a key survive an interruption)
  • Idempotency key (the key is made before the first send)

More in design patterns in mobile rounds.

Free: one follow-up round a week. A short interview question with a weak and a strong answer, by email. You also get the cheat sheet.

1. Scope and constraints (minutes 0 to 4)

In short: Hotels only. Booking works online only. Rides wait until the interviewer asks.

The prompt: "Design a hotel booking app." I ask five questions and give a default for each:

  • Hotels only, or rides too? Hotels.
  • Hold a room during checkout? Yes, for a short time. The server keeps the room. The length of the hold is a product choice.
  • Which payments? Cards and wallets. The app sends a token (a code that stands for the card). The bank may also ask for an extra check (3-D Secure).
  • Book offline? No. Saved bookings can be read offline.
  • Search? Search exists and returns quotes (prices with an ID and a time).
In scopeOut of scopeLeft for later, if you ask
Quote, hold, pay, confirm, find it againReviews, loyalty, host toolsRides with a live driver marker
Recovery from an interrupted paymentSearch ranking and autocompleteModify and cancel with refunds
Saved bookings offlineThe payment provider's internalsTwo devices; booking offline

The phone can stop the app in the bank page, lose a response, run a wrong clock, or send the user away and never back. The user must never be charged twice, or charged without a booking.

Your decision. The scope question I expect: "Add ride requests too." Do you include them, or leave them for later?

First idea, and why it fails. Say yes and share the checkout. But a ride adds driver matching and a live stream. Time runs out before I draw the recovery path.

What I would say.

Say this. "Hotels are the whole design. A ride adds matching and a live marker, so I will leave it for later. The key and the lookup carry over."

The follow-up question I expect: "It is the same checkout with a map."

Mostly, yes. The live stream is new, and it returns as follow-up 2.

45-minute plan

MinutesStepDrawn by the endCut if behind
0 to 4Scope and constraintsScope, phone risksFewer questions
4 to 14Data and contractsServer owns truth, key, four callsNumbers table
14 to 22Client structureLayers, who owns the pay callOne line per layer
22 to 40Make the hard part workCharge path, hold clockiOS bullets
40 to 45Break it, ship it, roll it backTop failures, the flagTwo failures

2. Data and contracts (minutes 4 to 14)

In short: The server owns rooms, price, time and state. The phone keeps one attempt record.

Your decision. The user taps Pay with no signal. Do you queue the booking like a chat message, or refuse it?

First idea, and why it fails. Queue it as pending, send it later, and show a confirmation. This fails when the room sells while the phone is offline. The app then confirmed a booking that cannot exist.

What I would say. Booking works online only, and I reject the queue. Android's offline-first guide says online-only writes suit work that must happen in near real time, such as a bank transfer (offline-first guide). I turn off the button and show the reason.

The follow-up question I expect: "The user taps Pay in a tunnel, and the signal drops after the tap."

The attempt record is already on disk. When the signal returns, I look up the booking by its key. If it exists, I use it. If not, I send again with the same key.

A price is a quote with an ID and a time. The hold request carries the quote ID. If the price changed, the server answers with a state, and the user must accept the new price.

The contract has four calls:

  • Hold: quoteId in. holdId and a duration out. You can read the hold again by holdId.
  • Pay: holdId, a wallet or card token and an Idempotency-Key header in. A booking with a version out.
  • Lookup: find a booking by the key that created it.
  • Close: the app asks the server to close a key. If a booking exists, the server returns it. If not, the server refuses any later request with that key.

The states run: HELD, PAYMENT_REQUIRED, ACTION_REQUIRED, PROCESSING, CONFIRMED. A booking can also end as EXPIRED, FAILED or CANCELLED.

  • HELD: the room is kept for the user. No payment has started.
  • PAYMENT_REQUIRED: the server waits for a payment token.
  • ACTION_REQUIRED: the bank asks for an extra check (3-D Secure).
  • PROCESSING: the payment provider is working. The result is not known yet.
  • CONFIRMED: paid and booked.

The build guide has the schema and the REST sketch.

My assumptions (examples, not measurements):

AssumptionArithmeticWhat it decides
Hold of 10 minutes, clock 20 minutes fast, send takes up to 2 sA deadline on the device clock is already 10 minutes past. Starting the count before the send costs at most 2 of 600 s, about 0.3 percentCount down from a server duration, on a monotonic clock (a clock that ignores date changes)
After the bank page, poll (ask the server again) at 1, 2, 4, then every 8 s7 s, plus six polls at 8 s is 55 s: 9 pollsPoll for about a minute. Then show "still checking" and rely on push and the next launch
HELDhold timer runsPAYMENT_REQUIREDACTION_REQUIREDonly when the bankasks for 3-D SecurePROCESSINGCONFIRMEDHold timercounts down from aserver durationEXPIRED or FAILEDcan happen beforeCONFIRMEDCANCELLEDafter CONFIRMED
The server moves a booking along one path. A hold timer runs while it is held, and a booking can end early or be cancelled later.

3. Client structure (minutes 14 to 22)

In short: The screen only watches. The pay call and the attempt record live below the screen.

Your decision. Who owns the pay call? Choose from three owners:

  • The ViewModel of the screen (the class that holds the screen state).
  • A background job.
  • A scope that the repository owns (the repository is the class that reads and writes data).

First idea, and why it fails. The ViewModel starts the call in viewModelScope. But Android clears a ViewModel when its owner goes away, for example when its screen leaves the back stack, the list of opened screens (ViewModel). Then the call is cancelled, or its result is lost after the charge.

SavedStateHandle (a small saved store for screen state) survives when the system stops the app, but not a force stop by the user. It holds only small values (saved state).

What I would say. Ownership goes below the screen.

  • A scope that the repository owns runs the call, so leaving the screen cancels nothing.
  • The attempt row holds the key and the status. I write it to Room (Android's on-device database) before the first send.
  • The screen watches the row and never changes the state itself.
  • On iOS the owner is a repository object (an actor) that lives as long as the app. The view model awaits it. I do not start the charge from a SwiftUI .task, because the system cancels that task when the view goes away. The row is SwiftData or Core Data.

In my view, I reject a background job for the charge itself. The user is waiting, and WorkManager (Android's library for background work) is for work that must run even if the app exits or the device restarts (task scheduling). The repository scope still ends when the app ends, which is why the row exists.

The follow-up question I expect: "Where does the recovery lookup run?"

A plain call at startup is enough. It finds the open attempts and asks the server about each one. A background job is the upgrade if recovery must run without the app opening.

readsobservesREST: server owns the truthpaytokeneventsUIsearch, checkout, tripsState holderViewModelRepositoriessearch, booking, tripsLocal databaseattempts, recents, tripsPayment sheetGoogle Pay / Apple PayPayment providertoken, 3-D SecureBackendinventory, holdsUIsearch, checkout, tripsobservesState holderViewModelRepositoriessearch, booking, tripsreadsLocal databaseattempts, recents, tripsPayment sheetGoogle Pay / Apple PaytokenPayment providertoken, 3-D SecureeventsBackendinventory, holds

More links

  • Repositories to Backend: REST: server owns the truth
  • State holder to Payment sheet: pay
Booking app architecture: the UI observes ViewModel state; repositories call a server that owns inventory, price and booking state; payment goes through a wallet and a payment provider.

In Android's terms, the screen and the ViewModel are the UI layer, and the repositories are the data layer. I add a domain layer only when several ViewModels share logic or one ViewModel grows too complex (recommendations). The ViewModel never calls the API. It asks the repository.

4. Make the hard part work (minutes 22 to 40)

In short: One key per attempt, saved first. The bank page is only a hint. The server owns the clock.

4.1 The charge that may or may not have happened (minutes 22 to 32)

Your decision. The pay call times out. You do not know whether the card was charged. What do you send next?

First idea, and why it fails. Send the pay call again, and guard it with a disabled button. Two problems:

  • The server charged the card and the response was lost. A retry with a new key is a second charge.
  • The disabled button lives in memory, and a stopped app forgets it.

What I would say.

Say this. "I make one key per attempt. I write it to Room before the first send. After a timeout, I look it up by that key. If the booking exists, I use it. If not, I send again with the same key, so the server can charge only once. A return from a bank page or wallet is only a hint. I move to processing and ask the server."

I reject a new key for each tap. Stripe's page says that in API v1 the server saves the first result for a key and returns it on retries (idempotent requests). That only works when the key is the same. (A request is idempotent when doing it twice has the same result as doing it once.)

The follow-up question I expect: "The user closes the bank page and taps Pay again. Same key?"

That is a new attempt, so I check the old one first.

  • Look up the old key. If a booking exists, use it.
  • Use a new key only after the old attempt is closed. Ask the server to close it (the Close call). Then a late request with the old key is refused.
  • A wallet sheet makes a new token each time. A new wallet try is therefore a new attempt with a new key. Stripe rejects the same key with different parameters.

The follow-up question I expect: "The bank page says done, then the app restarts. What do you show?"

I show processing, then the answer from the server. Stripe's page says to get the updated PaymentIntent (Stripe's record of one payment) after the challenge (3-D Secure). The redirect result is only a hint.

The follow-up after that: "The app stays closed for two days. The old attempt row is still there. Do you send with its key?"

  • Not blindly. I look the booking up by that key on my own server first. If it exists, I show it.
  • The hold is long gone, so a new send would only return EXPIRED. If no booking exists, I close the old attempt and start again from a fresh quote with a new key.
  • A payment provider keeps keys for a limited time. Stripe says keys may be pruned after at least 24 hours (idempotent requests). So I would keep my own key record on the server for longer, and not rely on the provider's.
1 Key saved firstone key for each attempt, written to disk2 Pay times outthe card may or may not be charged3 Ask the serverlook the booking up by that keyIt existsuse that bookingNot foundsend again withthe same keyA bank page return is a hintshow processing, then ask the server
One key is saved before the first send. After a timeout, the app looks the booking up by that key and sends again with the same key only if none exists.

4.2 The hold and whose clock (minutes 32 to 40)

Your decision. How does the screen know when the hold ends? Do you compare a stored end time with the clock of the device, or count down from a duration?

First idea, and why it fails. Compare a stored end time with the clock of the device. A phone with a clock 20 minutes fast (an example) shows a hold that has already ended. If the user changes the date, the countdown jumps.

What I would say.

Say this. "The server sends a duration. Before the request leaves, I note the time on a monotonic clock, a clock that ignores date changes. I count down from that time. Network delay makes the screen show a little less time than the server grants, never more. At zero, I lock Pay and read the hold again, because the server may have extended it. I save the duration and the clock reading with the attempt, so I can rebuild the countdown after a restart."

I reject the device clock for this. The server checks the hold again when the user pays.

The follow-up question I expect: "The hold ends while the bank page is open."

The server decides.

  • It returns EXPIRED, or it cancels the payment by its own rules.
  • The client shows that state, with an action to check again.

4.3 Where iOS changes the design

The architecture is the same, but the guarantees are different. The Swift code is in the build guide.

  • The Apple Pay sheet waits for my handler, so the server call stays short. A timeout means the result is unknown. I fail the sheet and look the booking up by key.
  • The system may end the app while the user is in the bank page. I restore the attempt record at launch, and the lookup starts when the app becomes active.
  • SceneStorage can restore a screen, but Apple does not say when it writes. So the attempt record goes to SwiftData or Core Data from the first send.
  • A normal URLSession request is suspended soon after the app goes to the background. Wrap the pay call in UIApplication.beginBackgroundTask. If it is cut off, the lookup repairs it.
  • Before I show the Apple Pay button, I check PKPaymentAuthorizationController.canMakePayments(). The app needs a merchant ID and the Apple Pay capability.
  • An Apple Pay retry makes a new token, so it is a new attempt with a new key, after the old key is closed.
  • For the countdown I use ContinuousClock, as the build guide explains.

5. Break it, ship it, roll it back (minutes 40 to 45)

In short: Every failure ends in a booking, a clear error, or a lookup. It never ends in a guess.

FailureUser seesData holdsRecovery
Lost acknowledgement"Checking your booking"Key on the attempt rowLook up, then use it or send again
App stops in the middle of a writeThe attempt, resumedAttempt row in RoomLookup at startup
Duplicate deliveryOne bookingThe same keyServer returns the saved result
Login expires in the bank page, or on the pay call"Checking your booking"Key on the attempt rowA 401 is not a failed payment. Refresh the token once, then call again with the same key
Late response with an older versionThe last known stateA version on the bookingIgnore it. The state never goes back
Wrong device clockA correct countdownDuration from the serverMonotonic countdown; server enforces the end
Permanent rejection"Price changed" or "Sold out"The new quoteUser accepts or goes back
Old app meets new server stateThe last known stateUnknown state valueAsk the server; ask the user to update
User logs out or switches account mid-attemptNothing from the other accountAttempt row with a user IDLook up only with that user's token, when they sign in again
Traveler's phone is in another time zoneThe hotel's dates, unchangedCalendar dates plus the hotel's time zone, from the serverShow dates in the hotel's zone; never convert with the device zone

Rows not linked to a source are my design choices. Sources are in Further reading.

Release reality:

  • Store rollouts can pause, but they do not recall. A halted Play rollout reaches no new users, and users who have the build keep it (staged rollouts). Apple's phased release runs 7 days and can pause for a total of 30 days (phased release). It does not mention reverting installed copies.
  • Old versions stay installed, so the server keeps accepting the old request.
  • The new payment path ships behind a remote flag (a setting the server can change). This is my kill switch, and it is the only rollback that reaches installed apps. The old path must still check the key before it charges.
  • A change to the attempt table, or a new state that old clients do not know, cannot be flagged. It ships one release earlier.

Say this. "I cannot recall a bad build, so the rollback is the flag plus a fixed build. I would watch the rate of unknown outcomes and the reports of duplicate charges, not conversion. I left out rides, modify and cancel, and two devices."

6. Follow-ups that change a constraint

In short: Each follow-up changes one constraint. A strong answer says what breaks.

These are practice prompts with example numbers, not claims about real rounds.

  1. The user taps Pay in a tunnel and stays offline for 30 minutes. Strong: the attempt row is on disk, and the screen says why Pay is off. On return of signal, look up by key before any new send, and expect the hold to have ended. Weak: "Queue the booking and sync later."
  2. Add ride requests with a live driver marker. Strong: the same key and lookup, and a socket (an open two-way connection) only while the trip screen is visible. On reconnect, fetch the latest trip state by ID. Weak: reuse the hotel screen with a map.
  3. Hold on the phone, pay on a laptop; also modify and cancel. Strong: server state is the truth, trips sync by version, and a hold belongs to the user. Modify and cancel reuse the key with a version check. Weak: syncing local rows between devices.
  4. A security review of card data and deep links (links that open a screen in the app). Strong: the app handles only a token, which I believe keeps raw card numbers out of my systems. PCI scope (the card industry's security rules) is my understanding, so I confirm it with the provider. Check every link parameter. Weak: "We store the card encrypted."
  5. After a release, "charged but no booking" reports double. Strong: check the rate of unknown outcomes, switch the flag to the old path, and confirm that it checks the key. Then ship a fix. Weak: "Roll back the release."
  6. The server adds a booking state, and three older app versions are live. Strong: for an unknown state, the app asks the server, shows the last known state and asks the user to update. Weak: assuming everyone updates.

7. What changes by level

In short: Levels differ in who raises the problem, and whether a rollout plan comes with it.

These levels are my own reading, drawn from vendor and prep material. They are not any company's rubric.

  • Mid-level: a working flow, error states, cached trips, and Pay disabled while the request is sending. I want to hear: "I disable Pay while the request is sending."
  • Senior: the saved key with a lookup before any new send, a server duration on a monotonic clock, and states driven by the server. It adds reconciliation after the app stops (comparing the phone with the server). I want to hear: "I write the key to Room before the first send, so after a crash I look the booking up instead of paying twice."
  • Staff: reconciliation across the hold, payment and booking services, flags, and metrics (staff guide). I want to hear: "For example, I would ship the new payment path to 1 percent of users behind a flag. I would watch reports of duplicate charges, not conversion."

Common weak answers. Twenty minutes on backend locks. A happy path with no failure behavior. The UI calling the network. No key before the first send. Trusting the bank redirect. No rollout plan. I took them from public prep material.

Staff answer: the decision and the rollout

  • Decision: a booking state machine owned by the server, with the client as a view of it. The cost is more server work and a poll or push path.
  • Alternative: the client guesses the outcome from redirects and timers. It ships faster, and it charges twice on the first lost response.
  • Revisit trigger: if unknown outcomes stay high after lookup-before-send ships, look at provider events first.
  • Guardrail: reports of duplicate charges and "charged but no booking" must not rise. A conversion win that moves them does not count.

What I read and what is my view: I read the Stripe, Android and store-rollout facts on official pages. The metrics, the rollout plan, the numbers and the level text are my opinion.

Test yourself

In short: Seven questions from this case. Answer each one out loud first, then open the answer.

1. Why does booking work online only, and not like a queued chat message?

A queued booking can be confirmed on the screen after the room has sold. The app would then show a booking that cannot exist. The button is turned off and the reason is shown.

2. The pay call times out. You do not know if the card was charged. What do you send next?

First look up the booking by the key. If it exists, use it. If not, send again with the same key, so the server can charge only once. A new key for each tap would risk a second charge.

3. When is the key made, and where is it saved?

Before the first send, and it is written to the on-device database (Room on Android) together with the attempt status. A disabled button lives in memory, and a stopped app forgets it.

4. Why does the ViewModel not own the pay call?

Android clears a ViewModel when its screen leaves the back stack. The call would be cancelled, or its result lost after the charge. A scope owned by the repository runs the call, and the screen only watches the attempt row.

5. The hold lasts 10 minutes and the phone clock is 20 minutes fast. How do you show the countdown?

Count down from a duration the server sends, on a monotonic clock (one that ignores date changes). A deadline taken from the device clock would already be 10 minutes past.

6. The user returns from the bank page. Do you show Confirmed?

No. The return is only a hint. Move to processing and ask the server, polling at 1, 2, 4, then every 8 seconds for about a minute. After that show still checking and rely on push and the next launch.

7. On iOS, where is the attempt record saved, and why not SceneStorage?

The attempt record goes to SwiftData or Core Data from the first send. SceneStorage can restore a screen, but Apple does not say when it writes. The system may end the app while the user is on the bank page, so the record must already be on disk at launch.

Further reading (official docs)

Words on this page (13)
Acknowledgement
A short reply that says the server got a message. If this reply is lost, the app does not know, so it sends the message again.
Deep link
A link that opens a specific screen in the app.
Idempotent
Doing it twice has the same result as doing it once. This makes a retry safe.
Kill switch
A remote flag that turns a feature off at once. It is the one rollback that reaches apps that are already installed.
Monotonic clock
A clock that only moves forward. The user cannot change it, so it is good for measuring how much time passed.
Offline-first
A design where the app works without a network. It saves each change on the phone first and sends it later.
Remote flag
A setting that the server can change. It can turn a feature on or off without a new release.
Repository
The class that reads and writes data for the rest of the app. It hides whether the data comes from the network or the database.
Rollback
Going back to the old behavior after a problem. A build on a user's phone cannot be taken back, so teams use a kill switch.
Room
Android's library for the database on the phone. You use a DAO to read and write the data.
Staged rollout
A release to a growing share of users, not to everyone at once. It limits the harm of a bad release.
ViewModel
A class that holds the state of one screen. It survives a screen rotation.
WorkManager
Android's tool for background work that must run later. The work survives when the app closes or the phone restarts.

Read the whole glossary

Verification notes (last reviewed 14 Oct 2026)

What I checked (official pages, read on 14 Oct 2026):

  • Stripe idempotent requests: the client sends a unique key (V4 UUID suggested, 255 characters), API v1 saves the first result including 500 errors, keys may be pruned after at least 24 hours, a different parameter set with the same key is an error, validation failures and concurrent conflicts are not saved.
  • Stripe 3-D Secure: requires_action, get the updated PaymentIntent after the challenge, wallets are not always supported.
  • Android: online-only writes for near-real-time work, ViewModel is cleared when its owner goes away, SavedStateHandle survives system process death but not force stop, WorkManager persists across restarts and coroutines do not.
  • Play staged rollout: a halt stops new installs, installed users keep the build. App Store phased release: 7 days, pause up to 30 days in total.

What I did not verify:

  • The Android and Apple clock reference pages did not load, so the monotonic clock advice rests on my earlier reading.
  • The Apple Pay pages did not load, including any time limit for the sheet.
  • The PCI sentence in follow-up 4 is my understanding. Ask your payment provider.
  • That some providers want a new key after an abandoned bank page. I word it as "providers differ".

My design, not a source: the failure table, the Close call, the rollout plan, the metrics, the numbers (10-minute hold, 20-minute clock error, polling delays, 1 percent rollout), the follow-ups and the level text. Follow-ups are practice prompts, not transcripts of real rounds. The arithmetic: 2 s of 600 s is 0.33 percent, and 1 + 2 + 4 = 7 s plus six polls at 8 s is 55 s, which is 9 polls.

Questions or corrections?

Add them to the discussion thread for this case on GitHub. To post, you need a free GitHub account. What you write there is public and follows GitHub's terms. Good answers are added to this page.

Keep reading

Get the free one-page cheat sheet

One page: the five steps, a 45-minute time plan and two checklists. Print it or keep it on your phone.

We email you the cheat sheet after you confirm your address. You can also open it now from the Start here page. You also get a short email each week with a follow-up round, and a note when a new case is published. Unsubscribe any time. Privacy.