#NoahBundeling
1 messages · Page 1 of 1 (latest)
Hi Hanzo, I'm hoping you can point me a little bit in the right direction.
I'm having the following code to return an upcoming invoice:
return $this->stripe_client->invoices->upcoming(
array(
'customer' => $customer_id,
'automatic_tax' => array(
'enabled' => true
),
'subscription_items' => array(
array(
'quantity' => 1,
'price' => $price
)
)
)
);```
With that, I'm trying to retrieve the following:
```php
if (isset($invoice->total_tax_amounts[0])) {
if (!empty($invoice->total_tax_amounts[0]->tax_rate)) {
$tax = $this->stripe_client->taxRates->retrieve($invoice->total_tax_amounts[0]->tax_rate);
$tax_percentage = $tax->percentage;
}
}
return $tax_percentage;```
This works fine if I choose NL as the customer's country, but if I change it to i.e. Greece or Mexico, I'm getting the error "no such tax_rate" through API.
I'm not sure what I'm doing wrong.
Apologies for the delay, server is a bit busy
It's okay
let me ask a teammate to hop in here
Hello, do you have the IDs of subscriptions that you have used to test this out? (sub_123)
Looking at an NL and non NL subscription may help me get better insight in to this
I don't have a subscription attached to it yet, just customer. That's this ID: cus_OCvDBhdGtefNPp (Greece) and an ID for NL customer: cus_OCtwjzO8YJntJf
I'm trying to create an 'example invoice' by getting an upcoming invoice for those customers with a price id from a random product (doesn't really matter), and then it returns a tax rate for NL but not for the other countries.
Right, these are preview invoices. Thanks for the ID anyways. Will let you know what I can find.
If you retrieve each customer and expand their tax property. Does the tax.automatic_tax property say enabled for both? https://stripe.com/docs/api/customers/object#customer_object-tax
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Gotcha, I'm trying to reproduce this on my side using the setup that you did.
Thanks!
Interesting, I am getting the proper tax amounts for both my NL and GR customer. Used the same price amount and tax category, not sure what else may be at play here
Is it maybe due to wrong settings in our account or something?
Double checking but I am not immediately aware of a setting that would allow automatic tax for one customer but not another like this
In our system, when we add invoice details, we sent a request to Stripe to create the customer with the provided address information. We do that with the following parameters:
$parameters = array(
'name' => $client->getName(),
'email' => $user->getEmail(),
'preferred_locales' => array(
'en-US'
),
'metadata' => array(
'selfservice' => $client->getSelfservice(),
'enviroment' => ENVIRONMENT,
'client_id' => $client->getId(),
'contact' => $user->getName()
),
'expand' => ['tax'],
);```
After that, through webhook customer.updated, we're trying to retrieve tax information based on creating an upcoming invoice when there's no subscription yet with the code I've provided earlier in the thread.
Maybe you notice something weird?
Gotcha, thanks for the context. Still looking...
Would you mind creating a test subscription on each of these customers and sending me the ID? I can't see the results of your upcoming invoice calls but I would be able to look at an existing subscription. I'm still having trouble seeing the difference in what we are doing in our tests.
Greece: sub_1NQWtSHtOqYWTCddD4vf9OdK
Dutch: sub_1NQWvjHtOqYWTCddZsh00YTp
Hopefully these can help.
(I'm Noah's coworker, taking over as he has left for now)