Skip to content

Commit

Permalink
TaxID: Correctly set country for non 'eu_vat' taxIDs
Browse files Browse the repository at this point in the history
'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
  • Loading branch information
feliixx committed Sep 25, 2024
1 parent 825150b commit a2a9ef3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion localstripe/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit a2a9ef3

Please sign in to comment.