#Rohit89

1 messages · Page 1 of 1 (latest)

glacial jettyBOT
frank notch
#

Hi
Do you want to use Stripe Tax (automatic tax) or tax rates ?

wispy bluff
#

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

frank notch
#

Just to make sure I understand you, you are passing tax rates when calling the upcoming API or you are using Stripe Automatic tax ?

wispy bluff
#

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

frank notch
#

In the response are you getting total_tax_amountsarray ?

#

I assume you are using Stripe Tax here ?

wispy bluff
#

"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?

frank notch
#

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)

wispy bluff
#

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

frank notch
wispy bluff
#

expand: ['total_tax_amounts.tax_rate'],

#

let me try

#

hold

frank notch
#

In your case, something like that:

const invoice = await stripe.invoices.retrieveUpcoming({
  customer: 'cus_123',
 expand: ['total_tax_amounts.tax_rate']
});
wispy bluff
#

Yeha let me try