#elias117-invoice-item-tax

1 messages ยท Page 1 of 1 (latest)

unkempt obsidian
#

Hi there ๐Ÿ‘‹ are you dynamically defining the invoice items price_data or are you using an existing price object?

cosmic yarrow
#

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

unkempt obsidian
#

Can you elaborate on what you mean when you say "it doesn't like that" or "tax code doesn't work"?

cosmic yarrow
#

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

#

and this is the version I'm using

#

Hello?

#

Is it possible that I could be using the wrong version of stripe.net?

#

This is more up to date

#

Is this thread still open?

unkempt obsidian
#

yes it is, sorry, got a lot to juggle at the moment

cosmic yarrow
#

oh ok thats fine I can wait

#

its just really important to us

unkempt obsidian
#

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.
cosmic yarrow
#

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"

unkempt obsidian
#

Glad to hear TaxCode is working! Let me double check my syntax regarding the extra parameters.

unkempt obsidian
cosmic yarrow
#

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

unkempt obsidian
#

Oohh, that would be much easier, is it behaving as you're expecting?