[ {"name": "Stripe volume example: 1 font at 7.00", "args": [1, [{"upTo": 5, "unitPrice": {"minor": 700, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}}, {"upTo": 10, "unitPrice": {"minor": 650, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}}, {"upTo": null, "unitPrice": {"minor": 600, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}}], "volume"], "expect": {"lines": [{"tier": 1, "quantity": 1, "unitPrice": {"minor": 700, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}, "amount": {"minor": 700, "currency": "USD"}}], "total": {"minor": 700, "currency": "USD"}}}, {"name": "Stripe volume example: 5 fonts, the top of the first tier", "args": [5, [{"upTo": 5, "unitPrice": {"minor": 700, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}}, {"upTo": 10, "unitPrice": {"minor": 650, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}}, {"upTo": null, "unitPrice": {"minor": 600, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}}], "volume"], "expect": {"lines": [{"tier": 1, "quantity": 5, "unitPrice": {"minor": 700, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}, "amount": {"minor": 3500, "currency": "USD"}}], "total": {"minor": 3500, "currency": "USD"}}}, {"name": "Stripe volume example: 6 fonts, all at the second tier's 6.50", "args": [6, [{"upTo": 5, "unitPrice": {"minor": 700, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}}, {"upTo": 10, "unitPrice": {"minor": 650, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}}, {"upTo": null, "unitPrice": {"minor": 600, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}}], "volume"], "expect": {"lines": [{"tier": 2, "quantity": 6, "unitPrice": {"minor": 650, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}, "amount": {"minor": 3900, "currency": "USD"}}], "total": {"minor": 3900, "currency": "USD"}}}, {"name": "Stripe volume example: 20 fonts, all at 6.00", "args": [20, [{"upTo": 5, "unitPrice": {"minor": 700, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}}, {"upTo": 10, "unitPrice": {"minor": 650, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}}, {"upTo": null, "unitPrice": {"minor": 600, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}}], "volume"], "expect": {"lines": [{"tier": 3, "quantity": 20, "unitPrice": {"minor": 600, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}, "amount": {"minor": 12000, "currency": "USD"}}], "total": {"minor": 12000, "currency": "USD"}}}, {"name": "Stripe volume example: 25 fonts", "args": [25, [{"upTo": 5, "unitPrice": {"minor": 700, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}}, {"upTo": 10, "unitPrice": {"minor": 650, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}}, {"upTo": null, "unitPrice": {"minor": 600, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}}], "volume"], "expect": {"lines": [{"tier": 3, "quantity": 25, "unitPrice": {"minor": 600, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}, "amount": {"minor": 15000, "currency": "USD"}}], "total": {"minor": 15000, "currency": "USD"}}}, {"name": "Stripe graduated example: 5 fonts", "args": [5, [{"upTo": 5, "unitPrice": {"minor": 700, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}}, {"upTo": 10, "unitPrice": {"minor": 650, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}}, {"upTo": null, "unitPrice": {"minor": 600, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}}], "graduated"], "expect": {"lines": [{"tier": 1, "quantity": 5, "unitPrice": {"minor": 700, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}, "amount": {"minor": 3500, "currency": "USD"}}], "total": {"minor": 3500, "currency": "USD"}}}, {"name": "Stripe graduated example: 6 fonts is 35.00 plus one at 6.50", "args": [6, [{"upTo": 5, "unitPrice": {"minor": 700, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}}, {"upTo": 10, "unitPrice": {"minor": 650, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}}, {"upTo": null, "unitPrice": {"minor": 600, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}}], "graduated"], "expect": {"lines": [{"tier": 1, "quantity": 5, "unitPrice": {"minor": 700, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}, "amount": {"minor": 3500, "currency": "USD"}}, {"tier": 2, "quantity": 1, "unitPrice": {"minor": 650, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}, "amount": {"minor": 650, "currency": "USD"}}], "total": {"minor": 4150, "currency": "USD"}}}, {"name": "Stripe graduated example: 20 fonts", "args": [20, [{"upTo": 5, "unitPrice": {"minor": 700, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}}, {"upTo": 10, "unitPrice": {"minor": 650, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}}, {"upTo": null, "unitPrice": {"minor": 600, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}}], "graduated"], "expect": {"lines": [{"tier": 1, "quantity": 5, "unitPrice": {"minor": 700, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}, "amount": {"minor": 3500, "currency": "USD"}}, {"tier": 2, "quantity": 5, "unitPrice": {"minor": 650, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}, "amount": {"minor": 3250, "currency": "USD"}}, {"tier": 3, "quantity": 10, "unitPrice": {"minor": 600, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}, "amount": {"minor": 6000, "currency": "USD"}}], "total": {"minor": 12750, "currency": "USD"}}}, {"name": "Stripe graduated example: 25 fonts", "args": [25, [{"upTo": 5, "unitPrice": {"minor": 700, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}}, {"upTo": 10, "unitPrice": {"minor": 650, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}}, {"upTo": null, "unitPrice": {"minor": 600, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}}], "graduated"], "expect": {"lines": [{"tier": 1, "quantity": 5, "unitPrice": {"minor": 700, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}, "amount": {"minor": 3500, "currency": "USD"}}, {"tier": 2, "quantity": 5, "unitPrice": {"minor": 650, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}, "amount": {"minor": 3250, "currency": "USD"}}, {"tier": 3, "quantity": 15, "unitPrice": {"minor": 600, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}, "amount": {"minor": 9000, "currency": "USD"}}], "total": {"minor": 15750, "currency": "USD"}}}, {"name": "Stripe flat-rate example, volume: 12 x 3.00 + 30.00", "args": [12, [{"upTo": 5, "unitPrice": {"minor": 500, "currency": "USD"}, "flatFee": {"minor": 1000, "currency": "USD"}}, {"upTo": 10, "unitPrice": {"minor": 400, "currency": "USD"}, "flatFee": {"minor": 2000, "currency": "USD"}}, {"upTo": 15, "unitPrice": {"minor": 300, "currency": "USD"}, "flatFee": {"minor": 3000, "currency": "USD"}}, {"upTo": 20, "unitPrice": {"minor": 200, "currency": "USD"}, "flatFee": {"minor": 4000, "currency": "USD"}}, {"upTo": null, "unitPrice": {"minor": 100, "currency": "USD"}, "flatFee": {"minor": 5000, "currency": "USD"}}], "volume"], "expect": {"lines": [{"tier": 3, "quantity": 12, "unitPrice": {"minor": 300, "currency": "USD"}, "flatFee": {"minor": 3000, "currency": "USD"}, "amount": {"minor": 6600, "currency": "USD"}}], "total": {"minor": 6600, "currency": "USD"}}}, {"name": "Stripe flat-rate example, graduated: three tiers and three flat fees", "args": [12, [{"upTo": 5, "unitPrice": {"minor": 500, "currency": "USD"}, "flatFee": {"minor": 1000, "currency": "USD"}}, {"upTo": 10, "unitPrice": {"minor": 400, "currency": "USD"}, "flatFee": {"minor": 2000, "currency": "USD"}}, {"upTo": 15, "unitPrice": {"minor": 300, "currency": "USD"}, "flatFee": {"minor": 3000, "currency": "USD"}}, {"upTo": 20, "unitPrice": {"minor": 200, "currency": "USD"}, "flatFee": {"minor": 4000, "currency": "USD"}}, {"upTo": null, "unitPrice": {"minor": 100, "currency": "USD"}, "flatFee": {"minor": 5000, "currency": "USD"}}], "graduated"], "expect": {"lines": [{"tier": 1, "quantity": 5, "unitPrice": {"minor": 500, "currency": "USD"}, "flatFee": {"minor": 1000, "currency": "USD"}, "amount": {"minor": 3500, "currency": "USD"}}, {"tier": 2, "quantity": 5, "unitPrice": {"minor": 400, "currency": "USD"}, "flatFee": {"minor": 2000, "currency": "USD"}, "amount": {"minor": 4000, "currency": "USD"}}, {"tier": 3, "quantity": 2, "unitPrice": {"minor": 300, "currency": "USD"}, "flatFee": {"minor": 3000, "currency": "USD"}, "amount": {"minor": 3600, "currency": "USD"}}], "total": {"minor": 11100, "currency": "USD"}}}, {"name": "no usage still bills the first tier's flat fee, graduated", "args": [0, [{"upTo": 5, "unitPrice": {"minor": 500, "currency": "USD"}, "flatFee": {"minor": 1000, "currency": "USD"}}, {"upTo": 10, "unitPrice": {"minor": 400, "currency": "USD"}, "flatFee": {"minor": 2000, "currency": "USD"}}, {"upTo": 15, "unitPrice": {"minor": 300, "currency": "USD"}, "flatFee": {"minor": 3000, "currency": "USD"}}, {"upTo": 20, "unitPrice": {"minor": 200, "currency": "USD"}, "flatFee": {"minor": 4000, "currency": "USD"}}, {"upTo": null, "unitPrice": {"minor": 100, "currency": "USD"}, "flatFee": {"minor": 5000, "currency": "USD"}}], "graduated"], "expect": {"lines": [{"tier": 1, "quantity": 0, "unitPrice": {"minor": 500, "currency": "USD"}, "flatFee": {"minor": 1000, "currency": "USD"}, "amount": {"minor": 1000, "currency": "USD"}}], "total": {"minor": 1000, "currency": "USD"}}}, {"name": "no usage still bills the first tier's flat fee, volume", "args": [0, [{"upTo": 5, "unitPrice": {"minor": 500, "currency": "USD"}, "flatFee": {"minor": 1000, "currency": "USD"}}, {"upTo": 10, "unitPrice": {"minor": 400, "currency": "USD"}, "flatFee": {"minor": 2000, "currency": "USD"}}, {"upTo": 15, "unitPrice": {"minor": 300, "currency": "USD"}, "flatFee": {"minor": 3000, "currency": "USD"}}, {"upTo": 20, "unitPrice": {"minor": 200, "currency": "USD"}, "flatFee": {"minor": 4000, "currency": "USD"}}, {"upTo": null, "unitPrice": {"minor": 100, "currency": "USD"}, "flatFee": {"minor": 5000, "currency": "USD"}}], "volume"], "expect": {"lines": [{"tier": 1, "quantity": 0, "unitPrice": {"minor": 500, "currency": "USD"}, "flatFee": {"minor": 1000, "currency": "USD"}, "amount": {"minor": 1000, "currency": "USD"}}], "total": {"minor": 1000, "currency": "USD"}}}, {"name": "usage of exactly a tier's upTo does not reach the next tier or its flat fee", "args": [10, [{"upTo": 5, "unitPrice": {"minor": 500, "currency": "USD"}, "flatFee": {"minor": 1000, "currency": "USD"}}, {"upTo": 10, "unitPrice": {"minor": 400, "currency": "USD"}, "flatFee": {"minor": 2000, "currency": "USD"}}, {"upTo": 15, "unitPrice": {"minor": 300, "currency": "USD"}, "flatFee": {"minor": 3000, "currency": "USD"}}, {"upTo": 20, "unitPrice": {"minor": 200, "currency": "USD"}, "flatFee": {"minor": 4000, "currency": "USD"}}, {"upTo": null, "unitPrice": {"minor": 100, "currency": "USD"}, "flatFee": {"minor": 5000, "currency": "USD"}}], "graduated"], "expect": {"lines": [{"tier": 1, "quantity": 5, "unitPrice": {"minor": 500, "currency": "USD"}, "flatFee": {"minor": 1000, "currency": "USD"}, "amount": {"minor": 3500, "currency": "USD"}}, {"tier": 2, "quantity": 5, "unitPrice": {"minor": 400, "currency": "USD"}, "flatFee": {"minor": 2000, "currency": "USD"}, "amount": {"minor": 4000, "currency": "USD"}}], "total": {"minor": 7500, "currency": "USD"}}}, {"name": "one unit past a boundary reaches the next tier and its flat fee", "args": [11, [{"upTo": 5, "unitPrice": {"minor": 500, "currency": "USD"}, "flatFee": {"minor": 1000, "currency": "USD"}}, {"upTo": 10, "unitPrice": {"minor": 400, "currency": "USD"}, "flatFee": {"minor": 2000, "currency": "USD"}}, {"upTo": 15, "unitPrice": {"minor": 300, "currency": "USD"}, "flatFee": {"minor": 3000, "currency": "USD"}}, {"upTo": 20, "unitPrice": {"minor": 200, "currency": "USD"}, "flatFee": {"minor": 4000, "currency": "USD"}}, {"upTo": null, "unitPrice": {"minor": 100, "currency": "USD"}, "flatFee": {"minor": 5000, "currency": "USD"}}], "graduated"], "expect": {"lines": [{"tier": 1, "quantity": 5, "unitPrice": {"minor": 500, "currency": "USD"}, "flatFee": {"minor": 1000, "currency": "USD"}, "amount": {"minor": 3500, "currency": "USD"}}, {"tier": 2, "quantity": 5, "unitPrice": {"minor": 400, "currency": "USD"}, "flatFee": {"minor": 2000, "currency": "USD"}, "amount": {"minor": 4000, "currency": "USD"}}, {"tier": 3, "quantity": 1, "unitPrice": {"minor": 300, "currency": "USD"}, "flatFee": {"minor": 3000, "currency": "USD"}, "amount": {"minor": 3300, "currency": "USD"}}], "total": {"minor": 10800, "currency": "USD"}}}, {"name": "a free allowance, then 2p a unit, then 1p a unit", "args": [25000, [{"upTo": 1000, "unitPrice": {"minor": 0, "currency": "GBP"}, "flatFee": {"minor": 0, "currency": "GBP"}}, {"upTo": 10000, "unitPrice": {"minor": 2, "currency": "GBP"}, "flatFee": {"minor": 0, "currency": "GBP"}}, {"upTo": null, "unitPrice": {"minor": 1, "currency": "GBP"}, "flatFee": {"minor": 0, "currency": "GBP"}}], "graduated"], "expect": {"lines": [{"tier": 1, "quantity": 1000, "unitPrice": {"minor": 0, "currency": "GBP"}, "flatFee": {"minor": 0, "currency": "GBP"}, "amount": {"minor": 0, "currency": "GBP"}}, {"tier": 2, "quantity": 9000, "unitPrice": {"minor": 2, "currency": "GBP"}, "flatFee": {"minor": 0, "currency": "GBP"}, "amount": {"minor": 18000, "currency": "GBP"}}, {"tier": 3, "quantity": 15000, "unitPrice": {"minor": 1, "currency": "GBP"}, "flatFee": {"minor": 0, "currency": "GBP"}, "amount": {"minor": 15000, "currency": "GBP"}}], "total": {"minor": 33000, "currency": "GBP"}}}, {"name": "a single open-ended tier is plain per-unit pricing", "args": [42, [{"upTo": null, "unitPrice": {"minor": 25, "currency": "GBP"}, "flatFee": {"minor": 0, "currency": "GBP"}}], "graduated"], "expect": {"lines": [{"tier": 1, "quantity": 42, "unitPrice": {"minor": 25, "currency": "GBP"}, "flatFee": {"minor": 0, "currency": "GBP"}, "amount": {"minor": 1050, "currency": "GBP"}}], "total": {"minor": 1050, "currency": "GBP"}}}, {"name": "a closed last tier prices usage right up to its end", "args": [200, [{"upTo": 100, "unitPrice": {"minor": 10, "currency": "GBP"}, "flatFee": {"minor": 0, "currency": "GBP"}}, {"upTo": 200, "unitPrice": {"minor": 5, "currency": "GBP"}, "flatFee": {"minor": 0, "currency": "GBP"}}], "volume"], "expect": {"lines": [{"tier": 2, "quantity": 200, "unitPrice": {"minor": 5, "currency": "GBP"}, "flatFee": {"minor": 0, "currency": "GBP"}, "amount": {"minor": 1000, "currency": "GBP"}}], "total": {"minor": 1000, "currency": "GBP"}}}, {"name": "usage past a closed last tier is an error", "args": [201, [{"upTo": 100, "unitPrice": {"minor": 10, "currency": "GBP"}, "flatFee": {"minor": 0, "currency": "GBP"}}, {"upTo": 200, "unitPrice": {"minor": 5, "currency": "GBP"}, "flatFee": {"minor": 0, "currency": "GBP"}}], "graduated"], "expectError": "exceeds the last tier"}, {"name": "a negative quantity is an error", "args": [-1, [{"upTo": 5, "unitPrice": {"minor": 700, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}}, {"upTo": 10, "unitPrice": {"minor": 650, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}}, {"upTo": null, "unitPrice": {"minor": 600, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}}], "graduated"], "expectError": "quantity must be a whole number of 0 or more"}, {"name": "no tiers is an error", "args": [5, [], "volume"], "expectError": "at least one tier"}, {"name": "tiers out of order are an error", "args": [5, [{"upTo": 10, "unitPrice": {"minor": 1, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}}, {"upTo": 5, "unitPrice": {"minor": 1, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}}, {"upTo": null, "unitPrice": {"minor": 1, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}}], "graduated"], "expectError": "strictly increasing"}, {"name": "an open-ended tier before the last is an error", "args": [5, [{"upTo": null, "unitPrice": {"minor": 1, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}}, {"upTo": 10, "unitPrice": {"minor": 1, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}}], "graduated"], "expectError": "only the last tier may be open-ended"}, {"name": "tiers in two currencies are an error", "args": [5, [{"upTo": 5, "unitPrice": {"minor": 1, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}}, {"upTo": null, "unitPrice": {"minor": 1, "currency": "EUR"}, "flatFee": {"minor": 0, "currency": "EUR"}}], "graduated"], "expectError": "currency mismatch"}, {"name": "an unknown mode is an error", "args": [5, [{"upTo": 5, "unitPrice": {"minor": 700, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}}, {"upTo": 10, "unitPrice": {"minor": 650, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}}, {"upTo": null, "unitPrice": {"minor": 600, "currency": "USD"}, "flatFee": {"minor": 0, "currency": "USD"}}], "stairstep"], "expectError": "unknown tier mode"} ]