mirror of
https://github.com/viq/NewsBlur.git
synced 2025-04-13 09:38:09 +00:00
Updating Stripe email when updating user email.
This commit is contained in:
parent
fc61ffd9dc
commit
a6a6e7e957
2 changed files with 25 additions and 7 deletions
|
@ -177,13 +177,7 @@ class AccountSettingsForm(forms.Form):
|
|||
social_profile.save()
|
||||
|
||||
|
||||
if self.user.email != email:
|
||||
self.user.email = email
|
||||
self.user.save()
|
||||
|
||||
sp = MSocialProfile.get_user(self.user.pk)
|
||||
sp.email = email
|
||||
sp.save()
|
||||
self.user.profile.update_email(email)
|
||||
|
||||
if old_password or new_password:
|
||||
change_password(self.user, old_password, new_password)
|
||||
|
|
|
@ -501,6 +501,30 @@ class Profile(models.Model):
|
|||
|
||||
return ipn[0].payer_email
|
||||
|
||||
def update_email(self, new_email):
|
||||
from apps.social.models import MSocialProfile
|
||||
|
||||
if self.user.email == new_email:
|
||||
return
|
||||
|
||||
self.user.email = new_email
|
||||
self.user.save()
|
||||
|
||||
sp = MSocialProfile.get_user(self.user.pk)
|
||||
sp.email = new_email
|
||||
sp.save()
|
||||
|
||||
if self.stripe_id:
|
||||
stripe_customer = self.stripe_customer()
|
||||
stripe_customer.update({'email': new_email})
|
||||
stripe_customer.save()
|
||||
|
||||
def stripe_customer(self):
|
||||
if self.stripe_id:
|
||||
stripe.api_key = settings.STRIPE_SECRET
|
||||
stripe_customer = stripe.Customer.retrieve(self.stripe_id)
|
||||
return stripe_customer
|
||||
|
||||
def activate_ios_premium(self, transaction_identifier=None, amount=36):
|
||||
payments = PaymentHistory.objects.filter(user=self.user,
|
||||
payment_identifier=transaction_identifier,
|
||||
|
|
Loading…
Add table
Reference in a new issue