#Rohit89
1 messages · Page 1 of 1 (latest)
Hi
Do you want to use Stripe Tax (automatic tax) or tax rates ?
I need tax rate (percentage) , Right now Stripe::Invoice.upcoming({
in response it says tax amount
I want to see how much tax % will be applied to upcoming invoice
Just to make sure I understand you, you are passing tax rates when calling the upcoming API or you are using Stripe Automatic tax ?
In the response you have the total_tax_amount array:
https://stripe.com/docs/api/invoices/object#invoice_object-total_tax_amounts
upcoming_invoice = {
subscription: subscription,
subscription_items: items,
subscription_proration_date: proration_date,
coupon: params[:coupon_code],
}
invoice = Stripe::Invoice.upcoming(upcoming_invoice)
I am executing this code
in the invoice response I want to see how much tax% will be applied
In the response are you getting total_tax_amountsarray ?
I assume you are using Stripe Tax here ?
"total_tax_amounts": [
{
"amount": 2166,
"inclusive": false,
"tax_rate": "txr_1NadQkLv5rdhLZWUQI992NZ6",
"taxability_reason": "standard_rated",
"taxable_amount": 24400
}
]
Tax % is not there
Is there way to get %age?
In that case you can compute it by your own from (amount and taxable_amount) or iterate over all the invocie's items and check the percentage one by one:
https://stripe.com/docs/api/invoices/line_item
Or you can expand total_tax_amounts.tax_rate when calling the upcoming APi
in that case you'll get the percentage of that tax_rate (txr_1NadQkLv5rdhLZWUQI992NZ6)
Yeah I can do that
tax_percentage = ((invoice.tax*100).to_f/invoice.subtotal.to_f)
It gives (8.87704918032787%) for one of our customer
But when we actually process the payment stripe charges 8.75%
how to expand
Check this:
https://stripe.com/docs/api/expanding_objects
In your case, something like that:
const invoice = await stripe.invoices.retrieveUpcoming({
customer: 'cus_123',
expand: ['total_tax_amounts.tax_rate']
});
Yeha let me try