← 返回博客列表
Stripe

Stripe Interview Question: Brazil Receivables & Contracts

2025-12-30

This question is deeply rooted in Stripe's actual business operations in Brazil. It evaluates a candidate's ability to handle state management, timeline overlaps, and complex business logic modeling.

Problem Description

In Brazil, credit card receivables are treated as financial assets that can be registered and traded. Stripe is required by regulations to report these receivables to a central Registry.

Part 1: Register Receivables

Given a transaction (Charge), you need to convert it into a "Receivable Unit". A Charge typically contains:

You need to implement a function to register this Charge with the Registry. Upon success, the Registry returns a unique receivable_id.

Part 2: Contracts & Updates

Merchants may sign "Prepayment Contracts" with banks, using their future receivables as collateral to get cash immediately. This introduces a "Locking" concept: Once a Receivable is locked by a Contract, Stripe cannot modify it (e.g., changing the payout date or amount) without specific handling.

Input Streams:

The Challenge: When receiving a Charge Update, you must check if the corresponding Receivable is covered by any Active Contract.

oavoservice Solution Analysis

The core difficulty lies in Data Consistency and State Validation.

1. Entity Modeling

Define clear classes:

class Charge:
    id: str
    amount: int
    payout_date: str

class Receivable:
    id: str  # ID from Registry
    charge_id: str
    amount: int
    status: str

class Contract:
    id: str
    target_charge_ids: List[str]
    status: str # ACTIVE, CANCELLED

2. Conflict Detection Logic

When processing a Charge Update, perform a "Pre-check":

  1. Find the receivable_id linked to the charge_id.
  2. Query the ContractRepository for any status == ACTIVE contract that includes this receivable_id.
  3. Key Detail: Watch out for time-based locks. Some variations only lock receivables within a specific date range.

3. Idempotency & Retries

Communication with the Registry might fail.


Overwhelmed by Business Logic?

Stripe interview questions are full of "detail traps." oavoservice mentors are senior engineers who know exactly how to deconstruct these complex requirements into simple CRUD + State Check logic.

Get Interview Coaching