I jumped straight to the math and forgot they wanted me to define the input schema first.
Start by clearly defining the input format (e.g., a list of objects with sku, price, quantity) and the output (total price). Then outline the computation: sum price*quantity for each item, add flat shipping, and explicitly state assumptions about tax (e.g., excluded) and currency (e.g., USD). Finally, mention edge cases like empty list, negative quantities, and rounding.
Pro tip: Show awareness of Stripe's domain by mentioning that in real payment systems, you'd use integer cents to avoid floating-point errors and handle currency-specific rounding. Also, note that tax and shipping might be separate line items in an invoice.
Specify the input as a list of order items, each with sku (string), price (number), and quantity (integer), plus a flat shipping cost (number). Define the output as a single total price (number).
Clearly state assumptions: e.g., prices are in the same currency (USD), tax is not included, shipping is added after item totals, and no discounts or promotions apply.
Describe the algorithm: initialize total to 0, iterate over items, add price * quantity to total, then add shipping cost. Optionally, round to two decimal places.
Mention handling empty list (total = shipping), zero or negative quantities (validate or ignore), and potential floating-point precision issues (use integer cents or round).
Provide a clean code implementation in a language of choice (e.g., Python), with clear variable names and comments. Optionally, include a simple test case.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.