Reputation: 13
I am working with the Stripe API to create invoices. According to the docs, the quantity field is an integer. In the .Net Stripe library, it is, in fact, a long. But either case, it doesn't support decimal.
The invoice has a labor line. Labor is sold by the hour.
Quantity: 1.25
Rate: $205.00
Total: $256.25
How can I represent the accurate quantity on the invoice line item?
I am creating the invoice line items similar to this:
string description = "Labor"
decimal rate = 205.00
decimal quantity = 1.25
var invoiceLine = new InvoiceLineOptions
{
Description = description
PriceData = new InvoiceLinePriceDataOptions
{
Currency = "usd",
UnitAmountDecimal = rate * 100,
ProductData = new InvoiceLinePriceDataProductDataOptions
{
Name = description
}
};
Quantity = (long?)quantity;
}
Obviously, casting to long
results in losing the decimal accuracy. But it seems to be all Stripe supports.
Similar question here , but that is on subscriptions. My use case is not. And I don't have a Unit
field on the InvoiceLineItem
that I can find.
Is there a Stripe option I am missing? Or how would I accomplish this?
Upvotes: 1
Views: 22
Reputation: 1178
Stripe does not natively support decimal quantities for invoice line items, as the quantity field is strictly an integer.
In your case, since you are billing for labor by the hour, consider using a smaller unit of time, such as minutes or even seconds. This way, you can represent fractional hours as whole numbers.
For example, instead of billing by the hour (1.25), you can bill by the minutes: 75 minutes.
Upvotes: 1