From a2a9ef3c910ba54b678b6b75a4692d0ddd857d62 Mon Sep 17 00:00:00 2001 From: feliixx Date: Wed, 25 Sep 2024 08:36:01 +0200 Subject: [PATCH] TaxID: Correctly set country for non 'eu_vat' taxIDs 'au_abn' and 'nz_gst' are numbers with only digits, they don't contain their country code. We can only guess the country from 'eu_vat' taxIDs, so let's adapt the code to better handle AU and NZ taxIDs number. See [the Stripe documentation] for the exact format of these two taxIDs number. [the Stripe documentation]: https://docs.stripe.com/billing/customer/tax-ids --- localstripe/resources.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/localstripe/resources.py b/localstripe/resources.py index 5d74d94..1de6cc5 100644 --- a/localstripe/resources.py +++ b/localstripe/resources.py @@ -3276,7 +3276,10 @@ def __init__(self, country=None, customer=None, type=None, value=None, assert type in ('eu_vat', 'nz_gst', 'au_abn') assert _type(value) is str and len(value) > 10 if country is None: - country = value[0:2] + if type == 'eu_vat': + country = value[0:2] + else: + country = type[0:2].upper() assert _type(country) is str except AssertionError: raise UserError(400, 'Bad request')