Make a Google Pay Charge Endpoint Safe to Retry With Idempotency Keys

Last updated: November 29, 2026

Quick Overview

Implement a server-side idempotency layer for a payment charge RPC so that client retries after timeouts never double charge, and a reused key with a different payload is rejected.

Google
Software Engineering Fundamentals
Software Engineer
Google
November 29, 2026
Software Engineer
Onsite
Software Engineering Fundamentals
Medium

0

0

0 solved


Implement a server-side idempotency layer for a payment charge RPC so that client retries after timeouts never double charge, and a reused key with a different payload is rejected.

Payments teams at Google care deeply about retries because mobile clients on flaky networks resend requests after timeouts. The interviewer checks that you separate the in-flight, completed and conflicting cases and that the key store is updated atomically with the side effect.

What the Interviewer Expects
  • Store the request fingerprint alongside the idempotency key
  • Return the saved response for a replay with the same payload
  • Reject the same key with a different payload
  • Handle a concurrent duplicate while the first is in flight
  • Discuss key expiry and storage cost
Key Topics to Cover
idempotency
retries
payments API
request fingerprinting
exactly-once effects
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
  • How do you make the key insert and the charge atomic across two systems?
  • What TTL would you choose and why?
  • Should a failed charge be cached or retried on replay?
  • How do you scope keys so two merchants cannot collide?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements
  • charge(key, merchant, request) performs the charge at most once per (merchant, key).
  • Same key and same body: return the original response, do not charge again.
  • Same key, different body: retu...
High-Level Design

Keys are scoped by merchant so they cannot collide across tenants. The store row holds state, a SHA-256 fingerprint of the canonical request, and the final response. The first request claims the key...


Submit Your Answer
Markdown supported