stripe / stripe-dotnet

Stripe.net is a sync/async .NET 4.6.1+ client, and a portable class library for stripe.com.
Apache License 2.0
1.36k stars 571 forks source link

`ProductData` is not present on `InvoiceItemPriceDataOptions`, making it impossible to create ad-hoc line items #2623

Closed abelbraaksma closed 1 year ago

abelbraaksma commented 1 year ago

Describe the bug

According to the docs, you can create a line item with an ad-hoc desription, ad-hoc price and ad-hoc product by using price_data and product_data properties.

However, the API doesn't provide product_data on InvoiceItemPriceDataOptions, making it virtually impossible to use (in fact, I don't know of a workaround).

To Reproduce

Basically (F# code, but you'll get my drift), this won't compile:

let productData = PriceProductDataOptions(Name = descr)
let priceData = InvoiceItemPriceDataOptions(UnitAmount = Nullable amountCents, Currency = "usd")
priceData.ProductData <- productData  // error, this property should be available acc. to the API

InvoiceItemCreateOptions(
    Customer = stripeCustomerId,
    Quantity = quantity,
    PriceData = priceData,
    Description = description
))

Expected behavior

The property ProductData is present.

Code snippets

No response

OS

any OS

.NET version

dotnet 6 & 7

Library version

40.3.0

API version

most recent

Additional context

No response

remi-stripe commented 1 year ago

@abelbraaksma The API doesn't support product_data today in this API which you can confirm here. Since the API doesn't support it, the stripe-dotnet library doesn't support it either.

You would either create a Product upfront first via the API and then pass that Product id product or you would instead pass directly the amount and currency parameter instead when creating the InvoiceItem.

Since this is not a bug or problem with the library and more an integration support question, I'd recommend working with our support team directly if you have any follow up questions. You can contact them here: https://support.stripe.com/contact

abelbraaksma commented 1 year ago

Thanks for the quick response. There was a post on SO that suggested this in json, so I assumed it ‘just worked’. Apparently that post was wrong.