Retrieve tax id if exists before creating a new one

This commit is contained in:
PCoder 2019-12-26 14:46:16 +05:30
parent ad52338653
commit 5ab0bf6993

View file

@ -437,6 +437,10 @@ class StripeUtils(object):
@handleStripeError
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(
stripe_customer_id,
type=type,