David542
David542

Reputation: 110277

Fractional quantities in stripe

I would like to use stripe to bill per GB of data used in an application. Here is an example of an invoice:

Usage: 2.38GB
Rate: $0.20/GB
Total: $0.46

However, it seems like Stripe only allows integer quantity, so how would the above be done? If I were to bill per MB, then I'd have the following:

Usage: 2380MB
Rate: $0.0002
Total: $0.46

However, the lowest rate that I could add (at least from what it looked like in the dashboard) was $0.01.

So, what would be the best way to accomplish the above (other than round to the nearest GB -- which looks a bit fishy to an end user, imho).

Upvotes: 2

Views: 1805

Answers (1)

Stripe Support
Stripe Support

Reputation: 131

Stripe cannot support charging less than the minimum unit for a currency (because you can't charge a customer less than that, for example if they only used 1 unit).

You could set your "Unit" to be the smallest amount of data that would total to one cent, so that you are rounding to the smallest amount possible. In this case, $0.20/GB = $0.0002/MB = $0.01/50MB, 1 cent per 50 MB. You would have to account for this when reporting usage to the API, by keeping track of their usage yourself and updating the API using action= set rather than increment[0].

While this is what you'd have to do behind the scenes, there's no reason you have to expose that to the user. You could still list your rate in units of MB, with a note saying that totals will be rounded to the nearest 50MB.

[0] https://stripe.com/docs/api/usage_records/create#usage_record_create-action

Upvotes: 2

Related Questions