#elias117-invoice-item-tax
1 messages ยท Page 1 of 1 (latest)
Hi there ๐ are you dynamically defining the invoice items price_data or are you using an existing price object?
I am actually doing a couple things first.
1.) I create the invoice
2.) I then create all products in the stripe API
3.) Then for each product in stripe API I create an Invoice Item with inline price data
But none of the tax behaviour seems to work in dotnet
for example I would like to add a tax_code in creating the product but it doesnt like that
var options = new ProductCreateOptions
{
Name = $"{lineItem.MenuItem.Name}",
TaxCode = "txcd_40060003"
};
var productRes = await productService.CreateAsync(options);
I basically want to use the invoices to automatically calculate the tax based on a users postal code and country
Also here is how I'm creating the invoice Item
var options = new InvoiceItemCreateOptions
{
Customer = $"{userRecord.StripeId}",
PriceData = new InvoiceItemPriceDataOptions
{
Currency = "CAD",
Product = stripeProductId,
tax_behaviour = "exclusive",
UnitAmount = lineItem.MenuItem.Price.ToCents(),
},
Quantity = lineItem.Quantity,
Invoice = invoice.Id
};
var res = await invoiceItemService.CreateAsync(options);
So tax code doesnt work and neither does tax behaviour
Can you elaborate on what you mean when you say "it doesn't like that" or "tax code doesn't work"?
sure
I mean that dotnet package doesnt have any way to set the tax behaviour like it says on the API reference. My intellisense says this
and it says the same thing for tax_code
I think there is a spelling mistake for behavior but it still doesnt recognize it
And I'm just following along with this as a reference
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
and this is the version I'm using
Hello?
Is it possible that I could be using the wrong version of stripe.net?
Stripe.net is a sync/async .NET 4.6.1+ client, and a portable class library for the Stripe API. (Official Library)
This is more up to date
Is this thread still open?
yes it is, sorry, got a lot to juggle at the moment
Completely understand, we do have a process to include parameters that aren't yet officially supported by the library being used. Let's use your product creation request as an example:
{
Name = $"{lineItem.MenuItem.Name}",
TaxCode = "txcd_40060003"
};
var productRes = await productService.CreateAsync(options);```
Because TaxCode isn't support you won't be able to use the above code, so please try this instead:
```var options = new ProductCreateOptions
{
Name = $"{lineItem.MenuItem.Name}",
};
options.AddExtraParam("tax_code", "txcd_40060003");
var productRes = await productService.CreateAsync(options);```
That `AddExtraParam` accepts two strings, the first being the parameter name and the second being the desired value.
Ahhh ok
just one min
So I updated to the latest package
And the TaxCode works I didnt need to use the method
but I tried to do it with InvoiceItemPriceDataOptions
var tempOptions = new InvoiceItemPriceDataOptions
{
Currency = "CAD",
Product = stripeProductId,
UnitAmount = lineItem.MenuItem.Price.ToCents(),
};
tempOptions.AddExtraParam("tax_behavior", "exclusive");
and it cant find the "AddExtraParam"
Glad to hear TaxCode is working! Let me double check my syntax regarding the extra parameters.
Can you provide this snippet along with the lines that create the invoice item?
yeah one second
I think I actually fixed it
var priceOptions = new PriceCreateOptions
{
UnitAmount = lineItem.MenuItem.Price.ToCents(),
Currency = "CAD",
Product = stripeProductId,
TaxBehavior = "exclusive",
};
var priceRes = await priceService.CreateAsync(priceOptions);
if (priceRes?.Id == null)
{
return new Result<string>("PaymentFailed", "Your payment was not processed. Please enter a new card.");
}
var options = new InvoiceItemCreateOptions
{
Customer = $"{userRecord.StripeId}",
Price = priceRes.Id,
Quantity = lineItem.Quantity,
Invoice = invoice.Id
};
var in
This is what I ended up doing
Oohh, that would be much easier, is it behaving as you're expecting?