Square logo

Square Software Engineer System Design Questions

16 practice questions for Square Software Engineer interviews

Square software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.

Software Engineer Backend Engineer Frontend Engineer Full Stack Engineer Mobile Engineer Data Engineer Data Scientist ML Engineer DevOps Engineer DevOps Engineer Product Manager SRE Security Engineer Engineering Manager Data Analyst UX/UI Designer QA Engineer

No verified questions yet for Square.

system design Hard api design #1

1. Design OfflinePOS — reconcile queued Square POS payments and refunds


Background
Square sellers need to keep recording sales when a point-of-sale terminal loses connectivity. Design an in-memory model of the merchant-side reconciliation logic: terminals queue payment and refund operations offline, then synchronize against shared order balances. This exercise models bookkeeping only, not card authorization, and its reconciliation policies are exercise-specific rather than claims about Square's production behavior.
Requirements
1. Orders and offline queues: Create orders with positive integer totals in cents. Each terminal has a FIFO queue. Enqueuing an operation must not change an order's balances; only sync can do so. All orders must be created before operations referencing them are queued.
2. Global idempotency: An operation ID is unique across all terminals and operation types. Enqueuing a new ID returns "QUEUED". Reusing an ID with exactly the same terminal, operation type, order, amount, and referenced payment returns "DUPLICATE", without re-enqueuing it. Reusing it with any different field returns "CONFLICT". Retain IDs even after rejection. For a previously seen operation ID, perform this identity check before validating the new payload.
3. Payment reconciliation: sync(device_id) processes that terminal's pending operations in FIFO order and removes them from its queue. A payment is applied only if captured_cents + amount_cents <= total_cents; otherwise reject it with "PAYMENT_LIMIT". Accept or reject the entire operation, never a portion. When terminals compete, the order in which sync is called determines the winner.
4. Refund reconciliation: A refund references a payment's operation ID. That payment must already have been applied to the same order when the refund is processed; otherwise reject the refund with "UNKNOWN_PAYMENT". Refunds against one payment may cumulatively total at most its captured amount; exceeding that amount produces "REFUND_LIMIT". Successful operations return "APPLIED". Rejections are final: a corrected attempt requires a new operation ID.
5. Balances and results: Track cumulative captured and refunded amounts separately. Refunds do not reopen an order for additional payments: due_cents = total_cents - captured_cents, and net_cents = captured_cents - refunded_cents. Each sync returns a list of {"operation_id": string, "status": string} results. Syncing an empty or unknown terminal returns []. Returned results and order snapshots must not expose mutable internal state.
6. Validation and execution model: Empty identifiers, nonpositive amounts or totals, duplicate order creation, and references to nonexistent orders raise ValueError without changing state. A refund may be queued before its referenced payment exists. Methods execute sequentially; synchronization is explicit, synchronous, and has no simulated transport failures.
Class API
  • OfflinePOS() — Construct an empty merchant reconciliation model.

  • create_order(order_id: str, total_cents: int) -> None — Register an order; duplicate order IDs are invalid.

  • queue_payment(device_id: str, operation_id: str, order_id: str, amount_cents: int) -> str — Queue a payment, returning QUEUED, DUPLICATE, or CONFLICT.

  • queue_refund(device_id: str, operation_id: str, order_id: str, payment_id: str, amount_cents: int) -> str — Queue a refund with the same enqueue-result semantics.

  • sync(device_id: str) -> list[dict[str, str]] — Reconcile and drain one terminal's queue.

  • get_order(order_id: str) -> dict[str, int] — Return total_cents, captured_cents, refunded_cents, due_cents, and net_cents.


Example 1:
Input sequence on a new instance:
[
  {"method": "create_order", "args": ["order-1", 1000]},
  {"method": "queue_payment", "args": ["terminal-A", "pay-1", "order-1", 600]},
  {"method": "queue_payment", "args": ["terminal-B", "pay-2", "order-1", 500]},
  {"method": "sync", "args": ["terminal-A"]},
  {"method": "sync", "args": ["terminal-B"]},
  {"method": "queue_payment", "args": ["terminal-B", "pay-3", "order-1", 400]},
  {"method": "sync", "args": ["terminal-B"]},
  {"method": "get_order", "args": ["order-1"]}
]

Output, one entry per method call:
[
  null,
  "QUEUED",
  "QUEUED",
  [{"operation_id": "pay-1", "status": "APPLIED"}],
  [{"operation_id": "pay-2", "status": "PAYMENT_LIMIT"}],
  "QUEUED",
  [{"operation_id": "pay-3", "status": "APPLIED"}],
  {"total_cents": 1000, "captured_cents": 1000, "refunded_cents": 0, "due_cents": 0, "net_cents": 1000}
]

Explanation: Terminal A captures 600 cents first. Terminal B's 500-cent operation would make the captured total 1100, so it is rejected. A new 400-cent operation brings the captured total to exactly 1000 cents.
Constraints
  • At most 100,000 orders, 100,000 distinct operations, and 100,000 terminals per instance; identifier lengths are 1–64 characters.

  • Totals and operation amounts are integers from 1 through 10^12 cents. Parameter types and upper bounds are guaranteed; implement the validation explicitly required above.

  • All calls are sequential. Use memory only; no database, threads, network calls, or payment-provider integration is required.

  • Target expected O(1) enqueue and balance-query time, and O(k) time to synchronize k pending operations.
Want to practise this one?
Create a free account to open the full question and practise Square questions with AI.
Sign up free
system design Senior messaging #2

2. Design a Notification System — A scalable service for managing notification dispatches


Background: Square relies heavily on real-time notifications for transactions, updates, and user interactions. A robust notification system can enhance user experience by promptly informing them about critical actions within the Square ecosystem.
Requirements:
1. The system must handle multiple notification types (e.g., email, push, SMS).
2. Notifications should be queued and delivered asynchronously to ensure a smooth user experience.
3. Implement throttling to manage rate limits for notification delivery.
4. The system should support user preferences for notification channels and types.
5. Provide metrics for notification delivery success and failure.
Class API:
  • send_notification(user_id: str, message: str, notification_type: str) -> bool

Sends a notification to the specified user and returns whether the notification was successfully queued.
  • set_preferences(user_id: str, preferences: dict) -> None

Updates the notification preferences for a user.
  • get_status(notification_id: str) -> dict

Returns the delivery status of the notification with the given ID.
  • flush_queue() -> None

Processes and sends notifications in the queue.
Example 1:
Input: send_notification('userA', 'Your payment was successful!', 'email') → Output: True → Explanation: The notification is queued successfully.
Example 2:
Input: set_preferences('userA', {'email': False, 'SMS': True}) → Output: None → Explanation: User preferences are updated without error.
Constraints:
  • Maximum of 100,000 notifications queued at any time.

  • User preferences can only be updated once per hour.

  • Notification delivery attempts are capped at 3 per notification.
system design Medium api design #3

3. Design PaymentProcessor — Class to handle payment transactions for Square


Background: Square's PaymentProcessor is critical for managing payment transactions efficiently and securely. Given the diverse payment methods and rigorous security standards in financial transactions, a robust structure to process and manage payment details is essential.
Requirements:
1. The class must allow adding supported payment methods (e.g., credit card, digital wallet).
2. It should validate payment details before processing the request.
3. The processor has to maintain a history of transactions and their statuses.
4. It should allow querying transaction history by transaction ID.
5. The class should implement concurrency control to handle multiple payment requests.
Class API:
  • add_payment_method(method: str) -> None: Adds a new payment method to be supported.

  • process_payment(transaction_id: str, amount: float, method: str) -> str: Processes a payment and returns the transaction status.

  • get_transaction_status(transaction_id: str) -> str: Retrieves the status of a given transaction.

  • get_transaction_history() -> List[Dict[str, Any]]: Returns a list of all transactions.


Example 1:
  • Input: add_payment_method("Credit Card") → Output: None → Explanation: Adds "Credit Card" as a valid payment method.

  • Input: process_payment("txn_123", 100.00, "Credit Card") → Output: "Success" → Explanation: Processes a payment for 100.00 using the credit card method.


Constraints:
  • Maximum of 10 different payment methods.

  • Each transaction must not exceed $10,000.

  • Up to 1000 concurrent transactions can be processed.
system design Medium api design #4

4. Design an End-to-End Banking System — a system that can manage user accounts, transactions, and balances.


Background: Square is expanding its offerings in the financial services domain, allowing users to manage their money seamlessly. A well-defined banking system is integral for these operations to maintain accuracy, security, and efficiency.
Problem Statement: Design a banking system that can handle multiple users, manage account creation, and allow transactions such as deposits and withdrawals while ensuring that account balances are accurately maintained. The system should support basic user authentication, and should not allow overdrafts in accounts. Make sure to implement appropriate error handling for each transaction.
Class Signature:
  • class BankAccount: - represents an individual user account.

- def __init__(self, account_id: str, initial_balance: float) -> None: - initializes a new account with a unique ID and balance.
- def deposit(self, amount: float) -> str: - deposits a specified amount into the account.
- def withdraw(self, amount: float) -> str: - withdraws a specified amount from the account.
- def get_balance(self) -> float: - returns the current balance of the account.
Example 1:
  • Input: account = BankAccount('12345', 100.0); account.deposit(50.0); account.withdraw(30.0)

  • Output: account.get_balance() → 120.0

  • Explanation: The account was initialized with 100.0, deposited 50.0, and withdrew 30.0, resulting in a balance of 120.0.


Example 2:
  • Input: account = BankAccount('67890', 200.0); account.withdraw(250.0)

  • Output: account.get_balance() → 200.0

  • Explanation: Attempting to withdraw 250.0 exceeds the current balance, so the withdrawal is rejected and the balance remains 200.0.


Constraints:
  • The account_id must be a unique string.

  • The initial_balance must be a non-negative float.

  • The amount for deposits and withdrawals must be a positive float.

  • Withdrawals must not exceed the current balance.
system design Medium api design #5

5. Design a Banking System — create an end-to-end banking system model.


Background: Square taps into the financial technology landscape, supporting transactions and banking operations for merchants and customers alike. A robust banking system is essential for facilitating transactions, maintaining account information, and managing user trust.
Requirements:
1. Manage user accounts and transactions.
2. Support basic operations like deposits, withdrawals, and fund transfers.
3. Implement transaction logging for auditing purposes.
4. Provide user authentication and authorization mechanisms.
Class API:
  • class User: Represents a bank user.

- def __init__(self, user_id: str, name: str) -> None: Initializes a new user with ID and name.
- def deposit(self, amount: float) -> None: Deposits a specified amount into the user's account.
- def withdraw(self, amount: float) -> None: Withdraws a specified amount from the user's account.
  • class Transaction: Represents a transaction in the banking system.

- def __init__(self, user_id: str, amount: float, type: str) -> None: Initializes a new transaction with user ID, amount, and type (deposit/withdraw).
  • class Bank: Main class for interaction.

- def create_user(self, name: str) -> User: Creates a new user.
- def transfer(self, from_user: User, to_user: User, amount: float) -> None: Transfers funding between users.
Example 1:
  • Input sequence: Create a user, deposit 100, withdraw 50 → Output: Account balance is 50.

  • Explanation: The user can perform deposit and withdraw operations, altering their balance accordingly.


Constraints:
  • Maximum of 1000 users.

  • Transaction amounts must be positive and capped at 10,000.

  • Users cannot withdraw more than their current balance.

Related Square Software Engineer interview prep

Start practicing Square questions

Sign up for free to access walkthroughs, AI-generated questions, and more.

Get Started Free