mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Refunding stripe payments.
This commit is contained in:
parent
eb98f4524e
commit
f2281ec7bc
2 changed files with 32 additions and 2 deletions
|
@ -219,7 +219,35 @@ class Profile(models.Model):
|
|||
if most_recent_payment_date:
|
||||
self.premium_expire = most_recent_payment_date + datetime.timedelta(days=365)
|
||||
self.save()
|
||||
|
||||
def refund_premium(self):
|
||||
if self.stripe_id:
|
||||
stripe.api_key = settings.STRIPE_SECRET
|
||||
stripe_customer = stripe.Customer.retrieve(self.stripe_id)
|
||||
stripe_payments = stripe.Charge.all(customer=stripe_customer.id).data
|
||||
stripe_payments[0].refund()
|
||||
logging.user(self.user, "~FRRefunding stripe payment: $%s" % (stripe_payments[0].amount/1000))
|
||||
self.cancel_premium()
|
||||
|
||||
def cancel_premium(self):
|
||||
self.cancel_premium_paypal()
|
||||
return self.cancel_premium_stripe()
|
||||
|
||||
def cancel_premium_paypal(self):
|
||||
pass
|
||||
|
||||
def cancel_premium_stripe(self):
|
||||
if not self.stripe_id:
|
||||
return
|
||||
|
||||
stripe.api_key = settings.STRIPE_SECRET
|
||||
stripe_customer = stripe.Customer.retrieve(self.stripe_id)
|
||||
stripe_customer.cancel_subscription()
|
||||
|
||||
logging.user(self.user, "~FRCanceling Stripe subscription")
|
||||
|
||||
return True
|
||||
|
||||
def queue_new_feeds(self, new_feeds=None):
|
||||
if not new_feeds:
|
||||
new_feeds = UserSubscription.objects.filter(user=self.user,
|
||||
|
@ -557,4 +585,4 @@ class PaymentHistory(models.Model):
|
|||
'payment_date': self.payment_date.strftime('%Y-%m-%d'),
|
||||
'payment_amount': self.payment_amount,
|
||||
'payment_provider': self.payment_provider,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -145,7 +145,9 @@ class ProcessFeed:
|
|||
self.feed.save_feed_history(304, "Not modified")
|
||||
return FEED_SAME, ret_values
|
||||
|
||||
if self.fpf.status in (302, 301):
|
||||
# 302: Temporary redirect: ignore
|
||||
# 301: Permanent redirect: save it
|
||||
if self.fpf.status == 301:
|
||||
if not self.fpf.href.endswith('feedburner.com/atom.xml'):
|
||||
self.feed.feed_address = self.fpf.href
|
||||
if not self.feed.known_good:
|
||||
|
|
Loading…
Add table
Reference in a new issue