mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Preventing double counting of Stripe payments.
This commit is contained in:
parent
32524cc7d0
commit
b93831609f
1 changed files with 3 additions and 0 deletions
|
@ -261,6 +261,7 @@ class Profile(models.Model):
|
|||
self.retrieve_stripe_ids()
|
||||
|
||||
stripe.api_key = settings.STRIPE_SECRET
|
||||
seen_payments = set()
|
||||
for stripe_id_model in self.user.stripe_ids.all():
|
||||
stripe_id = stripe_id_model.stripe_id
|
||||
stripe_customer = stripe.Customer.retrieve(stripe_id)
|
||||
|
@ -269,6 +270,8 @@ class Profile(models.Model):
|
|||
for payment in stripe_payments:
|
||||
created = datetime.datetime.fromtimestamp(payment.created)
|
||||
if payment.status == 'failed': continue
|
||||
if created in seen_payments: continue
|
||||
seen_payments.add(created)
|
||||
total_stripe_payments += 1
|
||||
PaymentHistory.objects.create(user=self.user,
|
||||
payment_date=created,
|
||||
|
|
Loading…
Add table
Reference in a new issue