← Questions

Subscription billing with proration and tiered usage

0
StripeCodingLast asked Oct 2026

Build a small billing engine that produces each user's charge for one 30-day cycle. Amounts are in cents, and the final charge per user is rounded down only once, at the end.

  1. Every user has one or more fixed-price subscriptions. Return each user's monthly total.
  2. Users change plans part-way through the cycle. Prorate: charge the old price for the days before the change and the new price for the rest.
  3. Add usage-based billing. Some metered items have a flat price per unit; others are tiered, where each block of units has its own price. A user may have usage without any subscription.

Each part builds on the one before, so structure the code to be extended.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding