Retrieve tax id if exists before creating a new one
This commit is contained in:
parent
ad52338653
commit
5ab0bf6993
1 changed files with 8 additions and 4 deletions
|
@ -437,6 +437,10 @@ class StripeUtils(object):
|
||||||
|
|
||||||
@handleStripeError
|
@handleStripeError
|
||||||
def create_tax_id_for_user(self, stripe_customer_id, vat_number, type="eu_vat"):
|
def create_tax_id_for_user(self, stripe_customer_id, vat_number, type="eu_vat"):
|
||||||
|
tax_id_obj = stripe.Customer.retrieve(
|
||||||
|
stripe_customer_id,type=type, value=vat_number
|
||||||
|
)
|
||||||
|
if tax_id_obj["response_object"]["error"]:
|
||||||
tax_id_obj = stripe.Customer.create_tax_id(
|
tax_id_obj = stripe.Customer.create_tax_id(
|
||||||
stripe_customer_id,
|
stripe_customer_id,
|
||||||
type=type,
|
type=type,
|
||||||
|
|
Loading…
Reference in a new issue