From 061ef7d0368b76a4b8829eb9ef4c26f917e37e6d Mon Sep 17 00:00:00 2001 From: PCoder Date: Sat, 13 Apr 2019 12:54:57 +0200 Subject: [PATCH] Fetch invoices whose date is greater than given date only --- hosting/management/commands/fetch_stripe_bills.py | 2 +- utils/stripe_utils.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hosting/management/commands/fetch_stripe_bills.py b/hosting/management/commands/fetch_stripe_bills.py index 2a37ed61..e321179d 100644 --- a/hosting/management/commands/fetch_stripe_bills.py +++ b/hosting/management/commands/fetch_stripe_bills.py @@ -35,7 +35,7 @@ class Command(BaseCommand): all_invoices_response = stripe_utils.get_all_invoices( user.stripecustomer.stripe_id, - created=created_gt + created_gt=created_gt ) if all_invoices_response['error'] is not None: self.stdout.write(self.style.ERROR(all_invoices_response['error'])) diff --git a/utils/stripe_utils.py b/utils/stripe_utils.py index b43470fa..577eab80 100644 --- a/utils/stripe_utils.py +++ b/utils/stripe_utils.py @@ -123,19 +123,19 @@ class StripeUtils(object): return card_details @handleStripeError - def get_all_invoices(self, customer_id, created): + def get_all_invoices(self, customer_id, created_gt): return_list = [] has_more_invoices = True starting_after = False while has_more_invoices: if starting_after: invoices = stripe.Invoice.list( - limit=10, customer=customer_id, created=created, + limit=10, customer=customer_id, created={'gt': created_gt}, starting_after=starting_after ) else: invoices = stripe.Invoice.list( - limit=10, customer=customer_id, created=created + limit=10, customer=customer_id, created={'gt': created_gt} ) has_more_invoices = invoices.has_more for invoice in invoices.data: