Compute costs with validation and sorting in Python | Stripe