#NoahBundeling

1 messages · Page 1 of 1 (latest)

quartz bridgeBOT
elfin zodiac
#

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.
tiny charm
#

Apologies for the delay, server is a bit busy

elfin zodiac
#

It's okay

tiny charm
#

let me ask a teammate to hop in here

dense crypt
#

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

elfin zodiac
#

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.

dense crypt
#

Right, these are preview invoices. Thanks for the ID anyways. Will let you know what I can find.

elfin zodiac
#

I'm getting 'supported' back

#

For both of the ID's.

dense crypt
#

Gotcha, I'm trying to reproduce this on my side using the setup that you did.

elfin zodiac
#

Thanks!

dense crypt
#

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

elfin zodiac
#

Is it maybe due to wrong settings in our account or something?

dense crypt
#

Double checking but I am not immediately aware of a setting that would allow automatic tax for one customer but not another like this

elfin zodiac
#

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?
dense crypt
#

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.

meager ore
#

Greece: sub_1NQWtSHtOqYWTCddD4vf9OdK
Dutch: sub_1NQWvjHtOqYWTCddZsh00YTp

Hopefully these can help.
(I'm Noah's coworker, taking over as he has left for now)

dense crypt
#

Thank you! Checking in to those

#

Apologies it took me a while to look in to those. It actually looks like automatic tax was not enabled for either of those test subscriptions. Would you mind creating two new ones while passing 'automatic_tax' => ['enabled' => true],?