Follow-up round: the user paid and the app died
The setup
You designed in-app purchases for an Android app with one monthly subscription. The user taps Buy and pays in Google Play, and the store takes the money. Before the app unlocks anything, the system kills the app.
The question
The interviewer asks: "The user paid, but the app died before it unlocked the feature. They open the app again. What happens?"
Stop here and answer out loud for one minute.
A weak reply
"When the purchase callback says OK, I unlock the feature and acknowledge the purchase." This works only if the app lives to the end of the callback. If the app dies between the unlock and the acknowledge, or my server was never told, no record exists where I control it. The user paid and has nothing.
A strong reply
- The store is the seller, so its record is the truth. The store still shows the purchase as not acknowledged, so it is not lost.
- On every start and every resume, the app asks the store for the user's purchases. This is called a reconcile. It finds the unfinished purchase.
- The app sends the store's proof to my server. The server checks it with the store, saves it under the store's purchase token and grants access.
- Only then does the app acknowledge the purchase. The order is: verify, grant, then tell the store.
- The same proof can arrive twice, once from the callback and once from the reconcile. The server uses a unique key on the purchase token, so the second send returns the first answer. The user gets access once.
The twist many people miss
The interviewer asks: "The user opens the app a week later, not a minute later."
A good answer: on Android, Google says a purchase must be acknowledged within three days, or it is refunded automatically and access is revoked. After a week, the money is already back. The app should show that cleanly: no purchase found, and a Buy button. The fix is to reconcile on every start and resume, so the gap is hours, not days. If my server is down, the app retries with backoff and shows "Processing your purchase", not "failed", and the retries must fit inside the three days.
Check yourself
- Did you say the store, not the app, holds the truth about the purchase?
- Did you say how the app finds the purchase again after it was killed?
- Did you put the steps in order: verify, grant, then acknowledge?
- Did you cover the same proof arriving twice, and the three-day window?
Score your answer on the score sheet.
Go deeper
- In-app purchases case: section 4.1 walks one purchase from tap to access, and the failure table has a row for an app that dies after payment.
- Build guide: the server tables, the calls and the code.
- Idempotency keys: why the same request twice must give one result.
Get the follow-up round by email
One short email each week. The cheat sheet comes with the first one.
You confirm your address first. Unsubscribe any time. Privacy.