From f51a0a257e8aa979ae86684ffcd742b9431feee3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Mon, 3 Feb 2020 11:11:21 +0200 Subject: [PATCH] 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. --- hc/accounts/tests/test_close_account.py | 3 --- hc/accounts/views.py | 4 ++-- hc/payments/models.py | 6 +----- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/hc/accounts/tests/test_close_account.py b/hc/accounts/tests/test_close_account.py index d51931df..b0e541c8 100644 --- a/hc/accounts/tests/test_close_account.py +++ b/hc/accounts/tests/test_close_account.py @@ -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()) diff --git a/hc/accounts/views.py b/hc/accounts/views.py index 14dacf7c..f3889097 100644 --- a/hc/accounts/views.py +++ b/hc/accounts/views.py @@ -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() diff --git a/hc/payments/models.py b/hc/payments/models.py index 7ff831e8..e7713b80 100644 --- a/hc/payments/models.py +++ b/hc/payments/models.py @@ -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()