Browse Source

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.
pull/328/head
Pēteris Caune 5 years ago
parent
commit
f51a0a257e
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
3 changed files with 3 additions and 10 deletions
  1. +0
    -3
      hc/accounts/tests/test_close_account.py
  2. +2
    -2
      hc/accounts/views.py
  3. +1
    -5
      hc/payments/models.py

+ 0
- 3
hc/accounts/tests/test_close_account.py 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())


+ 2
- 2
hc/accounts/views.py 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()


+ 1
- 5
hc/payments/models.py 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()


Loading…
Cancel
Save