Skip to content

Commit 75176bd

Browse files
committed
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
1 parent 825150b commit 75176bd

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

localstripe/resources.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -3276,7 +3276,13 @@ def __init__(self, country=None, customer=None, type=None, value=None,
32763276
assert type in ('eu_vat', 'nz_gst', 'au_abn')
32773277
assert _type(value) is str and len(value) > 10
32783278
if country is None:
3279-
country = value[0:2]
3279+
if type == 'eu_vat':
3280+
country = value[0:2]
3281+
elif type in ('nz_gst', 'au_abn'):
3282+
country = type[0:2].upper()
3283+
else:
3284+
# shouldn't happen because type is checked above
3285+
assert False
32803286
assert _type(country) is str
32813287
except AssertionError:
32823288
raise UserError(400, 'Bad request')

0 commit comments

Comments
 (0)