#JCrags-tax
1 messages ยท Page 1 of 1 (latest)
why not just use the upcoming invoice endpoint? I don't see why you have to actually create a draft invoice.
An invoice might not exist for the customer yet
You can't create an invoice without having line items, and you require the invoice to with items to retrieve the tax_rate (percentage)
https://stripe.com/docs/api/invoices/upcoming
https://stripe.com/docs/api/invoices/upcoming#upcoming_invoice-automatic_tax
https://stripe.com/docs/api/invoices/upcoming#upcoming_invoice-invoice_items to pass specific items
etc, you could probably use that.
Without it Stripe doesn't create an "Tax Rate" item.
fair enough! In any case our answer here is to use Checkout or Invoices for the payment directly, the workaround you suggest here to "get" the details of the tax we would automatically apply and then separately apply it to a one-off PaymentIntent seems like it works but it's not something we'd officially support or consider.
Let's asume I would call this:
params := &stripe.InvoiceParams{
Customer: stripe.String("cus_L77dLKb0SIUWOh"),
}
in, _ := invoice.GetNext(params)
would this return me with a "Tax Rate" ID or object too? Because all I need to get is the "tax percentage" on the front-end, with only the customer being logged in. The customer might not even purchase anything really. Only need to display good prices/tax rates based on the logged in user.
The point here is that I believe there is no tax automatically calculated by Stripe unless you add a line item to an invoice. But correct me if I am wrong about that.
I'm pretty sure you can use the upcoming invoice endpoint in the way I mentioned, the preview invoice returned should calculate tax. If it doesn't then creating a draft invoice + deleting it kind of works but I would investigate if the upcoming invoice endpoints works for you needs
to be clear, you can pass items to that endpoint to see what a hypothetical invoice would be, which really feels like your use case