Don't delete customer data in braintree when closing account.

Need customer data to stay in braintree until the end of each month for tax reports.
This commit is contained in:
Pēteris Caune 2020-02-03 11:11:21 +02:00
parent b8cf428899
commit f51a0a257e
No known key found for this signature in database
GPG Key ID: E28D7679E9A9EDE2
3 changed files with 3 additions and 10 deletions

View File

@ -31,9 +31,6 @@ class CloseAccountTestCase(BaseTestCase):
# Subscription should have been canceled
self.assertTrue(mock_braintree.Subscription.cancel.called)
# Braintree customer should have been deleted
self.assertTrue(mock_braintree.Customer.delete.called)
# Subscription should be gone
self.assertFalse(Subscription.objects.exists())

View File

@ -472,10 +472,10 @@ def unsubscribe_reports(request, signed_username):
def close(request):
user = request.user
# Subscription needs to be canceled before it is deleted:
# Cancel their subscription:
sub = Subscription.objects.filter(user=user).first()
if sub:
sub.cancel(delete_customer=True)
sub.cancel()
user.delete()

View File

@ -136,15 +136,11 @@ class Subscription(models.Model):
return result
def cancel(self, delete_customer=False):
def cancel(self):
if self.subscription_id:
braintree.Subscription.cancel(self.subscription_id)
self.subscription_id = ""
if self.customer_id and delete_customer:
braintree.Customer.delete(self.customer_id)
self.customer_id = ""
self.plan_id = ""
self.plan_name = ""
self.save()