Fetch invoices whose date is greater than given date only

This commit is contained in:
PCoder 2019-04-13 12:54:57 +02:00
parent 9ee21b9bc3
commit 061ef7d036
2 changed files with 4 additions and 4 deletions

View file

@ -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']))

View file

@ -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: