Skip to main content
All Questions

Match an incoming payment to its invoice using the payment's memo line.

Unlock detailed company stats for this questionUpgrade

Stripe's Invoicing product lets businesses send invoices, and standalone payments sometimes need to be reconciled with a customer's open invoices. Write a program that matches an incoming payment to its invoice. Payment format: "paymentId,amount,memo", with the amount in USD minor units ($1.00 = 100) and a memo like "Paying off: {INVOICE}". Invoice format: "invoiceId,dueDate,amountDue", with the amount in USD minor units. Example: f("payment5,1000,Paying off: invoiceC", ["invoiceA,2024-01-01,100", "invoiceB,2024-02-01,200", "invoiceC,2023-01-30,1000"]) returns "payment5 pays off 1000 for invoiceC due on 2023-01-30". Some candidates saw the memo reference as "XXXX:invoice_id" and output payment_name, amount, due_date and invoice_id.

Expect follow-ups like

  • If the memo has no invoice_id or it doesn't match, match by amount instead, choosing the invoice with the earliest due_date when several match.
  • Add an integer forgiveness so a payment matches when invoice_amount - forgiveness <= payment_amount <= invoice_amount + forgiveness, and include any difference in the output.

Format · A virtual onsite coding round in three parts, each building on the previous one.

Also asked as · Match a payment to an invoice using the invoice ID in the payment memo.

Community answers

No answers contributed by the community yet.

Related courses

Course

Software Engineering Interview Prep

Land your dream software engineering role at Google, Amazon, Microsoft, Meta, Apple, and other top companies. Learn from mock interviews, frameworks, and advice from senior candidates—practice data structures, algorithms, system design, people management, behavioral interviews, and more.

Course

System Design Interviews

Learn how to answer the latest system design questions across product, infrastructure, and AI domains. Features in-depth video examples, written breakdowns, and helpful reference patterns. Watch senior engineers and managers answer these questions in mock interview videos.