AO
Back

Payment–Invoice Matching

CodingPhone, OnsiteSoftware Engineer, Machine Learning EngineerLast reported August 2026High Frequency

Problem Overview

You are given a payment record (as a comma-separated string, e.g. 'payment-id, amount, memo/paying-off-text [, invoice-id]') and a list of invoice records (each a comma-separated string, e.g. 'invoice-id, amount, due-date'; one report's sample lists 'invoice-id, due-date, amount' instead, so confirm the field order). Implement a three-part progressive matching system:

Part 1 – Match by Invoice ID: The payment's memo field contains an explicit invoice reference (e.g. 'Paying off: invoice-id-X'; one report writes 'paying for: invoice-id-X'). Find the matching invoice by ID and return a formatted string such as: '{payment-id} paid {amount} for invoice {invoice-id} on date {due-date}' (or indicating whether payment was on time).

Part 2 – Match by Amount (no explicit invoice ID): The signal for Part 2 is a memo without the 'Paying off:' prefix; at least one candidate had to confirm this with the interviewer by comparing the two sample inputs. When the payment has no explicit invoice ID in its memo, match by finding all invoices whose amount equals the payment amount, then select the one with the earliest due date (most reports and the quoted prompt say earliest; two reports use wording that could also mean the closest date, so confirm the tie-break with the interviewer). Return the same formatted string. Code must still handle Part 1 logic when an invoice ID is present (ID match takes priority over amount match).

Part 3 – Range/Forgiveness Matching: A bank fee may cause the received payment amount to be slightly less than the invoice amount. Given a forgiveness threshold value, match any invoice whose amount is within the forgiveness range. Reports differ on the range shape: one says payment ± forgiveness, while the quoted bank-fee prompt only describes payments arriving short of the invoice ($15 invoice, $2 fee, $13 received); whether the boundary is inclusive is not reported. Confirm with the interviewer. If multiple invoices match, select the one with the earliest due date. Prefer exact amount matches over forgiveness-range matches, and prefer ID matches over both. The output string should indicate how much was forgiven. All three matching strategies must coexist with clear priority: ID > exact amount > forgiveness range.

Input is all plain strings (no JSON). Candidates must also write their own test cases covering edge cases and priority ordering.

Follow-up Arc

Interviewers escalate through these phases. The order varies, but most candidates see at least one from each bucket.
Edge cases · 1Trade-off discussion · 4
Edge cases

What edge cases haven't you handled yet?

Probes for: If candidate finishes early or interviewer probes design
Trade-off discussion

What if the payment has no invoice ID in the memo — how would you still match it to an invoice?

Probes for: After Part 1 is complete

Banks sometimes deduct a small fee, so the payment arrives slightly short of the invoice amount. How do you handle this?

Probes for: After Part 2 is complete

What test cases would you write for this?

Probes for: Throughout all parts

How would you ensure backward compatibility — that Part 1 logic still works after adding Part 2/3?

Probes for: After Part 2 or 3

What Reports Emphasize

Common mistakes: Misreading the input format — especially confusing a literal placeholder string in the sample input for an actual value — caused candidates to spend significant time on the wrong parsing logic and miss later parts.; Writing Part 1 too slowly or spending time trying to write elegant code left insufficient time for Parts 2 and 3.; One candidate wrote test cases during the session but accidentally introduced a bug through a test case they wrote themselves, which cost them time and contributed to not finishing.

Interviewer hints: When a candidate could not identify the signal distinguishing Part 1 from Part 2 inputs, the interviewer placed both sample inputs side by side and asked the candidate to spot the difference, rather than stating it directly.; One interviewer, when a candidate debated whether an edge case was valid, engaged in the discussion and ultimately agreed to add it — suggesting the interviewer is open to pushback if the candidate reasons through it.

What passers do: At least one candidate passed by completing Parts 1 and 2 fully using a dict and for loop, without finishing Part 3.

Edge cases probed: Multiple invoices with the same amount — must select the one with the earliest due date; Exact match and range match both available — exact match must take priority; ID match and amount match both possible — ID match must win

Practice

Write your own against 12 test cases, or read the worked solution — approach, complexity, and code that runs.

More Stripe Questions

Free preview

Every question in the Stripe catalog gets this depth

What you just read — canonical solution, follow-up arc, what passing candidates actually did — exists for all 70 Stripe questions, refreshed monthly from new candidate reports.

$59/mo — or $50/mo with the 3-month pass · cancel anytime
Stripe · Coding · Reported 18× across candidate reports
Is this helpful?