Add comments and clean up Lago customers

This commit is contained in:
2023-02-27 07:20:42 +00:00
parent 9d37e2bfb8
commit 5843000df6
2 changed files with 31 additions and 8 deletions

View File

@@ -106,6 +106,9 @@ class User(AbstractUser):
if self.stripe_id:
stripe.Customer.delete(self.stripe_id)
log.info(f"Deleted Stripe customer {self.stripe_id}")
if self.billing_provider_id:
billing.delete_customer(self)
log.info(f"Deleted Billing customer {self.billing_provider_id}")
super().delete(*args, **kwargs)
# Override save to update attributes in Lago
@@ -118,9 +121,8 @@ class User(AbstractUser):
self.stripe_id = billing.get_or_create(
self.email, self.first_name, self.last_name
)
billing_id = billing.create_or_update_customer(self)
self.billing_provider_id = billing_id
if not self.billing_provider_id:
self.billing_provider_id = billing.create_or_update_customer(self)
billing.update_customer_fields(self)